ok, properly fixes dirty tracking on the tags editor
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
vm.isLoading = false;
|
||||
|
||||
//ensure that the models are formatted correctly
|
||||
configureViewModel();
|
||||
configureViewModel(true);
|
||||
|
||||
// Set the visible prompt to -1 to ensure it will not be visible
|
||||
vm.promptIsVisible = "-1";
|
||||
@@ -140,17 +140,8 @@
|
||||
if (changes.value) {
|
||||
if (!changes.value.isFirstChange() && changes.value.currentValue !== changes.value.previousValue) {
|
||||
|
||||
if (initLoad) {
|
||||
//this occurs if we have to re-format the model on the init load, so set the flag to false
|
||||
//so the next time it actually changes we process it.
|
||||
initLoad = false;
|
||||
//we need to reset the form since it actually hasn't changed but it will be detected as changed
|
||||
vm.tagEditorForm.$setPristine();
|
||||
}
|
||||
else {
|
||||
configureViewModel();
|
||||
reValidate();
|
||||
}
|
||||
configureViewModel();
|
||||
reValidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,14 +155,19 @@
|
||||
$element.find('.tags-' + vm.htmlId).typeahead('destroy');
|
||||
}
|
||||
|
||||
function configureViewModel() {
|
||||
function configureViewModel(isInitLoad) {
|
||||
if (vm.value) {
|
||||
if (angular.isString(vm.value) && vm.value.length > 0) {
|
||||
if (vm.config.storageType === "Json") {
|
||||
//json storage
|
||||
vm.viewModel = JSON.parse(vm.value);
|
||||
updateModelValue(vm.viewModel);
|
||||
return;
|
||||
|
||||
//if this is the first load, we are just re-formatting the underlying model to be consistent
|
||||
//we don't want to notify the component parent of any changes, that will occur if the user actually
|
||||
//changes a value. If we notify at this point it will signal a form dirty change which we don't want.
|
||||
if (!isInitLoad) {
|
||||
updateModelValue(vm.viewModel);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//csv storage
|
||||
@@ -185,16 +181,18 @@
|
||||
return self.indexOf(v) === i;
|
||||
});
|
||||
|
||||
updateModelValue(vm.viewModel);
|
||||
return;
|
||||
//if this is the first load, we are just re-formatting the underlying model to be consistent
|
||||
//we don't want to notify the component parent of any changes, that will occur if the user actually
|
||||
//changes a value. If we notify at this point it will signal a form dirty change which we don't want.
|
||||
if (!isInitLoad) {
|
||||
updateModelValue(vm.viewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (angular.isArray(vm.value)) {
|
||||
vm.viewModel = vm.value;
|
||||
}
|
||||
}
|
||||
//if we've made it here we haven't had to re-format the model so we'll set this to false
|
||||
initLoad = false;
|
||||
}
|
||||
|
||||
function updateModelValue(val) {
|
||||
|
||||
Reference in New Issue
Block a user