Skip to content

Commit

Permalink
Elements need to obey sharing permissions (#2762)
Browse files Browse the repository at this point in the history
relates to xibosignage/xibo#3516

 - Prevent elements and groups to be deleted if parent widget isn't editable
 - Failed to create widget when adding widget due to permissions lock adding fix
 - Hide element group edit button if it's not editable
  • Loading branch information
maurofmferrao authored Oct 18, 2024
1 parent c95511b commit a52aa7d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
7 changes: 6 additions & 1 deletion ui/src/editor-core/element-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ const ElementGroup = function(data, widgetId, regionId, parentWidget) {

// Set element to have same properties for edit and delete as parent widget
this.isEditable = (parentWidget) ? parentWidget.isEditable : true;
this.isDeletable = (parentWidget) ? parentWidget.isDeletable : true;
// For elements to be deletable, the parent widget also needs to be editable
this.isDeletable = (parentWidget) ?
(
parentWidget.isDeletable &&
parentWidget.isEditable
) : true;
this.isViewable = (parentWidget) ? parentWidget.isViewable : true;
this.effect = data.effect || 'noTransition';

Expand Down
7 changes: 6 additions & 1 deletion ui/src/editor-core/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ const Element = function(data, widgetId, regionId, parentWidget) {

// Set element to have same properties for edit and delete as parent widget
this.isEditable = (parentWidget) ? parentWidget.isEditable : true;
this.isDeletable = (parentWidget) ? parentWidget.isDeletable : true;
// For elements to be deletable, the parent widget also needs to be editable
this.isDeletable = (parentWidget) ?
(
parentWidget.isDeletable &&
parentWidget.isEditable
) : true;
this.isViewable = (parentWidget) ? parentWidget.isViewable : true;

// Check if the element is visible on rendering ( true by default )
Expand Down
2 changes: 1 addition & 1 deletion ui/src/layout-editor/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,7 @@ lD.dropItemAdd = function(droppable, draggable, dropPosition) {

// Add element to the new widget
addToWidget(newWidget);
});
}).catch(itemAdded);
};

// Get a target widget
Expand Down
4 changes: 4 additions & 0 deletions ui/src/style/layout-editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,10 @@ body.editor-opened #content-wrapper .page-content>.row {
}
}

&:not(.editable) .group-edit-btn {
display: none;
}

.group-edit-btn {
position: absolute;
top: 2px;
Expand Down

0 comments on commit a52aa7d

Please sign in to comment.