diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbappheader.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbappheader.directive.js
index 372a816dd57e..2b9a96cf5501 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbappheader.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbappheader.directive.js
@@ -18,14 +18,14 @@
];
// when a user logs out or timesout
- evts.push(eventsService.on("app.notAuthenticated", function() {
+ evts.push(eventsService.on("app.notAuthenticated", function () {
scope.authenticated = false;
scope.user = null;
}));
// when the application is ready and the user is authorized setup the data
- evts.push(eventsService.on("app.ready", function(evt, data) {
-
+ evts.push(eventsService.on("app.ready", function (evt, data) {
+
scope.authenticated = true;
scope.user = data.user;
@@ -40,10 +40,10 @@
}));
- evts.push(eventsService.on("app.userRefresh", function(evt) {
- userService.refreshCurrentUser().then(function(data) {
+ evts.push(eventsService.on("app.userRefresh", function (evt) {
+ userService.refreshCurrentUser().then(function (data) {
scope.user = data;
-
+
if (scope.user.avatars) {
scope.avatar = [];
if (Utilities.isArray(scope.user.avatars)) {
@@ -54,10 +54,10 @@
}
});
}));
-
+
scope.rememberFocus = focusService.rememberFocus;
-
- scope.searchClick = function() {
+
+ scope.searchClick = function () {
var showSearch = appState.getSearchState("show");
appState.setSearchState("show", !showSearch);
};
@@ -71,7 +71,7 @@
};
scope.avatarClick = function () {
- if(!scope.userDialog) {
+ if (!scope.userDialog) {
scope.userDialog = {
view: "user",
show: true,
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js
index 91b0ba8754e5..d674b3d1e8c3 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js
@@ -38,7 +38,7 @@
//watch for changes to isNew, set the page.isNew accordingly and load the breadcrumb if we can
$scope.$watch('isNew', function (newVal, oldVal) {
-
+
$scope.page.isNew = Object.toBoolean(newVal);
//We fetch all ancestors of the node to generate the footer breadcrumb navigation
@@ -182,32 +182,32 @@
}
}));
- evts.push(eventsService.on("editors.content.reload", function (name, args) {
+ evts.push(eventsService.on("editors.content.reload", function (name, args) {
if (args && args.node && $scope.content.id === args.node.id) {
reload();
loadBreadcrumb();
syncTreeNode($scope.content, $scope.content.path);
}
}));
-
- evts.push(eventsService.on("rte.file.uploading", function(){
+
+ evts.push(eventsService.on("rte.file.uploading", function () {
$scope.page.saveButtonState = "busy";
$scope.page.buttonGroupState = "busy";
}));
- evts.push(eventsService.on("rte.file.uploaded", function(){
+ evts.push(eventsService.on("rte.file.uploaded", function () {
$scope.page.saveButtonState = "success";
$scope.page.buttonGroupState = "success";
}));
- evts.push(eventsService.on("rte.shortcut.save", function(){
+ evts.push(eventsService.on("rte.shortcut.save", function () {
if ($scope.page.showSaveButton) {
$scope.save();
}
}));
- evts.push(eventsService.on("content.saved", function(){
+ evts.push(eventsService.on("content.saved", function () {
// Clear out localstorage keys that start with tinymce__
// When we save/perist a content node
// NOTE: clearAll supports a RegEx pattern of items to remove
@@ -323,7 +323,7 @@
.then(function (syncArgs) {
$scope.page.menu.currentNode = syncArgs.node;
if (reloadChildren && syncArgs.node.expanded) {
- treeService.loadNodeChildren({node: syncArgs.node});
+ treeService.loadNodeChildren({ node: syncArgs.node });
}
}, function () {
//handle the rejection
@@ -784,7 +784,7 @@
var dialog = {
parentScope: $scope,
view: "views/content/overlays/schedule.html",
- variants: angular.copy($scope.content.variants), //set a model property for the dialog
+ variants: Utilities.copy($scope.content.variants), //set a model property for the dialog
skipFormValidation: true, //when submitting the overlay form, skip any client side validation
submitButtonLabelKey: "buttons_schedulePublish",
submit: function (model) {
@@ -818,7 +818,7 @@
}
model.submitButtonState = "error";
//re-map the dialog model since we've re-bound the properties
- dialog.variants = angular.copy($scope.content.variants);
+ dialog.variants = Utilities.copy($scope.content.variants);
//don't reject, we've handled the error
return $q.when(err);
});
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js
index a4dac046e5c0..6aba1e675880 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js
@@ -44,7 +44,7 @@
/** Called when the component initializes */
function onInit() {
- prevContentDateUpdated = angular.copy(vm.content.updateDate);
+ prevContentDateUpdated = Utilities.copy(vm.content.updateDate);
setActiveCulture();
}
@@ -68,7 +68,7 @@
function doCheck() {
if (!angular.equals(vm.content.updateDate, prevContentDateUpdated)) {
setActiveCulture();
- prevContentDateUpdated = angular.copy(vm.content.updateDate);
+ prevContentDateUpdated = Utilities.copy(vm.content.updateDate);
}
}
@@ -152,7 +152,7 @@
//copy the apps from the main model if not assigned yet to the variant
if (!variant.apps) {
- variant.apps = angular.copy(vm.content.apps);
+ variant.apps = Utilities.copy(vm.content.apps);
}
//if this is a variant has a culture/language than we need to assign the language drop down info
@@ -185,7 +185,7 @@
// keep track of the open variants across the different split views
// push the first variant then update the variant index based on the editor index
- if(vm.openVariants && vm.openVariants.length === 0) {
+ if (vm.openVariants && vm.openVariants.length === 0) {
vm.openVariants.push(variant.language.culture);
} else {
vm.openVariants[editorIndex] = variant.language.culture;
@@ -205,10 +205,10 @@
}
// make sure the same app it set to active in the new variant
- if(activeAppAlias) {
- angular.forEach(variant.apps, function(app) {
+ if (activeAppAlias) {
+ angular.forEach(variant.apps, function (app) {
app.active = false;
- if(app.alias === activeAppAlias) {
+ if (app.alias === activeAppAlias) {
app.active = true;
}
});
@@ -283,10 +283,10 @@
function selectVariant(variant, editorIndex) {
// prevent variants already open in a split view to be opened
- if(vm.openVariants.indexOf(variant.language.culture) !== -1) {
+ if (vm.openVariants.indexOf(variant.language.culture) !== -1) {
return;
}
-
+
//if the editor index is zero, then update the query string to track the lang selection, otherwise if it's part
//of a 2nd split view editor then update the model directly.
if (editorIndex === 0) {
@@ -313,7 +313,7 @@
//update the editors collection
insertVariantEditor(editorIndex, contentVariant);
-
+
}
}
@@ -322,21 +322,21 @@
* @param {any} app This is the model of the selected app
*/
function selectApp(app) {
- if(vm.onSelectApp) {
- vm.onSelectApp({"app": app});
+ if (vm.onSelectApp) {
+ vm.onSelectApp({ "app": app });
}
}
-
+
function selectAppAnchor(app, anchor) {
- if(vm.onSelectAppAnchor) {
- vm.onSelectAppAnchor({"app": app, "anchor": anchor});
+ if (vm.onSelectAppAnchor) {
+ vm.onSelectAppAnchor({ "app": app, "anchor": anchor });
}
}
-
-
- $scope.$on("editors.apps.appChanged", function($event, $args) {
+
+
+ $scope.$on("editors.apps.appChanged", function ($event, $args) {
var app = $args.app;
- if(app && app.alias) {
+ if (app && app.alias) {
activeAppAlias = app.alias;
}
});
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbrawmodel.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbrawmodel.directive.js
index 406f65781cbc..ab92cfdb91c2 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbrawmodel.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbrawmodel.directive.js
@@ -9,91 +9,91 @@ will override element type to textarea and add own attribute ngModel tied to jso
*/
angular.module("umbraco.directives")
- .directive('umbRawModel', function () {
- return {
- restrict: 'A',
- require: 'ngModel',
- template: '',
- replace : true,
- scope: {
- model: '=umbRawModel',
- validateOn:'='
- },
- link: function (scope, element, attrs, ngModelCtrl) {
-
- function setEditing (value) {
- scope.jsonEditing = angular.copy( jsonToString(value));
- }
-
- function updateModel (value) {
- scope.model = stringToJson(value);
- }
-
- function setValid() {
- ngModelCtrl.$setValidity('json', true);
- }
-
- function setInvalid () {
- ngModelCtrl.$setValidity('json', false);
- }
-
- function stringToJson(text) {
- try {
- return angular.fromJson(text);
- } catch (err) {
- setInvalid();
- return text;
- }
- }
-
- function jsonToString(object) {
- // better than JSON.stringify(), because it formats + filters $$hashKey etc.
- // NOTE that this will remove all $-prefixed values
- return Utilities.toJson(object, true);
- }
-
- function isValidJson(model) {
- var flag = true;
- try {
- angular.fromJson(model);
- } catch (err) {
- flag = false;
- }
- return flag;
- }
-
- //init
- setEditing(scope.model);
-
- var onInputChange = function(newval,oldval){
- if (newval !== oldval) {
- if (isValidJson(newval)) {
- setValid();
- updateModel(newval);
- } else {
- setInvalid();
- }
- }
- };
-
- if(scope.validateOn){
- element.on(scope.validateOn, function(){
- scope.$apply(function(){
- onInputChange(scope.jsonEditing);
- });
- });
- }else{
- //check for changes going out
- scope.$watch('jsonEditing', onInputChange, true);
- }
-
- //check for changes coming in
- scope.$watch('model', function (newval, oldval) {
- if (newval !== oldval) {
- setEditing(newval);
- }
- }, true);
-
- }
- };
- });
+ .directive('umbRawModel', function () {
+ return {
+ restrict: 'A',
+ require: 'ngModel',
+ template: '',
+ replace: true,
+ scope: {
+ model: '=umbRawModel',
+ validateOn: '='
+ },
+ link: function (scope, element, attrs, ngModelCtrl) {
+
+ function setEditing(value) {
+ scope.jsonEditing = Utilities.copy(jsonToString(value));
+ }
+
+ function updateModel(value) {
+ scope.model = stringToJson(value);
+ }
+
+ function setValid() {
+ ngModelCtrl.$setValidity('json', true);
+ }
+
+ function setInvalid() {
+ ngModelCtrl.$setValidity('json', false);
+ }
+
+ function stringToJson(text) {
+ try {
+ return angular.fromJson(text);
+ } catch (err) {
+ setInvalid();
+ return text;
+ }
+ }
+
+ function jsonToString(object) {
+ // better than JSON.stringify(), because it formats + filters $$hashKey etc.
+ // NOTE that this will remove all $-prefixed values
+ return Utilities.toJson(object, true);
+ }
+
+ function isValidJson(model) {
+ var flag = true;
+ try {
+ angular.fromJson(model);
+ } catch (err) {
+ flag = false;
+ }
+ return flag;
+ }
+
+ //init
+ setEditing(scope.model);
+
+ var onInputChange = function (newval, oldval) {
+ if (newval !== oldval) {
+ if (isValidJson(newval)) {
+ setValid();
+ updateModel(newval);
+ } else {
+ setInvalid();
+ }
+ }
+ };
+
+ if (scope.validateOn) {
+ element.on(scope.validateOn, function () {
+ scope.$apply(function () {
+ onInputChange(scope.jsonEditing);
+ });
+ });
+ } else {
+ //check for changes going out
+ scope.$watch('jsonEditing', onInputChange, true);
+ }
+
+ //check for changes coming in
+ scope.$watch('model', function (newval, oldval) {
+ if (newval !== oldval) {
+ setEditing(newval);
+ }
+ }, true);
+
+ }
+ };
+ });
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js
index fa1f4227a28b..ad396e7a9a15 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js
@@ -193,352 +193,351 @@ Opens an overlay to show a custom YSOD.
@param {string} position The overlay position ("left", "right", "center": "target").
**/
-(function() {
- 'use strict';
+(function () {
+ 'use strict';
function OverlayDirective($timeout, formHelper, overlayHelper, localizationService, $q, $templateCache, $http, $compile) {
- function link(scope, el, attr, ctrl) {
+ function link(scope, el, attr, ctrl) {
- scope.directive = {
- enableConfirmButton: false
- };
+ scope.directive = {
+ enableConfirmButton: false
+ };
- var overlayNumber = 0;
- var numberOfOverlays = 0;
- var isRegistered = false;
+ var overlayNumber = 0;
+ var numberOfOverlays = 0;
+ var isRegistered = false;
- var modelCopy = {};
- var unsubscribe = [];
+ var modelCopy = {};
+ var unsubscribe = [];
- function activate() {
- setView();
+ function activate() {
+ setView();
- setButtonText();
+ setButtonText();
- modelCopy = makeModelCopy(scope.model);
+ modelCopy = makeModelCopy(scope.model);
- $timeout(function() {
+ $timeout(function () {
- if (scope.position === "target" && scope.model.event) {
- setTargetPosition();
+ if (scope.position === "target" && scope.model.event) {
+ setTargetPosition();
- // update the position of the overlay on content changes
- // as these affect the layout/size of the overlay
- if ('ResizeObserver' in window)
- {
- var resizeObserver = new ResizeObserver(setTargetPosition);
- var contentArea = document.getElementById("contentwrapper");
- resizeObserver.observe(el[0]);
- if (contentArea) {
- resizeObserver.observe(contentArea);
- }
- unsubscribe.push(function () {
- resizeObserver.disconnect();
- });
- }
- }
+ // update the position of the overlay on content changes
+ // as these affect the layout/size of the overlay
+ if ('ResizeObserver' in window) {
+ var resizeObserver = new ResizeObserver(setTargetPosition);
+ var contentArea = document.getElementById("contentwrapper");
+ resizeObserver.observe(el[0]);
+ if (contentArea) {
+ resizeObserver.observe(contentArea);
+ }
+ unsubscribe.push(function () {
+ resizeObserver.disconnect();
+ });
+ }
+ }
- // this has to be done inside a timeout to ensure the destroy
- // event on other overlays is run before registering a new one
- registerOverlay();
-
- setOverlayIndent();
+ // this has to be done inside a timeout to ensure the destroy
+ // event on other overlays is run before registering a new one
+ registerOverlay();
- focusOnOverlayHeading()
- });
+ setOverlayIndent();
- }
+ focusOnOverlayHeading()
+ });
- // Ideally this would focus on the first natively focusable element in the overlay, but as the content can be dynamic, it is focusing on the heading.
- function focusOnOverlayHeading() {
- var heading = el.find(".umb-overlay__title");
+ }
+
+ // Ideally this would focus on the first natively focusable element in the overlay, but as the content can be dynamic, it is focusing on the heading.
+ function focusOnOverlayHeading() {
+ var heading = el.find(".umb-overlay__title");
- if(heading) {
- heading.focus();
- }
- }
+ if (heading) {
+ heading.focus();
+ }
+ }
- function setView() {
+ function setView() {
- if (scope.view) {
+ if (scope.view) {
- if (scope.view.indexOf(".html") === -1) {
- var viewAlias = scope.view.toLowerCase();
- scope.view = "views/common/overlays/" + viewAlias + "/" + viewAlias + ".html";
- }
+ if (scope.view.indexOf(".html") === -1) {
+ var viewAlias = scope.view.toLowerCase();
+ scope.view = "views/common/overlays/" + viewAlias + "/" + viewAlias + ".html";
+ }
- //if a custom parent scope is defined then we need to manually compile the view
- if (scope.parentScope) {
- var element = el.find(".scoped-view");
- $http.get(scope.view, { cache: $templateCache })
- .then(function (response) {
- var templateScope = scope.parentScope.$new();
- unsubscribe.push(function() {
- templateScope.$destroy();
+ //if a custom parent scope is defined then we need to manually compile the view
+ if (scope.parentScope) {
+ var element = el.find(".scoped-view");
+ $http.get(scope.view, { cache: $templateCache })
+ .then(function (response) {
+ var templateScope = scope.parentScope.$new();
+ unsubscribe.push(function () {
+ templateScope.$destroy();
+ });
+ templateScope.model = scope.model;
+ element.html(response.data);
+ element.show();
+ $compile(element.contents())(templateScope);
});
- templateScope.model = scope.model;
- element.html(response.data);
- element.show();
- $compile(element.contents())(templateScope);
- });
+ }
}
+
}
- }
+ function setButtonText() {
- function setButtonText() {
+ var labelKeys = [
+ "general_close",
+ "general_submit"
+ ];
- var labelKeys = [
- "general_close",
- "general_submit"
- ];
+ localizationService.localizeMany(labelKeys).then(function (values) {
+ if (!scope.model.closeButtonLabelKey && !scope.model.closeButtonLabel) {
+ scope.model.closeButtonLabel = values[0];
+ }
+ if (!scope.model.submitButtonLabelKey && !scope.model.submitButtonLabel) {
+ scope.model.submitButtonLabel = values[1];
+ }
+ });
+ }
- localizationService.localizeMany(labelKeys).then(function (values) {
- if (!scope.model.closeButtonLabelKey && !scope.model.closeButtonLabel) {
- scope.model.closeButtonLabel = values[0];
- }
- if (!scope.model.submitButtonLabelKey && !scope.model.submitButtonLabel) {
- scope.model.submitButtonLabel = values[1];
- }
- });
- }
+ function registerOverlay() {
- function registerOverlay() {
+ overlayNumber = overlayHelper.registerOverlay();
- overlayNumber = overlayHelper.registerOverlay();
+ $(document).on("keydown.overlay-" + overlayNumber, function (event) {
- $(document).on("keydown.overlay-" + overlayNumber, function(event) {
+ if (event.which === 27) {
- if (event.which === 27) {
+ numberOfOverlays = overlayHelper.getNumberOfOverlays();
- numberOfOverlays = overlayHelper.getNumberOfOverlays();
+ if (numberOfOverlays === overlayNumber && !scope.model.disableEscKey) {
+ scope.$apply(function () {
+ scope.closeOverLay();
+ });
+ }
- if (numberOfOverlays === overlayNumber && !scope.model.disableEscKey) {
- scope.$apply(function () {
- scope.closeOverLay();
- });
- }
-
- event.stopPropagation();
- event.preventDefault();
- }
+ event.stopPropagation();
+ event.preventDefault();
+ }
- if (event.which === 13) {
+ if (event.which === 13) {
- numberOfOverlays = overlayHelper.getNumberOfOverlays();
+ numberOfOverlays = overlayHelper.getNumberOfOverlays();
- if(numberOfOverlays === overlayNumber) {
+ if (numberOfOverlays === overlayNumber) {
- var activeElementType = document.activeElement.tagName;
- var clickableElements = ["A", "BUTTON"];
- var submitOnEnter = document.activeElement.hasAttribute("overlay-submit-on-enter");
- var submitOnEnterValue = submitOnEnter ? document.activeElement.getAttribute("overlay-submit-on-enter") : "";
+ var activeElementType = document.activeElement.tagName;
+ var clickableElements = ["A", "BUTTON"];
+ var submitOnEnter = document.activeElement.hasAttribute("overlay-submit-on-enter");
+ var submitOnEnterValue = submitOnEnter ? document.activeElement.getAttribute("overlay-submit-on-enter") : "";
- if(clickableElements.indexOf(activeElementType) >= 0) {
- // don't do anything, let the browser Enter key handle this
- } else if(activeElementType === "TEXTAREA" && !submitOnEnter) {
+ if (clickableElements.indexOf(activeElementType) >= 0) {
+ // don't do anything, let the browser Enter key handle this
+ } else if (activeElementType === "TEXTAREA" && !submitOnEnter) {
- } else if (submitOnEnter && submitOnEnterValue === "false") {
- // don't do anything
- }else {
- scope.$apply(function () {
- scope.submitForm(scope.model);
- });
- event.preventDefault();
- }
+ } else if (submitOnEnter && submitOnEnterValue === "false") {
+ // don't do anything
+ } else {
+ scope.$apply(function () {
+ scope.submitForm(scope.model);
+ });
+ event.preventDefault();
+ }
- }
+ }
- }
+ }
- });
+ });
+
+ isRegistered = true;
- isRegistered = true;
+ }
- }
+ function unregisterOverlay() {
- function unregisterOverlay() {
+ if (isRegistered) {
- if(isRegistered) {
+ overlayHelper.unregisterOverlay();
- overlayHelper.unregisterOverlay();
+ $(document).off("keydown.overlay-" + overlayNumber);
- $(document).off("keydown.overlay-" + overlayNumber);
+ isRegistered = false;
+ }
- isRegistered = false;
}
- }
+ function makeModelCopy(object) {
+
+ var newObject = {};
- function makeModelCopy(object) {
+ for (var key in object) {
+ if (key !== "event" && key !== "parentScope") {
+ newObject[key] = Utilities.copy(object[key]);
+ }
+ }
- var newObject = {};
+ return newObject;
- for (var key in object) {
- if (key !== "event" && key !== "parentScope") {
- newObject[key] = angular.copy(object[key]);
- }
}
- return newObject;
+ function setOverlayIndent() {
- }
+ var overlayIndex = overlayNumber - 1;
+ var indentSize = overlayIndex * 20;
+ var overlayWidth = el[0].clientWidth;
- function setOverlayIndent() {
+ el.css('width', overlayWidth - indentSize);
- var overlayIndex = overlayNumber - 1;
- var indentSize = overlayIndex * 20;
- var overlayWidth = el[0].clientWidth;
+ if (scope.position === "center" && overlayIndex > 0 || scope.position === "target" && overlayIndex > 0) {
+ var overlayTopPosition = el[0].offsetTop;
+ el.css('top', overlayTopPosition + indentSize);
+ }
- el.css('width', overlayWidth - indentSize);
-
- if(scope.position === "center" && overlayIndex > 0 || scope.position === "target" && overlayIndex > 0) {
- var overlayTopPosition = el[0].offsetTop;
- el.css('top', overlayTopPosition + indentSize);
}
- }
+ function setTargetPosition() {
+
+ var container = $("#contentwrapper");
+ var containerLeft = container[0].offsetLeft;
+ var containerRight = containerLeft + container[0].offsetWidth;
+ var containerTop = container[0].offsetTop;
+ var containerBottom = containerTop + container[0].offsetHeight;
+
+ var mousePositionClickX = null;
+ var mousePositionClickY = null;
+ var elementHeight = null;
+ var elementWidth = null;
+
+ var position = {
+ right: "inherit",
+ left: "inherit",
+ top: "inherit",
+ bottom: "inherit"
+ };
+
+ // click position
+ mousePositionClickX = scope.model.event.pageX;
+ mousePositionClickY = scope.model.event.pageY;
+
+ // element size
+ elementHeight = el[0].clientHeight;
+ elementWidth = el[0].clientWidth;
+
+ // move element to this position
+ position.left = mousePositionClickX - (elementWidth / 2);
+ position.top = mousePositionClickY - (elementHeight / 2);
+
+ // check to see if element is outside screen
+ // outside right
+ if (position.left + elementWidth > containerRight) {
+ position.right = 10;
+ position.left = "inherit";
+ }
+
+ // outside bottom
+ if (position.top + elementHeight > containerBottom) {
+ position.bottom = 10;
+ position.top = "inherit";
+ }
+
+ // outside left
+ if (position.left < containerLeft) {
+ position.left = containerLeft + 10;
+ position.right = "inherit";
+ }
- function setTargetPosition() {
+ // outside top
+ if (position.top < containerTop) {
+ position.top = 10;
+ position.bottom = "inherit";
+ }
- var container = $("#contentwrapper");
- var containerLeft = container[0].offsetLeft;
- var containerRight = containerLeft + container[0].offsetWidth;
- var containerTop = container[0].offsetTop;
- var containerBottom = containerTop + container[0].offsetHeight;
+ el.css(position);
+ }
- var mousePositionClickX = null;
- var mousePositionClickY = null;
- var elementHeight = null;
- var elementWidth = null;
+ scope.submitForm = function (model) {
+ if (scope.model.submit) {
+ if (formHelper.submitForm({ scope: scope, skipValidation: scope.model.skipFormValidation })) {
+
+ if (scope.model.confirmSubmit && scope.model.confirmSubmit.enable && !scope.directive.enableConfirmButton) {
+ //wrap in a when since we don't know if this is a promise or not
+ $q.when(scope.model.submit(model, modelCopy, scope.directive.enableConfirmButton)).then(
+ function () {
+ formHelper.resetForm({ scope: scope });
+ });
+ } else {
+ unregisterOverlay();
+ //wrap in a when since we don't know if this is a promise or not
+ $q.when(scope.model.submit(model, modelCopy, scope.directive.enableConfirmButton)).then(
+ function () {
+ formHelper.resetForm({ scope: scope });
+ });
+ }
- var position = {
- right: "inherit",
- left: "inherit",
- top: "inherit",
- bottom: "inherit"
+ }
+ }
};
- // click position
- mousePositionClickX = scope.model.event.pageX;
- mousePositionClickY = scope.model.event.pageY;
+ scope.cancelConfirmSubmit = function () {
+ scope.model.confirmSubmit.show = false;
+ };
- // element size
- elementHeight = el[0].clientHeight;
- elementWidth = el[0].clientWidth;
+ scope.closeOverLay = function () {
- // move element to this position
- position.left = mousePositionClickX - (elementWidth / 2);
- position.top = mousePositionClickY - (elementHeight / 2);
+ unregisterOverlay();
- // check to see if element is outside screen
- // outside right
- if (position.left + elementWidth > containerRight) {
- position.right = 10;
- position.left = "inherit";
- }
+ if (scope.model && scope.model.close) {
+ scope.model = modelCopy;
+ scope.model.close(scope.model);
+ } else {
+ scope.model.show = false;
+ scope.model = null;
+ }
- // outside bottom
- if (position.top + elementHeight > containerBottom) {
- position.bottom = 10;
- position.top = "inherit";
- }
+ };
- // outside left
- if (position.left < containerLeft) {
- position.left = containerLeft + 10;
- position.right = "inherit";
- }
+ scope.outSideClick = function () {
+ if (!scope.model.disableBackdropClick) {
+ scope.closeOverLay();
+ }
+ };
- // outside top
- if (position.top < containerTop) {
- position.top = 10;
- position.bottom = "inherit";
- }
+ unsubscribe.push(unregisterOverlay);
+ scope.$on('$destroy', function () {
+ for (var i = 0; i < unsubscribe.length; i++) {
+ unsubscribe[i]();
+ }
+ });
- el.css(position);
- }
-
- scope.submitForm = function(model) {
- if(scope.model.submit) {
- if (formHelper.submitForm({ scope: scope, skipValidation: scope.model.skipFormValidation})) {
-
- if (scope.model.confirmSubmit && scope.model.confirmSubmit.enable && !scope.directive.enableConfirmButton) {
- //wrap in a when since we don't know if this is a promise or not
- $q.when(scope.model.submit(model, modelCopy, scope.directive.enableConfirmButton)).then(
- function() {
- formHelper.resetForm({ scope: scope });
- });
- } else {
- unregisterOverlay();
- //wrap in a when since we don't know if this is a promise or not
- $q.when(scope.model.submit(model, modelCopy, scope.directive.enableConfirmButton)).then(
- function() {
- formHelper.resetForm({ scope: scope });
- });
- }
-
- }
- }
- };
-
- scope.cancelConfirmSubmit = function() {
- scope.model.confirmSubmit.show = false;
- };
-
- scope.closeOverLay = function() {
-
- unregisterOverlay();
-
- if (scope.model && scope.model.close) {
- scope.model = modelCopy;
- scope.model.close(scope.model);
- } else {
- scope.model.show = false;
- scope.model = null;
- }
+ activate();
- };
+ }
- scope.outSideClick = function() {
- if(!scope.model.disableBackdropClick) {
- scope.closeOverLay();
- }
+ var directive = {
+ transclude: true,
+ restrict: 'E',
+ replace: true,
+ templateUrl: 'views/components/overlays/umb-overlay.html',
+ scope: {
+ ngShow: "=",
+ model: "=",
+ view: "=",
+ position: "@",
+ size: "=?",
+ parentScope: "=?"
+ },
+ link: link
};
- unsubscribe.push(unregisterOverlay);
- scope.$on('$destroy', function () {
- for (var i = 0; i < unsubscribe.length; i++) {
- unsubscribe[i]();
- }
- });
-
- activate();
-
- }
-
- var directive = {
- transclude: true,
- restrict: 'E',
- replace: true,
- templateUrl: 'views/components/overlays/umb-overlay.html',
- scope: {
- ngShow: "=",
- model: "=",
- view: "=",
- position: "@",
- size: "=?",
- parentScope: "=?"
- },
- link: link
- };
-
- return directive;
- }
-
- angular.module('umbraco.directives').directive('umbOverlay', OverlayDirective);
+ return directive;
+ }
+
+ angular.module('umbraco.directives').directive('umbOverlay', OverlayDirective);
})();
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js
index a9b9cc52b1b2..762edefbd566 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js
@@ -1,738 +1,738 @@
-(function() {
- 'use strict';
-
- function GroupsBuilderDirective(contentTypeHelper, contentTypeResource, mediaTypeResource,
- dataTypeHelper, dataTypeResource, $filter, iconHelper, $q, $timeout, notificationsService,
- localizationService, editorService, eventsService, overlayService) {
-
- function link(scope, el, attr, ctrl) {
-
- var eventBindings = [];
- var validationTranslated = "";
- var tabNoSortOrderTranslated = "";
-
- scope.dataTypeHasChanged = false;
- scope.sortingMode = false;
- scope.toolbar = [];
- scope.sortableOptionsGroup = {};
- scope.sortableOptionsProperty = {};
- scope.sortingButtonKey = "general_reorder";
- scope.compositionsButtonState = "init";
-
- function activate() {
-
- setSortingOptions();
-
- // set placeholder property on each group
- if (scope.model.groups.length !== 0) {
- angular.forEach(scope.model.groups, function(group) {
- addInitProperty(group);
- });
- }
-
- // add init tab
- addInitGroup(scope.model.groups);
-
- activateFirstGroup(scope.model.groups);
-
- // localize texts
- localizationService.localize("validation_validation").then(function(value) {
- validationTranslated = value;
- });
-
- localizationService.localize("contentTypeEditor_tabHasNoSortOrder").then(function(value) {
- tabNoSortOrderTranslated = value;
- });
- }
-
- function setSortingOptions() {
-
- scope.sortableOptionsGroup = {
- axis: 'y',
- distance: 10,
- tolerance: "pointer",
- opacity: 0.7,
- scroll: true,
- cursor: "move",
- placeholder: "umb-group-builder__group-sortable-placeholder",
- zIndex: 6000,
- handle: ".umb-group-builder__group-handle",
- items: ".umb-group-builder__group-sortable",
- start: function(e, ui) {
- ui.placeholder.height(ui.item.height());
- },
- stop: function(e, ui) {
- updateTabsSortOrder();
- }
- };
-
- scope.sortableOptionsProperty = {
- axis: 'y',
- distance: 10,
- tolerance: "pointer",
- connectWith: ".umb-group-builder__properties",
- opacity: 0.7,
- scroll: true,
- cursor: "move",
- placeholder: "umb-group-builder__property_sortable-placeholder",
- zIndex: 6000,
- handle: ".umb-group-builder__property-handle",
- items: ".umb-group-builder__property-sortable",
- start: function(e, ui) {
- ui.placeholder.height(ui.item.height());
- },
- stop: function(e, ui) {
- updatePropertiesSortOrder();
- }
- };
+(function () {
+ 'use strict';
- }
+ function GroupsBuilderDirective(contentTypeHelper, contentTypeResource, mediaTypeResource,
+ dataTypeHelper, dataTypeResource, $filter, iconHelper, $q, $timeout, notificationsService,
+ localizationService, editorService, eventsService, overlayService) {
- function updateTabsSortOrder() {
+ function link(scope, el, attr, ctrl) {
- var first = true;
- var prevSortOrder = 0;
+ var eventBindings = [];
+ var validationTranslated = "";
+ var tabNoSortOrderTranslated = "";
- scope.model.groups.map(function(group){
+ scope.dataTypeHasChanged = false;
+ scope.sortingMode = false;
+ scope.toolbar = [];
+ scope.sortableOptionsGroup = {};
+ scope.sortableOptionsProperty = {};
+ scope.sortingButtonKey = "general_reorder";
+ scope.compositionsButtonState = "init";
- var index = scope.model.groups.indexOf(group);
+ function activate() {
- if(group.tabState !== "init") {
+ setSortingOptions();
- // set the first not inherited tab to sort order 0
- if(!group.inherited && first) {
+ // set placeholder property on each group
+ if (scope.model.groups.length !== 0) {
+ angular.forEach(scope.model.groups, function (group) {
+ addInitProperty(group);
+ });
+ }
- // set the first tab sort order to 0 if prev is 0
- if( prevSortOrder === 0 ) {
- group.sortOrder = 0;
- // when the first tab is inherited and sort order is not 0
- } else {
- group.sortOrder = prevSortOrder + 1;
- }
+ // add init tab
+ addInitGroup(scope.model.groups);
- first = false;
+ activateFirstGroup(scope.model.groups);
- } else if(!group.inherited && !first) {
+ // localize texts
+ localizationService.localize("validation_validation").then(function (value) {
+ validationTranslated = value;
+ });
- // find next group
- var nextGroup = scope.model.groups[index + 1];
+ localizationService.localize("contentTypeEditor_tabHasNoSortOrder").then(function (value) {
+ tabNoSortOrderTranslated = value;
+ });
+ }
- // if a groups is dropped in the middle of to groups with
- // same sort order. Give it the dropped group same sort order
- if( prevSortOrder === nextGroup.sortOrder ) {
- group.sortOrder = prevSortOrder;
- } else {
- group.sortOrder = prevSortOrder + 1;
- }
+ function setSortingOptions() {
+
+ scope.sortableOptionsGroup = {
+ axis: 'y',
+ distance: 10,
+ tolerance: "pointer",
+ opacity: 0.7,
+ scroll: true,
+ cursor: "move",
+ placeholder: "umb-group-builder__group-sortable-placeholder",
+ zIndex: 6000,
+ handle: ".umb-group-builder__group-handle",
+ items: ".umb-group-builder__group-sortable",
+ start: function (e, ui) {
+ ui.placeholder.height(ui.item.height());
+ },
+ stop: function (e, ui) {
+ updateTabsSortOrder();
+ }
+ };
+
+ scope.sortableOptionsProperty = {
+ axis: 'y',
+ distance: 10,
+ tolerance: "pointer",
+ connectWith: ".umb-group-builder__properties",
+ opacity: 0.7,
+ scroll: true,
+ cursor: "move",
+ placeholder: "umb-group-builder__property_sortable-placeholder",
+ zIndex: 6000,
+ handle: ".umb-group-builder__property-handle",
+ items: ".umb-group-builder__property-sortable",
+ start: function (e, ui) {
+ ui.placeholder.height(ui.item.height());
+ },
+ stop: function (e, ui) {
+ updatePropertiesSortOrder();
+ }
+ };
}
- // store this tabs sort order as reference for the next
- prevSortOrder = group.sortOrder;
+ function updateTabsSortOrder() {
- }
+ var first = true;
+ var prevSortOrder = 0;
- });
+ scope.model.groups.map(function (group) {
- }
+ var index = scope.model.groups.indexOf(group);
- function filterAvailableCompositions(selectedContentType, selecting) {
+ if (group.tabState !== "init") {
- //selecting = true if the user has check the item, false if the user has unchecked the item
+ // set the first not inherited tab to sort order 0
+ if (!group.inherited && first) {
- var selectedContentTypeAliases = selecting ?
- //the user has selected the item so add to the current list
- _.union(scope.compositionsDialogModel.compositeContentTypes, [selectedContentType.alias]) :
- //the user has unselected the item so remove from the current list
- _.reject(scope.compositionsDialogModel.compositeContentTypes, function(i) {
- return i === selectedContentType.alias;
- });
+ // set the first tab sort order to 0 if prev is 0
+ if (prevSortOrder === 0) {
+ group.sortOrder = 0;
+ // when the first tab is inherited and sort order is not 0
+ } else {
+ group.sortOrder = prevSortOrder + 1;
+ }
- //get the currently assigned property type aliases - ensure we pass these to the server side filer
- var propAliasesExisting = _.filter(_.flatten(_.map(scope.model.groups, function(g) {
- return _.map(g.properties, function(p) {
- return p.alias;
- });
- })), function (f) {
- return f !== null && f !== undefined;
- });
-
- //use a different resource lookup depending on the content type type
- var resourceLookup = scope.contentType === "documentType" ? contentTypeResource.getAvailableCompositeContentTypes : mediaTypeResource.getAvailableCompositeContentTypes;
-
- return resourceLookup(scope.model.id, selectedContentTypeAliases, propAliasesExisting).then(function (filteredAvailableCompositeTypes) {
- _.each(scope.compositionsDialogModel.availableCompositeContentTypes, function (current) {
- //reset first
- current.allowed = true;
- //see if this list item is found in the response (allowed) list
- var found = _.find(filteredAvailableCompositeTypes, function (f) {
- return current.contentType.alias === f.contentType.alias;
- });
+ first = false;
- //allow if the item was found in the response (allowed) list -
- // and ensure its set to allowed if it is currently checked,
- // DO not allow if it's a locked content type.
- current.allowed = scope.model.lockedCompositeContentTypes.indexOf(current.contentType.alias) === -1 &&
- (selectedContentTypeAliases.indexOf(current.contentType.alias) !== -1) || ((found !== null && found !== undefined) ? found.allowed : false);
+ } else if (!group.inherited && !first) {
- });
- });
- }
+ // find next group
+ var nextGroup = scope.model.groups[index + 1];
- function updatePropertiesSortOrder() {
+ // if a groups is dropped in the middle of to groups with
+ // same sort order. Give it the dropped group same sort order
+ if (prevSortOrder === nextGroup.sortOrder) {
+ group.sortOrder = prevSortOrder;
+ } else {
+ group.sortOrder = prevSortOrder + 1;
+ }
- angular.forEach(scope.model.groups, function(group){
- if( group.tabState !== "init" ) {
- group.properties = contentTypeHelper.updatePropertiesSortOrder(group.properties);
- }
- });
+ }
- }
+ // store this tabs sort order as reference for the next
+ prevSortOrder = group.sortOrder;
- function setupAvailableContentTypesModel(result) {
- scope.compositionsDialogModel.availableCompositeContentTypes = result;
- //iterate each one and set it up
- _.each(scope.compositionsDialogModel.availableCompositeContentTypes, function (c) {
- //enable it if it's part of the selected model
- if (scope.compositionsDialogModel.compositeContentTypes.indexOf(c.contentType.alias) !== -1) {
- c.allowed = true;
- }
+ }
- //set the inherited flags
- c.inherited = false;
- if (scope.model.lockedCompositeContentTypes.indexOf(c.contentType.alias) > -1) {
- c.inherited = true;
- }
- // convert icons for composite content types
- iconHelper.formatContentTypeIcons([c.contentType]);
- });
- }
+ });
- /* ---------- DELETE PROMT ---------- */
+ }
- scope.togglePrompt = function (object) {
- object.deletePrompt = !object.deletePrompt;
- };
+ function filterAvailableCompositions(selectedContentType, selecting) {
- scope.hidePrompt = function (object) {
- object.deletePrompt = false;
- };
+ //selecting = true if the user has check the item, false if the user has unchecked the item
- /* ---------- TOOLBAR ---------- */
+ var selectedContentTypeAliases = selecting ?
+ //the user has selected the item so add to the current list
+ _.union(scope.compositionsDialogModel.compositeContentTypes, [selectedContentType.alias]) :
+ //the user has unselected the item so remove from the current list
+ _.reject(scope.compositionsDialogModel.compositeContentTypes, function (i) {
+ return i === selectedContentType.alias;
+ });
- scope.toggleSortingMode = function(tool) {
+ //get the currently assigned property type aliases - ensure we pass these to the server side filer
+ var propAliasesExisting = _.filter(_.flatten(_.map(scope.model.groups, function (g) {
+ return _.map(g.properties, function (p) {
+ return p.alias;
+ });
+ })), function (f) {
+ return f !== null && f !== undefined;
+ });
- if (scope.sortingMode === true) {
+ //use a different resource lookup depending on the content type type
+ var resourceLookup = scope.contentType === "documentType" ? contentTypeResource.getAvailableCompositeContentTypes : mediaTypeResource.getAvailableCompositeContentTypes;
- var sortOrderMissing = false;
+ return resourceLookup(scope.model.id, selectedContentTypeAliases, propAliasesExisting).then(function (filteredAvailableCompositeTypes) {
+ _.each(scope.compositionsDialogModel.availableCompositeContentTypes, function (current) {
+ //reset first
+ current.allowed = true;
+ //see if this list item is found in the response (allowed) list
+ var found = _.find(filteredAvailableCompositeTypes, function (f) {
+ return current.contentType.alias === f.contentType.alias;
+ });
- for (var i = 0; i < scope.model.groups.length; i++) {
- var group = scope.model.groups[i];
- if (group.tabState !== "init" && group.sortOrder === undefined) {
- sortOrderMissing = true;
- group.showSortOrderMissing = true;
- notificationsService.error(validationTranslated + ": " + group.name + " " + tabNoSortOrderTranslated);
- }
- }
+ //allow if the item was found in the response (allowed) list -
+ // and ensure its set to allowed if it is currently checked,
+ // DO not allow if it's a locked content type.
+ current.allowed = scope.model.lockedCompositeContentTypes.indexOf(current.contentType.alias) === -1 &&
+ (selectedContentTypeAliases.indexOf(current.contentType.alias) !== -1) || ((found !== null && found !== undefined) ? found.allowed : false);
- if (!sortOrderMissing) {
- scope.sortingMode = false;
- scope.sortingButtonKey = "general_reorder";
- }
+ });
+ });
+ }
- } else {
+ function updatePropertiesSortOrder() {
- scope.sortingMode = true;
- scope.sortingButtonKey = "general_reorderDone";
+ angular.forEach(scope.model.groups, function (group) {
+ if (group.tabState !== "init") {
+ group.properties = contentTypeHelper.updatePropertiesSortOrder(group.properties);
+ }
+ });
- }
+ }
- };
+ function setupAvailableContentTypesModel(result) {
+ scope.compositionsDialogModel.availableCompositeContentTypes = result;
+ //iterate each one and set it up
+ _.each(scope.compositionsDialogModel.availableCompositeContentTypes, function (c) {
+ //enable it if it's part of the selected model
+ if (scope.compositionsDialogModel.compositeContentTypes.indexOf(c.contentType.alias) !== -1) {
+ c.allowed = true;
+ }
+
+ //set the inherited flags
+ c.inherited = false;
+ if (scope.model.lockedCompositeContentTypes.indexOf(c.contentType.alias) > -1) {
+ c.inherited = true;
+ }
+ // convert icons for composite content types
+ iconHelper.formatContentTypeIcons([c.contentType]);
+ });
+ }
- scope.openCompositionsDialog = function() {
+ /* ---------- DELETE PROMT ---------- */
- scope.compositionsDialogModel = {
- contentType: scope.model,
- compositeContentTypes: scope.model.compositeContentTypes,
- view: "views/common/infiniteeditors/compositions/compositions.html",
- size: "small",
- submit: function() {
+ scope.togglePrompt = function (object) {
+ object.deletePrompt = !object.deletePrompt;
+ };
- // make sure that all tabs has an init property
- if (scope.model.groups.length !== 0) {
- angular.forEach(scope.model.groups, function(group) {
- addInitProperty(group);
- });
- }
+ scope.hidePrompt = function (object) {
+ object.deletePrompt = false;
+ };
- // remove overlay
- editorService.close();
+ /* ---------- TOOLBAR ---------- */
- },
- close: function(oldModel) {
+ scope.toggleSortingMode = function (tool) {
- // reset composition changes
- scope.model.groups = oldModel.contentType.groups;
- scope.model.compositeContentTypes = oldModel.contentType.compositeContentTypes;
+ if (scope.sortingMode === true) {
- // remove overlay
- editorService.close();
+ var sortOrderMissing = false;
- },
- selectCompositeContentType: function (selectedContentType) {
-
- //first check if this is a new selection - we need to store this value here before any further digests/async
- // because after that the scope.model.compositeContentTypes will be populated with the selected value.
- var newSelection = scope.model.compositeContentTypes.indexOf(selectedContentType.alias) === -1;
-
- if (newSelection) {
- //merge composition with content type
-
- //use a different resource lookup depending on the content type type
- var resourceLookup = scope.contentType === "documentType" ? contentTypeResource.getById : mediaTypeResource.getById;
-
- resourceLookup(selectedContentType.id).then(function (composition) {
- //based on the above filtering we shouldn't be able to select an invalid one, but let's be safe and
- // double check here.
- var overlappingAliases = contentTypeHelper.validateAddingComposition(scope.model, composition);
- if (overlappingAliases.length > 0) {
- //this will create an invalid composition, need to uncheck it
- scope.compositionsDialogModel.compositeContentTypes.splice(
- scope.compositionsDialogModel.compositeContentTypes.indexOf(composition.alias), 1);
- //dissallow this until something else is unchecked
- selectedContentType.allowed = false;
- }
- else {
- contentTypeHelper.mergeCompositeContentType(scope.model, composition);
+ for (var i = 0; i < scope.model.groups.length; i++) {
+ var group = scope.model.groups[i];
+ if (group.tabState !== "init" && group.sortOrder === undefined) {
+ sortOrderMissing = true;
+ group.showSortOrderMissing = true;
+ notificationsService.error(validationTranslated + ": " + group.name + " " + tabNoSortOrderTranslated);
}
+ }
- //based on the selection, we need to filter the available composite types list
- filterAvailableCompositions(selectedContentType, newSelection).then(function () {
- // TODO: Here we could probably re-enable selection if we previously showed a throbber or something
- });
- });
- }
- else {
- // split composition from content type
- contentTypeHelper.splitCompositeContentType(scope.model, selectedContentType);
+ if (!sortOrderMissing) {
+ scope.sortingMode = false;
+ scope.sortingButtonKey = "general_reorder";
+ }
+
+ } else {
+
+ scope.sortingMode = true;
+ scope.sortingButtonKey = "general_reorderDone";
- //based on the selection, we need to filter the available composite types list
- filterAvailableCompositions(selectedContentType, newSelection).then(function () {
- // TODO: Here we could probably re-enable selection if we previously showed a throbber or something
- });
}
- }
- };
+ };
- //select which resource methods to use, eg document Type or Media Type versions
- var availableContentTypeResource = scope.contentType === "documentType" ? contentTypeResource.getAvailableCompositeContentTypes : mediaTypeResource.getAvailableCompositeContentTypes;
- var whereUsedContentTypeResource = scope.contentType === "documentType" ? contentTypeResource.getWhereCompositionIsUsedInContentTypes : mediaTypeResource.getWhereCompositionIsUsedInContentTypes;
- var countContentTypeResource = scope.contentType === "documentType" ? contentTypeResource.getCount : mediaTypeResource.getCount;
-
- //get the currently assigned property type aliases - ensure we pass these to the server side filer
- var propAliasesExisting = _.filter(_.flatten(_.map(scope.model.groups, function(g) {
- return _.map(g.properties, function(p) {
- return p.alias;
- });
- })), function(f) {
- return f !== null && f !== undefined;
- });
- scope.compositionsButtonState = "busy";
- $q.all([
- //get available composite types
- availableContentTypeResource(scope.model.id, [], propAliasesExisting, scope.model.isElement).then(function (result) {
- setupAvailableContentTypesModel(result);
- }),
- //get where used document types
- whereUsedContentTypeResource(scope.model.id).then(function (whereUsed) {
- //pass to the dialog model the content type eg documentType or mediaType
- scope.compositionsDialogModel.section = scope.contentType;
- //pass the list of 'where used' document types
- scope.compositionsDialogModel.whereCompositionUsed = whereUsed;
- }),
- //get content type count
- countContentTypeResource().then(function(result) {
- scope.compositionsDialogModel.totalContentTypes = parseInt(result, 10);
- })
- ]).then(function() {
- //resolves when both other promises are done, now show it
- editorService.open(scope.compositionsDialogModel);
- scope.compositionsButtonState = "init";
- });
+ scope.openCompositionsDialog = function () {
- };
+ scope.compositionsDialogModel = {
+ contentType: scope.model,
+ compositeContentTypes: scope.model.compositeContentTypes,
+ view: "views/common/infiniteeditors/compositions/compositions.html",
+ size: "small",
+ submit: function () {
+ // make sure that all tabs has an init property
+ if (scope.model.groups.length !== 0) {
+ angular.forEach(scope.model.groups, function (group) {
+ addInitProperty(group);
+ });
+ }
- scope.openDocumentType = function (documentTypeId) {
- const editor = {
- id: documentTypeId,
- submit: function (model) {
- const args = { node: scope.model };
- eventsService.emit("editors.documentType.reload", args);
- editorService.close();
- },
- close: function () {
- editorService.close();
- }
- };
- editorService.documentTypeEditor(editor);
+ // remove overlay
+ editorService.close();
+
+ },
+ close: function (oldModel) {
+
+ // reset composition changes
+ scope.model.groups = oldModel.contentType.groups;
+ scope.model.compositeContentTypes = oldModel.contentType.compositeContentTypes;
+
+ // remove overlay
+ editorService.close();
+
+ },
+ selectCompositeContentType: function (selectedContentType) {
+
+ //first check if this is a new selection - we need to store this value here before any further digests/async
+ // because after that the scope.model.compositeContentTypes will be populated with the selected value.
+ var newSelection = scope.model.compositeContentTypes.indexOf(selectedContentType.alias) === -1;
+
+ if (newSelection) {
+ //merge composition with content type
+
+ //use a different resource lookup depending on the content type type
+ var resourceLookup = scope.contentType === "documentType" ? contentTypeResource.getById : mediaTypeResource.getById;
+
+ resourceLookup(selectedContentType.id).then(function (composition) {
+ //based on the above filtering we shouldn't be able to select an invalid one, but let's be safe and
+ // double check here.
+ var overlappingAliases = contentTypeHelper.validateAddingComposition(scope.model, composition);
+ if (overlappingAliases.length > 0) {
+ //this will create an invalid composition, need to uncheck it
+ scope.compositionsDialogModel.compositeContentTypes.splice(
+ scope.compositionsDialogModel.compositeContentTypes.indexOf(composition.alias), 1);
+ //dissallow this until something else is unchecked
+ selectedContentType.allowed = false;
+ }
+ else {
+ contentTypeHelper.mergeCompositeContentType(scope.model, composition);
+ }
+
+ //based on the selection, we need to filter the available composite types list
+ filterAvailableCompositions(selectedContentType, newSelection).then(function () {
+ // TODO: Here we could probably re-enable selection if we previously showed a throbber or something
+ });
+ });
+ }
+ else {
+ // split composition from content type
+ contentTypeHelper.splitCompositeContentType(scope.model, selectedContentType);
- };
+ //based on the selection, we need to filter the available composite types list
+ filterAvailableCompositions(selectedContentType, newSelection).then(function () {
+ // TODO: Here we could probably re-enable selection if we previously showed a throbber or something
+ });
+ }
- /* ---------- GROUPS ---------- */
+ }
+ };
- scope.addGroup = function(group) {
+ //select which resource methods to use, eg document Type or Media Type versions
+ var availableContentTypeResource = scope.contentType === "documentType" ? contentTypeResource.getAvailableCompositeContentTypes : mediaTypeResource.getAvailableCompositeContentTypes;
+ var whereUsedContentTypeResource = scope.contentType === "documentType" ? contentTypeResource.getWhereCompositionIsUsedInContentTypes : mediaTypeResource.getWhereCompositionIsUsedInContentTypes;
+ var countContentTypeResource = scope.contentType === "documentType" ? contentTypeResource.getCount : mediaTypeResource.getCount;
- // set group sort order
- var index = scope.model.groups.indexOf(group);
- var prevGroup = scope.model.groups[index - 1];
+ //get the currently assigned property type aliases - ensure we pass these to the server side filer
+ var propAliasesExisting = _.filter(_.flatten(_.map(scope.model.groups, function (g) {
+ return _.map(g.properties, function (p) {
+ return p.alias;
+ });
+ })), function (f) {
+ return f !== null && f !== undefined;
+ });
+ scope.compositionsButtonState = "busy";
+ $q.all([
+ //get available composite types
+ availableContentTypeResource(scope.model.id, [], propAliasesExisting, scope.model.isElement).then(function (result) {
+ setupAvailableContentTypesModel(result);
+ }),
+ //get where used document types
+ whereUsedContentTypeResource(scope.model.id).then(function (whereUsed) {
+ //pass to the dialog model the content type eg documentType or mediaType
+ scope.compositionsDialogModel.section = scope.contentType;
+ //pass the list of 'where used' document types
+ scope.compositionsDialogModel.whereCompositionUsed = whereUsed;
+ }),
+ //get content type count
+ countContentTypeResource().then(function (result) {
+ scope.compositionsDialogModel.totalContentTypes = parseInt(result, 10);
+ })
+ ]).then(function () {
+ //resolves when both other promises are done, now show it
+ editorService.open(scope.compositionsDialogModel);
+ scope.compositionsButtonState = "init";
+ });
- if( index > 0) {
- // set index to 1 higher than the previous groups sort order
- group.sortOrder = prevGroup.sortOrder + 1;
+ };
- } else {
- // first group - sort order will be 0
- group.sortOrder = 0;
- }
- // activate group
- scope.activateGroup(group);
+ scope.openDocumentType = function (documentTypeId) {
+ const editor = {
+ id: documentTypeId,
+ submit: function (model) {
+ const args = { node: scope.model };
+ eventsService.emit("editors.documentType.reload", args);
+ editorService.close();
+ },
+ close: function () {
+ editorService.close();
+ }
+ };
+ editorService.documentTypeEditor(editor);
- // push new init tab to the scope
- addInitGroup(scope.model.groups);
- };
+ };
- scope.activateGroup = function(selectedGroup) {
+ /* ---------- GROUPS ---------- */
- // set all other groups that are inactive to active
- angular.forEach(scope.model.groups, function(group) {
- // skip init tab
- if (group.tabState !== "init") {
- group.tabState = "inActive";
- }
- });
+ scope.addGroup = function (group) {
- selectedGroup.tabState = "active";
+ // set group sort order
+ var index = scope.model.groups.indexOf(group);
+ var prevGroup = scope.model.groups[index - 1];
- };
+ if (index > 0) {
+ // set index to 1 higher than the previous groups sort order
+ group.sortOrder = prevGroup.sortOrder + 1;
- scope.canRemoveGroup = function(group){
- return group.inherited !== true && _.find(group.properties, function(property) { return property.locked === true; }) == null;
- }
+ } else {
+ // first group - sort order will be 0
+ group.sortOrder = 0;
+ }
- scope.removeGroup = function(groupIndex) {
- scope.model.groups.splice(groupIndex, 1);
- };
+ // activate group
+ scope.activateGroup(group);
- scope.updateGroupTitle = function(group) {
- if (group.properties.length === 0) {
- addInitProperty(group);
- }
- };
-
- scope.changeSortOrderValue = function(group) {
-
- if (group.sortOrder !== undefined) {
- group.showSortOrderMissing = false;
- }
- scope.model.groups = $filter('orderBy')(scope.model.groups, 'sortOrder');
- };
-
- function addInitGroup(groups) {
-
- // check i init tab already exists
- var addGroup = true;
-
- angular.forEach(groups, function(group) {
- if (group.tabState === "init") {
- addGroup = false;
- }
- });
-
- if (addGroup) {
- groups.push({
- properties: [],
- parentTabContentTypes: [],
- parentTabContentTypeNames: [],
- name: "",
- tabState: "init"
- });
- }
+ // push new init tab to the scope
+ addInitGroup(scope.model.groups);
+ };
- return groups;
- }
+ scope.activateGroup = function (selectedGroup) {
- function activateFirstGroup(groups) {
- if (groups && groups.length > 0) {
- var firstGroup = groups[0];
- if(!firstGroup.tabState || firstGroup.tabState === "inActive") {
- firstGroup.tabState = "active";
- }
- }
- }
+ // set all other groups that are inactive to active
+ angular.forEach(scope.model.groups, function (group) {
+ // skip init tab
+ if (group.tabState !== "init") {
+ group.tabState = "inActive";
+ }
+ });
- /* ---------- PROPERTIES ---------- */
+ selectedGroup.tabState = "active";
- scope.addPropertyToActiveGroup = function () {
- var group = _.find(scope.model.groups, group => group.tabState === "active");
- if (!group && scope.model.groups.length) {
- group = scope.model.groups[0];
- }
+ };
- if (!group || !group.name) {
- return;
- }
+ scope.canRemoveGroup = function (group) {
+ return group.inherited !== true && _.find(group.properties, function (property) { return property.locked === true; }) == null;
+ }
- var property = _.find(group.properties, property => property.propertyState === "init");
- if (!property) {
- return;
- }
- scope.addProperty(property, group);
- }
+ scope.removeGroup = function (groupIndex) {
+ scope.model.groups.splice(groupIndex, 1);
+ };
- scope.addProperty = function(property, group) {
+ scope.updateGroupTitle = function (group) {
+ if (group.properties.length === 0) {
+ addInitProperty(group);
+ }
+ };
- // set property sort order
- var index = group.properties.indexOf(property);
- var prevProperty = group.properties[index - 1];
+ scope.changeSortOrderValue = function (group) {
- if( index > 0) {
- // set index to 1 higher than the previous property sort order
- property.sortOrder = prevProperty.sortOrder + 1;
+ if (group.sortOrder !== undefined) {
+ group.showSortOrderMissing = false;
+ }
+ scope.model.groups = $filter('orderBy')(scope.model.groups, 'sortOrder');
+ };
- } else {
- // first property - sort order will be 0
- property.sortOrder = 0;
- }
+ function addInitGroup(groups) {
- // open property settings dialog
- scope.editPropertyTypeSettings(property, group);
-
- };
-
- scope.editPropertyTypeSettings = function(property, group) {
-
- if (!property.inherited) {
-
- var oldPropertyModel = angular.copy(property);
- if (oldPropertyModel.allowCultureVariant === undefined) {
- // this is necessary for comparison when detecting changes to the property
- oldPropertyModel.allowCultureVariant = scope.model.allowCultureVariant;
- oldPropertyModel.alias = "";
- }
- var propertyModel = angular.copy(property);
-
- var propertySettings = {
- title: "Property settings",
- property: propertyModel,
- contentType: scope.contentType,
- contentTypeName: scope.model.name,
- contentTypeAllowCultureVariant: scope.model.allowCultureVariant,
- view: "views/common/infiniteeditors/propertysettings/propertysettings.html",
- size: "small",
- submit: function(model) {
-
- property.inherited = false;
- property.dialogIsOpen = false;
- property.propertyState = "active";
-
- // apply all property changes
- property.label = propertyModel.label;
- property.alias = propertyModel.alias;
- property.description = propertyModel.description;
- property.config = propertyModel.config;
- property.editor = propertyModel.editor;
- property.view = propertyModel.view;
- property.dataTypeId = propertyModel.dataTypeId;
- property.dataTypeIcon = propertyModel.dataTypeIcon;
- property.dataTypeName = propertyModel.dataTypeName;
- property.validation.mandatory = propertyModel.validation.mandatory;
- property.validation.mandatoryMessage = propertyModel.validation.mandatoryMessage;
- property.validation.pattern = propertyModel.validation.pattern;
- property.validation.patternMessage = propertyModel.validation.patternMessage;
- property.showOnMemberProfile = propertyModel.showOnMemberProfile;
- property.memberCanEdit = propertyModel.memberCanEdit;
- property.isSensitiveData = propertyModel.isSensitiveData;
- property.isSensitiveValue = propertyModel.isSensitiveValue;
- property.allowCultureVariant = propertyModel.allowCultureVariant;
-
- // update existing data types
- if(model.updateSameDataTypes) {
- updateSameDataTypes(property);
- }
-
- // close the editor
- editorService.close();
-
- // push new init property to group
- addInitProperty(group);
-
- // set focus on init property
- var numberOfProperties = group.properties.length;
- group.properties[numberOfProperties - 1].focus = true;
-
- notifyChanged();
- },
- close: function() {
- if(_.isEqual(oldPropertyModel, propertyModel) === false) {
- localizationService.localizeMany(["general_confirm", "contentTypeEditor_propertyHasChanges", "general_cancel", "general_ok"]).then(function (data) {
- const overlay = {
- title: data[0],
- content: data[1],
- closeButtonLabel: data[2],
- submitButtonLabel: data[3],
- submitButtonStyle: "danger",
- close: function () {
- overlayService.close();
- },
- submit: function () {
- // close the confirmation
- overlayService.close();
- // close the editor
- editorService.close();
- }
- };
-
- overlayService.open(overlay);
+ // check i init tab already exists
+ var addGroup = true;
+
+ angular.forEach(groups, function (group) {
+ if (group.tabState === "init") {
+ addGroup = false;
+ }
});
- }
- else {
- // remove the editor
- editorService.close();
- }
+
+ if (addGroup) {
+ groups.push({
+ properties: [],
+ parentTabContentTypes: [],
+ parentTabContentTypeNames: [],
+ name: "",
+ tabState: "init"
+ });
+ }
+
+ return groups;
}
- };
- // open property settings editor
- editorService.open(propertySettings);
+ function activateFirstGroup(groups) {
+ if (groups && groups.length > 0) {
+ var firstGroup = groups[0];
+ if (!firstGroup.tabState || firstGroup.tabState === "inActive") {
+ firstGroup.tabState = "active";
+ }
+ }
+ }
- // set property states
- property.dialogIsOpen = true;
+ /* ---------- PROPERTIES ---------- */
- }
- };
+ scope.addPropertyToActiveGroup = function () {
+ var group = _.find(scope.model.groups, group => group.tabState === "active");
+ if (!group && scope.model.groups.length) {
+ group = scope.model.groups[0];
+ }
- scope.deleteProperty = function(tab, propertyIndex) {
+ if (!group || !group.name) {
+ return;
+ }
- // remove property
- tab.properties.splice(propertyIndex, 1);
+ var property = _.find(group.properties, property => property.propertyState === "init");
+ if (!property) {
+ return;
+ }
+ scope.addProperty(property, group);
+ }
- notifyChanged();
- };
+ scope.addProperty = function (property, group) {
- function notifyChanged() {
- eventsService.emit("editors.groupsBuilder.changed");
- }
+ // set property sort order
+ var index = group.properties.indexOf(property);
+ var prevProperty = group.properties[index - 1];
- function addInitProperty(group) {
+ if (index > 0) {
+ // set index to 1 higher than the previous property sort order
+ property.sortOrder = prevProperty.sortOrder + 1;
- var addInitPropertyBool = true;
- var initProperty = {
- label: null,
- alias: null,
- propertyState: "init",
- validation: {
- mandatory: false,
- mandatoryMessage: null,
- pattern: null,
- patternMessage: null
- }
- };
+ } else {
+ // first property - sort order will be 0
+ property.sortOrder = 0;
+ }
- // check if there already is an init property
- angular.forEach(group.properties, function(property) {
- if (property.propertyState === "init") {
- addInitPropertyBool = false;
- }
- });
+ // open property settings dialog
+ scope.editPropertyTypeSettings(property, group);
+
+ };
+
+ scope.editPropertyTypeSettings = function (property, group) {
+
+ if (!property.inherited) {
+
+ var oldPropertyModel = Utilities.copy(property);
+ if (oldPropertyModel.allowCultureVariant === undefined) {
+ // this is necessary for comparison when detecting changes to the property
+ oldPropertyModel.allowCultureVariant = scope.model.allowCultureVariant;
+ oldPropertyModel.alias = "";
+ }
+ var propertyModel = Utilities.copy(property);
+
+ var propertySettings = {
+ title: "Property settings",
+ property: propertyModel,
+ contentType: scope.contentType,
+ contentTypeName: scope.model.name,
+ contentTypeAllowCultureVariant: scope.model.allowCultureVariant,
+ view: "views/common/infiniteeditors/propertysettings/propertysettings.html",
+ size: "small",
+ submit: function (model) {
+
+ property.inherited = false;
+ property.dialogIsOpen = false;
+ property.propertyState = "active";
+
+ // apply all property changes
+ property.label = propertyModel.label;
+ property.alias = propertyModel.alias;
+ property.description = propertyModel.description;
+ property.config = propertyModel.config;
+ property.editor = propertyModel.editor;
+ property.view = propertyModel.view;
+ property.dataTypeId = propertyModel.dataTypeId;
+ property.dataTypeIcon = propertyModel.dataTypeIcon;
+ property.dataTypeName = propertyModel.dataTypeName;
+ property.validation.mandatory = propertyModel.validation.mandatory;
+ property.validation.mandatoryMessage = propertyModel.validation.mandatoryMessage;
+ property.validation.pattern = propertyModel.validation.pattern;
+ property.validation.patternMessage = propertyModel.validation.patternMessage;
+ property.showOnMemberProfile = propertyModel.showOnMemberProfile;
+ property.memberCanEdit = propertyModel.memberCanEdit;
+ property.isSensitiveData = propertyModel.isSensitiveData;
+ property.isSensitiveValue = propertyModel.isSensitiveValue;
+ property.allowCultureVariant = propertyModel.allowCultureVariant;
+
+ // update existing data types
+ if (model.updateSameDataTypes) {
+ updateSameDataTypes(property);
+ }
+
+ // close the editor
+ editorService.close();
+
+ // push new init property to group
+ addInitProperty(group);
+
+ // set focus on init property
+ var numberOfProperties = group.properties.length;
+ group.properties[numberOfProperties - 1].focus = true;
+
+ notifyChanged();
+ },
+ close: function () {
+ if (_.isEqual(oldPropertyModel, propertyModel) === false) {
+ localizationService.localizeMany(["general_confirm", "contentTypeEditor_propertyHasChanges", "general_cancel", "general_ok"]).then(function (data) {
+ const overlay = {
+ title: data[0],
+ content: data[1],
+ closeButtonLabel: data[2],
+ submitButtonLabel: data[3],
+ submitButtonStyle: "danger",
+ close: function () {
+ overlayService.close();
+ },
+ submit: function () {
+ // close the confirmation
+ overlayService.close();
+ // close the editor
+ editorService.close();
+ }
+ };
+
+ overlayService.open(overlay);
+ });
+ }
+ else {
+ // remove the editor
+ editorService.close();
+ }
+ }
+ };
- if (addInitPropertyBool) {
- group.properties.push(initProperty);
- }
+ // open property settings editor
+ editorService.open(propertySettings);
- return group;
- }
+ // set property states
+ property.dialogIsOpen = true;
- function updateSameDataTypes(newProperty) {
+ }
+ };
- // find each property
- angular.forEach(scope.model.groups, function(group){
- angular.forEach(group.properties, function(property){
+ scope.deleteProperty = function (tab, propertyIndex) {
- if(property.dataTypeId === newProperty.dataTypeId) {
+ // remove property
+ tab.properties.splice(propertyIndex, 1);
- // update property data
- property.config = newProperty.config;
- property.editor = newProperty.editor;
- property.view = newProperty.view;
- property.dataTypeId = newProperty.dataTypeId;
- property.dataTypeIcon = newProperty.dataTypeIcon;
- property.dataTypeName = newProperty.dataTypeName;
+ notifyChanged();
+ };
+ function notifyChanged() {
+ eventsService.emit("editors.groupsBuilder.changed");
}
- });
- });
- }
-
- function hasPropertyOfDataTypeId(dataTypeId) {
-
- // look at each property
- var result = _.filter(scope.model.groups, function(group) {
- return _.filter(group.properties, function(property) {
- return (property.dataTypeId === dataTypeId);
+ function addInitProperty(group) {
+
+ var addInitPropertyBool = true;
+ var initProperty = {
+ label: null,
+ alias: null,
+ propertyState: "init",
+ validation: {
+ mandatory: false,
+ mandatoryMessage: null,
+ pattern: null,
+ patternMessage: null
+ }
+ };
+
+ // check if there already is an init property
+ angular.forEach(group.properties, function (property) {
+ if (property.propertyState === "init") {
+ addInitPropertyBool = false;
+ }
});
- });
-
- return (result.length > 0);
- }
+ if (addInitPropertyBool) {
+ group.properties.push(initProperty);
+ }
- eventBindings.push(scope.$watch('model', function(newValue, oldValue) {
- if (newValue !== undefined && newValue.groups !== undefined) {
- activate();
- }
- }));
-
- // clean up
- eventBindings.push(eventsService.on("editors.dataTypeSettings.saved", function (name, args) {
- if(hasPropertyOfDataTypeId(args.dataType.id)) {
- scope.dataTypeHasChanged = true;
+ return group;
}
- }));
-
- // clean up
- eventBindings.push(scope.$on('$destroy', function() {
- for(var e in eventBindings) {
- eventBindings[e]();
+
+ function updateSameDataTypes(newProperty) {
+
+ // find each property
+ angular.forEach(scope.model.groups, function (group) {
+ angular.forEach(group.properties, function (property) {
+
+ if (property.dataTypeId === newProperty.dataTypeId) {
+
+ // update property data
+ property.config = newProperty.config;
+ property.editor = newProperty.editor;
+ property.view = newProperty.view;
+ property.dataTypeId = newProperty.dataTypeId;
+ property.dataTypeIcon = newProperty.dataTypeIcon;
+ property.dataTypeName = newProperty.dataTypeName;
+
+ }
+
+ });
+ });
}
- // if a dataType has changed, we want to notify which properties that are affected by this dataTypeSettings change
- if(scope.dataTypeHasChanged === true) {
- var args = {documentType: scope.model};
- eventsService.emit("editors.documentType.saved", args);
+
+ function hasPropertyOfDataTypeId(dataTypeId) {
+
+ // look at each property
+ var result = _.filter(scope.model.groups, function (group) {
+ return _.filter(group.properties, function (property) {
+ return (property.dataTypeId === dataTypeId);
+ });
+ });
+
+ return (result.length > 0);
}
- }));
+
+ eventBindings.push(scope.$watch('model', function (newValue, oldValue) {
+ if (newValue !== undefined && newValue.groups !== undefined) {
+ activate();
+ }
+ }));
+
+ // clean up
+ eventBindings.push(eventsService.on("editors.dataTypeSettings.saved", function (name, args) {
+ if (hasPropertyOfDataTypeId(args.dataType.id)) {
+ scope.dataTypeHasChanged = true;
+ }
+ }));
+
+ // clean up
+ eventBindings.push(scope.$on('$destroy', function () {
+ for (var e in eventBindings) {
+ eventBindings[e]();
+ }
+ // if a dataType has changed, we want to notify which properties that are affected by this dataTypeSettings change
+ if (scope.dataTypeHasChanged === true) {
+ var args = { documentType: scope.model };
+ eventsService.emit("editors.documentType.saved", args);
+ }
+ }));
+
+ }
+
+ var directive = {
+ restrict: "E",
+ replace: true,
+ templateUrl: "views/components/umb-groups-builder.html",
+ scope: {
+ model: "=",
+ compositions: "=",
+ sorting: "=",
+ contentType: "@"
+ },
+ link: link
+ };
+
+ return directive;
}
- var directive = {
- restrict: "E",
- replace: true,
- templateUrl: "views/components/umb-groups-builder.html",
- scope: {
- model: "=",
- compositions: "=",
- sorting: "=",
- contentType: "@"
- },
- link: link
- };
-
- return directive;
- }
-
- angular.module('umbraco.directives').directive('umbGroupsBuilder', GroupsBuilderDirective);
+ angular.module('umbraco.directives').directive('umbGroupsBuilder', GroupsBuilderDirective);
})();
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbnestedcontent.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbnestedcontent.directive.js
index 471714d30bcd..72dba3ca2f7b 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbnestedcontent.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbnestedcontent.directive.js
@@ -3,12 +3,12 @@
function () {
var link = function ($scope) {
-
+
// Clone the model because some property editors
// do weird things like updating and config values
// so we want to ensure we start from a fresh every
// time, we'll just sync the value back when we need to
- $scope.model = angular.copy($scope.ngModel);
+ $scope.model = Utilities.copy($scope.ngModel);
$scope.nodeContext = $scope.model;
// Find the selected tab
@@ -31,7 +31,7 @@
// Tell inner controls we are submitting
$scope.$broadcast("formSubmitting", { scope: $scope });
-
+
// Sync the values back
angular.forEach($scope.ngModel.variants[0].tabs, function (tab) {
if (tab.alias.toLowerCase() === selectedTab.alias.toLowerCase()) {
diff --git a/src/Umbraco.Web.UI.Client/src/common/interceptors/donotpostdollarvariablesrequest.interceptor.js b/src/Umbraco.Web.UI.Client/src/common/interceptors/donotpostdollarvariablesrequest.interceptor.js
index 03373089d7db..f3dd60bdcedc 100644
--- a/src/Umbraco.Web.UI.Client/src/common/interceptors/donotpostdollarvariablesrequest.interceptor.js
+++ b/src/Umbraco.Web.UI.Client/src/common/interceptors/donotpostdollarvariablesrequest.interceptor.js
@@ -1,40 +1,40 @@
-(function() {
- 'use strict';
-
+(function () {
+ 'use strict';
+
function removeProperty(obj, propertyPrefix) {
for (var property in obj) {
if (obj.hasOwnProperty(property)) {
-
+
if (property.startsWith(propertyPrefix) && obj[property] !== undefined) {
obj[property] = undefined;
}
-
+
if (typeof obj[property] === "object") {
removeProperty(obj[property], propertyPrefix);
}
}
}
-
+
}
-
- function transform(data){
+
+ function transform(data) {
removeProperty(data, "$");
}
-
+
function doNotPostDollarVariablesRequestInterceptor($q, urlHelper) {
return {
//dealing with requests:
- 'request': function(config) {
- if(config.method === "POST"){
- var clone = angular.copy(config);
+ 'request': function (config) {
+ if (config.method === "POST") {
+ var clone = Utilities.copy(config);
transform(clone.data);
return clone;
}
-
+
return config;
}
};
- }
+ }
angular.module('umbraco.interceptors').factory('doNotPostDollarVariablesOnPostRequestInterceptor', doNotPostDollarVariablesRequestInterceptor);
})();
diff --git a/src/Umbraco.Web.UI.Client/src/common/services/contenttypehelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/contenttypehelper.service.js
index 42431b751ffa..1be66cc68f93 100644
--- a/src/Umbraco.Web.UI.Client/src/common/services/contenttypehelper.service.js
+++ b/src/Umbraco.Web.UI.Client/src/common/services/contenttypehelper.service.js
@@ -7,21 +7,21 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
var contentTypeHelperService = {
- createIdArray: function(array) {
+ createIdArray: function (array) {
- var newArray = [];
+ var newArray = [];
- angular.forEach(array, function(arrayItem){
+ angular.forEach(array, function (arrayItem) {
- if(Utilities.isObject(arrayItem)) {
- newArray.push(arrayItem.id);
- } else {
- newArray.push(arrayItem);
- }
+ if (Utilities.isObject(arrayItem)) {
+ newArray.push(arrayItem.id);
+ } else {
+ newArray.push(arrayItem);
+ }
- });
+ });
- return newArray;
+ return newArray;
},
@@ -30,18 +30,18 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
var modelsResource = $injector.has("modelsBuilderManagementResource") ? $injector.get("modelsBuilderManagementResource") : null;
var modelsBuilderEnabled = Umbraco.Sys.ServerVariables.umbracoPlugins.modelsBuilder.enabled;
if (modelsBuilderEnabled && modelsResource) {
- modelsResource.buildModels().then(function(result) {
+ modelsResource.buildModels().then(function (result) {
deferred.resolve(result);
//just calling this to get the servar back to life
modelsResource.getModelsOutOfDateStatus();
- }, function(e) {
+ }, function (e) {
deferred.reject(e);
});
}
- else {
- deferred.resolve(false);
+ else {
+ deferred.resolve(false);
}
return deferred.promise;
},
@@ -49,10 +49,10 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
checkModelsBuilderStatus: function () {
var deferred = $q.defer();
var modelsResource = $injector.has("modelsBuilderManagementResource") ? $injector.get("modelsBuilderManagementResource") : null;
- var modelsBuilderEnabled = (Umbraco && Umbraco.Sys && Umbraco.Sys.ServerVariables && Umbraco.Sys.ServerVariables.umbracoPlugins && Umbraco.Sys.ServerVariables.umbracoPlugins.modelsBuilder && Umbraco.Sys.ServerVariables.umbracoPlugins.modelsBuilder.enabled === true);
-
+ var modelsBuilderEnabled = (Umbraco && Umbraco.Sys && Umbraco.Sys.ServerVariables && Umbraco.Sys.ServerVariables.umbracoPlugins && Umbraco.Sys.ServerVariables.umbracoPlugins.modelsBuilder && Umbraco.Sys.ServerVariables.umbracoPlugins.modelsBuilder.enabled === true);
+
if (modelsBuilderEnabled && modelsResource) {
- modelsResource.getModelsOutOfDateStatus().then(function(result) {
+ modelsResource.getModelsOutOfDateStatus().then(function (result) {
//Generate models buttons should be enabled if it is 0
deferred.resolve(result.status === 0);
});
@@ -64,37 +64,37 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
},
makeObjectArrayFromId: function (idArray, objectArray) {
- var newArray = [];
+ var newArray = [];
- for (var idIndex = 0; idArray.length > idIndex; idIndex++) {
- var id = idArray[idIndex];
+ for (var idIndex = 0; idArray.length > idIndex; idIndex++) {
+ var id = idArray[idIndex];
- for (var objectIndex = 0; objectArray.length > objectIndex; objectIndex++) {
- var object = objectArray[objectIndex];
- if (id === object.id) {
- newArray.push(object);
- }
- }
+ for (var objectIndex = 0; objectArray.length > objectIndex; objectIndex++) {
+ var object = objectArray[objectIndex];
+ if (id === object.id) {
+ newArray.push(object);
+ }
+ }
- }
+ }
- return newArray;
+ return newArray;
},
- validateAddingComposition: function(contentType, compositeContentType) {
+ validateAddingComposition: function (contentType, compositeContentType) {
//Validate that by adding this group that we are not adding duplicate property type aliases
- var propertiesAdding = _.flatten(_.map(compositeContentType.groups, function(g) {
- return _.map(g.properties, function(p) {
+ var propertiesAdding = _.flatten(_.map(compositeContentType.groups, function (g) {
+ return _.map(g.properties, function (p) {
return p.alias;
});
}));
- var propAliasesExisting = _.filter(_.flatten(_.map(contentType.groups, function(g) {
- return _.map(g.properties, function(p) {
+ var propAliasesExisting = _.filter(_.flatten(_.map(contentType.groups, function (g) {
+ return _.map(g.properties, function (p) {
return p.alias;
});
- })), function(f) {
+ })), function (f) {
return f !== null && f !== undefined;
});
@@ -108,7 +108,7 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
return [];
},
- mergeCompositeContentType: function(contentType, compositeContentType) {
+ mergeCompositeContentType: function (contentType, compositeContentType) {
//Validate that there are no overlapping aliases
var overlappingAliases = this.validateAddingComposition(contentType, compositeContentType);
@@ -116,107 +116,107 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
throw new Error("Cannot add this composition, these properties already exist on the content type: " + overlappingAliases.join());
}
- angular.forEach(compositeContentType.groups, function(compositionGroup) {
+ angular.forEach(compositeContentType.groups, function (compositionGroup) {
- // order composition groups based on sort order
- compositionGroup.properties = $filter('orderBy')(compositionGroup.properties, 'sortOrder');
+ // order composition groups based on sort order
+ compositionGroup.properties = $filter('orderBy')(compositionGroup.properties, 'sortOrder');
- // get data type details
- angular.forEach(compositionGroup.properties, function(property) {
- dataTypeResource.getById(property.dataTypeId)
- .then(function(dataType) {
- property.dataTypeIcon = dataType.icon;
- property.dataTypeName = dataType.name;
- });
- });
+ // get data type details
+ angular.forEach(compositionGroup.properties, function (property) {
+ dataTypeResource.getById(property.dataTypeId)
+ .then(function (dataType) {
+ property.dataTypeIcon = dataType.icon;
+ property.dataTypeName = dataType.name;
+ });
+ });
- // set inherited state on tab
- compositionGroup.inherited = true;
+ // set inherited state on tab
+ compositionGroup.inherited = true;
- // set inherited state on properties
- angular.forEach(compositionGroup.properties, function(compositionProperty) {
- compositionProperty.inherited = true;
- });
+ // set inherited state on properties
+ angular.forEach(compositionGroup.properties, function (compositionProperty) {
+ compositionProperty.inherited = true;
+ });
- // set tab state
- compositionGroup.tabState = "inActive";
+ // set tab state
+ compositionGroup.tabState = "inActive";
- // if groups are named the same - merge the groups
- angular.forEach(contentType.groups, function(contentTypeGroup) {
+ // if groups are named the same - merge the groups
+ angular.forEach(contentType.groups, function (contentTypeGroup) {
- if (contentTypeGroup.name === compositionGroup.name) {
+ if (contentTypeGroup.name === compositionGroup.name) {
- // set flag to show if properties has been merged into a tab
- compositionGroup.groupIsMerged = true;
+ // set flag to show if properties has been merged into a tab
+ compositionGroup.groupIsMerged = true;
- // make group inherited
- contentTypeGroup.inherited = true;
+ // make group inherited
+ contentTypeGroup.inherited = true;
- // add properties to the top of the array
- contentTypeGroup.properties = compositionGroup.properties.concat(contentTypeGroup.properties);
+ // add properties to the top of the array
+ contentTypeGroup.properties = compositionGroup.properties.concat(contentTypeGroup.properties);
- // update sort order on all properties in merged group
- contentTypeGroup.properties = contentTypeHelperService.updatePropertiesSortOrder(contentTypeGroup.properties);
+ // update sort order on all properties in merged group
+ contentTypeGroup.properties = contentTypeHelperService.updatePropertiesSortOrder(contentTypeGroup.properties);
- // make parentTabContentTypeNames to an array so we can push values
- if (contentTypeGroup.parentTabContentTypeNames === null || contentTypeGroup.parentTabContentTypeNames === undefined) {
- contentTypeGroup.parentTabContentTypeNames = [];
- }
+ // make parentTabContentTypeNames to an array so we can push values
+ if (contentTypeGroup.parentTabContentTypeNames === null || contentTypeGroup.parentTabContentTypeNames === undefined) {
+ contentTypeGroup.parentTabContentTypeNames = [];
+ }
- // push name to array of merged composite content types
- contentTypeGroup.parentTabContentTypeNames.push(compositeContentType.name);
+ // push name to array of merged composite content types
+ contentTypeGroup.parentTabContentTypeNames.push(compositeContentType.name);
- // make parentTabContentTypes to an array so we can push values
- if (contentTypeGroup.parentTabContentTypes === null || contentTypeGroup.parentTabContentTypes === undefined) {
- contentTypeGroup.parentTabContentTypes = [];
- }
+ // make parentTabContentTypes to an array so we can push values
+ if (contentTypeGroup.parentTabContentTypes === null || contentTypeGroup.parentTabContentTypes === undefined) {
+ contentTypeGroup.parentTabContentTypes = [];
+ }
- // push id to array of merged composite content types
- contentTypeGroup.parentTabContentTypes.push(compositeContentType.id);
+ // push id to array of merged composite content types
+ contentTypeGroup.parentTabContentTypes.push(compositeContentType.id);
- // get sort order from composition
- contentTypeGroup.sortOrder = compositionGroup.sortOrder;
+ // get sort order from composition
+ contentTypeGroup.sortOrder = compositionGroup.sortOrder;
- // splice group to the top of the array
- var contentTypeGroupCopy = angular.copy(contentTypeGroup);
- var index = contentType.groups.indexOf(contentTypeGroup);
- contentType.groups.splice(index, 1);
- contentType.groups.unshift(contentTypeGroupCopy);
+ // splice group to the top of the array
+ var contentTypeGroupCopy = Utilities.copy(contentTypeGroup);
+ var index = contentType.groups.indexOf(contentTypeGroup);
+ contentType.groups.splice(index, 1);
+ contentType.groups.unshift(contentTypeGroupCopy);
- }
+ }
- });
+ });
- // if group is not merged - push it to the end of the array - before init tab
- if (compositionGroup.groupIsMerged === false || compositionGroup.groupIsMerged === undefined) {
+ // if group is not merged - push it to the end of the array - before init tab
+ if (compositionGroup.groupIsMerged === false || compositionGroup.groupIsMerged === undefined) {
- // make parentTabContentTypeNames to an array so we can push values
- if (compositionGroup.parentTabContentTypeNames === null || compositionGroup.parentTabContentTypeNames === undefined) {
- compositionGroup.parentTabContentTypeNames = [];
- }
+ // make parentTabContentTypeNames to an array so we can push values
+ if (compositionGroup.parentTabContentTypeNames === null || compositionGroup.parentTabContentTypeNames === undefined) {
+ compositionGroup.parentTabContentTypeNames = [];
+ }
+
+ // push name to array of merged composite content types
+ compositionGroup.parentTabContentTypeNames.push(compositeContentType.name);
- // push name to array of merged composite content types
- compositionGroup.parentTabContentTypeNames.push(compositeContentType.name);
+ // make parentTabContentTypes to an array so we can push values
+ if (compositionGroup.parentTabContentTypes === null || compositionGroup.parentTabContentTypes === undefined) {
+ compositionGroup.parentTabContentTypes = [];
+ }
- // make parentTabContentTypes to an array so we can push values
- if (compositionGroup.parentTabContentTypes === null || compositionGroup.parentTabContentTypes === undefined) {
- compositionGroup.parentTabContentTypes = [];
- }
+ // push id to array of merged composite content types
+ compositionGroup.parentTabContentTypes.push(compositeContentType.id);
- // push id to array of merged composite content types
- compositionGroup.parentTabContentTypes.push(compositeContentType.id);
-
- // push group before placeholder tab
- contentType.groups.unshift(compositionGroup);
+ // push group before placeholder tab
+ contentType.groups.unshift(compositionGroup);
- }
+ }
- });
+ });
- // sort all groups by sortOrder property
- contentType.groups = $filter('orderBy')(contentType.groups, 'sortOrder');
+ // sort all groups by sortOrder property
+ contentType.groups = $filter('orderBy')(contentType.groups, 'sortOrder');
- return contentType;
+ return contentType;
},
@@ -224,22 +224,22 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
var groups = [];
- angular.forEach(contentType.groups, function(contentTypeGroup){
+ angular.forEach(contentType.groups, function (contentTypeGroup) {
- if( contentTypeGroup.tabState !== "init" ) {
+ if (contentTypeGroup.tabState !== "init") {
var idIndex = contentTypeGroup.parentTabContentTypes.indexOf(compositeContentType.id);
var nameIndex = contentTypeGroup.parentTabContentTypeNames.indexOf(compositeContentType.name);
var groupIndex = contentType.groups.indexOf(contentTypeGroup);
- if( idIndex !== -1 ) {
+ if (idIndex !== -1) {
var properties = [];
// remove all properties from composite content type
- angular.forEach(contentTypeGroup.properties, function(property){
- if(property.contentTypeId !== compositeContentType.id) {
+ angular.forEach(contentTypeGroup.properties, function (property) {
+ if (property.contentTypeId !== compositeContentType.id) {
properties.push(property);
}
});
@@ -252,22 +252,22 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
contentTypeGroup.parentTabContentTypeNames.splice(nameIndex, 1);
// remove inherited state if there are no inherited properties
- if(contentTypeGroup.parentTabContentTypes.length === 0) {
+ if (contentTypeGroup.parentTabContentTypes.length === 0) {
contentTypeGroup.inherited = false;
}
// remove group if there are no properties left
- if(contentTypeGroup.properties.length > 1) {
+ if (contentTypeGroup.properties.length > 1) {
//contentType.groups.splice(groupIndex, 1);
groups.push(contentTypeGroup);
}
} else {
- groups.push(contentTypeGroup);
+ groups.push(contentTypeGroup);
}
} else {
- groups.push(contentTypeGroup);
+ groups.push(contentTypeGroup);
}
// update sort order on properties
@@ -281,67 +281,67 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
updatePropertiesSortOrder: function (properties) {
- var sortOrder = 0;
+ var sortOrder = 0;
- angular.forEach(properties, function(property) {
- if( !property.inherited && property.propertyState !== "init") {
- property.sortOrder = sortOrder;
- }
- sortOrder++;
- });
+ angular.forEach(properties, function (property) {
+ if (!property.inherited && property.propertyState !== "init") {
+ property.sortOrder = sortOrder;
+ }
+ sortOrder++;
+ });
- return properties;
+ return properties;
},
- getTemplatePlaceholder: function() {
+ getTemplatePlaceholder: function () {
- var templatePlaceholder = {
- "name": "",
- "icon": "icon-layout",
- "alias": "templatePlaceholder",
- "placeholder": true
- };
+ var templatePlaceholder = {
+ "name": "",
+ "icon": "icon-layout",
+ "alias": "templatePlaceholder",
+ "placeholder": true
+ };
- return templatePlaceholder;
+ return templatePlaceholder;
},
- insertDefaultTemplatePlaceholder: function(defaultTemplate) {
+ insertDefaultTemplatePlaceholder: function (defaultTemplate) {
- // get template placeholder
- var templatePlaceholder = contentTypeHelperService.getTemplatePlaceholder();
+ // get template placeholder
+ var templatePlaceholder = contentTypeHelperService.getTemplatePlaceholder();
- // add as default template
- defaultTemplate = templatePlaceholder;
+ // add as default template
+ defaultTemplate = templatePlaceholder;
- return defaultTemplate;
+ return defaultTemplate;
},
- insertTemplatePlaceholder: function(array) {
+ insertTemplatePlaceholder: function (array) {
- // get template placeholder
- var templatePlaceholder = contentTypeHelperService.getTemplatePlaceholder();
+ // get template placeholder
+ var templatePlaceholder = contentTypeHelperService.getTemplatePlaceholder();
- // add as selected item
- array.push(templatePlaceholder);
+ // add as selected item
+ array.push(templatePlaceholder);
- return array;
+ return array;
- },
+ },
- insertChildNodePlaceholder: function (array, name, icon, id) {
+ insertChildNodePlaceholder: function (array, name, icon, id) {
- var placeholder = {
- "name": name,
- "icon": icon,
- "id": id
- };
+ var placeholder = {
+ "name": name,
+ "icon": icon,
+ "id": id
+ };
- array.push(placeholder);
+ array.push(placeholder);
- }
+ }
};
diff --git a/src/Umbraco.Web.UI.Client/src/common/services/editor.service.js b/src/Umbraco.Web.UI.Client/src/common/services/editor.service.js
index 9c935086a071..538bd41ce028 100644
--- a/src/Umbraco.Web.UI.Client/src/common/services/editor.service.js
+++ b/src/Umbraco.Web.UI.Client/src/common/services/editor.service.js
@@ -164,14 +164,14 @@ When building a custom infinite editor view you can use the same components as a
"use strict";
function editorService(eventsService, keyboardService, $timeout) {
-
-
+
+
let editorsKeyboardShorcuts = [];
var editors = [];
var isEnabled = true;
var lastElementInFocus = null;
-
-
+
+
// events for backdrop
eventsService.on("appState.backdrop", function (name, args) {
if (args.show === true) {
@@ -180,7 +180,7 @@ When building a custom infinite editor view you can use the same components as a
focus();
}
});
-
+
/**
* @ngdoc method
@@ -205,7 +205,7 @@ When building a custom infinite editor view you can use the same components as a
function getNumberOfEditors() {
return editors.length;
};
-
+
/**
* @ngdoc method
* @name umbraco.services.editorService#blur
@@ -232,7 +232,7 @@ When building a custom infinite editor view you can use the same components as a
* Method to tell editors that they are gaining focus again.
*/
function focus() {
- if(isEnabled === false) {
+ if (isEnabled === false) {
/* keyboard shortcuts will be overwritten by the new infinite editor
so we need to store the shortcuts for the current editor so they can be rebound
when the infinite editor closes
@@ -241,7 +241,7 @@ When building a custom infinite editor view you can use the same components as a
isEnabled = true;
}
}
-
+
/**
* @ngdoc method
* @name umbraco.services.editorService#open
@@ -305,7 +305,7 @@ When building a custom infinite editor view you can use the same components as a
// delay required to map the properties to the correct editor due
// to another delay in the closing animation of the editor
- $timeout(function() {
+ $timeout(function () {
// rebind keyboard shortcuts for the new editor in focus
rebindKeyboardShortcuts();
@@ -651,7 +651,7 @@ When building a custom infinite editor view you can use the same components as a
editor.view = "views/mediatypes/edit.html";
open(editor);
}
-
+
/**
* @ngdoc method
* @name umbraco.services.editorService#memberTypeEditor
@@ -928,21 +928,21 @@ When building a custom infinite editor view you can use the same components as a
open(editor);
}
- /**
- * @ngdoc method
- * @name umbraco.services.editorService#memberPicker
- * @methodOf umbraco.services.editorService
- *
- * @description
- * Opens a member picker in infinite editing, the submit callback returns an array of selected items
- *
- * @param {Object} editor rendering options
- * @param {Boolean} editor.multiPicker Pick one or multiple items
- * @param {Function} editor.submit Callback function when the submit button is clicked. Returns the editor model object
- * @param {Function} editor.close Callback function when the close button is clicked.
- *
- * @returns {Object} editor object
- */
+ /**
+ * @ngdoc method
+ * @name umbraco.services.editorService#memberPicker
+ * @methodOf umbraco.services.editorService
+ *
+ * @description
+ * Opens a member picker in infinite editing, the submit callback returns an array of selected items
+ *
+ * @param {Object} editor rendering options
+ * @param {Boolean} editor.multiPicker Pick one or multiple items
+ * @param {Function} editor.submit Callback function when the submit button is clicked. Returns the editor model object
+ * @param {Function} editor.close Callback function when the close button is clicked.
+ *
+ * @returns {Object} editor object
+ */
function memberPicker(editor) {
editor.view = "views/common/infiniteeditors/treepicker/treepicker.html";
if (!editor.size) editor.size = "small";
@@ -985,7 +985,7 @@ When building a custom infinite editor view you can use the same components as a
*
*/
function unbindKeyboardShortcuts() {
- const shortcuts = angular.copy(keyboardService.keyboardEvent);
+ const shortcuts = Utilities.copy(keyboardService.keyboardEvent);
editorsKeyboardShorcuts.push(shortcuts);
// unbind the current shortcuts because we only want to
diff --git a/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js b/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js
index 6401fa3aef42..019890711901 100644
--- a/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js
+++ b/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js
@@ -26,60 +26,60 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
navReadyPromise.resolve(mainTreeApi);
});
-
+
//A list of query strings defined that when changed will not cause a reload of the route
var nonRoutingQueryStrings = ["mculture", "cculture", "lq", "sr"];
var retainedQueryStrings = ["mculture"];
-
+
function setMode(mode) {
switch (mode) {
- case 'tree':
- appState.setGlobalState("navMode", "tree");
- appState.setGlobalState("showNavigation", true);
- appState.setMenuState("showMenu", false);
- appState.setMenuState("showMenuDialog", false);
- appState.setGlobalState("stickyNavigation", false);
- appState.setGlobalState("showTray", false);
- break;
- case 'menu':
- appState.setGlobalState("navMode", "menu");
- appState.setGlobalState("showNavigation", true);
- appState.setMenuState("showMenu", true);
- appState.setMenuState("showMenuDialog", false);
- appState.setGlobalState("stickyNavigation", true);
- break;
- case 'dialog':
- appState.setGlobalState("navMode", "dialog");
- appState.setGlobalState("stickyNavigation", true);
- appState.setGlobalState("showNavigation", true);
- appState.setMenuState("showMenu", false);
- appState.setMenuState("showMenuDialog", true);
- appState.setMenuState("allowHideMenuDialog", true);
- break;
- case 'search':
- appState.setGlobalState("navMode", "search");
- appState.setGlobalState("stickyNavigation", false);
- appState.setGlobalState("showNavigation", true);
- appState.setMenuState("showMenu", false);
- appState.setSectionState("showSearchResults", true);
- appState.setMenuState("showMenuDialog", false);
- break;
- default:
- appState.setGlobalState("navMode", "default");
- appState.setMenuState("showMenu", false);
- appState.setMenuState("showMenuDialog", false);
- appState.setMenuState("allowHideMenuDialog", true);
- appState.setSectionState("showSearchResults", false);
- appState.setGlobalState("stickyNavigation", false);
- appState.setGlobalState("showTray", false);
- appState.setMenuState("currentNode", null);
-
- if (appState.getGlobalState("isTablet") === true) {
- appState.setGlobalState("showNavigation", false);
- }
+ case 'tree':
+ appState.setGlobalState("navMode", "tree");
+ appState.setGlobalState("showNavigation", true);
+ appState.setMenuState("showMenu", false);
+ appState.setMenuState("showMenuDialog", false);
+ appState.setGlobalState("stickyNavigation", false);
+ appState.setGlobalState("showTray", false);
+ break;
+ case 'menu':
+ appState.setGlobalState("navMode", "menu");
+ appState.setGlobalState("showNavigation", true);
+ appState.setMenuState("showMenu", true);
+ appState.setMenuState("showMenuDialog", false);
+ appState.setGlobalState("stickyNavigation", true);
+ break;
+ case 'dialog':
+ appState.setGlobalState("navMode", "dialog");
+ appState.setGlobalState("stickyNavigation", true);
+ appState.setGlobalState("showNavigation", true);
+ appState.setMenuState("showMenu", false);
+ appState.setMenuState("showMenuDialog", true);
+ appState.setMenuState("allowHideMenuDialog", true);
+ break;
+ case 'search':
+ appState.setGlobalState("navMode", "search");
+ appState.setGlobalState("stickyNavigation", false);
+ appState.setGlobalState("showNavigation", true);
+ appState.setMenuState("showMenu", false);
+ appState.setSectionState("showSearchResults", true);
+ appState.setMenuState("showMenuDialog", false);
+ break;
+ default:
+ appState.setGlobalState("navMode", "default");
+ appState.setMenuState("showMenu", false);
+ appState.setMenuState("showMenuDialog", false);
+ appState.setMenuState("allowHideMenuDialog", true);
+ appState.setSectionState("showSearchResults", false);
+ appState.setGlobalState("stickyNavigation", false);
+ appState.setGlobalState("showTray", false);
+ appState.setMenuState("currentNode", null);
+
+ if (appState.getGlobalState("isTablet") === true) {
+ appState.setGlobalState("showNavigation", false);
+ }
- break;
+ break;
}
}
@@ -114,7 +114,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
}
var service = {
-
+
/**
* @ngdoc method
* @name umbraco.services.navigationService#isRouteChangingNavigation
@@ -151,7 +151,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
var nextRoutingKeys = _.difference(_.keys(nextUrlParams), nonRoutingQueryStrings);
var diff1 = _.difference(currRoutingKeys, nextRoutingKeys);
var diff2 = _.difference(nextRoutingKeys, currRoutingKeys);
-
+
//if the routing parameter keys are the same, we'll compare their values to see if any have changed and if so then the routing will be allowed.
if (diff1.length === 0 && diff2.length === 0) {
var partsChanged = 0;
@@ -223,7 +223,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @param {Object} nextRouteParams The next route parameters
*/
retainQueryStrings: function (currRouteParams, nextRouteParams) {
- var toRetain = angular.copy(nextRouteParams);
+ var toRetain = Utilities.copy(nextRouteParams);
var updated = false;
_.each(retainedQueryStrings, function (r) {
@@ -260,7 +260,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* and load the dashboard related to the section
* @param {string} sectionAlias The alias of the section
*/
- changeSection: function(sectionAlias, force) {
+ changeSection: function (sectionAlias, force) {
setMode("default-opensection");
if (force && appState.getSectionState("currentSection") === sectionAlias) {
@@ -360,19 +360,19 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
TODO: Delete this if not required
*/
- _syncPath: function(path, forceReload) {
+ _syncPath: function (path, forceReload) {
return navReadyPromise.promise.then(function () {
return mainTreeApi.syncTree({ path: path, forceReload: forceReload });
});
},
-
- reloadNode: function(node) {
+
+ reloadNode: function (node) {
return navReadyPromise.promise.then(function () {
return mainTreeApi.reloadNode(node);
});
},
-
- reloadSection: function(sectionAlias) {
+
+ reloadSection: function (sectionAlias) {
return navReadyPromise.promise.then(function () {
treeService.clearCache({ section: sectionAlias });
return mainTreeApi.load(sectionAlias);
@@ -387,11 +387,11 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @description
* Hides the tree by hiding the containing dom element
*/
- hideTree: function() {
+ hideTree: function () {
if (appState.getGlobalState("isTablet") === true && !appState.getGlobalState("stickyNavigation")) {
//reset it to whatever is in the url
- appState.setSectionState("currentSection", $routeParams.section);
+ appState.setSectionState("currentSection", $routeParams.section);
setMode("default-hidesectiontree");
}
@@ -409,19 +409,19 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
*
* @param {Event} event the click event triggering the method, passed from the DOM element
*/
- showMenu: function(args) {
-
+ showMenu: function (args) {
+
var self = this;
return treeService.getMenu({ treeNode: args.node })
- .then(function(data) {
+ .then(function (data) {
//check for a default
//NOTE: event will be undefined when a call to hideDialog is made so it won't re-load the default again.
// but perhaps there's a better way to deal with with an additional parameter in the args ? it works though.
if (data.defaultAlias && !args.skipDefault) {
- var found = _.find(data.menuItems, function(item) {
+ var found = _.find(data.menuItems, function (item) {
return item.alias = data.defaultAlias;
});
@@ -450,7 +450,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
return $q.resolve();
});
-
+
},
/**
@@ -461,7 +461,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @description
* Hides the menu by hiding the containing dom element
*/
- hideMenu: function() {
+ hideMenu: function () {
//SD: Would we ever want to access the last action'd node instead of clearing it here?
appState.setMenuState("currentNode", null);
appState.setMenuState("menuActions", []);
@@ -532,7 +532,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
});
}
},
-
+
/**
* @ngdoc method
@@ -553,7 +553,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @param {Scope} args.scope current scope passed to the dialog
* @param {Object} args.action the clicked action containing `name` and `alias`
*/
- showDialog: function(args) {
+ showDialog: function (args) {
if (!args) {
throw "showDialog is missing the args parameter";
@@ -578,20 +578,20 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
if (args.action.metaData["actionView"]) {
templateUrl = args.action.metaData["actionView"];
}
- else {
+ else {
var treeAlias = treeService.getTreeAlias(args.node);
if (!treeAlias) {
throw "Could not get tree alias for node " + args.node.id;
- }
+ }
templateUrl = this.getTreeTemplateUrl(treeAlias, args.action.alias);
}
setMode("dialog");
- if(templateUrl) {
+ if (templateUrl) {
appState.setMenuState("dialogTemplateUrl", templateUrl);
}
-
+
},
/**
* @ngdoc method
@@ -607,7 +607,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* we will also check for a 'packageName' for the current tree, if it exists then the convention will be:
* for example: /App_Plugins/{mypackage}/backoffice/{treetype}/create.html
*/
- getTreeTemplateUrl: function(treeAlias, action) {
+ getTreeTemplateUrl: function (treeAlias, action) {
var packageTreeFolder = treeService.getTreePackageFolder(treeAlias);
if (packageTreeFolder) {
return Umbraco.Sys.ServerVariables.umbracoSettings.appPluginsPath +
@@ -661,7 +661,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @description
* shows the search pane
*/
- showSearch: function() {
+ showSearch: function () {
setMode("search");
},
/**
@@ -672,7 +672,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @description
* hides the search pane
*/
- hideSearch: function() {
+ hideSearch: function () {
setMode("default-hidesearch");
},
/**
@@ -683,7 +683,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @description
* hides any open navigation panes and resets the tree, actions and the currently selected node
*/
- hideNavigation: function() {
+ hideNavigation: function () {
appState.setMenuState("menuActions", []);
setMode("default");
}
diff --git a/src/Umbraco.Web.UI.Client/src/init.js b/src/Umbraco.Web.UI.Client/src/init.js
index d5c5166d214d..ce824f63c067 100644
--- a/src/Umbraco.Web.UI.Client/src/init.js
+++ b/src/Umbraco.Web.UI.Client/src/init.js
@@ -34,7 +34,7 @@ app.run(['$rootScope', '$route', '$location', 'urlHelper', 'navigationService',
else {
const introTourShown = localStorageService.get("introTourShown");
- if(!introTourShown){
+ if (!introTourShown) {
// Go & show email marketing tour (ONLY when intro tour is completed or been dismissed)
tourService.getTourByAlias("umbEmailMarketing").then(function (emailMarketingTour) {
// Only show the email marketing tour one time - dismissing it or saying no will make sure it never appears again
@@ -45,7 +45,7 @@ app.run(['$rootScope', '$route', '$location', 'urlHelper', 'navigationService',
// Only show the email tour once per logged in session
// The localstorage key is removed on logout or user session timeout
const emailMarketingTourShown = localStorageService.get("emailMarketingTourShown");
- if(!emailMarketingTourShown){
+ if (!emailMarketingTourShown) {
tourService.startTour(emailMarketingTour);
localStorageService.set("emailMarketingTourShown", true);
}
@@ -89,7 +89,7 @@ app.run(['$rootScope', '$route', '$location', 'urlHelper', 'navigationService',
currentRouteParams = toRetain;
}
else {
- currentRouteParams = angular.copy(current.params);
+ currentRouteParams = Utilities.copy(current.params);
}
@@ -183,7 +183,7 @@ app.run(['$rootScope', '$route', '$location', 'urlHelper', 'navigationService',
currentRouteParams = toRetain;
}
else {
- currentRouteParams = angular.copy(next.params);
+ currentRouteParams = Utilities.copy(next.params);
}
//always clear the 'sr' query string (soft redirect) if it exists
@@ -191,7 +191,7 @@ app.run(['$rootScope', '$route', '$location', 'urlHelper', 'navigationService',
currentRouteParams.sr = null;
$route.updateParams(currentRouteParams);
}
-
+
}
}
});
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/compositions/compositions.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/compositions/compositions.controller.js
index 7cfa02f95ac8..aa0cd54dfffb 100644
--- a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/compositions/compositions.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/compositions/compositions.controller.js
@@ -17,7 +17,7 @@
/* make a copy of the init model so it is possible to roll
back the changes on cancel */
- oldModel = angular.copy($scope.model);
+ oldModel = Utilities.copy($scope.model);
if (!$scope.model.title) {
$scope.model.title = "Compositions";
@@ -39,7 +39,7 @@
});
}
-
+
function isSelected(alias) {
if ($scope.model.contentType.compositeContentTypes.indexOf(alias) !== -1) {
@@ -68,7 +68,7 @@
or the confirm checkbox has been checked */
if (compositionRemoved) {
vm.allowSubmit = false;
- localizationService.localize("general_remove").then(function(value) {
+ localizationService.localize("general_remove").then(function (value) {
const dialog = {
view: "views/common/infiniteeditors/compositions/overlays/confirmremove.html",
title: value,
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/linkpicker/linkpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/linkpicker/linkpicker.controller.js
index 47607b7f0bc0..a9803b70f9f1 100644
--- a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/linkpicker/linkpicker.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/linkpicker/linkpicker.controller.js
@@ -1,7 +1,7 @@
//used for the media picker dialog
angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController",
function ($scope, eventsService, entityResource, mediaResource, mediaHelper, udiParser, userService, localizationService, editorService) {
-
+
var vm = this;
var dialogOptions = $scope.model;
@@ -16,7 +16,7 @@ angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController",
if (!$scope.model.title) {
localizationService.localize("defaultdialogs_selectLink")
- .then(function(value) {
+ .then(function (value) {
$scope.model.title = value;
});
}
@@ -59,7 +59,7 @@ angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController",
if (dialogOptions.currentTarget) {
// clone the current target so we don't accidentally update the caller's model while manipulating $scope.model.target
- $scope.model.target = angular.copy(dialogOptions.currentTarget);
+ $scope.model.target = Utilities.copy(dialogOptions.currentTarget);
// if we have a node ID, we fetch the current node to build the form data
if ($scope.model.target.id || $scope.model.target.udi) {
@@ -194,7 +194,7 @@ angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController",
tree: "content"
});
},
- close: function() {
+ close: function () {
editorService.close();
}
};
@@ -251,13 +251,13 @@ angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController",
}
function close() {
- if($scope.model && $scope.model.close) {
+ if ($scope.model && $scope.model.close) {
$scope.model.close();
}
}
function submit() {
- if($scope.model && $scope.model.submit) {
+ if ($scope.model && $scope.model.submit) {
$scope.model.submit($scope.model);
}
}
diff --git a/src/Umbraco.Web.UI.Client/src/views/languages/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/languages/edit.controller.js
index 5f1c46de4cbe..96441e610103 100644
--- a/src/Umbraco.Web.UI.Client/src/views/languages/edit.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/languages/edit.controller.js
@@ -57,7 +57,7 @@
};
if ($routeParams.create) {
- vm.page.name = vm.labels.addLanguage;
+ vm.page.name = vm.labels.addLanguage;
}
});
@@ -87,14 +87,14 @@
if (!$routeParams.create) {
- promises.push(languageResource.getById($routeParams.id).then(function(lang) {
+ promises.push(languageResource.getById($routeParams.id).then(function (lang) {
vm.language = lang;
vm.page.name = vm.language.name;
/* we need to store the initial default state so we can disable the toggle if it is the default.
we need to prevent from not having a default language. */
- vm.initIsDefault = angular.copy(vm.language.isDefault);
+ vm.initIsDefault = Utilities.copy(vm.language.isDefault);
makeBreadcrumbs();
@@ -182,12 +182,12 @@
function toggleDefault() {
// it shouldn't be possible to uncheck the default language
- if(vm.initIsDefault) {
+ if (vm.initIsDefault) {
return;
}
vm.language.isDefault = !vm.language.isDefault;
- if(vm.language.isDefault) {
+ if (vm.language.isDefault) {
vm.showDefaultLanguageInfo = true;
} else {
vm.showDefaultLanguageInfo = false;
diff --git a/src/Umbraco.Web.UI.Client/src/views/packages/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/packages/edit.controller.js
index 70688f045cb7..63750ff0f218 100644
--- a/src/Umbraco.Web.UI.Client/src/views/packages/edit.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/packages/edit.controller.js
@@ -40,7 +40,7 @@
vm.versionRegex = /^(\d+\.)(\d+\.)(\*|\d+)$/;
function onInit() {
-
+
if (create) {
// Pre populate package with some values
packageResource.getEmpty().then(scaffold => {
@@ -78,7 +78,7 @@
});
-
+
localizationService.localizeMany(["buttons_save", "packager_includeAllChildNodes"]).then(function (values) {
vm.labels.button = values[0];
vm.labels.includeAllChildNodes = values[1];
@@ -232,7 +232,7 @@
function openFilePicker() {
- let selection = angular.copy(vm.package.files);
+ let selection = Utilities.copy(vm.package.files);
const filePicker = {
title: "Select files",
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.controller.js
index 10b2f19e83b9..2568f62cf4d3 100644
--- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.controller.js
@@ -185,7 +185,7 @@ angular.module("umbraco")
var rteId = value.id;
if ($.inArray(rteId, notIncludedRte) < 0) {
-
+
// remember this RTEs settings, cause we need to update it later.
var editor = _.findWhere(tinyMCE.editors, { id: rteId })
if (editor) {
@@ -197,17 +197,17 @@ angular.module("umbraco")
}
else {
$(event.target).find(".umb-rte").each(function () {
-
+
var rteId = $(this).attr("id");
-
+
if ($.inArray(rteId, notIncludedRte) < 0) {
-
+
// remember this RTEs settings, cause we need to update it later.
var editor = _.findWhere(tinyMCE.editors, { id: rteId })
if (editor) {
draggedRteSettings[rteId] = editor.settings;
}
-
+
notIncludedRte.splice(0, 0, $(this).attr("id"));
}
});
@@ -227,12 +227,12 @@ angular.module("umbraco")
// reset dragged RTE settings in case a RTE isn't dragged
draggedRteSettings = {};
notIncludedRte = [];
-
+
ui.item[0].style.display = "block";
ui.item.find(".umb-rte").each(function (key, value) {
-
+
var rteId = value.id;
-
+
// remember this RTEs settings, cause we need to update it later.
var editor = _.findWhere(tinyMCE.editors, { id: rteId });
@@ -255,17 +255,17 @@ angular.module("umbraco")
ui.item.offsetParent().find(".umb-rte").each(function (key, value) {
var rteId = value.id;
if ($.inArray(rteId, notIncludedRte) < 0) {
-
+
var editor = _.findWhere(tinyMCE.editors, { id: rteId });
if (editor) {
draggedRteSettings[rteId] = editor.settings;
}
-
+
// add all dragged's neighbouring RTEs in the new cell
notIncludedRte.splice(0, 0, rteId);
}
});
-
+
// reconstruct the dragged RTE (could be undefined when dragging something else than RTE)
if (draggedRteSettings !== undefined) {
tinyMCE.init(draggedRteSettings);
@@ -327,13 +327,13 @@ angular.module("umbraco")
title: title,
availableItems: area.$allowedEditors,
event: event,
- submit: function(model) {
+ submit: function (model) {
if (model.selectedItem) {
$scope.addControl(model.selectedItem, area, index);
overlayService.close();
}
},
- close: function() {
+ close: function () {
overlayService.close();
}
});
@@ -345,7 +345,7 @@ angular.module("umbraco")
// *********************************************
$scope.addTemplate = function (template) {
- $scope.model.value = angular.copy(template);
+ $scope.model.value = Utilities.copy(template);
//default row data
_.forEach($scope.model.value.sections, function (section) {
@@ -387,7 +387,7 @@ angular.module("umbraco")
$scope.addRow = function (section, layout, isInit) {
//copy the selected layout into the rows collection
- var row = angular.copy(layout);
+ var row = Utilities.copy(layout);
// Init row value
row = $scope.initRow(row);
@@ -408,7 +408,7 @@ angular.module("umbraco")
setTimeout(function () {
var newRowEl = $element.find("[data-rowid='" + row.$uniqueId + "']");
- if(newRowEl !== null) {
+ if (newRowEl !== null) {
newRowEl.focus();
}
}, 0);
@@ -467,10 +467,10 @@ angular.module("umbraco")
var styles, config;
if (itemType === 'control') {
styles = null;
- config = angular.copy(gridItem.editor.config.settings);
+ config = Utilities.copy(gridItem.editor.config.settings);
} else {
- styles = _.filter(angular.copy($scope.model.config.items.styles), function (item) { return shouldApply(item, itemType, gridItem); });
- config = _.filter(angular.copy($scope.model.config.items.config), function (item) { return shouldApply(item, itemType, gridItem); });
+ styles = _.filter(Utilities.copy($scope.model.config.items.styles), function (item) { return shouldApply(item, itemType, gridItem); });
+ config = _.filter(Utilities.copy($scope.model.config.items.config), function (item) { return shouldApply(item, itemType, gridItem); });
}
if (Utilities.isObject(gridItem.config)) {
@@ -763,7 +763,7 @@ angular.module("umbraco")
// allowed for this template based on the current config.
_.each(found.sections, function (templateSection, index) {
- angular.extend($scope.model.value.sections[index], angular.copy(templateSection));
+ angular.extend($scope.model.value.sections[index], Utilities.copy(templateSection));
});
}
@@ -835,7 +835,7 @@ angular.module("umbraco")
return null;
} else {
//make a copy to not touch the original config
- original = angular.copy(original);
+ original = Utilities.copy(original);
original.styles = row.styles;
original.config = row.config;
original.hasConfig = gridItemHasConfig(row.styles, row.config);
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.prevalues.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.prevalues.controller.js
index 27ea819884d8..f273ea63e615 100644
--- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.prevalues.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/grid/grid.prevalues.controller.js
@@ -1,296 +1,296 @@
angular.module("umbraco")
.controller("Umbraco.PropertyEditors.GridPrevalueEditorController",
- function ($scope, gridService, editorService) {
-
- var emptyModel = {
- styles:[
- {
- label: "Set a background image",
- description: "Set a row background",
- key: "background-image",
- view: "imagepicker",
- modifier: "url({0})"
- }
- ],
-
- config:[
- {
- label: "Class",
- description: "Set a css class",
- key: "class",
- view: "textstring"
- }
- ],
-
- columns: 12,
- templates:[
- {
- name: "1 column layout",
- sections: [
- {
- grid: 12
- }
- ]
- },
- {
- name: "2 column layout",
- sections: [
- {
- grid: 4
- },
- {
- grid: 8
- }
- ]
- }
- ],
+ function ($scope, gridService, editorService) {
+
+ var emptyModel = {
+ styles: [
+ {
+ label: "Set a background image",
+ description: "Set a row background",
+ key: "background-image",
+ view: "imagepicker",
+ modifier: "url({0})"
+ }
+ ],
+
+ config: [
+ {
+ label: "Class",
+ description: "Set a css class",
+ key: "class",
+ view: "textstring"
+ }
+ ],
+
+ columns: 12,
+ templates: [
+ {
+ name: "1 column layout",
+ sections: [
+ {
+ grid: 12
+ }
+ ]
+ },
+ {
+ name: "2 column layout",
+ sections: [
+ {
+ grid: 4
+ },
+ {
+ grid: 8
+ }
+ ]
+ }
+ ],
+
+
+ layouts: [
+ {
+ label: "Headline",
+ name: "Headline",
+ areas: [
+ {
+ grid: 12,
+ editors: ["headline"]
+ }
+ ]
+ },
+ {
+ label: "Article",
+ name: "Article",
+ areas: [
+ {
+ grid: 4
+ },
+ {
+ grid: 8
+ }
+ ]
+ }
+ ]
+ };
+ /****************
+ template
+ *****************/
- layouts:[
- {
- label: "Headline",
- name: "Headline",
- areas: [
- {
- grid: 12,
- editors: ["headline"]
- }
- ]
- },
- {
- label: "Article",
- name: "Article",
- areas: [
- {
- grid: 4
- },
- {
- grid: 8
- }
- ]
+ $scope.configureTemplate = function (template) {
+
+ var index = $scope.model.value.templates.indexOf(template);
+
+ if (template === undefined) {
+ template = {
+ name: "",
+ sections: [
+
+ ]
+ };
}
- ]
- };
-
- /****************
- template
- *****************/
-
- $scope.configureTemplate = function(template) {
-
- var index = $scope.model.value.templates.indexOf(template);
-
- if (template === undefined) {
- template = {
- name: "",
- sections: [
-
- ]
- };
- }
-
- var layoutConfigOverlay = {
- currentLayout: angular.copy(template),
- rows: $scope.model.value.layouts,
- columns: $scope.model.value.columns,
- view: "views/propertyEditors/grid/dialogs/layoutconfig.html",
- size: "small",
- submit: function (model) {
- if (index === -1) {
- $scope.model.value.templates.push(model);
- } else {
- $scope.model.value.templates[index] = model;
+
+ var layoutConfigOverlay = {
+ currentLayout: Utilities.copy(template),
+ rows: $scope.model.value.layouts,
+ columns: $scope.model.value.columns,
+ view: "views/propertyEditors/grid/dialogs/layoutconfig.html",
+ size: "small",
+ submit: function (model) {
+ if (index === -1) {
+ $scope.model.value.templates.push(model);
+ } else {
+ $scope.model.value.templates[index] = model;
+ }
+ editorService.close();
+ },
+ close: function (model) {
+ editorService.close();
}
- editorService.close();
- },
- close: function(model) {
- editorService.close();
- }
+ };
+
+ editorService.open(layoutConfigOverlay);
+
+ };
+
+ $scope.deleteTemplate = function (index) {
+ $scope.model.value.templates.splice(index, 1);
};
- editorService.open(layoutConfigOverlay);
-
- };
- $scope.deleteTemplate = function(index){
- $scope.model.value.templates.splice(index, 1);
- };
-
+ /****************
+ Row
+ *****************/
- /****************
- Row
- *****************/
+ $scope.configureLayout = function (layout) {
- $scope.configureLayout = function(layout) {
+ var index = $scope.model.value.layouts.indexOf(layout);
- var index = $scope.model.value.layouts.indexOf(layout);
-
- if(layout === undefined){
- layout = {
- name: "",
- areas:[
+ if (layout === undefined) {
+ layout = {
+ name: "",
+ areas: [
- ]
- };
- }
-
- var rowConfigOverlay = {
- currentRow: angular.copy(layout),
- editors: $scope.editors,
- columns: $scope.model.value.columns,
- view: "views/propertyEditors/grid/dialogs/rowconfig.html",
- size: "small",
- submit: function (model) {
- if (index === -1) {
- $scope.model.value.layouts.push(model);
- } else {
- $scope.model.value.layouts[index] = model;
- }
- editorService.close();
- },
- close: function(model) {
- editorService.close();
- }
- };
-
- editorService.open(rowConfigOverlay);
-
- };
-
- //var rowDeletesPending = false;
- $scope.deleteLayout = function(index) {
-
- var rowDeleteOverlay = {
- dialogData: {
- rowName: $scope.model.value.layouts[index].name
- },
- view: "views/propertyEditors/grid/dialogs/rowdeleteconfirm.html",
- size: "small",
- submit: function(model) {
- $scope.model.value.layouts.splice(index, 1);
- editorService.close();
- },
- close: function(model) {
- editorService.close();
+ ]
+ };
}
+
+ var rowConfigOverlay = {
+ currentRow: Utilities.copy(layout),
+ editors: $scope.editors,
+ columns: $scope.model.value.columns,
+ view: "views/propertyEditors/grid/dialogs/rowconfig.html",
+ size: "small",
+ submit: function (model) {
+ if (index === -1) {
+ $scope.model.value.layouts.push(model);
+ } else {
+ $scope.model.value.layouts[index] = model;
+ }
+ editorService.close();
+ },
+ close: function (model) {
+ editorService.close();
+ }
+ };
+
+ editorService.open(rowConfigOverlay);
+
};
- editorService.open(rowDeleteOverlay);
- };
+ //var rowDeletesPending = false;
+ $scope.deleteLayout = function (index) {
+
+ var rowDeleteOverlay = {
+ dialogData: {
+ rowName: $scope.model.value.layouts[index].name
+ },
+ view: "views/propertyEditors/grid/dialogs/rowdeleteconfirm.html",
+ size: "small",
+ submit: function (model) {
+ $scope.model.value.layouts.splice(index, 1);
+ editorService.close();
+ },
+ close: function (model) {
+ editorService.close();
+ }
+ };
+
+ editorService.open(rowDeleteOverlay);
+ };
- /****************
- utillities
- *****************/
- $scope.toggleCollection = function(collection, toggle){
- if(toggle){
- collection = [];
- }else{
- collection = null;
- }
- };
+ /****************
+ utillities
+ *****************/
+ $scope.toggleCollection = function (collection, toggle) {
+ if (toggle) {
+ collection = [];
+ } else {
+ collection = null;
+ }
+ };
- $scope.percentage = function(spans){
- return ((spans / $scope.model.value.columns) * 100).toFixed(8);
- };
+ $scope.percentage = function (spans) {
+ return ((spans / $scope.model.value.columns) * 100).toFixed(8);
+ };
- $scope.zeroWidthFilter = function (cell) {
+ $scope.zeroWidthFilter = function (cell) {
return cell.grid > 0;
- };
-
- /****************
- Config
- *****************/
-
- $scope.removeConfigValue = function(collection, index){
- collection.splice(index, 1);
- };
-
- var editConfigCollection = function(configValues, title, callback) {
-
- var editConfigCollectionOverlay = {
- config: configValues,
- title: title,
- view: "views/propertyeditors/grid/dialogs/editconfig.html",
- size: "small",
- submit: function(model) {
- callback(model.config);
- editorService.close();
- },
- close: function(model) {
- editorService.close();
- }
};
- editorService.open(editConfigCollectionOverlay);
- };
-
- $scope.editConfig = function() {
- editConfigCollection($scope.model.value.config, "Settings", function(data) {
- $scope.model.value.config = data;
- });
- };
-
- $scope.editStyles = function() {
- editConfigCollection($scope.model.value.styles, "Styling", function(data){
- $scope.model.value.styles = data;
- });
- };
-
- /****************
- editors
- *****************/
- gridService.getGridEditors().then(function(response){
- $scope.editors = response.data;
- });
+ /****************
+ Config
+ *****************/
+ $scope.removeConfigValue = function (collection, index) {
+ collection.splice(index, 1);
+ };
- /* init grid data */
- if (!$scope.model.value || $scope.model.value === "" || !$scope.model.value.templates) {
- $scope.model.value = emptyModel;
- } else {
+ var editConfigCollection = function (configValues, title, callback) {
+
+ var editConfigCollectionOverlay = {
+ config: configValues,
+ title: title,
+ view: "views/propertyeditors/grid/dialogs/editconfig.html",
+ size: "small",
+ submit: function (model) {
+ callback(model.config);
+ editorService.close();
+ },
+ close: function (model) {
+ editorService.close();
+ }
+ };
- if (!$scope.model.value.columns) {
- $scope.model.value.columns = emptyModel.columns;
- }
+ editorService.open(editConfigCollectionOverlay);
+ };
+ $scope.editConfig = function () {
+ editConfigCollection($scope.model.value.config, "Settings", function (data) {
+ $scope.model.value.config = data;
+ });
+ };
- if (!$scope.model.value.config) {
- $scope.model.value.config = [];
- }
+ $scope.editStyles = function () {
+ editConfigCollection($scope.model.value.styles, "Styling", function (data) {
+ $scope.model.value.styles = data;
+ });
+ };
- if (!$scope.model.value.styles) {
- $scope.model.value.styles = [];
+ /****************
+ editors
+ *****************/
+ gridService.getGridEditors().then(function (response) {
+ $scope.editors = response.data;
+ });
+
+
+ /* init grid data */
+ if (!$scope.model.value || $scope.model.value === "" || !$scope.model.value.templates) {
+ $scope.model.value = emptyModel;
+ } else {
+
+ if (!$scope.model.value.columns) {
+ $scope.model.value.columns = emptyModel.columns;
+ }
+
+
+ if (!$scope.model.value.config) {
+ $scope.model.value.config = [];
+ }
+
+ if (!$scope.model.value.styles) {
+ $scope.model.value.styles = [];
+ }
}
- }
-
- /****************
- Clean up
- *****************/
- var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
- var ts = $scope.model.value.templates;
- var ls = $scope.model.value.layouts;
-
- _.each(ts, function(t){
- _.each(t.sections, function(section, index){
- if(section.grid === 0){
- t.sections.splice(index, 1);
- }
- });
+
+ /****************
+ Clean up
+ *****************/
+ var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
+ var ts = $scope.model.value.templates;
+ var ls = $scope.model.value.layouts;
+
+ _.each(ts, function (t) {
+ _.each(t.sections, function (section, index) {
+ if (section.grid === 0) {
+ t.sections.splice(index, 1);
+ }
+ });
+ });
+
+ _.each(ls, function (l) {
+ _.each(l.areas, function (area, index) {
+ if (area.grid === 0) {
+ l.areas.splice(index, 1);
+ }
+ });
+ });
});
- _.each(ls, function(l){
- _.each(l.areas, function(area, index){
- if(area.grid === 0){
- l.areas.splice(index, 1);
- }
- });
+ //when the scope is destroyed we need to unsubscribe
+ $scope.$on('$destroy', function () {
+ unsubscribe();
});
- });
- //when the scope is destroyed we need to unsubscribe
- $scope.$on('$destroy', function () {
- unsubscribe();
});
-
- });
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.controller.js
index 68e7ea4f5cec..30715dfd5ec8 100644
--- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.controller.js
@@ -1,223 +1,223 @@
angular.module('umbraco')
.controller("Umbraco.PropertyEditors.ImageCropperController",
- function ($scope, fileManager, $timeout) {
-
- var config = angular.copy($scope.model.config);
-
- $scope.filesSelected = onFileSelected;
- $scope.filesChanged = onFilesChanged;
- $scope.fileUploaderInit = onFileUploaderInit;
- $scope.imageLoaded = imageLoaded;
- $scope.crop = crop;
- $scope.done = done;
- $scope.clear = clear;
- $scope.reset = reset;
- $scope.close = close;
- $scope.isCustomCrop = isCustomCrop;
- $scope.focalPointChanged = focalPointChanged;
- //declare a special method which will be called whenever the value has changed from the server
- $scope.model.onValueChanged = onValueChanged;
-
- /**
- * Called when the umgImageGravity component updates the focal point value
- * @param {any} left
- * @param {any} top
- */
- function focalPointChanged(left, top) {
- //update the model focalpoint value
- $scope.model.value.focalPoint = {
- left: left,
- top: top
- };
-
- //set form to dirty to track changes
- $scope.imageCropperForm.$setDirty();
- }
+ function ($scope, fileManager, $timeout) {
+
+ var config = Utilities.copy($scope.model.config);
+
+ $scope.filesSelected = onFileSelected;
+ $scope.filesChanged = onFilesChanged;
+ $scope.fileUploaderInit = onFileUploaderInit;
+ $scope.imageLoaded = imageLoaded;
+ $scope.crop = crop;
+ $scope.done = done;
+ $scope.clear = clear;
+ $scope.reset = reset;
+ $scope.close = close;
+ $scope.isCustomCrop = isCustomCrop;
+ $scope.focalPointChanged = focalPointChanged;
+ //declare a special method which will be called whenever the value has changed from the server
+ $scope.model.onValueChanged = onValueChanged;
+
+ /**
+ * Called when the umgImageGravity component updates the focal point value
+ * @param {any} left
+ * @param {any} top
+ */
+ function focalPointChanged(left, top) {
+ //update the model focalpoint value
+ $scope.model.value.focalPoint = {
+ left: left,
+ top: top
+ };
- /**
- * Used to assign a new model value
- * @param {any} src
- */
- function setModelValueWithSrc(src) {
- if (!$scope.model.value || !$scope.model.value.src) {
- //we are copying to not overwrite the original config
- $scope.model.value = angular.extend(angular.copy($scope.model.config), { src: src });
+ //set form to dirty to track changes
+ $scope.imageCropperForm.$setDirty();
}
- }
- /**
- * called whenever the value has changed from the server
- * @param {any} newVal
- * @param {any} oldVal
- */
- function onValueChanged(newVal, oldVal) {
- //clear current uploaded files
- fileManager.setFiles({
- propertyAlias: $scope.model.alias,
- culture: $scope.model.culture,
- files: []
- });
- }
+ /**
+ * Used to assign a new model value
+ * @param {any} src
+ */
+ function setModelValueWithSrc(src) {
+ if (!$scope.model.value || !$scope.model.value.src) {
+ //we are copying to not overwrite the original config
+ $scope.model.value = angular.extend(Utilities.copy($scope.model.config), { src: src });
+ }
+ }
- /**
- * Called when the a new file is selected
- * @param {any} value
- */
- function onFileSelected(value, files) {
- setModelValueWithSrc(value);
- //set form to dirty to track changes
- $scope.imageCropperForm.$setDirty();
- }
+ /**
+ * called whenever the value has changed from the server
+ * @param {any} newVal
+ * @param {any} oldVal
+ */
+ function onValueChanged(newVal, oldVal) {
+ //clear current uploaded files
+ fileManager.setFiles({
+ propertyAlias: $scope.model.alias,
+ culture: $scope.model.culture,
+ files: []
+ });
+ }
- function imageLoaded (isCroppable, hasDimensions) {
- $scope.isCroppable = isCroppable;
- $scope.hasDimensions = hasDimensions;
- };
-
- /**
- * Called when the file collection changes
- * @param {any} value
- * @param {any} files
- */
- function onFilesChanged(files) {
- if (files && files[0]) {
- $scope.imageSrc = files[0].fileSrc;
+ /**
+ * Called when the a new file is selected
+ * @param {any} value
+ */
+ function onFileSelected(value, files) {
+ setModelValueWithSrc(value);
//set form to dirty to track changes
$scope.imageCropperForm.$setDirty();
}
- }
- /**
- * Called when the file uploader initializes
- * @param {any} value
- */
- function onFileUploaderInit(value, files) {
- //move previously saved value to the editor
- if ($scope.model.value) {
- //backwards compat with the old file upload (incase some-one swaps them..)
- if (Utilities.isString($scope.model.value)) {
- setModelValueWithSrc($scope.model.value);
+ function imageLoaded(isCroppable, hasDimensions) {
+ $scope.isCroppable = isCroppable;
+ $scope.hasDimensions = hasDimensions;
+ };
+
+ /**
+ * Called when the file collection changes
+ * @param {any} value
+ * @param {any} files
+ */
+ function onFilesChanged(files) {
+ if (files && files[0]) {
+ $scope.imageSrc = files[0].fileSrc;
+ //set form to dirty to track changes
+ $scope.imageCropperForm.$setDirty();
}
- else {
- //sync any config changes with the editor and drop outdated crops
- _.each($scope.model.value.crops, function (saved) {
- var configured = _.find(config.crops, function (item) { return item.alias === saved.alias });
+ }
- if (configured && configured.height === saved.height && configured.width === saved.width) {
- configured.coordinates = saved.coordinates;
+ /**
+ * Called when the file uploader initializes
+ * @param {any} value
+ */
+ function onFileUploaderInit(value, files) {
+ //move previously saved value to the editor
+ if ($scope.model.value) {
+ //backwards compat with the old file upload (incase some-one swaps them..)
+ if (Utilities.isString($scope.model.value)) {
+ setModelValueWithSrc($scope.model.value);
+ }
+ else {
+ //sync any config changes with the editor and drop outdated crops
+ _.each($scope.model.value.crops, function (saved) {
+ var configured = _.find(config.crops, function (item) { return item.alias === saved.alias });
+
+ if (configured && configured.height === saved.height && configured.width === saved.width) {
+ configured.coordinates = saved.coordinates;
+ }
+ });
+ $scope.model.value.crops = config.crops;
+
+ //restore focalpoint if missing
+ if (!$scope.model.value.focalPoint) {
+ $scope.model.value.focalPoint = { left: 0.5, top: 0.5 };
}
- });
- $scope.model.value.crops = config.crops;
+ }
- //restore focalpoint if missing
- if (!$scope.model.value.focalPoint) {
- $scope.model.value.focalPoint = { left: 0.5, top: 0.5 };
+ //if there are already files in the client assigned then set the src
+ if (files && files[0]) {
+ $scope.imageSrc = files[0].fileSrc;
}
+ else {
+ $scope.imageSrc = $scope.model.value.src;
+ }
+
}
+ }
- //if there are already files in the client assigned then set the src
- if (files && files[0]) {
- $scope.imageSrc = files[0].fileSrc;
+ /**
+ * crop a specific crop
+ * @param {any} targetCrop
+ */
+ function crop(targetCrop) {
+ if (!$scope.currentCrop) {
+ // clone the crop so we can discard the changes
+ $scope.currentCrop = Utilities.copy(targetCrop);
+ $scope.currentPoint = null;
+
+ //set form to dirty to track changes
+ $scope.imageCropperForm.$setDirty();
}
else {
- $scope.imageSrc = $scope.model.value.src;
+ // we have a crop open already - close the crop (this will discard any changes made)
+ close();
+
+ // the crop editor needs a digest cycle to close down properly, otherwise its state
+ // is reused for the new crop... and that's really bad
+ $timeout(function () {
+ crop(targetCrop);
+ $scope.pendingCrop = false;
+ });
+
+ // this is necessary to keep the screen from flickering too badly while we wait for the new crop to open
+ // - check the view for its usage (basically it makes sure we keep the space reserved for the new crop)
+ $scope.pendingCrop = true;
}
-
- }
- }
+ };
- /**
- * crop a specific crop
- * @param {any} targetCrop
- */
- function crop(targetCrop) {
- if (!$scope.currentCrop) {
- // clone the crop so we can discard the changes
- $scope.currentCrop = angular.copy(targetCrop);
- $scope.currentPoint = null;
+ /** done cropping */
+ function done() {
+ if (!$scope.currentCrop) {
+ return;
+ }
+ // find the original crop by crop alias and update its coordinates
+ var editedCrop = _.find($scope.model.value.crops, crop => crop.alias === $scope.currentCrop.alias);
+ editedCrop.coordinates = $scope.currentCrop.coordinates;
+ $scope.close();
//set form to dirty to track changes
$scope.imageCropperForm.$setDirty();
- }
- else {
- // we have a crop open already - close the crop (this will discard any changes made)
- close();
-
- // the crop editor needs a digest cycle to close down properly, otherwise its state
- // is reused for the new crop... and that's really bad
- $timeout(function () {
- crop(targetCrop);
- $scope.pendingCrop = false;
- });
+ };
- // this is necessary to keep the screen from flickering too badly while we wait for the new crop to open
- // - check the view for its usage (basically it makes sure we keep the space reserved for the new crop)
- $scope.pendingCrop = true;
+ function reset() {
+ $scope.currentCrop.coordinates = undefined;
+ $scope.done();
}
- };
- /** done cropping */
- function done() {
- if (!$scope.currentCrop) {
- return;
+ function close() {
+ $scope.currentCrop = undefined;
+ $scope.currentPoint = undefined;
}
- // find the original crop by crop alias and update its coordinates
- var editedCrop = _.find($scope.model.value.crops, crop => crop.alias === $scope.currentCrop.alias);
- editedCrop.coordinates = $scope.currentCrop.coordinates;
- $scope.close();
-
- //set form to dirty to track changes
- $scope.imageCropperForm.$setDirty();
- };
-
- function reset() {
- $scope.currentCrop.coordinates = undefined;
- $scope.done();
- }
- function close() {
- $scope.currentCrop = undefined;
- $scope.currentPoint = undefined;
- }
+ /**
+ * crop a specific crop
+ * @param {any} crop
+ */
+ function clear(crop) {
+ //clear current uploaded files
+ fileManager.setFiles({
+ propertyAlias: $scope.model.alias,
+ culture: $scope.model.culture,
+ files: []
+ });
- /**
- * crop a specific crop
- * @param {any} crop
- */
- function clear(crop) {
- //clear current uploaded files
- fileManager.setFiles({
- propertyAlias: $scope.model.alias,
- culture: $scope.model.culture,
- files: []
- });
+ //clear the ui
+ $scope.imageSrc = null;
+ if ($scope.model.value) {
+ $scope.model.value = null;
+ }
- //clear the ui
- $scope.imageSrc = null;
- if ($scope.model.value) {
- $scope.model.value = null;
- }
+ //set form to dirty to track changes
+ $scope.imageCropperForm.$setDirty();
+ };
- //set form to dirty to track changes
- $scope.imageCropperForm.$setDirty();
- };
-
- function isCustomCrop(crop) {
- return !!crop.coordinates;
- }
+ function isCustomCrop(crop) {
+ return !!crop.coordinates;
+ }
- var unsubscribe = $scope.$on("formSubmitting", function () {
- $scope.currentCrop = null;
- $scope.currentPoint = null;
- });
+ var unsubscribe = $scope.$on("formSubmitting", function () {
+ $scope.currentCrop = null;
+ $scope.currentPoint = null;
+ });
- $scope.$on('$destroy', function () {
- unsubscribe();
- });
- })
+ $scope.$on('$destroy', function () {
+ unsubscribe();
+ });
+ })
.run(function (mediaHelper, umbRequestHelper) {
if (mediaHelper && mediaHelper.registerFileResolver) {
-
+
//NOTE: The 'entity' can be either a normal media entity or an "entity" returned from the entityResource
// they contain different data structures so if we need to query against it we need to be aware of this.
mediaHelper.registerFileResolver("Umbraco.ImageCropper", function (property, entity, thumbnail) {
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js
index a25d5e798e77..68c50c7ef77d 100644
--- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js
@@ -14,7 +14,7 @@
});
function NestedContentController($scope, $interpolate, $filter, $timeout, contentResource, localizationService, iconHelper, clipboardService, eventsService, overlayService, $routeParams, editorState) {
-
+
var vm = this;
var model = $scope.$parent.$parent.model;
@@ -58,9 +58,9 @@
updateModel();
vm.currentNode = node;
}
-
- var copyAllEntries = function() {
-
+
+ var copyAllEntries = function () {
+
syncCurrentNode();
// list aliases
@@ -68,14 +68,14 @@
// remove dublicates
aliases = aliases.filter((item, index) => aliases.indexOf(item) === index);
-
+
var nodeName = "";
- if(vm.umbVariantContent) {
+ if (vm.umbVariantContent) {
nodeName = vm.umbVariantContent.editor.content.name;
}
- localizationService.localize("clipboard_labelForArrayOfItemsFrom", [model.label, nodeName]).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);
});
}
@@ -146,7 +146,7 @@
orderBy: "$index",
view: "itempicker",
event: $event,
- clickPasteItem: function(item) {
+ clickPasteItem: function (item) {
if (item.type === "elementTypeArray") {
_.each(item.data, function (entry) {
pasteFromClipboard(entry);
@@ -183,9 +183,9 @@
if (vm.overlayMenu.availableItems.length === 0) {
return;
}
-
+
vm.overlayMenu.size = vm.overlayMenu.availableItems.length > 6 ? "medium" : "small";
-
+
vm.overlayMenu.pasteItems = [];
var singleEntriesForPaste = clipboardService.retriveEntriesOfType("elementType", contentTypeAliases);
@@ -197,7 +197,7 @@
icon: entry.icon
});
});
-
+
var arrayEntriesForPaste = clipboardService.retriveEntriesOfType("elementTypeArray", contentTypeAliases);
_.each(arrayEntriesForPaste, function (entry) {
vm.overlayMenu.pasteItems.push({
@@ -393,10 +393,10 @@
clipboardService.copy("elementType", node.contentTypeAlias, node);
$event.stopPropagation();
}
-
-
+
+
function pasteFromClipboard(newNode) {
-
+
if (newNode === undefined) {
return;
}
@@ -407,7 +407,7 @@
vm.nodes.push(newNode);
setDirty();
//updateModel();// done by setting current node...
-
+
setCurrentNode(newNode);
}
@@ -515,7 +515,7 @@
}
function createNode(scaffold, fromNcEntry) {
- var node = angular.copy(scaffold);
+ var node = Utilities.copy(scaffold);
node.key = fromNcEntry && fromNcEntry.key ? fromNcEntry.key : String.CreateGuid();
@@ -596,12 +596,12 @@
}
-
+
var propertyActions = [
copyAllEntriesAction,
removeAllEntriesAction
];
-
+
this.$onInit = function () {
if (this.umbProperty) {
this.umbProperty.setPropertyActions(propertyActions);
diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js
index 30aa677b8be3..781ff731d293 100644
--- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js
@@ -8,7 +8,7 @@
var infiniteMode = $scope.model && $scope.model.infiniteMode;
var id = infiniteMode ? $scope.model.id : $routeParams.id;
var create = infiniteMode ? $scope.model.create : $routeParams.create;
-
+
vm.header = {};
vm.header.editorfor = "template_template";
vm.header.setPageTitle = true;
@@ -26,7 +26,7 @@
vm.page.insertDefaultButton = {
labelKey: "general_insert",
addEllipsis: "true",
- handler: function() {
+ handler: function () {
vm.openInsertOverlay();
}
};
@@ -68,16 +68,16 @@
//Keyboard shortcuts for help dialog
vm.page.keyboardShortcutsOverview = [];
- templateHelper.getGeneralShortcuts().then(function(data){
+ templateHelper.getGeneralShortcuts().then(function (data) {
vm.page.keyboardShortcutsOverview.push(data);
});
- templateHelper.getEditorShortcuts().then(function(data){
+ templateHelper.getEditorShortcuts().then(function (data) {
vm.page.keyboardShortcutsOverview.push(data);
});
- templateHelper.getTemplateEditorShortcuts().then(function(data){
+ templateHelper.getTemplateEditorShortcuts().then(function (data) {
vm.page.keyboardShortcutsOverview.push(data);
});
-
+
vm.save = function (suppressNotification) {
vm.page.saveButtonState = "busy";
@@ -87,36 +87,36 @@
saveMethod: templateResource.save,
scope: $scope,
content: vm.template,
- rebindCallback: function (orignal, saved) {}
+ rebindCallback: function (orignal, saved) { }
}).then(function (saved) {
- if (!suppressNotification) {
- localizationService.localizeMany(["speechBubbles_templateSavedHeader", "speechBubbles_templateSavedText"]).then(function(data){
+ if (!suppressNotification) {
+ localizationService.localizeMany(["speechBubbles_templateSavedHeader", "speechBubbles_templateSavedText"]).then(function (data) {
var header = data[0];
var message = data[1];
notificationsService.success(header, message);
});
- }
+ }
vm.page.saveButtonState = "success";
vm.template = saved;
//sync state
- if(!infiniteMode) {
+ if (!infiniteMode) {
editorState.set(vm.template);
}
-
+
// sync tree
// if master template alias has changed move the node to it's new location
- if(!infiniteMode && oldMasterTemplateAlias !== vm.template.masterTemplateAlias) {
-
+ if (!infiniteMode && oldMasterTemplateAlias !== vm.template.masterTemplateAlias) {
+
// When creating a new template the id is -1. Make sure We don't remove the root node.
if (vm.page.menu.currentNode.id !== "-1") {
// move node to new location in tree
//first we need to remove the node that we're working on
treeService.removeNode(vm.page.menu.currentNode);
}
-
+
// update stored alias to the new one so the node won't move again unless the alias is changed again
oldMasterTemplateAlias = vm.template.masterTemplateAlias;
@@ -127,7 +127,7 @@
} else {
// normal tree sync
- if(!infiniteMode) {
+ if (!infiniteMode) {
navigationService.syncTree({ tree: "templates", path: vm.template.path, forceReload: true }).then(function (syncArgs) {
vm.page.menu.currentNode = syncArgs.node;
});
@@ -138,7 +138,7 @@
// clear $dirty state on form
setFormState("pristine");
- if(infiniteMode) {
+ if (infiniteMode) {
submit();
}
@@ -164,16 +164,16 @@
// load templates - used in the master template picker
templateResource.getAll()
- .then(function(templates) {
+ .then(function (templates) {
vm.templates = templates;
});
- if(create) {
+ if (create) {
templateResource.getScaffold((id)).then(function (template) {
- vm.ready(template);
- });
+ vm.ready(template);
+ });
} else {
- templateResource.getById(id).then(function(template){
+ templateResource.getById(id).then(function (template) {
vm.ready(template);
});
}
@@ -181,26 +181,26 @@
};
- vm.ready = function(template){
- vm.page.loading = false;
+ vm.ready = function (template) {
+ vm.page.loading = false;
vm.template = template;
- // if this is a new template, bind to the blur event on the name
- if (create) {
- $timeout(function() {
- var nameField = angular.element(document.querySelector('[data-element="editor-name-field"]'));
- if (nameField) {
- nameField.on('blur', function(event) {
- if (event.target.value) {
- vm.save(true);
- }
- });
- }
- });
- }
-
+ // if this is a new template, bind to the blur event on the name
+ if (create) {
+ $timeout(function () {
+ var nameField = angular.element(document.querySelector('[data-element="editor-name-field"]'));
+ if (nameField) {
+ nameField.on('blur', function (event) {
+ if (event.target.value) {
+ vm.save(true);
+ }
+ });
+ }
+ });
+ }
+
// sync state
- if(!infiniteMode) {
+ if (!infiniteMode) {
editorState.set(vm.template);
navigationService.syncTree({ tree: "templates", path: vm.template.path, forceReload: true }).then(function (syncArgs) {
vm.page.menu.currentNode = syncArgs.node;
@@ -208,7 +208,7 @@
}
// save state of master template to use for comparison when syncing the tree on save
- oldMasterTemplateAlias = angular.copy(template.masterTemplateAlias);
+ oldMasterTemplateAlias = Utilities.copy(template.masterTemplateAlias);
// ace configuration
vm.aceOption = {
@@ -221,12 +221,12 @@
enableBasicAutocompletion: true,
enableLiveAutocompletion: false
},
- onLoad: function(_editor) {
+ onLoad: function (_editor) {
vm.editor = _editor;
-
+
//Update the auto-complete method to use ctrl+alt+space
_editor.commands.bindKey("ctrl-alt-space", "startAutocomplete");
-
+
// Unassigns the keybinding (That was previously auto-complete)
// As conflicts with our own tree search shortcut
_editor.commands.bindKey("ctrl-space", null);
@@ -238,20 +238,20 @@
{
name: 'unSelectOrFindPrevious',
bindKey: 'Alt-Shift-K',
- exec: function() {
+ exec: function () {
// Toggle the show keyboard shortcuts overlay
- $scope.$apply(function(){
+ $scope.$apply(function () {
vm.showKeyboardShortcut = !vm.showKeyboardShortcut;
});
-
+
},
readOnly: true
},
{
name: 'insertUmbracoValue',
bindKey: 'Alt-Shift-V',
- exec: function() {
- $scope.$apply(function(){
+ exec: function () {
+ $scope.$apply(function () {
openPageFieldOverlay();
});
},
@@ -260,18 +260,18 @@
{
name: 'insertPartialView',
bindKey: 'Alt-Shift-P',
- exec: function() {
- $scope.$apply(function(){
+ exec: function () {
+ $scope.$apply(function () {
openPartialOverlay();
});
},
readOnly: true
},
- {
+ {
name: 'insertDictionary',
bindKey: 'Alt-Shift-D',
- exec: function() {
- $scope.$apply(function(){
+ exec: function () {
+ $scope.$apply(function () {
openDictionaryItemOverlay();
});
},
@@ -280,8 +280,8 @@
{
name: 'insertUmbracoMacro',
bindKey: 'Alt-Shift-M',
- exec: function() {
- $scope.$apply(function(){
+ exec: function () {
+ $scope.$apply(function () {
openMacroOverlay();
});
},
@@ -290,8 +290,8 @@
{
name: 'insertQuery',
bindKey: 'Alt-Shift-Q',
- exec: function() {
- $scope.$apply(function(){
+ exec: function () {
+ $scope.$apply(function () {
openQueryBuilderOverlay();
});
},
@@ -300,8 +300,8 @@
{
name: 'insertSection',
bindKey: 'Alt-Shift-S',
- exec: function() {
- $scope.$apply(function(){
+ exec: function () {
+ $scope.$apply(function () {
openSectionsOverlay();
});
},
@@ -310,21 +310,21 @@
{
name: 'chooseMasterTemplate',
bindKey: 'Alt-Shift-T',
- exec: function() {
- $scope.$apply(function(){
+ exec: function () {
+ $scope.$apply(function () {
openMasterTemplateOverlay();
});
},
readOnly: true
}
-
+
]);
-
+
// initial cursor placement
// Keep cursor in name field if we are create a new template
// else set the cursor at the bottom of the code editor
- if(!create) {
- $timeout(function(){
+ if (!create) {
+ $timeout(function () {
vm.editor.navigateFileEnd();
vm.editor.focus();
persistCurrentLocation();
@@ -335,9 +335,9 @@
vm.editor.on("blur", persistCurrentLocation);
vm.editor.on("focus", persistCurrentLocation);
vm.editor.on("change", changeAceEditor);
- }
+ }
}
-
+
};
vm.openPageFieldOverlay = openPageFieldOverlay;
@@ -363,15 +363,15 @@
partial: true,
umbracoField: true
},
- submit: function(model) {
- switch(model.insert.type) {
+ submit: function (model) {
+ switch (model.insert.type) {
case "macro":
var macroObject = macroService.collectValueData(model.insert.selectedMacro, model.insert.macroParams, "Mvc");
insert(macroObject.syntax);
break;
case "dictionary":
- var code = templateHelper.getInsertDictionarySnippet(model.insert.node.name);
- insert(code);
+ var code = templateHelper.getInsertDictionarySnippet(model.insert.node.name);
+ insert(code);
break;
case "partial":
var code = templateHelper.getInsertPartialSnippet(model.insert.node.parentId, model.insert.node.name);
@@ -383,7 +383,7 @@
}
editorService.close();
},
- close: function(oldModel) {
+ close: function (oldModel) {
// close the dialog
editorService.close();
// focus editor
@@ -401,7 +401,7 @@
insert(macroObject.syntax);
editorService.close();
},
- close: function() {
+ close: function () {
editorService.close();
vm.editor.focus();
}
@@ -431,7 +431,7 @@
"emptyStates_emptyDictionaryTree"
];
- localizationService.localizeMany(labelKeys).then(function(values){
+ localizationService.localizeMany(labelKeys).then(function (values) {
var title = values[0];
var emptyStateMessage = values[1];
@@ -442,7 +442,7 @@
multiPicker: false,
title: title,
emptyStateMessage: emptyStateMessage,
- select: function(node){
+ select: function (node) {
var code = templateHelper.getInsertDictionarySnippet(node.name);
insert(code);
editorService.close();
@@ -463,22 +463,22 @@
function openPartialOverlay() {
- localizationService.localize("template_insertPartialView").then(function(value){
+ localizationService.localize("template_insertPartialView").then(function (value) {
var title = value;
var partialItem = {
- section: "settings",
+ section: "settings",
treeAlias: "partialViews",
entityType: "partialView",
multiPicker: false,
title: title,
- filter: function(i) {
- if(i.name.indexOf(".cshtml") === -1 && i.name.indexOf(".vbhtml") === -1) {
+ filter: function (i) {
+ if (i.name.indexOf(".cshtml") === -1 && i.name.indexOf(".vbhtml") === -1) {
return true;
}
},
filterCssClass: "not-allowed",
- select: function(node){
+ select: function (node) {
var code = templateHelper.getInsertPartialSnippet(node.parentId, node.name);
insert(code);
editorService.close();
@@ -505,7 +505,7 @@
close: function () {
editorService.close();
// focus editor
- vm.editor.focus();
+ vm.editor.focus();
}
};
editorService.queryBuilder(queryBuilder);
@@ -515,7 +515,7 @@
function openSectionsOverlay() {
var templateSections = {
isMaster: vm.template.isMasterTemplate,
- submit: function(model) {
+ submit: function (model) {
if (model.insertType === 'renderBody') {
var code = templateHelper.getRenderBodySnippet();
@@ -535,7 +535,7 @@
editorService.close();
},
- close: function(model) {
+ close: function (model) {
editorService.close();
vm.editor.focus();
}
@@ -559,12 +559,12 @@
}
});
- localizationService.localize("template_mastertemplate").then(function(value){
+ localizationService.localize("template_mastertemplate").then(function (value) {
var title = value;
var masterTemplate = {
title: title,
availableItems: availableMasterTemplates,
- submit: function(model) {
+ submit: function (model) {
var template = model.selectedItem;
if (template && template.alias) {
vm.template.masterTemplateAlias = template.alias;
@@ -575,7 +575,7 @@
}
editorService.close();
},
- close: function(oldModel) {
+ close: function (oldModel) {
// close dialog
editorService.close();
// focus editor
@@ -596,14 +596,14 @@
vm.template.masterTemplateAlias = null;
setLayout(null);
}
-
+
}
function getMasterTemplateName(masterTemplateAlias, templates) {
- if(masterTemplateAlias) {
+ if (masterTemplateAlias) {
var templateName = "";
- angular.forEach(templates, function(template){
- if(template.alias === masterTemplateAlias) {
+ angular.forEach(templates, function (template) {
+ if (template.alias === masterTemplateAlias) {
templateName = template.name;
}
});
@@ -620,8 +620,8 @@
}
- function setLayout(templatePath){
-
+ function setLayout(templatePath) {
+
var templateCode = vm.editor.getValue();
var newValue = templatePath;
var layoutDefRegex = new RegExp("(@{[\\s\\S]*?Layout\\s*?=\\s*?)(\"[^\"]*?\"|null)(;[\\s\\S]*?})", "gi");
@@ -645,7 +645,7 @@
vm.editor.setValue(templateCode);
vm.editor.clearSelection();
vm.editor.navigateFileStart();
-
+
vm.editor.focus();
// set form state to $dirty
setFormState("dirty");
@@ -668,7 +668,7 @@
str = str.replace("{0}", selectedContent);
vm.editor.insert(str);
vm.editor.focus();
-
+
// set form state to $dirty
setFormState("dirty");
}
@@ -682,14 +682,14 @@
}
function setFormState(state) {
-
+
// get the current form
var currentForm = angularHelper.getCurrentForm($scope);
// set state
- if(state === "dirty") {
+ if (state === "dirty") {
currentForm.$setDirty();
- } else if(state === "pristine") {
+ } else if (state === "pristine") {
currentForm.$setPristine();
}
}
@@ -699,18 +699,18 @@
}
function submit() {
- if($scope.model.submit) {
+ if ($scope.model.submit) {
$scope.model.template = vm.template;
$scope.model.submit($scope.model);
}
}
function close() {
- if($scope.model.close) {
+ if ($scope.model.close) {
$scope.model.close();
}
}
-
+
vm.init();
}
diff --git a/src/Umbraco.Web.UI.Client/src/views/users/group.controller.js b/src/Umbraco.Web.UI.Client/src/views/users/group.controller.js
index 43339adf042b..f996e944dbe9 100644
--- a/src/Umbraco.Web.UI.Client/src/views/users/group.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/users/group.controller.js
@@ -6,7 +6,7 @@
var vm = this;
var contentPickerOpen = false;
- vm.page = {};
+ vm.page = {};
vm.page.rootIcon = "icon-folder";
vm.userGroup = {};
vm.labels = {};
@@ -63,9 +63,9 @@
});
} else {
// get user group
- userGroupsResource.getUserGroup($routeParams.id).then(function (userGroup) {
- vm.userGroup = userGroup;
- formatGranularPermissionSelection();
+ userGroupsResource.getUserGroup($routeParams.id).then(function (userGroup) {
+ vm.userGroup = userGroup;
+ formatGranularPermissionSelection();
setSectionIcon(vm.userGroup.sections);
makeBreadcrumbs();
vm.loading = false;
@@ -101,7 +101,7 @@
function openSectionPicker() {
var currentSelection = [];
- angular.copy(vm.userGroup.sections, currentSelection);
+ Utilities.copy(vm.userGroup.sections, currentSelection);
var sectionPicker = {
selection: currentSelection,
submit: function (model) {
@@ -166,7 +166,7 @@
function openUserPicker() {
var currentSelection = [];
- angular.copy(vm.userGroup.users, currentSelection);
+ Utilities.copy(vm.userGroup.users, currentSelection);
var userPicker = {
selection: currentSelection,
submit: function (model) {
@@ -212,8 +212,8 @@
if (model.selection) {
var node = model.selection[0];
//check if this is already in our selection
- var found = _.find(vm.userGroup.assignedPermissions, function(i) {
- return i.id === node.id;
+ var found = _.find(vm.userGroup.assignedPermissions, function (i) {
+ return i.id === node.id;
});
node = found ? found : node;
setPermissionsForNode(node);
@@ -231,7 +231,7 @@
//clone the current defaults to pass to the model
if (!node.permissions) {
- node.permissions = angular.copy(vm.userGroup.defaultPermissions);
+ node.permissions = Utilities.copy(vm.userGroup.defaultPermissions);
}
vm.nodePermissions = {
@@ -257,7 +257,7 @@
editorService.close();
- if(contentPickerOpen) {
+ if (contentPickerOpen) {
editorService.close();
contentPickerOpen = false;
}
diff --git a/src/Umbraco.Web.UI.Client/src/views/users/user.controller.js b/src/Umbraco.Web.UI.Client/src/views/users/user.controller.js
index 56d01a860474..ecea3b1dbae8 100644
--- a/src/Umbraco.Web.UI.Client/src/views/users/user.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/users/user.controller.js
@@ -8,7 +8,7 @@
vm.page = {};
vm.page.rootIcon = "icon-folder";
vm.user = {
- changePassword: null
+ changePassword: null
};
vm.breadcrumbs = [];
vm.showBackButton = true;
@@ -17,12 +17,12 @@
vm.maxFileSize = Umbraco.Sys.ServerVariables.umbracoSettings.maxFileSize + "KB";
vm.acceptedFileTypes = mediaHelper.formatFileTypes(Umbraco.Sys.ServerVariables.umbracoSettings.imageFileTypes);
vm.usernameIsEmail = Umbraco.Sys.ServerVariables.umbracoSettings.usernameIsEmail;
-
+
//create the initial model for change password
vm.changePasswordModel = {
- config: {},
- isChanging: false,
- value: {}
+ config: {},
+ isChanging: false,
+ value: {}
};
vm.goToPage = goToPage;
@@ -38,7 +38,7 @@
vm.changeAvatar = changeAvatar;
vm.clearAvatar = clearAvatar;
vm.save = save;
-
+
vm.changePassword = changePassword;
vm.toggleChangePassword = toggleChangePassword;
@@ -83,40 +83,39 @@
//go get the config for the membership provider and add it to the model
authResource.getMembershipProviderConfig().then(function (data) {
- vm.changePasswordModel.config = data;
-
- //the user has a password if they are not states: Invited, NoCredentials
- vm.changePasswordModel.config.hasPassword = vm.user.userState !== 3 && vm.user.userState !== 4;
-
- vm.changePasswordModel.config.disableToggle = true;
-
- //this is only relavent for membership providers now (it's basically obsolete)
- vm.changePasswordModel.config.enableReset = false;
-
- //in the ASP.NET Identity world, this config option will allow an admin user to change another user's password
- //if the user has access to the user section. So if this editor is being access, the user of course has access to this section.
- //the authorization check is also done on the server side when submitted.
-
- // only update the setting if not the current logged in user, otherwise leave the value as it is
- // currently set in the web.config
- if (!vm.user.isCurrentUser)
- {
- vm.changePasswordModel.config.allowManuallyChangingPassword = true;
- }
-
- vm.loading = false;
+ vm.changePasswordModel.config = data;
+
+ //the user has a password if they are not states: Invited, NoCredentials
+ vm.changePasswordModel.config.hasPassword = vm.user.userState !== 3 && vm.user.userState !== 4;
+
+ vm.changePasswordModel.config.disableToggle = true;
+
+ //this is only relavent for membership providers now (it's basically obsolete)
+ vm.changePasswordModel.config.enableReset = false;
+
+ //in the ASP.NET Identity world, this config option will allow an admin user to change another user's password
+ //if the user has access to the user section. So if this editor is being access, the user of course has access to this section.
+ //the authorization check is also done on the server side when submitted.
+
+ // only update the setting if not the current logged in user, otherwise leave the value as it is
+ // currently set in the web.config
+ if (!vm.user.isCurrentUser) {
+ vm.changePasswordModel.config.allowManuallyChangingPassword = true;
+ }
+
+ vm.loading = false;
});
});
}
-
+
function getLocalDate(date, culture, format) {
- if(date) {
+ if (date) {
var dateVal;
var serverOffset = Umbraco.Sys.ServerVariables.application.serverTimeOffset;
var localOffset = new Date().getTimezoneOffset();
var serverTimeNeedsOffsetting = (-serverOffset !== localOffset);
- if(serverTimeNeedsOffsetting) {
+ if (serverTimeNeedsOffsetting) {
dateVal = dateHelper.convertToLocalMomentTime(date, serverOffset);
} else {
dateVal = moment(date, "YYYY-MM-DD HH:mm:ss");
@@ -144,11 +143,11 @@
submit: model => {
overlayService.close();
vm.changePasswordModel.value = model.changePassword;
- changePassword();
+ changePassword();
}
};
overlayService.open(overlay);
- });
+ });
}
function save() {
@@ -165,16 +164,16 @@
.then(function (saved) {
//if the user saved, then try to execute all extended save options
- extendedSave(saved).then(function(result) {
+ extendedSave(saved).then(function (result) {
//if all is good, then reset the form
formHelper.resetForm({ scope: $scope });
}, Utilities.noop);
-
+
vm.user = _.omit(saved, "navigation");
//restore
vm.user.navigation = currentNav;
setUserDisplayState();
- formatDatesToLocal(vm.user);
+ formatDatesToLocal(vm.user);
vm.page.saveButtonState = "success";
@@ -184,7 +183,7 @@
err: err,
showNotifications: true
});
-
+
vm.page.saveButtonState = "error";
});
}
@@ -201,15 +200,15 @@
//if allowManuallyChangingPassword=false, then we are using default settings and the user will need to enter their old password to change their own password.
vm.changePasswordModel.value.reset = (!vm.changePasswordModel.value.oldPassword && !vm.user.isCurrentUser) || vm.changePasswordModel.config.allowManuallyChangingPassword;
}
-
+
// since we don't send the entire user model, the id is required
vm.changePasswordModel.value.id = vm.user.id;
-
+
usersResource.changePassword(vm.changePasswordModel.value)
.then(() => {
vm.changePasswordModel.isChanging = false;
vm.changePasswordModel.value = {};
-
+
//the user has a password if they are not states: Invited, NoCredentials
vm.changePasswordModel.config.hasPassword = vm.user.userState !== 3 && vm.user.userState !== 4;
}, err => {
@@ -219,7 +218,7 @@
});
});
}
-
+
/**
* Used to emit the save event and await any async operations being performed by editor extensions
* @param {any} savedUser
@@ -228,7 +227,7 @@
//used to track any promises added by the event handlers to be awaited
var promises = [];
-
+
var args = {
//getPromise: getPromise,
user: savedUser,
@@ -240,10 +239,10 @@
//emit the event
eventsService.emit("editors.user.editController.save", args);
-
+
//await all promises to complete
var resultPromise = $q.all(promises);
-
+
return resultPromise;
}
@@ -253,7 +252,7 @@
function openUserGroupPicker() {
var currentSelection = [];
- angular.copy(vm.user.userGroups, currentSelection);
+ Utilities.copy(vm.user.userGroups, currentSelection);
var userGroupPicker = {
selection: currentSelection,
submit: function (model) {
@@ -263,7 +262,7 @@
}
editorService.close();
},
- close: function () {
+ close: function () {
editorService.close();
}
};
@@ -355,10 +354,10 @@
vm.user.userState = 1;
setUserDisplayState();
vm.disableUserButtonState = "success";
-
+
}, function (error) {
vm.disableUserButtonState = "error";
-
+
});
}
@@ -380,7 +379,7 @@
vm.user.failedPasswordAttempts = 0;
setUserDisplayState();
vm.unlockUserButtonState = "success";
-
+
}, function (error) {
vm.unlockUserButtonState = "error";
});
@@ -448,7 +447,7 @@
function clearAvatar() {
// get user
usersResource.clearAvatar(vm.user.id).then(function (data) {
- vm.user.avatars = data;
+ vm.user.avatars = data;
});
}
@@ -469,15 +468,15 @@
}).progress(function (evt) {
if (vm.avatarFile.uploadStatus !== "done" && vm.avatarFile.uploadStatus !== "error") {
- // set uploading status on file
- vm.avatarFile.uploadStatus = "uploading";
+ // set uploading status on file
+ vm.avatarFile.uploadStatus = "uploading";
- // calculate progress in percentage
- var progressPercentage = parseInt(100.0 * evt.loaded / evt.total, 10);
+ // calculate progress in percentage
+ var progressPercentage = parseInt(100.0 * evt.loaded / evt.total, 10);
- // set percentage property on file
- vm.avatarFile.uploadProgress = progressPercentage;
- }
+ // set percentage property on file
+ vm.avatarFile.uploadProgress = progressPercentage;
+ }
}).success(function (data, status, headers, config) {
diff --git a/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.controller.js b/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.controller.js
index 4ac385921ed5..102efae7026f 100644
--- a/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.controller.js
@@ -67,7 +67,7 @@
];
// Get last selected layout for "users" (defaults to first layout = card layout)
- vm.activeLayout = listViewHelper.getLayout("users", vm.layouts);
+ vm.activeLayout = listViewHelper.getLayout("users", vm.layouts);
// Don't show the invite button if no email is configured
if (Umbraco.Sys.ServerVariables.umbracoSettings.showUserInvite) {
@@ -247,19 +247,19 @@
function selectLayout(selectedLayout) {
// save the selected layout for "users" so it's applied next time the user visits this section
- vm.activeLayout = listViewHelper.setLayout("users", selectedLayout, vm.layouts);
+ vm.activeLayout = listViewHelper.setLayout("users", selectedLayout, vm.layouts);
}
-
+
function isSelectable(user) {
return !user.isCurrentUser;
}
-
+
function selectUser(user) {
-
+
if (!isSelectable(user)) {
return;
}
-
+
if (user.selected) {
var index = vm.selection.indexOf(user.id);
vm.selection.splice(index, 1);
@@ -268,9 +268,9 @@
user.selected = true;
vm.selection.push(user.id);
}
-
+
setBulkActions(vm.users);
-
+
}
function clearSelection() {
@@ -279,14 +279,14 @@
});
vm.selection = [];
}
-
+
function clickUser(user, $event) {
-
+
$event.stopPropagation();
-
+
if ($event) {
// targeting a new tab/window?
- if ($event.ctrlKey ||
+ if ($event.ctrlKey ||
$event.shiftKey ||
$event.metaKey || // apple
($event.button && $event.button === 1) // middle click, >IE9 + everyone else
@@ -295,7 +295,7 @@
return;
}
}
-
+
goToUser(user);
$event.preventDefault();
@@ -398,7 +398,7 @@
function openUserGroupPicker() {
var currentSelection = [];
- angular.copy(vm.newUser.userGroups, currentSelection);
+ Utilities.copy(vm.newUser.userGroups, currentSelection);
var userGroupPicker = {
selection: currentSelection,
submit: function (model) {
@@ -611,7 +611,7 @@
// copy to clip board success
function copySuccess() {
if (vm.page.copyPasswordButtonState !== "success") {
- $timeout(function(){
+ $timeout(function () {
vm.page.copyPasswordButtonState = "success";
});
$timeout(function () {
@@ -623,7 +623,7 @@
// copy to clip board error
function copyError() {
if (vm.page.copyPasswordButtonState !== "error") {
- $timeout(function() {
+ $timeout(function () {
vm.page.copyPasswordButtonState = "error";
});
$timeout(function () {
@@ -654,7 +654,7 @@
return null;
}
-
+
function getEditPath(user) {
return pathToUser(user) + usersOptionsAsQueryString();
}
@@ -699,7 +699,7 @@
vm.usersOptions.pageSize = data.pageSize;
vm.usersOptions.totalItems = data.totalItems;
vm.usersOptions.totalPages = data.totalPages;
-
+
formatDates(vm.users);
setUserDisplayState(vm.users);
vm.userStatesFilter = usersHelper.getUserStatesFilter(data.userStates);
@@ -753,19 +753,19 @@
var firstSelectedUserGroups;
angular.forEach(users, function (user) {
-
+
if (!user.selected) {
return;
}
-
-
+
+
// if the current user is selected prevent any bulk actions with the user included
if (user.isCurrentUser) {
vm.allowDisableUser = false;
vm.allowEnableUser = false;
vm.allowUnlockUser = false;
vm.allowSetUserGroup = false;
-
+
return false;
}
diff --git a/src/Umbraco.Web.UI.Client/test/lib/angular/angular-mocks.js b/src/Umbraco.Web.UI.Client/test/lib/angular/angular-mocks.js
index 965fcdce71b1..2888351783aa 100644
--- a/src/Umbraco.Web.UI.Client/test/lib/angular/angular-mocks.js
+++ b/src/Umbraco.Web.UI.Client/test/lib/angular/angular-mocks.js
@@ -51,12 +51,12 @@ angular.mock.$Browser = function () {
self.onUrlChange = function (listener) {
self.pollFns.push(
- function () {
- if (self.$$lastUrl != self.$$url) {
- self.$$lastUrl = self.$$url;
- listener(self.$$url);
- }
- }
+ function () {
+ if (self.$$lastUrl != self.$$url) {
+ self.$$lastUrl = self.$$url;
+ listener(self.$$url);
+ }
+ }
);
return listener;
@@ -172,8 +172,8 @@ angular.mock.$Browser.prototype = {
}
} else {
if (!angular.equals(this.cookieHash, this.lastCookieHash)) {
- this.lastCookieHash = angular.copy(this.cookieHash);
- this.cookieHash = angular.copy(this.cookieHash);
+ this.lastCookieHash = Utilities.copy(this.cookieHash);
+ this.cookieHash = Utilities.copy(this.cookieHash);
}
return this.cookieHash;
}
@@ -397,7 +397,7 @@ angular.mock.$LogProvider = function () {
});
if (errors.length) {
errors.unshift("Expected $log to be empty! Either a message was logged unexpectedly, or an expected " +
- "log message was not checked and removed:");
+ "log message was not checked and removed:");
errors.push('');
throw new Error(errors.join('\n---------\n'));
}
@@ -581,12 +581,12 @@ angular.mock.$LogProvider = function () {
if (self.toISOString) {
self.toISOString = function () {
return padNumber(self.origDate.getUTCFullYear(), 4) + '-' +
- padNumber(self.origDate.getUTCMonth() + 1, 2) + '-' +
- padNumber(self.origDate.getUTCDate(), 2) + 'T' +
- padNumber(self.origDate.getUTCHours(), 2) + ':' +
- padNumber(self.origDate.getUTCMinutes(), 2) + ':' +
- padNumber(self.origDate.getUTCSeconds(), 2) + '.' +
- padNumber(self.origDate.getUTCMilliseconds(), 3) + 'Z'
+ padNumber(self.origDate.getUTCMonth() + 1, 2) + '-' +
+ padNumber(self.origDate.getUTCDate(), 2) + 'T' +
+ padNumber(self.origDate.getUTCHours(), 2) + ':' +
+ padNumber(self.origDate.getUTCMinutes(), 2) + ':' +
+ padNumber(self.origDate.getUTCSeconds(), 2) + '.' +
+ padNumber(self.origDate.getUTCMilliseconds(), 3) + 'Z'
}
}
@@ -1004,7 +1004,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
throw wasExpected ?
Error('No response defined !') :
Error('Unexpected request: ' + method + ' ' + url + '\n' +
- (expectation ? 'Expected ' + expectation : 'No more request expected'));
+ (expectation ? 'Expected ' + expectation : 'No more request expected'));
}
/**