Updating code style, removes obsolete files, now we can move the tree to the Translation section

This commit is contained in:
Sebastiaan Janssen
2018-06-13 15:17:31 +02:00
parent 9c33f1b1c9
commit d66e951b68
25 changed files with 315 additions and 611 deletions

View File

@@ -3,7 +3,7 @@
* @name umbraco.resources.dictionaryResource
* @description Loads in data for dictionary items
**/
function dictionaryResource($q, $http, umbRequestHelper, umbDataFormatter) {
function dictionaryResource($q, $http, $location, umbRequestHelper, umbDataFormatter) {
/**
* @ngdoc method
@@ -146,12 +146,41 @@ function dictionaryResource($q, $http, umbRequestHelper, umbDataFormatter) {
"Failed to get list");
}
/**
* @ngdoc method
* @name umbraco.resources.dictionaryResource#getSection
* @methodOf umbraco.resources.dictionaryResource
*
* @description
* Gets the current section that the dictionary tree is in (only settings and translation are allowed currently)
*
* ##usage
* <pre>
* var section = dictionaryResource.getSection();
* </pre>
*
* @returns string.
*
**/
function getSection() {
var section = $location.$$path;
if (section.startsWith("/")) {
section = section.substring(1, section.length);
}
var firstSlash = section.indexOf("/");
if (firstSlash !== -1) {
section = section.substring(0, firstSlash);
}
return section;
}
var resource = {
deleteById: deleteById,
create: create,
getById: getById,
save: save,
getList : getList
getList : getList,
getSection: getSection
};
return resource;
@@ -159,4 +188,4 @@ function dictionaryResource($q, $http, umbRequestHelper, umbDataFormatter) {
}
angular.module("umbraco.resources").factory("dictionaryResource", dictionaryResource);
angular.module("umbraco.resources").factory("dictionaryResource", dictionaryResource);

View File

@@ -7,37 +7,38 @@
* The controller for creating dictionary items
*/
function DictionaryCreateController($scope, $location, dictionaryResource, navigationService, notificationsService, formHelper) {
vm = this;
var vm = this;
vm.itemKey = '';
vm.itemKey = "";
function createItem() {
function createItem() {
var node = $scope.dialogOptions.currentNode;
var node = $scope.dialogOptions.currentNode;
dictionaryResource.create(node.id, vm.itemKey).then(function(data) {
navigationService.hideMenu();
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 });
// 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 });
// reset form state
formHelper.resetForm({ scope: $scope });
// navigate to edit view
$location.path("/settings/dictionary/edit/" + data);
// navigate to edit view
var section = dictionaryResource.getSection();
$location.path("/" + section + "/dictionary/edit/" + data);
},function(err) {
if (err.data && err.data.message) {
notificationsService.error(err.data.message);
navigationService.hideMenu();
}
});
}
vm.createItem = createItem;
}, function (err) {
if (err.data && err.data.message) {
notificationsService.error(err.data.message);
navigationService.hideMenu();
}
});
}
vm.createItem = createItem;
}
angular.module("umbraco").controller("Umbraco.Editors.Dictionary.CreateController", DictionaryCreateController);
angular.module("umbraco").controller("Umbraco.Editors.Dictionary.CreateController", DictionaryCreateController);

View File

@@ -7,43 +7,44 @@
* The controller for deleting dictionary items
*/
function DictionaryDeleteController($scope, $location, dictionaryResource, treeService, navigationService) {
vm = this;
var vm = this;
function cancel() {
navigationService.hideDialog();
}
function cancel() {
navigationService.hideDialog();
}
function performDelete() {
// stop from firing again on double-click
if ($scope.busy) { return false; }
function performDelete() {
// stop from firing again on double-click
if ($scope.busy) { return false; }
//mark it for deletion (used in the UI)
$scope.currentNode.loading = true;
$scope.busy = true;
//mark it for deletion (used in the UI)
$scope.currentNode.loading = true;
$scope.busy = true;
dictionaryResource.deleteById($scope.currentNode.id).then(function () {
$scope.currentNode.loading = false;
dictionaryResource.deleteById($scope.currentNode.id).then(function () {
$scope.currentNode.loading = false;
// get the parent id
var parentId = $scope.currentNode.parentId;
// get the parent id
var parentId = $scope.currentNode.parentId;
treeService.removeNode($scope.currentNode);
treeService.removeNode($scope.currentNode);
navigationService.hideMenu();
navigationService.hideMenu();
if (parentId !== "-1") {
// set the view of the parent item
$location.path("/settings/dictionary/edit/" + parentId);
} else {
// we have no parent, so redirect to section
$location.path("/settings/");
}
});
}
var section = dictionaryResource.getSection();
if (parentId !== "-1") {
// set the view of the parent item
$location.path("/" + section + "/dictionary/edit/" + parentId);
} else {
// we have no parent, so redirect to section
$location.path("/" + section + "/");
}
vm.cancel = cancel;
vm.performDelete = performDelete;
});
}
vm.cancel = cancel;
vm.performDelete = performDelete;
}
angular.module("umbraco").controller("Umbraco.Editors.Dictionary.DeleteController", DictionaryDeleteController);
angular.module("umbraco").controller("Umbraco.Editors.Dictionary.DeleteController", DictionaryDeleteController);

View File

@@ -7,7 +7,7 @@
* The controller for editing dictionary items
*/
function DictionaryEditController($scope, $routeParams, dictionaryResource, treeService, navigationService, appState, editorState, contentEditingHelper, formHelper, notificationsService, localizationService) {
vm = this;
var vm = this;
//setup scope vars
vm.nameDirty = false;
@@ -17,7 +17,7 @@ function DictionaryEditController($scope, $routeParams, dictionaryResource, tree
vm.page.menu = {};
vm.page.menu.currentSection = appState.getSectionState("currentSection");
vm.page.menu.currentNode = null;
vm.description = '';
vm.description = "";
function loadDictionary() {
@@ -42,8 +42,8 @@ function DictionaryEditController($scope, $routeParams, dictionaryResource, tree
}
function bindDictionary(data) {
localizationService.localize('dictionaryItem_description').then(function (value) {
vm.description = value.replace('%0%', data.name);
localizationService.localize("dictionaryItem_description").then(function (value) {
vm.description = value.replace("%0%", data.name);
});
// create data for umb-property displaying
@@ -104,7 +104,7 @@ function DictionaryEditController($scope, $routeParams, dictionaryResource, tree
$scope.$watch("vm.content.name", function (newVal, oldVal) {
//when the value changes, we need to set the name dirty
if (newVal && (newVal !== oldVal) && typeof(oldVal) !== 'undefined') {
if (newVal && (newVal !== oldVal) && typeof(oldVal) !== "undefined") {
vm.nameDirty = true;
}
});
@@ -112,4 +112,4 @@ function DictionaryEditController($scope, $routeParams, dictionaryResource, tree
onInit();
}
angular.module("umbraco").controller("Umbraco.Editors.Dictionary.EditController", DictionaryEditController);
angular.module("umbraco").controller("Umbraco.Editors.Dictionary.EditController", DictionaryEditController);

View File

@@ -7,8 +7,8 @@
* The controller for listting dictionary items
*/
function DictionaryListController($scope, $location, dictionaryResource, localizationService) {
vm = this;
vm.title = 'Dictionary overview';
var vm = this;
vm.title = "Dictionary overview";
vm.loading = false;
vm.items = [];
@@ -26,13 +26,14 @@ function DictionaryListController($scope, $location, dictionaryResource, localiz
}
function clickItem(id) {
$location.path("/settings/dictionary/edit/" + id);
var section = dictionaryResource.getSection();
$location.path("/" + section + "/dictionary/edit/" + id);
}
vm.clickItem = clickItem;
function onInit() {
localizationService.localize('dictionaryItem_overviewTitle').then(function (value) {
localizationService.localize("dictionaryItem_overviewTitle").then(function (value) {
vm.title = value;
});
@@ -43,4 +44,4 @@ function DictionaryListController($scope, $location, dictionaryResource, localiz
}
angular.module("umbraco").controller("Umbraco.Editors.Dictionary.ListController", DictionaryListController);
angular.module("umbraco").controller("Umbraco.Editors.Dictionary.ListController", DictionaryListController);