Merge branch 'dev-v7-contenttypeeditor' of https://github.com/umbraco/Umbraco-CMS into dev-v7-contenttypeeditor

This commit is contained in:
Shannon
2015-08-05 17:27:53 +02:00
11 changed files with 127 additions and 145 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -30,7 +30,7 @@
</div>
<div class="text-center" ng-if="(availableItems | compareArrays:selectedItems:'alias').length === 0">
<small>All {{name}}s are added</small>
<small>All {{itemLabel}}s are added</small>
</div>
<umb-overlay

View File

@@ -49,7 +49,7 @@
<li ng-class="{'umb-group-builder__property-sortable': sortingMode && !property.inherited}" ng-repeat="property in tab.properties">
<!-- Init property / Property placeholder / add new property -->
<a href="" class="umb-group-builder__property -placeholder" ng-if="property.propertyState=='init' && !sortingMode" ng-class="{'-placeholder': property.propertyState=='init'}" hotkey="alt+shift+p" ng-click="addProperty(property, tab.properties)">
<a href="" class="umb-group-builder__property -placeholder" ng-if="property.propertyState=='init' && !sortingMode" ng-class="{'-placeholder': property.propertyState=='init'}" hotkey="alt+shift+p" ng-click="addProperty(property, tab)">
<div class="umb-group-builder__property-meta">
<div class="umb-group-builder__placeholder-box -input-small"></div>
@@ -101,7 +101,7 @@
</div>
<div tabindex="-1" class="umb-group-builder__property-preview" ng-click="editPropertyTypeSettings(property)" ng-if="!sortingMode" ng-class="{'-not-clickable': !sortingMode && property.inherited}">
<div tabindex="-1" class="umb-group-builder__property-preview" ng-click="editPropertyTypeSettings(property, tab)" ng-if="!sortingMode" ng-class="{'-not-clickable': !sortingMode && property.inherited}">
<span class="umb-group-builder__property-preview-overlay"></span>
@@ -125,7 +125,7 @@
</div>
<!-- settings for property -->
<a href="" class="umb-group-builder__property-action" ng-click="editPropertyTypeSettings(property)">
<a href="" class="umb-group-builder__property-action" ng-click="editPropertyTypeSettings(property, tab)">
<i class="icon icon-settings"></i>
</a>

View File

@@ -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);

View File

@@ -1,6 +0,0 @@
<div class="dialog-grid">
<a href="" class="dialog-grid-element" ng-repeat="contentType in model.contentTypes | compareArrays:model.allowedContentTypes:'alias'" ng-click="model.chooseContentType(contentType)">
<i class="icon {{contentType.icon}}"></i>
{{ contentType.name }}
</a>
</div>

View File

@@ -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");
}
};

View File

@@ -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();
}

View File

@@ -51,7 +51,7 @@
<input type="checkbox" ng-model="model.property.validation.mandatory"> Field is mandatory
</label>
<select class="umb-dropdown" ng-options="validationType as validationType.name for validationType in validationTypes" ng-model="selectedValidationType" ng-change="changeValidationType(selectedValidationType)">
<select class="umb-dropdown" ng-options="validationType.name for validationType in validationTypes" ng-model="selectedValidationType" ng-change="changeValidationType(selectedValidationType)">
<option value="">Validation</option>
</select>

View File

@@ -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);

View File

@@ -1,8 +0,0 @@
<div ng-controller="Umbraco.Editors.DocumentType.AvailableTemplatesController">
<div class="dialog-grid">
<a href="" class="dialog-grid-element" ng-repeat="availableTemplate in model.availableTemplates | compareArrays:model.allowedTemplates:'alias' | orderBy:'name'" ng-click="model.chooseTemplate(availableTemplate)">
<i class="icon {{ availableTemplate.icon }}"></i>
<span class="dialog-grid-element-text">{{ availableTemplate.name }}</span>
</a>
</div>
</div>