Removes hacky way to get the section name and replaces it with the normal way to get it
This commit is contained in:
@@ -145,42 +145,13 @@ function dictionaryResource($q, $http, $location, umbRequestHelper, umbDataForma
|
||||
"getList")),
|
||||
"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,
|
||||
getSection: getSection
|
||||
getList : getList
|
||||
};
|
||||
|
||||
return resource;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* @description
|
||||
* The controller for creating dictionary items
|
||||
*/
|
||||
function DictionaryCreateController($scope, $location, dictionaryResource, navigationService, notificationsService, formHelper) {
|
||||
function DictionaryCreateController($scope, $location, dictionaryResource, navigationService, notificationsService, formHelper, appState) {
|
||||
var vm = this;
|
||||
|
||||
vm.itemKey = "";
|
||||
@@ -26,8 +26,8 @@ function DictionaryCreateController($scope, $location, dictionaryResource, navig
|
||||
formHelper.resetForm({ scope: $scope });
|
||||
|
||||
// navigate to edit view
|
||||
var section = dictionaryResource.getSection();
|
||||
$location.path("/" + section + "/dictionary/edit/" + data);
|
||||
var currentSection = appState.getSectionState("currentSection");
|
||||
$location.path("/" + currentSection + "/dictionary/edit/" + data);
|
||||
|
||||
|
||||
}, function (err) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* @description
|
||||
* The controller for deleting dictionary items
|
||||
*/
|
||||
function DictionaryDeleteController($scope, $location, dictionaryResource, treeService, navigationService) {
|
||||
function DictionaryDeleteController($scope, $location, dictionaryResource, treeService, navigationService, appState) {
|
||||
var vm = this;
|
||||
|
||||
function cancel() {
|
||||
@@ -31,13 +31,13 @@ function DictionaryDeleteController($scope, $location, dictionaryResource, treeS
|
||||
|
||||
navigationService.hideMenu();
|
||||
|
||||
var section = dictionaryResource.getSection();
|
||||
var currentSection = appState.getSectionState("currentSection");
|
||||
if (parentId !== "-1") {
|
||||
// set the view of the parent item
|
||||
$location.path("/" + section + "/dictionary/edit/" + parentId);
|
||||
$location.path("/" + currentSection + "/dictionary/edit/" + parentId);
|
||||
} else {
|
||||
// we have no parent, so redirect to section
|
||||
$location.path("/" + section + "/");
|
||||
$location.path("/" + currentSection + "/");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* @description
|
||||
* The controller for listting dictionary items
|
||||
*/
|
||||
function DictionaryListController($scope, $location, dictionaryResource, localizationService) {
|
||||
function DictionaryListController($scope, $location, dictionaryResource, localizationService, appState) {
|
||||
var vm = this;
|
||||
vm.title = "Dictionary overview";
|
||||
vm.loading = false;
|
||||
@@ -26,8 +26,8 @@ function DictionaryListController($scope, $location, dictionaryResource, localiz
|
||||
}
|
||||
|
||||
function clickItem(id) {
|
||||
var section = dictionaryResource.getSection();
|
||||
$location.path("/" + section + "/dictionary/edit/" + id);
|
||||
var currentSection = appState.getSectionState("currentSection");
|
||||
$location.path("/" + currentSection + "/dictionary/edit/" + id);
|
||||
}
|
||||
|
||||
vm.clickItem = clickItem;
|
||||
|
||||
Reference in New Issue
Block a user