Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to model exclusive behavior and make it configurable
    text
    copied!<p>We have to present a list of options with the following rules</p> <pre><code>* you can select multiple items, as many as you want * however, some of the items are mutually exclusive, i.e. selecting itemA should automatically deselects itemC ( if itemC is selected prviously ) </code></pre> <p>this is best explained with the following list example of fules for a car</p> <pre><code>Gas Diesel Electric BioFuel Ethanol </code></pre> <p>a car can have multiple fuel types selected such as</p> <pre><code>biofuel and Gas Gas and Electric Gas, Ethanol and Biofuel but not Diesel and Gas at the same time </code></pre> <p>Trying to come up with some configurable logic such that the code reads the configuration and applies the rules rather than knowing about specifics esp. since there's another list which has similar constraints</p> <p>Any help/pointers on how to model this behavior ?</p> <p>UPDATE -</p> <p>Thanks everyone for the great ideas, the simplest solution seems to define a list of Incompatible Types in a config file/table for each fuel type as follows</p> <p>FuelID/FuelName/IncompatibleTypes 1/Gas/2 2/Diesel/1 3/Electric/ 4/BioFuel/ 5/Ethanol/ etc.</p> <p>Where IncomatibleTypes is say nvarchar(50) and will store the incompatible types like so 2,5,6,... etc.</p> <p>So the code will read the definitions and if an item is selected, it will read the other selected items and if it finds anything on the incomatible list, it can either display a message or simply auto deselect the other incompatible item etc.</p> <p>this may be inelegant but seems the most generic solution without the code knowing anything about specific items at all, plus it can be freely extended as in reality * there will likely be a couple dozen max selections at best * if the list of incomatibilities increases the storage can be changed to say nvarchar(100) without any changes to code itself</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload