@ravindrasinghsha
Raise > Recognise > Respond
Hands on web developer, believe in writing code which speaks for itself. Always keen to learn and create something new and exciting. My best still has to come!
Designing solution architecture, knowledge exchange, building prototypes, anything exciting to develop.
No blogs yet.
If you think and argue over component based programming, you'll realize that this concept advise to make code work as independent possible. Therefore, you create a components, and to make it independent you have to design it in a way that, it accepts arguments (properties, params) as input and gives you output (it may or may not hold any business logic). Having said that, avoid coupling components together. Design it in a way that parent component maintains the state and pass props to dumb/child components.
If I understand properly, you want to pass dynamic data to API to search based on inputs entered by user. My proposal for solution will be to create a structure of JSON object and pass it to POST method and read that data in your API method. Example: Create JSON object structure, and fill values in this on Search click event. WhereTheProperty will be array type as you have dynamic values in that, based on rows added by user create array objects. { "AllWords": "value1, value2", "ExactPhrase": "value3", "AnyOfThese": "value4,value5", "NoneOfThese": "value6,value7", "ResultType": "AllResults", " WhereTheProperty ": [ { "PickProperty": "Property1", "Contains": "ContainValue", "Text": "EnteredTextValue" }, { "PickProperty": "Property2", "Contains": "ContainValue", "Text": "EnteredTextValue" }, { "PickProperty": "Property3", "Contains": "ContainValue", "Text": "EnteredTextValue" } ] } I'll assume that you are using AngularJS custom component for adding dynamic rows, use indexing in those rows to access row data. I hope this answers your question.
As you are using jQuery / JavaScript and if you don't want to write a complex code. Then I will suggest easiest steps for this. Step 1: When rendering question in view: Place integerOne in one placeholder, operator in another placeholder and integerSecond in another. Example: <div class="row" id="row-1"><span class="intOne">{integerOne}</span><span class="operator">{operator}</span><span class="intSecond">{integerSecond}</span></div> Step 2: Bind this Div with your calculate button Step 3: On Click of calculate button, read integers and operator from PlaceHolders and do case calculation as j has mentioned below. This is just easiest way for solution, maybe once it start working you can polish it with more robust code.
"I'm a fanboy of front-end frameworks but , now it seems like developers of these frameworks are overdoing it, bringing too much modularity and too many small tools and supporting libraries . " -- On basis of what context you derived this conclusion? Would love to hear clear bullets, if you get time. Thanks.
Hi, as far I could understand your problem, you need a starting database design in NoSQL. I have formed intial very basic data design to start with, you can modify it as per your understanding. Location : [ {id:"LocationId1", name:"ABC Location-1"}, {id:"LocationId2", name:"ABC Location-2"}, {id:"LocationId3", name:"ABC Location-3"} ] Restaurant : [ {id:"RestaurantId1", name:"ABC Name"}, {id:"RestaurantId2", name:"ABC Name"}, {id:"RestaurantId3", name:"ABC Name"} ] Menu : [ {id:"MenuId1", name:"dish name1", ingredients:"a,b,c,d", price:"$5.00"}, {id:"MenuId2", name:"dish name2", ingredients:"a,b,c,d,e", price:"$4.00"} {id:"MenuId3", name:"dish name3", ingredients:"a,b,c,d,y", price:"$3.50"} ] RestaurantLocationMapping :[ {id:"RestaurantLocationMappingId", LocationId:"LocationId1",RestaurantId:"RestaurantId1"} {id:"RestaurantLocationMappingId", LocationId:"LocationId1",RestaurantId:"RestaurantId2"} ] RestaurantMenuMapping :[ {{id:"RestaurantMenuMappingId", MenuId:"MenuId1",RestaurantId:"RestaurantId1"} {id:"RestaurantMenuMappingId", MenuId:"MenuId1",RestaurantId:"RestaurantId2"} }] Query Based on Location -> Fetch LocationId and then select all restaurants which are mapped in RestaurantLocationMapping object to get restaurants list. Similarly then query RestaurantMenuMapping based on restaurant id to get the menu list. Note that all Ids should be unique. Hope it helps you to proceed. Let me know if I didn't understand your question.