refactored how communication is done between propertyEditorController and umbPropertyDirective
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
</label>
|
||||
|
||||
<umb-property-actions actions="propertyEditorAPI.propertyActions"></umb-property-actions>
|
||||
<umb-property-actions actions="propertyActions"></umb-property-actions>
|
||||
|
||||
<small class="control-description" ng-bind-html="property.description | preserveNewLineInHtml"></small>
|
||||
</div>
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user