I have a problem statement where, there are 2 features assign privilege and remove privilege to people. Now one can select single person or multiple person to assign/remove privilege. Both features have various common UI elements.Below are the common features of assign and remove privilege:
- Same tabular layout of privileges to assign (in case single/multiple people) and remove(in case multiple people are selected).
- Same set of filters to filter through privileges to assign.
- A step layout where first step will show selection view for privileges, step 2 will take extra input before assigning/removing privileges and step 3 will show the success message which all privileges are assigned/removed.
Below are the differences:
- In case of remove privilege when only one person selected the list of already assigned privileges will be shown instead of the list of all the privileges.
- The service to assign and remove privilege is different.
- In case of remove privilege when only one person selected the filters should filter form the list assigned privileges only(so in this case the service call will be different).
We were developing assign privilege first, so I created a component which support assign privilege. Now we got the requirement for remove privilege. Considering the similarities I want to reuse my assign privilege component.
I want to refactor my code in such a way that it should not get messed up, as it might become difficult to manage if I keep on adding if else conditions for assign and remove privilege for single and multiple people in the same component.
Kindly suggest me some design pattern or any example to effectively achieve this.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire