Eureka Dynamically Hide/Show Rows - swift

I have a option field that I created using Eureka. I want to create new fields according of the answer of my first option and show new row accordingly.
form +++ Section("First Section")
<<< ActionSheetRow<String>() {
$0.title = "Select Option"
$0.selectorTitle = "1 or 2"
$0.options = ["1","2"]
}
For example, if I want to show new row according to the answer of the first question; so different form field row for 1 and 2, which was initially hidden. How can it be achieved?
So I want the flow to be: If 1 selected, show second question which is option select as well. If 2 selected show option with different set of options. But don't show that row before first option value is selected.

I had been working in your questions, this are my results, you need to setup a tag for your section and then search in the form with tag get the section and add another cell according your needs, this code can help you
<<< ActionSheetRow<String>() {
$0.title = "Select Option"
$0.selectorTitle = "1 or 2"
$0.options = ["1","2"]
$0.onChange({ (row) in
debugPrint("\(row.value) was selected")
if let section = self.form.sectionBy(tag: "first") {
let actionSheetRow = ActionSheetRow<String>()
actionSheetRow.title = "Select Option2"
actionSheetRow.title = "2 or 3"
actionSheetRow.options = ["2","3"]
actionSheetRow.onChange({ (row2) in
debugPrint("\(row2.value) was selected")
})
section.append(actionSheetRow)
section.reload(with: .none)
}
})
}
I hope this helps you, best regards

Related

How to get the highest probability records from the collection. (Show most time searched)

I am creating application where it contains many dropdowns(more than 20), user can select any dropdowns to get the results. Every user login they are selecting dropdowns and get the results.
What I am doing is, storing all the selected dropdown values of each user(basically search string), planning to show your common searches, where they can just copy that search string and get the results.
Dropdown selection is mutiple
Intention is reducing the effort of selecting dropdowns if they have most common/almost common search they have. My dataset looks like below data stored in MongoDB.
This data is for single user, likewise it contains for all users.
{
"UserID": "123",
"SearchData": [
{
"searchText": "Area=[Bengaluru,Mumbai] Street_Number=[123,787] Locality=[Hebala,Electronic City] Branch=India",
"searchDateTime": "2020-04-03"
},
{
"searchText": "Area=Delhi Street_Number=[123,797,753,64] Locality=[Rajbhava,Redfort]",
"searchDateTime": "2020-04-04"
},
{
"searchText": "Region=[Asia,Europe] Branch=[India,Germany] Area=Delhi",
"searchDateTime": "2020-04-02"
},
{
"searchText": "Area=[Bengaluru,Mumbai] Team_name=[Team 1, Team 2] IsNewTeam=1 Region=[Asia,Europe] Branch=India",
"searchDateTime": "2020-03-04"
},
{
"searchText": "Region=United_States Branch=NewYork Team=[Team 1,Team 4] Locality=WTO",
"searchDateTime": "2020-04-04"
}
]
}
Expected Results like:
Your most searched/selected fields and Values are(Results for last 150 days searchText), Because I am planning not to keep Old data
1. Area=[Bengaluru,Mumbai] Branch=India Team 1 // Since this is common in many stings(Ex: Here in two strings)
2. Region=[Asia,Europe]
3. Branch=India
4. Team =Team 1
5. Area=[Bengaluru,Mumbai]
6. IsNewTeam == //If any common match found.
7. Area = //If any other common values found Expect the **Bengaluru,Mumbai**
//Ex : Dehli, Noida. This should come here
Any help would be very much appreciated.
Thanks in advance

How to access Delete Row function in a Multivalued row for a Eureka form

I would like to access the delete row function in the eureka form but I couldn't find how to do it. The reason is that I have an i variable that keeps track of how many rows I have and because of that my form breaks when a row is deleted.
This is how my implementation currently looks in my code:
+++ MultivaluedSection(multivaluedOptions: [.Reorder, .Insert, .Delete], header: "Exercises", footer: "List of Exercises for workout"){
$0.addButtonProvider = {section in
return ButtonRow(){
$0.title = "Add Another Exercise"
self.i+=1
}
}
$0.multivaluedRowToInsertAt = { index in
return TextRow() {
$0.title = "Exercise \(self.i) Name"
$0.tag = "Exercise \(self.i) Name"
self.i+=1
}
}
$0 <<< TextRow(){ //change this to SuggestionRow later
$0.title = "Exercise \(self.i) Name"
$0.tag = "Exercise \(self.i) Name"
$0.add(ruleSet: strictRules)
}
}
What I'm looking for is something like:
$0.multivaluedRowToDeleteAt = { index in
self.i-=1
}
Does something like this exist? If not, is there any other way to get the number of rows for this multivalued section at submission time?

I want to change the number of items with lineupemate of orderupdate

I want to change the number of items with lineupemate of orderupdate.
Now we set the values ​​as follows.
"lineItemUpdates": {
"item id": {
"extension":{
"#type":"types.example.com/standard/id",
"quantity":0
}
},
},
I do not know how to set extention type and other fiel.
Please tell me the solution.

Get Programmatically Product Attribute Options Values

