Fixes: U4-6102 After renaming Grid row configurations all data is lost, also ensures that all events are unsubscribed on destroy
This commit is contained in:
@@ -48,27 +48,29 @@ function valFormManager(serverValidationManager, $rootScope, $log, $timeout, not
|
||||
element.addClass(className);
|
||||
}
|
||||
|
||||
var unsubscribe = [];
|
||||
|
||||
//listen for the forms saving event
|
||||
scope.$on(savingEventName, function (ev, args) {
|
||||
unsubscribe.push(scope.$on(savingEventName, function(ev, args) {
|
||||
element.addClass(className);
|
||||
|
||||
//set the flag so we can check to see if we should display the error.
|
||||
isSavingNewItem = $routeParams.create;
|
||||
});
|
||||
}));
|
||||
|
||||
//listen for the forms saved event
|
||||
scope.$on(savedEvent, function (ev, args) {
|
||||
unsubscribe.push(scope.$on(savedEvent, function(ev, args) {
|
||||
//remove validation class
|
||||
element.removeClass(className);
|
||||
|
||||
//clear form state as at this point we retrieve new data from the server
|
||||
//and all validation will have cleared at this point
|
||||
formCtrl.$setPristine();
|
||||
});
|
||||
}));
|
||||
|
||||
//This handles the 'unsaved changes' dialog which is triggered when a route is attempting to be changed but
|
||||
// the form has pending changes
|
||||
var locationEvent = $rootScope.$on('$locationChangeStart', function(event, nextLocation, currentLocation) {
|
||||
unsubscribe.push($rootScope.$on('$locationChangeStart', function(event, nextLocation, currentLocation) {
|
||||
if (!formCtrl.$dirty || isSavingNewItem) {
|
||||
return;
|
||||
}
|
||||
@@ -91,11 +93,11 @@ function valFormManager(serverValidationManager, $rootScope, $log, $timeout, not
|
||||
eventsService.emit("valFormManager.pendingChanges", true);
|
||||
}
|
||||
|
||||
});
|
||||
}));
|
||||
//Ensure to remove the event handler when this instance is destroyted
|
||||
scope.$on('$destroy', function() {
|
||||
if(locationEvent){
|
||||
locationEvent();
|
||||
for (var u in unsubscribe) {
|
||||
unsubscribe[u]();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -96,8 +96,10 @@ function valPropertyMsg(serverValidationManager) {
|
||||
//create properties on our custom scope so we can use it in our template
|
||||
scope.errorMsg = "";
|
||||
|
||||
var unsubscribe = [];
|
||||
|
||||
//listen for form error changes
|
||||
scope.$on("valStatusChanged", function (evt, args) {
|
||||
unsubscribe.push(scope.$on("valStatusChanged", function(evt, args) {
|
||||
if (args.form.$invalid) {
|
||||
|
||||
//first we need to check if the valPropertyMsg validity is invalid
|
||||
@@ -123,10 +125,10 @@ function valPropertyMsg(serverValidationManager) {
|
||||
hasError = false;
|
||||
scope.errorMsg = "";
|
||||
}
|
||||
}, true);
|
||||
}, true));
|
||||
|
||||
//listen for the forms saving event
|
||||
scope.$on("formSubmitting", function (ev, args) {
|
||||
unsubscribe.push(scope.$on("formSubmitting", function(ev, args) {
|
||||
showValidation = true;
|
||||
if (hasError && scope.errorMsg === "") {
|
||||
scope.errorMsg = getErrorMsg();
|
||||
@@ -135,15 +137,15 @@ function valPropertyMsg(serverValidationManager) {
|
||||
scope.errorMsg = "";
|
||||
stopWatch();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
//listen for the forms saved event
|
||||
scope.$on("formSubmitted", function (ev, args) {
|
||||
unsubscribe.push(scope.$on("formSubmitted", function(ev, args) {
|
||||
showValidation = false;
|
||||
scope.errorMsg = "";
|
||||
formCtrl.$setValidity('valPropertyMsg', true);
|
||||
stopWatch();
|
||||
});
|
||||
}));
|
||||
|
||||
//listen for server validation changes
|
||||
// NOTE: we pass in "" in order to listen for all validation changes to the content property, not for
|
||||
@@ -179,7 +181,16 @@ function valPropertyMsg(serverValidationManager) {
|
||||
serverValidationManager.unsubscribe(scope.property.alias, "");
|
||||
});
|
||||
}
|
||||
|
||||
//when the scope is disposed we need to unsubscribe
|
||||
scope.$on('$destroy', function () {
|
||||
for (var u in unsubscribe) {
|
||||
unsubscribe[u]();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
angular.module('umbraco.directives.validation').directive("valPropertyMsg", valPropertyMsg);
|
||||
@@ -43,8 +43,10 @@ function valToggleMsg(serverValidationManager) {
|
||||
}
|
||||
});
|
||||
|
||||
var unsubscribe = [];
|
||||
|
||||
//listen for the saving event (the result is a callback method which is called to unsubscribe)
|
||||
var unsubscribeSaving = scope.$on("formSubmitting", function (ev, args) {
|
||||
unsubscribe.push(scope.$on("formSubmitting", function(ev, args) {
|
||||
showValidation = true;
|
||||
if (formCtrl[attr.valMsgFor].$error[attr.valToggleMsg]) {
|
||||
element.show();
|
||||
@@ -56,20 +58,21 @@ function valToggleMsg(serverValidationManager) {
|
||||
else {
|
||||
element.hide();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
//listen for the saved event (the result is a callback method which is called to unsubscribe)
|
||||
var unsubscribeSaved = scope.$on("formSubmitted", function (ev, args) {
|
||||
unsubscribe.push(scope.$on("formSubmitted", function(ev, args) {
|
||||
showValidation = false;
|
||||
element.hide();
|
||||
});
|
||||
}));
|
||||
|
||||
//when the element is disposed we need to unsubscribe!
|
||||
// NOTE: this is very important otherwise if this directive is part of a modal, the listener still exists because the dom
|
||||
// element might still be there even after the modal has been hidden.
|
||||
element.bind('$destroy', function () {
|
||||
unsubscribeSaving();
|
||||
unsubscribeSaved();
|
||||
for (var u in unsubscribe) {
|
||||
unsubscribe[u]();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -537,6 +537,13 @@ angular.module('umbraco.services')
|
||||
template: 'views/common/dialogs/ysod.html',
|
||||
show: true
|
||||
});
|
||||
},
|
||||
|
||||
confirmDialog: function (ysodError) {
|
||||
|
||||
options.template = 'views/common/dialogs/confirm.html';
|
||||
options.show = true;
|
||||
return openDialog(options);
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -49,13 +49,18 @@ function mediaPickerController($scope, dialogService, entityResource, $log, icon
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$on("formSubmitting", function (ev, args) {
|
||||
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
|
||||
var currIds = _.map($scope.renderModel, function (i) {
|
||||
return i.id;
|
||||
});
|
||||
$scope.model.value = trim(currIds.join(), ",");
|
||||
});
|
||||
|
||||
//when the scope is destroyed we need to unsubscribe
|
||||
$scope.$on('$destroy', function () {
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
//load media data
|
||||
var modelIds = $scope.model.value ? $scope.model.value.split(',') : [];
|
||||
entityResource.getByIds(modelIds, dialogOptions.entityType).then(function (data) {
|
||||
|
||||
@@ -58,10 +58,15 @@ angular.module('umbraco')
|
||||
};
|
||||
|
||||
|
||||
$scope.$on("formSubmitting", function (ev, args) {
|
||||
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
|
||||
$scope.model.value = trim($scope.ids.join(), ",");
|
||||
});
|
||||
|
||||
//when the scope is destroyed we need to unsubscribe
|
||||
$scope.$on('$destroy', function () {
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
function trim(str, chr) {
|
||||
var rgxtrim = (!chr) ? new RegExp('^\\s+|\\s+$', 'g') : new RegExp('^'+chr+'+|'+chr+'+$', 'g');
|
||||
return str.replace(rgxtrim, '');
|
||||
|
||||
@@ -43,13 +43,18 @@ angular.module('umbraco')
|
||||
|
||||
|
||||
//we always need to ensure we dont submit anything broken
|
||||
$scope.$on("formSubmitting", function (ev, args) {
|
||||
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
|
||||
if($scope.model.value.type === "member"){
|
||||
$scope.model.value.id = -1;
|
||||
$scope.model.value.query = "";
|
||||
}
|
||||
});
|
||||
|
||||
//when the scope is destroyed we need to unsubscribe
|
||||
$scope.$on('$destroy', function () {
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
function populate(item){
|
||||
$scope.clear();
|
||||
item.icon = iconHelper.convertFromLegacyIcon(item.icon);
|
||||
|
||||
@@ -91,15 +91,17 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.ChangePasswordCont
|
||||
//set model to null
|
||||
$scope.model.value = null;
|
||||
};
|
||||
|
||||
|
||||
var unsubscribe = [];
|
||||
|
||||
//listen for the saved event, when that occurs we'll
|
||||
//change to changing = false;
|
||||
$scope.$on("formSubmitted", function () {
|
||||
unsubscribe.push($scope.$on("formSubmitted", function() {
|
||||
if ($scope.model.config.disableToggle === false) {
|
||||
$scope.changing = false;
|
||||
}
|
||||
});
|
||||
$scope.$on("formSubmitting", function() {
|
||||
}
|
||||
}));
|
||||
unsubscribe.push($scope.$on("formSubmitting", function() {
|
||||
//if there was a previously generated password displaying, clear it
|
||||
if ($scope.changing && $scope.model.value) {
|
||||
$scope.model.value.generatedPassword = null;
|
||||
@@ -108,6 +110,13 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.ChangePasswordCont
|
||||
//we are not changing, so the model needs to be null
|
||||
$scope.model.value = null;
|
||||
}
|
||||
}));
|
||||
|
||||
//when the scope is destroyed we need to unsubscribe
|
||||
$scope.$on('$destroy', function () {
|
||||
for (var u in unsubscribe) {
|
||||
unsubscribe[u]();
|
||||
}
|
||||
});
|
||||
|
||||
$scope.showReset = function() {
|
||||
|
||||
@@ -158,13 +158,18 @@ function contentPickerController($scope, dialogService, entityResource, editorSt
|
||||
$scope.renderModel = [];
|
||||
};
|
||||
|
||||
$scope.$on("formSubmitting", function (ev, args) {
|
||||
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
|
||||
var currIds = _.map($scope.renderModel, function (i) {
|
||||
return i.id;
|
||||
});
|
||||
$scope.model.value = trim(currIds.join(), ",");
|
||||
});
|
||||
|
||||
//when the scope is destroyed we need to unsubscribe
|
||||
$scope.$on('$destroy', function () {
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
//load current data
|
||||
var modelIds = $scope.model.value ? $scope.model.value.split(',') : [];
|
||||
entityResource.getByIds(modelIds, entityType).then(function (data) {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<div>
|
||||
<div class="umb-panel-body no-header with-footer compact">
|
||||
|
||||
<umb-pane>
|
||||
<umb-control-group>
|
||||
|
||||
<h3 class="alert alert-warn ng-scope">Warning!</h3>
|
||||
|
||||
<p>
|
||||
You are deleting the row configuration '<strong>{{dialogData.rowName}}</strong>'
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If there is existing content with the row configuration '<strong>{{dialogData.rowName}}</strong>' then
|
||||
the content in that row will be lost.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Do you want to continue?
|
||||
</p>
|
||||
|
||||
|
||||
</umb-control-group>
|
||||
</umb-pane>
|
||||
</div>
|
||||
|
||||
<div class="umb-panel-footer">
|
||||
<umb-confirm on-confirm="submit" on-cancel="close">
|
||||
</umb-confirm>
|
||||
</div>
|
||||
</div>
|
||||
@@ -127,9 +127,24 @@ angular.module("umbraco")
|
||||
);
|
||||
};
|
||||
|
||||
//var rowDeletesPending = false;
|
||||
$scope.deleteLayout = function (index) {
|
||||
//rowDeletesPending = true;
|
||||
|
||||
$scope.deleteLayout = function(index){
|
||||
$scope.model.value.layouts.splice(index, 1);
|
||||
//show ok/cancel dialog
|
||||
var confirmDialog = dialogService.open(
|
||||
{
|
||||
template: "views/propertyEditors/grid/dialogs/rowdeleteconfirm.html",
|
||||
show: true,
|
||||
callback: function() {
|
||||
$scope.model.value.layouts.splice(index, 1);
|
||||
},
|
||||
dialogData: {
|
||||
rowName: $scope.model.value.layouts[index].name
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -216,7 +231,7 @@ angular.module("umbraco")
|
||||
/****************
|
||||
Clean up
|
||||
*****************/
|
||||
$scope.$on("formSubmitting", function (ev, args) {
|
||||
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
|
||||
var ts = $scope.model.value.templates;
|
||||
var ls = $scope.model.value.layouts;
|
||||
|
||||
@@ -237,4 +252,9 @@ angular.module("umbraco")
|
||||
});
|
||||
});
|
||||
|
||||
//when the scope is destroyed we need to unsubscribe
|
||||
$scope.$on('$destroy', function () {
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -85,7 +85,7 @@ angular.module('umbraco')
|
||||
$scope.renderModel = [];
|
||||
};
|
||||
|
||||
$scope.$on("formSubmitting", function (ev, args) {
|
||||
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
|
||||
var syntax = [];
|
||||
angular.forEach($scope.renderModel, function(value, key){
|
||||
syntax.push(value.syntax);
|
||||
@@ -94,6 +94,11 @@ angular.module('umbraco')
|
||||
$scope.model.value = syntax.join("");
|
||||
});
|
||||
|
||||
//when the scope is destroyed we need to unsubscribe
|
||||
$scope.$on('$destroy', function () {
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
|
||||
function trim(str, chr) {
|
||||
var rgxtrim = (!chr) ? new RegExp('^\\s+|\\s+$', 'g') : new RegExp('^'+chr+'+|'+chr+'+$', 'g');
|
||||
|
||||
@@ -65,13 +65,18 @@ function memberGroupPicker($scope, dialogService){
|
||||
$scope.renderModel = [];
|
||||
};
|
||||
|
||||
$scope.$on("formSubmitting", function (ev, args) {
|
||||
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
|
||||
var currIds = _.map($scope.renderModel, function (i) {
|
||||
return i.id;
|
||||
});
|
||||
$scope.model.value = trim(currIds.join(), ",");
|
||||
});
|
||||
|
||||
//when the scope is destroyed we need to unsubscribe
|
||||
$scope.$on('$destroy', function () {
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
angular.module('umbraco').controller("Umbraco.PropertyEditors.MemberGroupPickerController", memberGroupPicker);
|
||||
@@ -60,13 +60,18 @@ function memberPickerController($scope, dialogService, entityResource, $log, ico
|
||||
$scope.renderModel = [];
|
||||
};
|
||||
|
||||
$scope.$on("formSubmitting", function (ev, args) {
|
||||
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
|
||||
var currIds = _.map($scope.renderModel, function (i) {
|
||||
return i.id;
|
||||
});
|
||||
$scope.model.value = trim(currIds.join(), ",");
|
||||
});
|
||||
|
||||
//when the scope is destroyed we need to unsubscribe
|
||||
$scope.$on('$destroy', function () {
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
//load member data
|
||||
var modelIds = $scope.model.value ? $scope.model.value.split(',') : [];
|
||||
entityResource.getByIds(modelIds, "Member").then(function (data) {
|
||||
|
||||
@@ -58,12 +58,16 @@ angular.module("umbraco").controller("Umbraco.PrevalueEditors.RteController",
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$on("formSubmitting", function (ev, args) {
|
||||
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
|
||||
|
||||
var commands = _.where($scope.tinyMceConfig.commands, {selected: true});
|
||||
$scope.model.value.toolbar = _.pluck(commands, "frontEndCommand");
|
||||
|
||||
|
||||
});
|
||||
|
||||
//when the scope is destroyed we need to unsubscribe
|
||||
$scope.$on('$destroy', function () {
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user