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 d12e8834c5..bdd99cc5c3 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 @@ -74,51 +74,7 @@ ui.placeholder.height(ui.item.height()); }, stop: function(e, ui) { - - var first = true; - var prevSortOrder = 0; - - scope.model.groups.map(function(group){ - - var index = scope.model.groups.indexOf(group); - - if(group.tabState !== "init") { - - // set the first not inherited tab to sort order 0 - if(!group.inherited && first) { - - // 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; - } - - first = false; - - } else if(!group.inherited && !first) { - - // find next group - var nextGroup = scope.model.groups[index + 1]; - - // 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; - } - - } - - // store this tabs sort order as reference for the next - prevSortOrder = group.sortOrder; - - } - - }); - + updateTabsSortOrder(); }, }; @@ -143,6 +99,54 @@ } + function updateTabsSortOrder() { + + var first = true; + var prevSortOrder = 0; + + scope.model.groups.map(function(group){ + + var index = scope.model.groups.indexOf(group); + + if(group.tabState !== "init") { + + // set the first not inherited tab to sort order 0 + if(!group.inherited && first) { + + // 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; + } + + first = false; + + } else if(!group.inherited && !first) { + + // find next group + var nextGroup = scope.model.groups[index + 1]; + + // 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; + } + + } + + // store this tabs sort order as reference for the next + prevSortOrder = group.sortOrder; + + } + + }); + + } + function updatePropertiesSortOrder() { angular.forEach(scope.model.groups, function(group){ @@ -169,6 +173,14 @@ scope.compositionsDialogModel.show = true; scope.compositionsDialogModel.submit = function(model) { + + // make sure that all tabs has an init property + if (scope.model.groups.length !== 0) { + angular.forEach(scope.model.groups, function(group) { + addInitProperty(group); + }); + } + // remove overlay scope.compositionsDialogModel.show = false; scope.compositionsDialogModel = null; @@ -189,6 +201,7 @@ if (scope.model.compositeContentTypes.indexOf(compositeContentType.alias) === -1) { //merge composition with content type contentTypeHelper.mergeCompositeContentType(scope.model, compositeContentType); + } else { // split composition from content type contentTypeHelper.splitCompositeContentType(scope.model, compositeContentType); @@ -279,11 +292,11 @@ /* ---------- PROPERTIES ---------- */ - scope.addProperty = function(property, properties) { + scope.addProperty = function(property, group) { // set property sort order - var index = properties.indexOf(property); - var prevProperty = properties[index - 1]; + var index = group.properties.indexOf(property); + var prevProperty = group.properties[index - 1]; if( index > 0) { // set index to 1 higher than the previous property sort order @@ -295,11 +308,11 @@ } // open property settings dialog - scope.editPropertyTypeSettings(property); + scope.editPropertyTypeSettings(property, group); }; - scope.editPropertyTypeSettings = function(property) { + scope.editPropertyTypeSettings = function(property, group) { if (!property.inherited) { @@ -332,8 +345,8 @@ scope.propertySettingsDialogModel.show = false; scope.propertySettingsDialogModel = null; - // push new init property to scope - addInitPropertyOnActiveGroup(scope.model.groups); + // push new init property to group + addInitProperty(group); }; @@ -490,6 +503,15 @@ function addInitProperty(group) { var addInitPropertyBool = true; + var initProperty = { + label: null, + alias: null, + propertyState: "init", + validation: { + mandatory: false, + pattern: null + } + }; // check if there already is an init property angular.forEach(group.properties, function(property) { @@ -499,40 +521,12 @@ }); if (addInitPropertyBool) { - group.properties.push({ - propertyState: "init" - }); + group.properties.push(initProperty); } return group; } - function addInitPropertyOnActiveGroup(groups) { - - var addInitPropertyBool = true; - - angular.forEach(groups, function(group) { - - if (group.tabState === 'active') { - - angular.forEach(group.properties, function(property) { - if (property.propertyState === "init") { - addInitPropertyBool = false; - } - }); - - if (addInitPropertyBool) { - group.properties.push({ - propertyState: "init" - }); - } - - } - }); - - return groups; - } - function updateSameDataTypes(newProperty) { // find each property 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 89ef50ec0d..56b5c853ae 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 @@ -119,9 +119,6 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter) { // push id to array of merged composite content types compositionGroup.parentTabContentTypes.push(compositeContentType.id); - //push init property to group - compositionGroup.properties.push({propertyState: "init"}); - // push group before placeholder tab contentType.groups.unshift(compositionGroup); diff --git a/src/Umbraco.Web.UI.Client/src/views/components/umb-grid-selector.html b/src/Umbraco.Web.UI.Client/src/views/components/umb-grid-selector.html index 110b91ba6c..6a40dd74dc 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/umb-grid-selector.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/umb-grid-selector.html @@ -30,7 +30,7 @@
- All {{name}}s are added + All {{itemLabel}}s are added
- +
@@ -101,7 +101,7 @@
-
+
@@ -125,7 +125,7 @@
-
+ diff --git a/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/contenttypes/contenttypes.controller.js b/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/contenttypes/contenttypes.controller.js deleted file mode 100644 index 01f28b50a8..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/contenttypes/contenttypes.controller.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @ngdoc controller - * @name Umbraco.Editors.DocumentType.PropertyController - * @function - * - * @description - * The controller for the content type editor property dialog - */ -function CompositionsController($scope, contentTypeResource) { - - - -} - -angular.module("umbraco").controller("Umbraco.Editors.DocumentType.CompositionsController", CompositionsController); diff --git a/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/contenttypes/contenttypes.html b/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/contenttypes/contenttypes.html deleted file mode 100644 index b98b316385..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/contenttypes/contenttypes.html +++ /dev/null @@ -1,6 +0,0 @@ - \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/editdatatype/editdatatype.controller.js b/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/editdatatype/editdatatype.controller.js index de13484984..bec9dce0fd 100644 --- a/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/editdatatype/editdatatype.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/editdatatype/editdatatype.controller.js @@ -12,8 +12,8 @@ function EditDataTypeController($scope, dataTypeResource, dataTypeHelper) { $scope.model.multiActions = [ { - key: "save", - label: "Save", + key: "overwrite", + label: "Overwrite", defaultAction: true, action: function(model) { saveDataType($scope.model.dataType, false); @@ -42,7 +42,7 @@ function EditDataTypeController($scope, dataTypeResource, dataTypeHelper) { if( $scope.model.dataType.name !== dataTypeNameCopy) { setDefaultMultiAction($scope.model.multiActions, "saveAsNew"); } else { - setDefaultMultiAction($scope.model.multiActions, "save"); + setDefaultMultiAction($scope.model.multiActions, "overwrite"); } }; diff --git a/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/editpropertysettings/editpropertysettings.controller.js b/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/editpropertysettings/editpropertysettings.controller.js index 2b96fe6f4f..7eb530428e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/editpropertysettings/editpropertysettings.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/editpropertysettings/editpropertysettings.controller.js @@ -12,43 +12,77 @@ function EditPropertySettingsController($scope, contentTypeResource) { $scope.propertySettings.validationTypes = []; $scope.propertySettings.showValidationPattern = false; + //$scope.selectedValidationType = {}; $scope.validationTypes = [ { "name": "Validate as email", + "key": "email", "pattern": "[a-zA-Z0-9_\.\+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-\.]+", "enableEditing": true }, { "name": "Validate as a number", - "pattern": "^[1-9]\d*$", + "key": "number", + "pattern": "^[0-9]*$", "enableEditing": true }, { "name": "Validate as a Url", + "key": "url", "pattern": "https?\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}", "enableEditing": true }, { "name": "...or enter a custom validation", + "key": "custom", "pattern": "", "enableEditing": true } ]; + function activate() { - $scope.changeValidationType = function(selectedValidationType) { - - if($scope.model.property.validation === undefined) { - $scope.model.property.validation = {}; - } - - $scope.model.property.validation.pattern = selectedValidationType.pattern; - - $scope.propertySettings.showValidationPattern = true; + matchValidationType(); } + function matchValidationType() { + + if($scope.model.property.validation.pattern !== null) { + + var match = false; + + // find and show if a match from the list has been chosen + angular.forEach($scope.validationTypes, function(validationType, index){ + if($scope.model.property.validation.pattern === validationType.pattern) { + $scope.selectedValidationType = $scope.validationTypes[index]; + $scope.propertySettings.showValidationPattern = true; + match = true; + } + }); + + // if there is no match - choose the custom validation option. + if(!match) { + angular.forEach($scope.validationTypes, function(validationType){ + if(validationType.key === "custom") { + $scope.selectedValidationType = validationType; + $scope.propertySettings.showValidationPattern = true; + } + }); + } + + } + + } + + $scope.changeValidationType = function(selectedValidationType) { + $scope.model.property.validation.pattern = selectedValidationType.pattern; + $scope.propertySettings.showValidationPattern = true; + } + + activate(); + } diff --git a/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/editpropertysettings/editpropertysettings.html b/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/editpropertysettings/editpropertysettings.html index 8c55730da8..92e29543a4 100644 --- a/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/editpropertysettings/editpropertysettings.html +++ b/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/editpropertysettings/editpropertysettings.html @@ -51,7 +51,7 @@ Field is mandatory - diff --git a/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/templates/templates.controller.js b/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/templates/templates.controller.js deleted file mode 100644 index 13645ab827..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/templates/templates.controller.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @ngdoc controller - * @name Umbraco.Editors.DocumentType.PropertyController - * @function - * - * @description - * The controller for the content type editor property dialog - */ -function AvailableTemplatesController($scope) { - - -} - -angular.module("umbraco").controller("Umbraco.Editors.DocumentType.AvailableTemplatesController", AvailableTemplatesController); diff --git a/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/templates/templates.html b/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/templates/templates.html deleted file mode 100644 index 01305e09b9..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/documenttype/dialogs/templates/templates.html +++ /dev/null @@ -1,8 +0,0 @@ -
- -
\ No newline at end of file