From b4ae7ebe2ce99d2fb7c114a96fa7b0a84ccd5748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 25 Nov 2019 15:38:11 +0100 Subject: [PATCH] refactored how communication is done between propertyEditorController and umbPropertyDirective --- .../property/umbproperty.directive.js | 21 +++++--------- .../components/property/umb-property.html | 2 +- .../nestedcontent/nestedcontent.component.js | 28 ++++++++++--------- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/property/umbproperty.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/property/umbproperty.directive.js index 06b9e51fba..9917b884a0 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/property/umbproperty.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/property/umbproperty.directive.js @@ -15,19 +15,20 @@ angular.module("umbraco.directives") restrict: 'E', replace: true, templateUrl: 'views/components/property/umb-property.html', - link: function (scope) { + link: function ($scope) { - scope.propertyEditorAPI = {}; + $scope.propertyActions = []; userService.getCurrentUser().then(function (u) { var isAdmin = u.userGroups.indexOf('admin') !== -1; - scope.propertyAlias = (Umbraco.Sys.ServerVariables.isDebuggingEnabled === true || isAdmin) ? scope.property.alias : null; + $scope.propertyAlias = (Umbraco.Sys.ServerVariables.isDebuggingEnabled === true || isAdmin) ? $scope.property.alias : null; }); }, //Define a controller for this directive to expose APIs to other directives controller: function ($scope, $timeout) { var self = this; + self.propertyActions = []; //set the API properties/methods @@ -35,18 +36,10 @@ angular.module("umbraco.directives") self.setPropertyError = function (errorMsg) { $scope.property.propertyErrorMessage = errorMsg; }; - - var unsubscribe = $scope.$on("ExposePropertyEditorAPI", function(event, api) { - - //avoid eventual parent properties to capture this. - event.stopPropagation(); - - $scope.propertyEditorAPI = api; - }); - $scope.$on("$destroy", function () { - unsubscribe(); - }); + self.setPropertyActions = function(actions) { + $scope.propertyActions = actions; + }; } }; diff --git a/src/Umbraco.Web.UI.Client/src/views/components/property/umb-property.html b/src/Umbraco.Web.UI.Client/src/views/components/property/umb-property.html index 927f677463..46660fc685 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/property/umb-property.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/property/umb-property.html @@ -21,7 +21,7 @@ - + diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.component.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.component.js index 03a7207720..0504e29a8b 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.component.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.component.js @@ -7,12 +7,13 @@ templateUrl: 'views/propertyeditors/nestedcontent/nestedcontent.propertyeditor.html', controller: NestedContentController, controllerAs: 'vm', - bindings: { - + require: { + umbProperty: '^umbProperty', + umbVariantContent: '?^^umbVariantContent' } }); - function NestedContentController($scope, $interpolate, $filter, $timeout, contentResource, localizationService, iconHelper, clipboardService, eventsService, overlayService, $routeParams, editorState, propertyEditorService) { + function NestedContentController($scope, $interpolate, $filter, $timeout, contentResource, localizationService, iconHelper, clipboardService, eventsService, overlayService, $routeParams, editorState) { var vm = this; var model = $scope.$parent.$parent.model; @@ -65,14 +66,14 @@ // remove dublicates aliases = aliases.filter((item, index) => aliases.indexOf(item) === index); + + var nodeName = ""; - // Retrive variant name - var culture = $routeParams.cculture ? $routeParams.cculture : $routeParams.mculture; - var activeVariant = _.find(editorState.current.variants, function (v) { - return !v.language || v.language.culture === culture; - }); + if(vm.umbVariantContent) { + nodeName = vm.umbVariantContent.editor.content.name; + } - localizationService.localize("clipboard_labelForArrayOfItemsFrom", [model.label, activeVariant.name]).then(function(data) { + localizationService.localize("clipboard_labelForArrayOfItemsFrom", [model.label, nodeName]).then(function(data) { clipboardService.copyArray("elementTypeArray", aliases, vm.nodes, data, "icon-thumbnail-list", model.id); }); } @@ -538,13 +539,14 @@ - var api = {}; - api.propertyActions = [ + var propertyActions = [ copyAllEntriesAction ]; - propertyEditorService.exposeAPI($scope, api);// must be executed at a state where the API is set. - + this.$onInit = function () { + this.umbProperty.setPropertyActions(propertyActions); + }; + var unsubscribe = $scope.$on("formSubmitting", function (ev, args) { updateModel(); });