I'm probably going to go overboard on information. I figure it's better to know to much than not to know enough.
I have a single page application built with PHP, AngularJS, and Twitter Bootstrap. The SPA manages rules. Each rule has conditions. Each condition has a buyer, and a dollar range. A rule may have a single condition, or a rule may have multiple conditions (there may be up to nine legal ASCENDING ranges e.g. $0 - $2,000, $2,001 - $2,500, etc.). Whether there is a single condition, or there are multiple conditions in a rule, all dollar ranges must be accounted for from $0 to $999,999,999.
Currently, I validate whether or not all ranges are accounted for by subtraction. I start with a variable equal to 999,999,999 and subtract the difference of each condition range in a loop (e.g. 25,001 - 50,000 would subtract 24,999 from 999,999,999) from that variable. If when the loop finishes, the variable is not equal to 0, then the ranges have not been properly accounted for and a warning message is displayed.
The requirement that is coming down the pipes is that I somehow force the user to address the gaps, overlaps, or illegal ranges. I have a couple of ideas on how to make this happen, but I wanted to get some fresh input and see what others might do to force the user to address the improper ranges.
So far, my thoughts are along these lines:
- Wait to save any changes until the user is done making any and all changes. That is, once a change is made, a submit button magically appears to save their changes. Said submit button would be in an inactive/disabled state until all dollar ranges are accounted for. If all ranges are accounted for, only then would the submit button be active/enabled so that they could actually save their changes.
- Once a change is made to a condition, a condition is added, etc., then the main form elements (Search By, and Lookup) are disabled until they save their changes, there by forcing them to either save or cancel their changes. They could simply leave the page, but since their changes aren't committed until the step above is completed, it would be a no harm no foul situation.
What do you think? What would you do?
In the SPA's current state, the following is true:
A) When a condition is added to a rule, there is a form which allows the user to select both a buyer, and a dollar range to said condition. Conditions can be added to rules without conditions. Conditions may also be added to rules with existing conditions.
B) The range of an existing condition may be altered by a user.
C) If the cumulative ranges of a rules conditions do not range completely from $0 to $999,999,999, a warning is shown to the user indicating that a gap, an overlap, or an illegal range is in play.
D) Conditions can be removed by the user, which creates a gap if the other conditions are not altered in the case of a rule with multiple conditions. If a condition is removed from a rule where said condition is the only condition, it is valid, since a rule may have no conditions associate to it legally. However, if any conditions are present, then all dollar ranges MUST be accounted for.
E) Once any of the aforementioned forms are submitted, the database is updated on the fly (Ajax) and AngularJS pushes the data under the Change Requests in Process header below the rule conditions (oddly enough, the conditions for a rule are called conditions... I work for the government, so that explains that).
Dollar Range Requirements:
General - Dollar Range(s) must cumulatively range from $0 to $999,999,999
No Gaps - All dollar ranges must be accounted for.
Rule Condition A: $0 - $25,000
Gap (Unaccounted Dollar Range): $25,001 - $50,000
Rule Condition B: $50,001 - $999,999,999
No Overlap - Dollar ranges may not be accounted for more than once in a single rule with multiple conditions.
Rule Condition A: $0 - $50,000
Rule Condition B: $25,001 - $999,999,999
Overlap (Multiple Assignments of a Single Dollar Range): $25,001 - $50,000
No Illegal Ranges - Anything that defies COMMON SENSE
Illegal Condition: $50,000 - $25,000
Dollar Range Form Select Box Values
Minimum Dollar Ranges:
0 | 2,001 | 2,501 | 10,001 | 25,001 | 50,001 | 100,001 | 1,000,001 | 5,000,001
Maximum Dollar Ranges:
2,000 | 2,500 | 10,000 | 25,000 | 50,000 | 100,000 | 1,000,000 | 5,000,000 | 999,999,999