Skip to content

Commit 136815d

Browse files
committed
Added built in doctype properties to the ui
1 parent 4d262c1 commit 136815d

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

src/Our.Umbraco.GraphQL/Web/UI/source/controllers/dashboard.controller.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ angular.module("umbraco").controller("graphql.for.umbraco.dashboardcontroller",
2626
$scope.selectedDocType = false;
2727
$scope.selectedDocTypeAlias = '';
2828
$scope.selectedDocTypeName = '';
29+
30+
// TODO: pull from API?
31+
$scope.builtInProperties = [{ name: "Id", alias: "id" }, { name: "Name", alias: "name" }, { name: "Url", alias: "url" },
32+
{ name: "Url Absolute", alias: "urlAbsolute" }, { name: "Creator Name", alias: "creatorName" }, { name: "Writer Name", alias: "writerName" },
33+
{ name: "Create Date", alias: "createDate" }, { name: "Update Date", alias: "updateDate" },
34+
{ name: "Document Type Alias", alias: "documentTypeAlias" }, { name: "Is Visible", alias: "isVisible" },
35+
{ name: "Index", alias: "index" }, { name: "Level", alias: "level" }, { name: "Parent", alias: "parent" },
36+
{ name: "Sort Order", alias: "sortOrder" }, { name: "Is First", alias: "isFirst" }, { name: "Is Last", alias: "isLast" }];
2937
};
3038

3139
/**
@@ -150,15 +158,18 @@ angular.module("umbraco").controller("graphql.for.umbraco.dashboardcontroller",
150158
* with the matching `propertyAlias`.
151159
* @param {string} docTypeAlias
152160
* @param {string} propertyAlias
161+
* @param {boolean} isBuiltInProperty
153162
* @returns {boolean}
154163
*/
155-
$scope.isPropertyVisible = function(docTypeAlias, propertyAlias) {
164+
$scope.isPropertyVisible = function(docTypeAlias, propertyAlias, isBuiltInProperty) {
156165
var isVisible = false;
157166
$scope.pendingPermissions.forEach(function(permission) {
158167
if (permission.alias === docTypeAlias) {
159168
permission.properties.forEach(function(property) {
160169
if (property.alias === propertyAlias) {
161-
isVisible = true;
170+
if (property.isBuiltInProperty === isBuiltInProperty) {
171+
isVisible = true;
172+
}
162173
}
163174
})
164175
}
@@ -228,6 +239,7 @@ angular.module("umbraco").controller("graphql.for.umbraco.dashboardcontroller",
228239
*/
229240
$scope.onPropertyVisibilityChange = function(e) {
230241
var propertyAlias = e.target.getAttribute('data-alias');
242+
var isBuiltInProperty = e.target.getAttribute('data-isBuiltInProperty');
231243
var isChecked = e.target.checked;
232244
var doesDocTypeHavePermissions = false;
233245
var doesPropertyPermissionExist = false;
@@ -243,7 +255,7 @@ angular.module("umbraco").controller("graphql.for.umbraco.dashboardcontroller",
243255
if (!doesPropertyPermissionExist) {
244256
permission.properties.push({
245257
alias: propertyAlias,
246-
isBuiltInProperty: false, // TODO: Need to know how to get true value for this.
258+
isBuiltInProperty: isBuiltInProperty,
247259
notes: '',
248260
permission: 'Read'
249261
});
@@ -255,7 +267,7 @@ angular.module("umbraco").controller("graphql.for.umbraco.dashboardcontroller",
255267
alias: $scope.selectedDocTypeAlias,
256268
properties: [{
257269
alias: propertyAlias,
258-
isBuiltInProperty: false, // TODO: Need to know how to get true value for this.
270+
isBuiltInProperty: isBuiltInProperty,
259271
notes: '',
260272
permission: 'Read'
261273
}]

src/Our.Umbraco.GraphQL/Web/UI/source/resources/graphql.for.umbraco.api.resource.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ angular.module("umbraco.resources").factory("graphQLForUmbracoApiResource", func
5050
return {
5151
doctypeAlias: item.DoctypeAlias,
5252
propertyAlias: item.PropertyAlias,
53-
isBuiltInProperty: item.IsBuildInProperty,
53+
isBuiltInProperty: item.IsBuiltInProperty,
5454
notes: item.Notes,
5555
permission: item.Permission
5656
};

src/Our.Umbraco.GraphQL/Web/UI/source/views/dashboard.html

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,33 @@ <h4>Select DocType</h4>
4040
<h4>Select Visible Properties For <i>{{selectedDocTypeName}}</i></h4>
4141
<p><a class="gql4u-link" ng-click="onChangeDocTypeClick($event)" href="#change-doc-type">Change DocType</a></p>
4242
<p>Select which properties you would like to have visible to GraphQL within the selected docType.</p>
43+
<div>
44+
<h5>Built In Properties</h5>
45+
<!-- Table of Properties -->
46+
<div class="gql4u-table">
47+
<div class="head row">
48+
<div class="cell span1 text-center">Visible</div>
49+
<div class="cell span2">Name</div>
50+
<div class="cell span2">Alias</div>
51+
<div class="cell span7"></div>
52+
</div>
53+
<div class="body">
54+
<div class="row" ng-repeat="property in builtInProperties">
55+
<div class="cell span1 text-center">
56+
<input type="checkbox"
57+
ng-checked="isPropertyVisible(selectedDocTypeAlias, property.alias, true)"
58+
ng-click="onPropertyVisibilityChange($event)"
59+
data-alias={{property.alias}}
60+
data-isBuiltInProperty="true" />
61+
</div>
62+
<div class="cell span2">{{property.name}}</div>
63+
<div class="cell span2"><em>{{property.alias}}</em></div>
64+
<div class="cell span7"></div>
65+
</div>
66+
</div>
67+
</div>
68+
<!-- End Table -->
69+
</div>
4370
<div ng-repeat="group in groups">
4471
<h5>{{group.name}}</h5>
4572
<!-- Table of Properties -->
@@ -55,9 +82,10 @@ <h5>{{group.name}}</h5>
5582
<div class="cell span1 text-center">
5683
<input
5784
type="checkbox"
58-
ng-checked="isPropertyVisible(selectedDocTypeAlias, property.alias)"
85+
ng-checked="isPropertyVisible(selectedDocTypeAlias, property.alias, false)"
5986
ng-click="onPropertyVisibilityChange($event)"
6087
data-alias={{property.alias}}
88+
data-isBuiltInProperty="false"
6189
/>
6290
</div>
6391
<div class="cell span2">{{property.name}}</div>

0 commit comments

Comments
 (0)