* This universal function is called when child model or child form is modified * by the modified component itself. * It will update the corresponding tracking list, the number of modified components * and the form itself if required. * * @param {FormContr
(ctrl, list)
| 84 | * @param {FormController[]|NgModelController[]} list The tracking list of modified controllers (models or forms) |
| 85 | */ |
| 86 | function onModifiedStateChanged (ctrl, list) { |
| 87 | |
| 88 | var listIndex = list.indexOf(ctrl); |
| 89 | var presentInList = (-1 !== listIndex); |
| 90 | |
| 91 | if (ctrl.modified && !presentInList) { |
| 92 | |
| 93 | // Adding model to the internal list of modified models. |
| 94 | list.push(ctrl); |
| 95 | |
| 96 | updateFormState(); |
| 97 | |
| 98 | } else if (!ctrl.modified && presentInList) { |
| 99 | |
| 100 | // Removing model from the internal list of modified models. |
| 101 | list.splice(listIndex, 1); |
| 102 | |
| 103 | updateFormState(); |
| 104 | |
| 105 | } |
| 106 | |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Updates form state and notifies it's parents. |
no test coverage detected