I would like to get options values from my own product attribute. "Catalog input type for Store Owner" of that attribute is Dropdown. For every option we have three values "Is Default", "Admin", "Default Store View"
I tried this code:
//eavConfig is \Magento\Eav\Model\Config class
$attribute = $this->eavConfig->getAttribute('catalog_product', 'designer_id');
$options = $attribute->getSource()->getAllOptions();
var_dump($options);
When I var_dump($options) I can see array of options with values "value" and "label", where "value" is option_id and "label" is "Default Store View" field value.
How to get all fields ("Is Default", "Admin", "Default Store View") values ?
In Magento1:
Use store emulation to get admin store label.
In Magento2:
Default Store View
$formOptions = $this->productAttributeRepository->get('attribute')->getOptions();
foreach ($formOptions as $formOption) {
$name = $formOption->getLabel();
}
Admin:
$this->storeManager->setCurrentStore('admin');
// same code
Is Default:
// same code
$formOption->getIsDefault();

Hierarchial JSON model and UI5

I am creating a demo application with JSON data and UI5. The idea (in a nutshell) is provide various information views for a selected item. I am using IconTabBar control. I have created an example scenario so (hopefully) I can explain the problem more clearly.
1.IconTabBar's first tab has list of employees and user can select one by selecting a radio button on the left
2.This takes the user to the next tab that displays say, sales view. The user can click on any tab and move to the respective view.
3.User can modify the information in any view. If the users forgets or ignores to Save the data, the tab color is set to Red.
4.User can Save the data.
5.Some of the views have information in master detail format.
The problem(s) I am facing are:-
1.How to filter the model data based on the item selected in the table?
2.How to update the filtered data and set back to model?
3.I also would like to know whether the data is structured correctly
I am using following code to update the binding path after company is selected. The GREP function is not returning correct values for proposals. It returns ONLY 1 proposal for E001 whereas it should return 2. It doesn't work properly for orders either. I am not sure whether the data is structured correctly.
var oModel_Data = oJSONDataModel.getData();
var oView_Data = oViewDataModel.getData();
var aModelData = oModel_Data[sSelected_Key];
var aViewData = oView_Data[sSelected_Key];
aViewData = jQuery.grep(aModelData, function(data, index) {
return data.id === sSelected_id
})[0];
oView_Data[sSelected_Key]=aViewData;
oViewDataModel.setData(oView_Data);
oViewDataModel.refresh(true);
I am using following code to check whether user has changed data.
var oView_Data = oViewDataModel.getData();
var oModel_Data = oJSONDataModel.getData();
var aViewData = oView_Data[in_sKey];
var aModelData = oModel_Data[in_sKey];
aModelData.forEach(function(item, index, array) {
var valueView = aViewData;
if (item.id === sSelected_id){
//The code here need to consider complex(nested) data types
//Thus it should check type of not only valueView and item
//but also their each and every child elements
/*---------Temporary Solution---------------------*/
var sViewValue = JSON.stringify(valueView);
var sItem = JSON.stringify(item);
var bSameData = sViewValue === sItem;
if (bSameData==true){
flag_data_changed=false;
}else{
return flag_data_changed=true;
}
}
});
My json model is as below.
{
"employees": [
{"id":"E0001" ,
"name":"Alec Stewert"
},
{"id":"E0002" ,
"name":"Debra Manning"
}
],
"sales": [
{"id":"E0001" ,
"sale_q1":"10000",
"sale_q2":"3000",
"sale_q3":"8000",
"sale_q4":"2000"
},
{"id":"E0002" ,
"sale_q1":"8000",
"sale_q2":"3000",
"sale_q3":"7000",
"sale_q4":"5000"
}
],
"proposal":[
{"id":"E0001",
"fi_q":"Q2",
"value":"12000",
"customer":"6000"
},
{ "id":"E0001",
"fi_q":"Q2",
"value":"8000",
"customer":"2300"
}
],
"key_orders": [
{"id":"E0001",
"order_hdr":
[
{"id":"O0001",
"fi_q":"Q1",
"value":"2000",
"customer":"2000"
},
{"id":"O0002",
"fi_q":"Q1",
"value":"2000",
"customer":"2000"
}
],
"order_dtl":[
{
"id":"O0001",
"itm":"Item X",
"Qty":"100",
"rate":"20"
}
]
},
{"id":"E0002",
"order_hdr":
[
{"id":"O0011",
"fi_q":"Q1",
"value":"2000",
"customer":"5000"
},
{"id":"O0012",
"fi_q":"Q1",
"value":"1000",
"customer":"5000"
}
],
"order_dtl":[
{
"id":"O00011",
"itm":"Item Z",
"Qty":"200",
"rate":"10"
}
]
}
]
}
I have investigated online and in SAP Help but failed to understand what needs to be done. Any help is appreciated.
1.How to filter the model data based on the item selected in the table?
If you prepare the JSONModel you can use the Filter
2.How to update the filtered data and set back to model?
If you bind the table to the JSONModel, by default the JSNOModel is 2 way binding so any edited data will be in the JSONModel
3.I also would like to know whether the data is structured correctly
Go through the Example of the Table So you will get an idea of the Model and binding model to the Table