diff --git a/ui/src/editor-core/widget.js b/ui/src/editor-core/widget.js index a0f4346248..b5a2dc1e17 100644 --- a/ui/src/editor-core/widget.js +++ b/ui/src/editor-core/widget.js @@ -667,6 +667,12 @@ Widget.prototype.saveElements = function( forceRequest = false, } = {}, ) { + // If widget isn't editable, throw an error + if (this.isEditable === false) { + toastr.error(errorMessagesTrans.canvasWidgetNotShared); + return; + } + const self = this; const app = this.editorObject; const widgetId = this.widgetId; diff --git a/ui/src/layout-editor/main.js b/ui/src/layout-editor/main.js index 026a268a2e..544efa64ce 100644 --- a/ui/src/layout-editor/main.js +++ b/ui/src/layout-editor/main.js @@ -1144,6 +1144,11 @@ lD.undoLastAction = function() { * Delete selected object */ lD.deleteSelectedObject = function() { + // Prevent delete if it doesn't have permissions + if (lD.selectedObject.isDeletable === false) { + return; + } + // For now, we always delete the region if (lD.selectedObject.type === 'region') { lD.deleteObject( @@ -2918,6 +2923,18 @@ lD.openContextMenu = function(obj, position = {x: 0, y: 0}) { layoutObject.type === 'element-group' ); + // If target is a frame, send single widget info + const singleWidget = ( + layoutObject.type === 'region' && + layoutObject.subType === 'frame' + ) ? Object.values(layoutObject.widgets)[0] : {}; + + // If target is group or element group, send parent widget + const elementWidget = ( + layoutObject.type === 'element' || + layoutObject.type === 'element-group' + ) ? lD.getObjectByTypeAndId('widget', objAuxId, 'canvas') : {}; + // Create menu and append to the designer div // ( using the object extended with translations ) lD.editorContainer.append( @@ -2927,6 +2944,12 @@ lD.openContextMenu = function(obj, position = {x: 0, y: 0}) { canHaveNewConfig: canHaveNewConfig, canChangeLayer: canChangeLayer, canUngroup: canUngroup, + widget: singleWidget, + isElementBased: ( + layoutObject.type === 'element' || + layoutObject.type === 'element-group' + ), + elementWidget: elementWidget, })), ); @@ -3301,9 +3324,37 @@ lD.openContextMenu = function(obj, position = {x: 0, y: 0}) { }); }); } else { - layoutObject.editPropertyForm( - target.data('property'), target.data('propertyType'), - ); + const property = target.data('property'); + const propertyType = target.data('propertyType'); + + // If we're editing permissions and it's a frame + // edit the widget's permissions instead + if ( + property === 'PermissionsWidget' && + layoutObject.type === 'region' && + layoutObject.subType === 'frame' + ) { + // Call edit for widget instead + const regionWidget = Object.values(layoutObject.widgets)[0]; + regionWidget.editPropertyForm('Permissions'); + } else if ( + property === 'PermissionsCanvasWidget' && + ( + layoutObject.type === 'element' || + layoutObject.type === 'element-group' + ) + ) { + // Call edit for canvas widget instead + const canvasWidget = + lD.getObjectByTypeAndId('widget', objAuxId, 'canvas'); + canvasWidget.editPropertyForm('Permissions'); + } else { + // Call normal edit form + layoutObject.editPropertyForm( + property, + propertyType, + ); + } } // Remove context menu diff --git a/ui/src/layout-editor/region.js b/ui/src/layout-editor/region.js index b8ae0703ec..c75eebed4f 100644 --- a/ui/src/layout-editor/region.js +++ b/ui/src/layout-editor/region.js @@ -33,6 +33,7 @@ const Region = function(id, data, {backgroundColor = '#aaa'} = {}) { this.isDeletable = data.isDeletable; this.isPermissionsModifiable = data.isPermissionsModifiable; this.isPlaylist = data.type === 'playlist'; + this.isFrame = data.type === 'frame'; this.isFrameOrZone = ( data.type === 'frame' || data.type === 'zone' diff --git a/ui/src/layout-editor/viewer.js b/ui/src/layout-editor/viewer.js index 723743b848..e8a44344fd 100644 --- a/ui/src/layout-editor/viewer.js +++ b/ui/src/layout-editor/viewer.js @@ -824,7 +824,8 @@ Viewer.prototype.handleInteractions = function() { clicks = 0; if ( - $(e.target).data('subType') === 'playlist' + $(e.target).data('subType') === 'playlist' && + $(e.target).hasClass('editable') ) { // Edit region if it's a playlist playlistEditorBtnClick($(e.target).attr('id')); @@ -1166,8 +1167,11 @@ Viewer.prototype.renderRegion = function( // Append layout html to the container div $container.html(html); - // If it's playlist add some playlist controls - if (isPlaylist) { + // If it's (an editable) playlist, add some playlist controls + if ( + isPlaylist && + region.isEditable + ) { region.playlistCountOfWidgets = res.extra && res.extra.countOfWidgets ? res.extra.countOfWidgets : 1; @@ -2799,7 +2803,8 @@ Viewer.prototype.updateMoveable = function( ( $selectedElement && $.contains(document, $selectedElement[0]) && - !$selectedElement.hasClass('drawerWidget') + !$selectedElement.hasClass('drawerWidget') && + $selectedElement.hasClass('editable') ) ) { if ($selectedElement.hasClass('designer-element-group')) { diff --git a/ui/src/style/layout-editor.scss b/ui/src/style/layout-editor.scss index c5b95ca5d9..2277428d41 100644 --- a/ui/src/style/layout-editor.scss +++ b/ui/src/style/layout-editor.scss @@ -736,11 +736,8 @@ body.editor-opened { color: $xibo-color-primary-l5; padding: 30px; background-color: $xibo-color-semantic-error; - - &.invalid-region-message { - margin: 16px; - border-radius: 3px; - } + border-radius: 4px; + margin: 16px 16px 0 0; } .loading-container { @@ -1489,7 +1486,6 @@ body.editor-opened { /* Locked mode */ #layout-editor #lockedOverlay { - z-index: 1; display: block; position: absolute; } diff --git a/ui/src/templates/context-menu.hbs b/ui/src/templates/context-menu.hbs index 47cca12b65..8ce368f195 100644 --- a/ui/src/templates/context-menu.hbs +++ b/ui/src/templates/context-menu.hbs @@ -67,10 +67,30 @@ {{/if}} - {{#if isPermissionsModifiable}} -
- {{trans.editPermissions}} -
+ {{#if isFrame}} + {{#if widget.isPermissionsModifiable}} +
+ {{trans.editPermissions}} +
+ {{/if}} + + {{#if isPermissionsModifiable}} +
+ {{trans.editRegionPermissions}} +
+ {{/if}} + {{else if isElementBased}} + {{#if elementWidget.isPermissionsModifiable}} +
+ {{trans.editPermissions}} +
+ {{/if}} + {{else}} + {{#if isPermissionsModifiable}} +
+ {{trans.editPermissions}} +
+ {{/if}} {{/if}} {{#if canBeCopied}} diff --git a/ui/src/templates/viewer-element-group.hbs b/ui/src/templates/viewer-element-group.hbs index 258ad437a0..146e39a1c5 100644 --- a/ui/src/templates/viewer-element-group.hbs +++ b/ui/src/templates/viewer-element-group.hbs @@ -1,4 +1,4 @@ -
-

{{object.type}}