diff --git a/awx/ui/client/src/instance-groups/instance-groups.service.js b/awx/ui/client/src/instance-groups/instance-groups.service.js index cf809932c2..6dbbaa95a0 100644 --- a/awx/ui/client/src/instance-groups/instance-groups.service.js +++ b/awx/ui/client/src/instance-groups/instance-groups.service.js @@ -7,6 +7,24 @@ export default let defers = groups.map((group) => Rest.post(group)); return Promise.all(defers); }, + /** + * This function compares the currently saved ids and the selected ids - as soon as + * we encounter a difference between the two arrays, we mark all remaining currently + * saved ids in the array for disassociation. + * + * Example Scenario + * ----------------- + * page is loaded with [1,2,3,4,5,6] as the currently selected tags + * user removes tag 3 from the middle + * user adds a new tag 7 to the end + * user appends tag 3 to the end + * + * _______ all ids here and to the right are disassociated + * | + * current: [1,2,3,4,5,6] + * selected: [1,2,4,5,6,7,3] + * |_______ all ids here and to the right are (re)associated + */ editInstanceGroups: function(url, instance_groups) { Rest.setUrl(url); return Rest.get()