Ionic permanently removing items from tab list - list

Having an issue with actually clearing out and refreshing list items within a tab view.
A) Within the service, refresh sets the return object to null (verified) calls for fresh data (verified) and returns it to the controller (verified).
B) Within the controller, before refresh is called, i validate the length of the previously returned object(verified as length of 6), then set the object to null (verified as null), refresh the data and then validate the returned object (verified as length of 6 again).
My expectation is for the original list of 6 items to clear out and be replaced with the new list of 6 items. However, the html template list of 6 items grows to a list of 12, basically duplicating the original list. Further more, the new list of 12 seems to be sorted so the duplicates are listed in order as pairs - which seems like its being sorted. I don't understand this behavior and I can't figure out how to get displayed list to actually clear out.
.controller:
$scope.doRefresh = function() {
alert(Object.keys($scope.prods).length) ; // (6)
$scope.prods= {} ;
alert(Object.keys($scope.prods).length) ; // (0)
$scope.prods= Prods.refresh();
alert(Object.keys($scope.prods).length) ; // (6)
}
.service:
refresh: function() {
prods= [] ;
getProds() ;
return prods;
},

I fixed the issue. It was my own code. in "getProds()" I wasn't setting the return object to null, Every time I hit refresh the object was simply adding all the new data onto existing object, and returning back to the controller twice the previous size.

Related

Oracle APEX Compare Two Items Values to Fire a Dynamic Action

I want to create a Dynamic Action thats when my page item P2014_BALANCE < P2014_CURRENT_PRICE then P2014_CURRENT_PRICE gets the static value 0.
The problem is that i can't compare these two page items. I try to when section in my Dynamic Action to use Javascript expression like this:
if(apex.item( "P2014_CURRENT_PRICE " ).getValue() < apex.item( "P2014_CURRENT_PRICE " ).getValue()){
alert('Wrong Number');
};
but when my page loads gets an error (even Fire on Initialization = False).
I also try this:
still nothing.
This is a web application. All page items contain string values. So if you want to do number comparison, make them numbers:
if (Number(apex.item( "P2014_BALANCE" ).getValue()) < Number(apex.item( "P2014_CURRENT_PRICE" ).getValue())) {
alert('Wrong Number');
};
Note that in your example you have P2014_CURRENT_PRICE twice - that will always yield false anyways.
This is how you would implement this in a dynamic action. Note that I tried on 21.1 but it should be similar in 5 (consider upgrading):
Dynamic Action on Change of Item P2014_CURRENT_PRICE with client Side Condition of type Javascript Expression
Source:
apex.locale.toNumber(apex.item( "P2014_CURRENT_PRICE" ).getValue()) > apex.locale.toNumber(apex.item( "P2014_BALANCE" ).getValue())
True Action with Action Set Value
Set Type Static Assignment
Value "0"
Affected Element Item P2014_CURRENT_PRICE

Do not display options in v-autocomplete until there is input vuetify

I currently have a v-autocomplete component but once the user clicks the search it expands and shows all available items. I want the list of items to only display once there is input. There are too many available items and don't want the user seeing all of them right off the bat. Also if there is a way to limit it to only showing the top 5 that match the user input.
<v-autocomplete class="vtext"
v-model="selectedTopic"
:items="getTopics"
item-text="Name"
item-value="Id"
:outlined="false"
:rounded="true"
:solo="true"
:single-line="true"
append-icon='fa fa-search'
#change="topicSelected()"
:hide-no-data="true"
:allow-overflow="false"
no-data-text="No topic found"
return-object
>
</v-autocomplete>
The reason it shows all items on initialization (when clicking empty), is because you are setting the items right away with getTopics what you need to do in that function is check
<v-autocomplete class="vtext"
...
#input="handleInput"
if (inputModel){ //get the topics}
else { return []}
In terms of only getting the first 5 results, again you do it in the same function:
if (inputModel){
// do search
return results.slice(0,5)}

Add empty option to List Validator

I'm trying to add the option to my users that, on a List Validator, to allow select any of the options or a blank option. Spreadjs has the IgnoreBlanks setting, which I use, so when the user uses the delete key or the backspace and deletes the cell it validates correctly.
However, I would love to use the same functionality as in Excel, which allows blank options in the list validator, in part of the list.
I've tried to target the <select> element that holds the list and programmatically add the empty element, however, it crashes after the user selects the empty option.
I've also tried to add different escaped characters to the list. If I select a character that represents an empty string or a tab, it won't add a new option to the list. If I use any strange character, or even the null character \0 you get a new option to select, but the content is that typical rectangle you see when your font doesn't have the character you're trying to display.
I've also tested using a regular ListValidator like in the example pages, not our custom functionality and doesn't work either.
https://www.grapecity.com/demos/spread/JS/TutorialSample/#/demos/basicDataValidator
I have also tried creating a FormulaListValidator, and if my range has empty cells I could then get an empty option on my list, however, because the range may have duplicates, I get duplicated options.
After researching a little bit I found a workaround in a different language which I adapted to Typescript (Angular 6)
export const getListValidatorFromArray = (spread: GC.Spread.Sheets.Workbook, data: any[]) => {
// saving validation list values in a hidden sheet
spread.addSheet(spread.getSheetCount());
const sheet = spread.getSheet(spread.getSheetCount() - 1);
sheet.visible(false);
for (let i = 0; i < data.length; i++) {
sheet.setValue(i, 0, data[i]);
}
// create validator based on the values
const dv = GC.Spread.Sheets.DataValidation.createFormulaListValidator(
'=' + sheet.name() + '!$A$1:' + sheet.name() + '!$A$' + data.length
);
return dv;
};
Note: This creates an extra sheet for each validator you create. Makes sure you reuse them as much as possible (i.e. assigning it to a variable when it's created, and reusing the variable for other columns/rows that use the same one).

Unity Slider mapped to list<float>?

I currently have a list<float> that are arranged in an increasing order. My sliders min.value is the lowest value of my list (i.e. first element of my list) and sliders max.value is equal to the last item of my list.
What I want to do is that whenever my slider is at a specific value or +-0.1 to one of the elements on my list, I Want to be able to get the index out that specific element to perform a task.
Any suggestions?
Someone asked for code, I don't even like this code since it only gives me the right value once I press "play" from zero, but then it removes my data, so I can't go back with the slider
this code is inside update void, and isPlaying is true when I press a "play" button
if(isPlaying){
timeSlider.value += Time.deltaTime;
timer = timeSlider.value;
print(timeSlider.value);
if((newTimes[0]>=(timer-0.1f)) && (newTimes[0]<=(timer+0.1f))){
print("time: " + newTimes[0]+ " at run time: " + timer);
NewTimes.RemoveAt(0);
}
}
You can set the slider to use whole numbers in the inspector and use the value as your index?
My first thought would be:
Set Slider Steps to Floats in your List
-> Perform task on List[currentSliderStep] as needed

1-indexed Model in QCombobox

I have a 1-indexed (readonly-)model and want to use it for a combobox.
I parse the data (comes from a file-parser) and have for example:
1: Variable Number 1 and that will be my first item, next
2: Variable Number 2 and so on.
When I click on an item the currentIndex()-method from QCombobox will give me a 0-indexed int, so my problem is:
I don't want to write everytime I parse a file +1 respectively -1 when writing back to the file (although the model is readonly, I can alter the data in the file). (I have nearly 30 UIs where I need the model, and for every UI I have to parse other data)
I currently use something like:
virtual int currentIndex() const { return QComboBox::currentIndex() + 1; }
virtual void setCurrentIndex(int index) { QComboBox::setCurrentIndex(index-1); }
I know that this is not ideal, because (set-)currentIndex is not virtual. But to avoid +/-1 I used this for now.
Does anybode have a good suggestion for this problem?
If you have a custom model you could add a role that returns the "real" index value.
If you just use strings to fill the combobox, you could use the setItemData() and itemData() methods to associated your reference value.
E.g.
comboBox->addItem("Number 1", 1);
and
int refValue = comboBox->itemData(comboIndex).toInt();
The associated data can be anything that can be stored in a QVariant.