Merge pull request #3479 from umbraco/temp8-IAction-cleanup

v8 IAction cleanup
This commit is contained in:
Warren Buckley
2018-10-31 14:18:38 +00:00
committed by GitHub
116 changed files with 1006 additions and 3517 deletions

View File

@@ -33,7 +33,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
* Returns the root angular scope
*/
function getRootScope() {
return angular.element(document.getElementById("umbracoMainPageBody")).scope();
return top.$("#umbracoMainPageBody").scope();
}
/**
@@ -46,7 +46,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
* Returns the root angular injector
*/
function getRootInjector() {
return angular.element(document.getElementById("umbracoMainPageBody")).injector();
return top.$("#umbracoMainPageBody").injector();
}
@@ -327,7 +327,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
//add the callback to the jquery data for the modal so we can call it on close to support the legacy way dialogs worked.
dialog.element.data("modalCb", onCloseCallback);
//add the close triggers
if (angular.isArray(closeTriggers)) {
if (top.angular.isArray(closeTriggers)) {
for (var i = 0; i < closeTriggers.length; i++) {
var e = dialog.find(closeTriggers[i]);
if (e.length > 0) {

View File

@@ -402,21 +402,34 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
throw "Cannot get a descendant node from a section container node without a treeAlias specified";
}
//if it is a section container, we need to find the tree to be searched
if (treeNode.isContainer) {
var foundRoot = null;
for (var c = 0; c < treeNode.children.length; c++) {
if (this.getTreeAlias(treeNode.children[c]) === treeAlias) {
foundRoot = treeNode.children[c];
break;
//the treeNode passed in could be a section container, or it could be a section group
//in either case we need to go through the children until we can find the actual tree root with the treeAlias
var self = this;
function getTreeRoot(tn) {
//if it is a section container, we need to find the tree to be searched
if (tn.isContainer) {
for (var c = 0; c < tn.children.length; c++) {
if (tn.children[c].isContainer) {
//recurse
return getTreeRoot(tn.children[c]);
}
else if (self.getTreeAlias(tn.children[c]) === treeAlias) {
return tn.children[c];
}
}
return null;
}
if (!foundRoot) {
throw "Could not find a tree in the current section with alias " + treeAlias;
else {
return tn;
}
treeNode = foundRoot;
}
var foundRoot = getTreeRoot(treeNode);
if (!foundRoot) {
throw "Could not find a tree in the current section with alias " + treeAlias;
}
treeNode = foundRoot;
//check this node
if (treeNode.id === id) {
return treeNode;

View File

@@ -0,0 +1,34 @@
/**
* @ngdoc controller
* @name Umbraco.Dialogs.LegacyDeleteController
* @function
*
* @description
* The controller for deleting content
*/
function LegacyDeleteController($scope, legacyResource, treeService, navigationService) {
$scope.performDelete = function () {
//mark it for deletion (used in the UI)
$scope.currentNode.loading = true;
legacyResource.deleteItem({
nodeId: $scope.currentNode.id,
nodeType: $scope.currentNode.nodeType,
alias: $scope.currentNode.name
}).then(function () {
$scope.currentNode.loading = false;
//TODO: Need to sync tree, etc...
treeService.removeNode($scope.currentNode);
navigationService.hideMenu();
});
};
$scope.cancel = function () {
navigationService.hideDialog();
};
}
angular.module("umbraco").controller("Umbraco.Dialogs.LegacyDeleteController", LegacyDeleteController);

View File

@@ -0,0 +1,14 @@
<div class="umb-dialog" ng-controller="Umbraco.Dialogs.LegacyDeleteController">
<div class="umb-dialog-body" >
<div class="umb-pane">
<p>
<localize key="defaultdialogs_confirmdelete">Are you sure you want to delete</localize> <strong>{{currentNode.name}}</strong> ?
</p>
<umb-confirm on-confirm="performDelete" on-cancel="cancel">
</umb-confirm>
</div>
</div>
</div>