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

This commit is contained in:
Sebastiaan Janssen
2018-07-25 17:12:29 +02:00
5 changed files with 65 additions and 36 deletions

View File

@@ -4,6 +4,9 @@ function includePropsPreValsController($rootScope, $scope, localizationService,
$scope.model.value = [];
}
$scope.hasError = false;
$scope.errorMsg = "";
$scope.propertyAliases = [];
$scope.selectedField = null;
$scope.systemFields = [
@@ -45,6 +48,11 @@ function includePropsPreValsController($rootScope, $scope, localizationService,
return alias;
}
$scope.changeField = function () {
$scope.hasError = false;
$scope.errorMsg = "";
}
$scope.removeField = function(e) {
$scope.model.value = _.reject($scope.model.value, function (x) {
return x.alias === e.alias;
@@ -123,19 +131,34 @@ function includePropsPreValsController($rootScope, $scope, localizationService,
$scope.addField = function () {
var val = $scope.selectedField;
var isSystem = val.startsWith("_system_");
if (isSystem) {
val = val.trimStart("_system_");
}
if (val) {
var isSystem = val.startsWith("_system_");
if (isSystem) {
val = val.trimStart("_system_");
}
var exists = _.find($scope.model.value, function (i) {
return i.alias === val;
});
if (!exists) {
$scope.model.value.push({
alias: val,
isSystem: isSystem ? 1 : 0
var exists = _.find($scope.model.value, function (i) {
return i.alias === val;
});
if (!exists) {
$scope.hasError = false;
$scope.errorMsg = "";
$scope.model.value.push({
alias: val,
isSystem: isSystem ? 1 : 0
});
}
else {
//there was an error, do the highlight (will be set back by the directive)
$scope.hasError = true;
$scope.errorMsg = "Property is already added";
}
}
else {
$scope.hasError = true;
$scope.errorMsg = "No property selected";
}
}

View File

@@ -1,7 +1,7 @@
<div class="umb-editor" ng-controller="Umbraco.PrevalueEditors.IncludePropertiesListViewController">
<div class="control-group">
<select ng-model="selectedField">
<select ng-model="selectedField" ng-change="changeField()" val-highlight="{{hasError}}">
<option ng-repeat="field in systemFields" value="_system_{{field.value}}">{{field.name}}</option>
<option class="select-dash" disabled="disabled">----</option>
<option ng-repeat="alias in propertyAliases" value="{{alias}}">{{alias}}</option>
@@ -9,6 +9,7 @@
<button type="button" class="btn" ng-click="addField()">
<localize key="general_add">Add</localize>
</button>
<span class="help-inline">{{errorMsg}}</span>
</div>
<div class="control-group">
<table ng-show="model.value.length > 0" class="table">

View File

@@ -57,24 +57,27 @@ function listViewController($rootScope, $scope, $routeParams, $injector, $cookie
totalPages: 0,
items: []
};
//when this is null, we don't check permissions
$scope.currentNodePermissions = null;
if ($scope.entityType === "content") {
//Just ensure we do have an editorState
if (editorState.current) {
//Fetch current node allowed actions for the current user
//This is the current node & not each individual child node in the list
var currentUserPermissions = editorState.current.allowedActions;
$scope.currentNodePermissions = {}
//Just ensure we do have an editorState
if (editorState.current) {
//Fetch current node allowed actions for the current user
//This is the current node & not each individual child node in the list
var currentUserPermissions = editorState.current.allowedActions;
//Create a nicer model rather than the funky & hard to remember permissions strings
$scope.currentNodePermissions = {
"canCopy": _.contains(currentUserPermissions, 'O'), //Magic Char = O
"canCreate": _.contains(currentUserPermissions, 'C'), //Magic Char = C
"canDelete": _.contains(currentUserPermissions, 'D'), //Magic Char = D
"canMove": _.contains(currentUserPermissions, 'M'), //Magic Char = M
"canPublish": _.contains(currentUserPermissions, 'U'), //Magic Char = U
"canUnpublish": _.contains(currentUserPermissions, 'U'), //Magic Char = Z (however UI says it can't be set, so if we can publish 'U' we can unpublish)
};
//Create a nicer model rather than the funky & hard to remember permissions strings
$scope.currentNodePermissions = {
"canCopy": _.contains(currentUserPermissions, 'O'), //Magic Char = O
"canCreate": _.contains(currentUserPermissions, 'C'), //Magic Char = C
"canDelete": _.contains(currentUserPermissions, 'D'), //Magic Char = D
"canMove": _.contains(currentUserPermissions, 'M'), //Magic Char = M
"canPublish": _.contains(currentUserPermissions, 'U'), //Magic Char = U
"canUnpublish": _.contains(currentUserPermissions, 'U'), //Magic Char = Z (however UI says it can't be set, so if we can publish 'U' we can unpublish)
};
}
}
//when this is null, we don't check permissions

View File

@@ -10,7 +10,7 @@
<umb-editor-sub-header-content-left>
<umb-editor-sub-header-section ng-if="(listViewAllowedTypes && listViewAllowedTypes.length > 0 && !isAnythingSelected()) && currentNodePermissions.canCreate">
<umb-editor-sub-header-section ng-if="(listViewAllowedTypes && listViewAllowedTypes.length > 0 && !isAnythingSelected()) && (currentNodePermissions == null || currentNodePermissions.canCreate)">
<div class="btn-group" ng-show="listViewAllowedTypes.length > 1">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<localize key="actions_create">Create</localize>

View File

@@ -37,14 +37,16 @@ namespace Umbraco.Web.PropertyEditors
new {name = "Grid", path = "views/propertyeditors/listview/layouts/grid/grid.html", icon = "icon-thumbnails-small", isSystem = 1, selected = true}
}
},
{"bulkActionPermissions", new
{
"bulkActionPermissions", new
{
allowBulkPublish = true,
allowBulkUnpublish = true,
allowBulkCopy = true,
allowBulkMove = false,
allowBulkDelete = true
}}
}
}
};
}
}
@@ -52,7 +54,7 @@ namespace Umbraco.Web.PropertyEditors
internal class ListViewPreValueEditor : PreValueEditor
{
[PreValueField("tabName", "Tab Name", "textstring", Description = "The name of the listview tab (default if empty: 'Child Items')")]
public int TabName { get; set; }
public string TabName { get; set; }
[PreValueField("displayAtTabNumber", "Display At Tab Number", "number", Description = "Which tab position that the list of child items will be displayed")]
public int DisplayAtTabNumber { get; set; }
@@ -61,7 +63,7 @@ namespace Umbraco.Web.PropertyEditors
public int PageSize { get; set; }
[PreValueField("layouts", "Layouts", "views/propertyeditors/listview/layouts.prevalues.html")]
public int Layouts { get; set; }
public object Layouts { get; set; }
[PreValueField("includeProperties", "Columns Displayed", "views/propertyeditors/listview/includeproperties.prevalues.html",
Description = "The properties that will be displayed for each column")]
@@ -69,10 +71,10 @@ namespace Umbraco.Web.PropertyEditors
[PreValueField("orderBy", "Order By", "views/propertyeditors/listview/sortby.prevalues.html",
Description = "The default sort order for the list")]
public int OrderBy { get; set; }
public string OrderBy { get; set; }
[PreValueField("orderDirection", "Order Direction", "views/propertyeditors/listview/orderdirection.prevalues.html")]
public int OrderDirection { get; set; }
public string OrderDirection { get; set; }
[PreValueField("bulkActionPermissions", "Bulk Action Permissions", "views/propertyeditors/listview/bulkactionpermissions.prevalues.html",
Description = "The bulk actions that are allowed from the list view")]