Skip to content

Commit

Permalink
Hand over delete permissions for each item and set selectable state
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianallgeier committed Jan 21, 2025
1 parent 8fb0858 commit 86f5006
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
3 changes: 2 additions & 1 deletion config/sections/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@
'mime' => $file->mime(),
'parent' => $file->parent()->panel()->path(),
'permissions' => [
'sort' => $permissions->can('sort'),
'delete' => $permissions->can('delete'),
'sort' => $permissions->can('sort'),
],
'template' => $file->template(),
'text' => $file->toSafeString($this->text),
Expand Down
3 changes: 2 additions & 1 deletion config/sections/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,11 @@
'link' => $panel->url(true),
'parent' => $page->parentId(),
'permissions' => [
'sort' => $permissions->can('sort'),
'delete' => $permissions->can('delete'),
'changeSlug' => $permissions->can('changeSlug'),
'changeStatus' => $permissions->can('changeStatus'),
'changeTitle' => $permissions->can('changeTitle'),
'sort' => $permissions->can('sort'),
],
'status' => $page->status(),
'template' => $page->intendedTemplate()->name(),
Expand Down
40 changes: 23 additions & 17 deletions panel/src/components/Sections/FilesSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,29 @@ export default {
};
},
items() {
return this.data.map((file) => ({
...file,
column: this.column,
data: {
"data-id": file.id,
"data-template": file.template
},
options: this.$dropdown(file.link, {
query: {
view: "list",
delete: this.data.length > this.options.min
}
}),
selectable: this.isSelecting,
sortable:
file.permissions.sort && this.options.sortable && !this.isSelecting
}));
return this.data.map((file) => {
const sortable =
file.permissions.sort && this.options.sortable && !this.isSelecting;
const deletable =
file.permissions.delete && this.data.length > this.options.min;
return {
...file,
column: this.column,
data: {
"data-id": file.id,
"data-template": file.template
},
options: this.$dropdown(file.link, {
query: {
view: "list",
delete: deletable
}
}),
selectable: this.isSelecting && deletable,
sortable: sortable
};
});
},
type() {
return "files";
Expand Down
2 changes: 1 addition & 1 deletion panel/src/components/Sections/ModelsSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default {
help: this.options.help,
items: this.items,
pagination: this.pagination,
selectable: !this.isProcessing && this.isSelecting,
selecting: !this.isProcessing && this.isSelecting,
sortable: !this.isProcessing && this.options.sortable,
size: this.options.size
};
Expand Down
5 changes: 3 additions & 2 deletions panel/src/components/Sections/PagesSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export default {
return this.data.map((page) => {
const sortable =
page.permissions.sort && this.options.sortable && !this.isSelecting;
const deletable = this.data.length > this.options.min;
const deletable =
page.permissions.delete && this.data.length > this.options.min;
const flag = {
...this.$helper.page.status(
Expand Down Expand Up @@ -41,7 +42,7 @@ export default {
sort: sortable
}
}),
selectable: this.isSelecting,
selectable: this.isSelecting && deletable,
sortable
};
});
Expand Down

0 comments on commit 86f5006

Please sign in to comment.