* Added button for cancelling dictionary create action * Use hideMenu * Align dictionary create with the other creates * Align import documenttype * Align for data type folder create * Align document type create buttons * Forgot small ng-show * Align create media folder buttons * Align create macro buttons * Align create relation buttons * Align create partial view macro folder buttons * Align partial view folder create buttons * Align create scripts folder buttons * Align create scripts folder buttons * Use primary instead of success
54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
/**
|
|
* @ngdoc controller
|
|
* @name Umbraco.Editors.Dictionary.CreateController
|
|
* @function
|
|
*
|
|
* @description
|
|
* The controller for creating dictionary items
|
|
*/
|
|
function DictionaryCreateController($scope, $location, dictionaryResource, navigationService, notificationsService, formHelper, appState) {
|
|
|
|
var vm = this;
|
|
|
|
vm.itemKey = "";
|
|
vm.createItem = createItem;
|
|
vm.close = close;
|
|
$scope.$emit("$changeTitle", "");
|
|
|
|
function close() {
|
|
navigationService.hideDialog();
|
|
}
|
|
|
|
function createItem() {
|
|
|
|
if (formHelper.submitForm({ scope: $scope, formCtrl: $scope.createDictionaryForm })) {
|
|
|
|
var node = $scope.currentNode;
|
|
|
|
dictionaryResource.create(node.id, vm.itemKey).then(function (data) {
|
|
navigationService.hideMenu();
|
|
|
|
// set new item as active in tree
|
|
var currPath = node.path ? node.path : "-1";
|
|
navigationService.syncTree({ tree: "dictionary", path: currPath + "," + data, forceReload: true, activate: true });
|
|
|
|
// reset form state
|
|
formHelper.resetForm({ scope: $scope, formCtrl: $scope.createDictionaryForm });
|
|
|
|
// navigate to edit view
|
|
var currentSection = appState.getSectionState("currentSection");
|
|
$location.path("/" + currentSection + "/dictionary/edit/" + data);
|
|
|
|
}, function (err) {
|
|
formHelper.resetForm({ scope: $scope, formCtrl: $scope.createDictionaryForm, hasErrors: true });
|
|
if (err.data && err.data.message) {
|
|
notificationsService.error(err.data.message);
|
|
navigationService.hideMenu();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
angular.module("umbraco").controller("Umbraco.Editors.Dictionary.CreateController", DictionaryCreateController);
|