From 2fe00d645588d6d2f45d1849238bf401ae15dad1 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Wed, 3 Jun 2015 21:30:45 +0200 Subject: [PATCH] content type permissions sub view --- .../src/less/pages/document-type-editor.less | 94 +++++++++++++++ .../permissions/permissions.controller.js | 111 ++++++++++++++++++ .../views/permissions/permissions.html | 78 +++++++++++- 3 files changed, 282 insertions(+), 1 deletion(-) create mode 100644 src/Umbraco.Web.UI.Client/src/views/documenttype/views/permissions/permissions.controller.js diff --git a/src/Umbraco.Web.UI.Client/src/less/pages/document-type-editor.less b/src/Umbraco.Web.UI.Client/src/less/pages/document-type-editor.less index e28ab97e83..b729c99665 100644 --- a/src/Umbraco.Web.UI.Client/src/less/pages/document-type-editor.less +++ b/src/Umbraco.Web.UI.Client/src/less/pages/document-type-editor.less @@ -602,4 +602,98 @@ } +/* ---------- SUB VIEWS COLUMNS ----------- */ + +.sub-view-columns { + display: flex; + margin-bottom: 40px; + h5 { + margin-top: 0; + } +} + +.sub-view-column-left { + flex: 0 0 250px; + margin-right: 70px; +} + +.sub-view-column-right { + flex: 1; +} + +/* ---------- CHILD NODE TREE ---------- */ + +.node-tree { + + .child-notes-wrapper { + margin-left: 30px; + } + + .node { + background: @grayLighter; + padding: 5px 15px; + margin-bottom: 5px; + min-width: 300px; + display: flex; + border-radius: 5px; + animation: fadeIn 0.5s; + } + + .node-description { + flex: 1; + } + + .node-actions { + flex: 0 0 50px; + text-align: right; + } + + .node.node-parent { + background: #f1f1f1; + padding-top: 10px; + padding-bottom: 10px; + .node-icon-wrapper { + display: inline-block; + width: 20px; + } + .node-name { + font-weight: bold; + } + } + + .node.node-child { + .node-icon-wrapper { + display: inline-block; + width: 15px; + } + .node-name { + font-size: 12px; + } + .icon-trash { + cursor: pointer; + } + } + + .node-placeholder { + border: 1px dashed @grayLight; + background: none; + border-radius: 5px; + cursor: pointer; + text-align: center; + justify-content: center; + padding: 10px; + .node-placeholder-text { + color: @blue; + font-weight: bold; + } + } + + .node-select { + margin-bottom: 0; + margin-right: 10px; + float: left; + } + +} + diff --git a/src/Umbraco.Web.UI.Client/src/views/documenttype/views/permissions/permissions.controller.js b/src/Umbraco.Web.UI.Client/src/views/documenttype/views/permissions/permissions.controller.js new file mode 100644 index 0000000000..33225d18c4 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/documenttype/views/permissions/permissions.controller.js @@ -0,0 +1,111 @@ +/** + * @ngdoc controller + * @name Umbraco.Editors.DocumentType.PropertyController + * @function + * + * @description + * The controller for the content type editor property dialog + */ +function PermissionsController($scope, contentTypeResource) { + + /* ----------- SCOPE VARIABLES ----------- */ + + $scope.contentTypes = []; + $scope.showPlaceholderDetails = false; + + /* ---------- INIT ---------- */ + + init(); + + function init() { + + contentTypeResource.getAll().then(function(contentTypes){ + + $scope.contentTypes = contentTypes; + + angular.forEach($scope.contentTypes, function(contentType){ + + var exists = false; + + angular.forEach($scope.contentType.allowedContentTypes, function(allowedContentType){ + + if( contentType.alias === allowedContentType.alias ) { + exists = true; + } + + }); + + if(exists) { + contentType.show = false; + } else { + contentType.show = true; + } + + }); + + }); + + } + + $scope.addSelectedContentType = function(selectedContentType) { + + if(selectedContentType.alias !== "undefined" || selectedContentType.alias !== null) { + + var reformatedContentType = { + "name": selectedContentType.name, + "id": { + "m_boxed": { + "m_value": selectedContentType.id + } + }, + "icon": selectedContentType.icon, + "key": selectedContentType.key, + "alias": selectedContentType.alias + }; + + // push selected content type to allowed array + $scope.contentType.allowedContentTypes.push(reformatedContentType); + + // hide selected content type from content types array + for (var contentTypeIndex = 0; contentTypeIndex < $scope.contentTypes.length; contentTypeIndex++) { + + var contentType = $scope.contentTypes[contentTypeIndex]; + + if( selectedContentType.alias === contentType.alias ) { + contentType.show = false; + } + } + + // hide placeholder details + $scope.showPlaceholderDetails = false; + + } + + }; + + $scope.togglePlaceholderDetails = function() { + $scope.showPlaceholderDetails = !$scope.showPlaceholderDetails; + }; + + $scope.removeAllowedChildNode = function(selectedContentType) { + + // splice from array + var selectedContentTypeIndex = $scope.contentType.allowedContentTypes.indexOf(selectedContentType); + $scope.contentType.allowedContentTypes.splice(selectedContentTypeIndex, 1); + + // show content type in content types array + for (var contentTypeIndex = 0; contentTypeIndex < $scope.contentTypes.length; contentTypeIndex++) { + + var contentType = $scope.contentTypes[contentTypeIndex]; + + if( selectedContentType.alias === contentType.alias ) { + contentType.show = true; + } + } + + }; + + +} + +angular.module("umbraco").controller("Umbraco.Editors.DocumentType.PermissionsController", PermissionsController); diff --git a/src/Umbraco.Web.UI.Client/src/views/documenttype/views/permissions/permissions.html b/src/Umbraco.Web.UI.Client/src/views/documenttype/views/permissions/permissions.html index f033a122a9..5e6b087b93 100644 --- a/src/Umbraco.Web.UI.Client/src/views/documenttype/views/permissions/permissions.html +++ b/src/Umbraco.Web.UI.Client/src/views/documenttype/views/permissions/permissions.html @@ -1 +1,77 @@ -permissions \ No newline at end of file +
+
+ +
+
Allow as root
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vulputate velit a velit consectetur luctus. +
+
+ +
+ +
+ +
+ +
+
Allowed child node types
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vulputate velit a velit consectetur luctus. +
+ +
+ +
+ + +
+
+
+ +
+ {{ contentType.name }} + (Current) +
+
+ +
+ + +
+
+
+ +
+ {{ allowedType.name }} +
+
+ +
+
+ + +
+
Allow child node
+
+ + Allow +
+
+ + +
+ All content types are added as child nodes +
+ +
+ +
+ +
+ +
+ +
\ No newline at end of file