No need to do an extra userService request, if the contentType is null we can't access the settings section, that's a good enough test

Also fixed the bug where editors would see the node name instead of the content type name
This commit is contained in:
Sebastiaan Janssen
2018-08-23 23:36:50 +02:00
parent b67c06a85a
commit 3454db6ee8
4 changed files with 16 additions and 26 deletions

View File

@@ -12,16 +12,10 @@
scope.disableTemplates = Umbraco.Sys.ServerVariables.features.disabledFeatures.disableTemplates;
function onInit() {
// By default don't show the open anchors
scope.allowOpen = false;
// If logged in as an admin user show the open anchors
userService.getCurrentUser().then(function (currentUser) {
if(currentUser.userType === "admin"){
scope.allowOpen = true;
}
});
// If logged in user has access to the settings section
// show the open anchors - if the user doesn't have
// access, documentType is null, see ContentModelMapper
scope.allowOpen = scope.node.documentType !== null;
scope.datePickerConfig = {
pickDate: true,
@@ -53,7 +47,9 @@
setNodePublishStatus(scope.node);
// Declare a fallback URL for the <umb-node-preview/> directive
scope.previewOpenUrl = '#/settings/documenttypes/edit/' + scope.documentType.id;
if (scope.documentType !== null) {
scope.previewOpenUrl = '#/settings/documenttypes/edit/' + scope.documentType.id;
}
}
scope.auditTrailPageChange = function (pageNumber) {

View File

@@ -8,20 +8,14 @@
var evts = [];
function onInit() {
// By default don't show the open anchors
scope.allowOpenMediaType = false;
// If logged in as an admin user show the open anchors
userService.getCurrentUser().then(function (currentUser) {
if(currentUser.userType === "admin"){
scope.allowOpenMediaType = true;
}
});
// If logged in user has access to the settings section
// show the open anchors - if the user doesn't have
// access, contentType is null, see MediaModelMapper
scope.allowOpen = scope.node.contentType !== null;
// get document type details
scope.mediaType = scope.node.contentType;
// get node url
scope.nodeUrl = scope.node.mediaLink;
// set the media link initially
setMediaLink();
// make sure dates are formatted to the user's locale

View File

@@ -179,7 +179,7 @@
<umb-node-preview
style="max-width: 100%; margin-bottom: 0;"
icon="node.icon"
name="node.name"
name="node.contentTypeName"
allow-open="allowOpen"
on-open="openDocumentType(documentType)"
open-url="previewOpenUrl">

View File

@@ -41,8 +41,8 @@
<umb-node-preview
style="max-width: 100%; margin-bottom: 0px;"
icon="node.icon"
name="node.name"
allow-open="allowOpenMediaType"
name="node.contentTypeName"
allow-open="allowOpen"
on-open="openMediaType(mediaType)">
</umb-node-preview>
</umb-control-group>