Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Models sections: non-mutating items computed #6480

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions panel/src/components/Sections/FilesSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,24 @@ export default {
},
items() {
return this.data.map((file) => {
file.sortable = this.options.sortable;
file.column = this.column;
file.options = this.$dropdown(file.link, {
query: {
view: "list",
update: this.options.sortable,
delete: this.data.length > this.options.min
}
});
const sortable = this.options.sortable;

// add data-attributes info for item
file.data = {
"data-id": file.id,
"data-template": file.template
return {
...file,
column: this.column,
data: {
"data-id": file.id,
"data-template": file.template
},
options: this.$dropdown(file.link, {
query: {
view: "list",
update: sortable,
delete: this.data.length > this.options.min
}
}),
sortable
};

return file;
});
},
type() {
Expand Down
57 changes: 29 additions & 28 deletions panel/src/components/Sections/PagesSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,37 @@ export default {
},
items() {
return this.data.map((page) => {
const disabled = page.permissions.changeStatus === false;
const status = this.$helper.page.status(page.status, disabled);
status.click = () => this.$dialog(page.link + "/changeStatus");
const sortable = page.permissions.sort && this.options.sortable;
const deletable = this.data.length > this.options.min;

page.flag = {
status: page.status,
disabled: disabled,
click: () => this.$dialog(page.link + "/changeStatus")
return {
...page,
buttons: [
{
...this.$helper.page.status(
page.status,
page.permissions.changeStatus === false
),
click: () => this.$dialog(page.link + "/changeStatus")
},
...(page.buttons ?? [])
],
column: this.column,
data: {
"data-id": page.id,
"data-status": page.status,
"data-template": page.template
},
deletable,
options: this.$dropdown(page.link, {
query: {
view: "list",
delete: deletable,
sort: sortable
}
}),
sortable
};

page.sortable = page.permissions.sort && this.options.sortable;
page.deletable = this.data.length > this.options.min;
page.column = this.column;
page.buttons = [status, ...(page.buttons ?? [])];
page.options = this.$dropdown(page.link, {
query: {
view: "list",
delete: page.deletable,
sort: page.sortable
}
});

// add data-attributes info for item
page.data = {
"data-id": page.id,
"data-status": page.status,
"data-template": page.template
};

return page;
});
},
type() {
Expand Down
Loading