Skip to content

Commit 07fd85a

Browse files
feat: Discard and save individual items
1 parent a0d0c32 commit 07fd85a

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

panel/src/components/Dialogs/ChangesDialog.vue

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
:buttons="buttons('pages')"
66
:label="$t('lock.unsaved.pages')"
77
>
8-
<k-items :items="pages" layout="list" />
8+
<k-items :items="items(pages)" layout="list" />
99
</k-section>
1010

1111
<k-section
1212
v-if="files.length"
1313
:buttons="buttons('files')"
1414
:label="$t('lock.unsaved.files')"
1515
>
16-
<k-items :items="files" layout="list" />
16+
<k-items :items="items(files)" layout="list" />
1717
</k-section>
1818

1919
<k-section
2020
v-if="users.length"
2121
:buttons="buttons('users')"
2222
:label="$t('lock.unsaved.users')"
2323
>
24-
<k-items :items="users" layout="list" />
24+
<k-items :items="items(users)" layout="list" />
2525
</k-section>
2626

2727
<k-section
@@ -113,6 +113,14 @@ export default {
113113
}
114114
];
115115
},
116+
async discard(model) {
117+
try {
118+
await this.$panel.api.post(model.link + "/changes/discard");
119+
this.$panel.dialog.refresh();
120+
} catch (e) {
121+
this.$panel.notification.error(e);
122+
}
123+
},
116124
async discardAll(type) {
117125
try {
118126
await this.$panel.api.post("/changes/discard/" + type);
@@ -122,6 +130,42 @@ export default {
122130
this.$panel.notification.error(e);
123131
}
124132
},
133+
items(items) {
134+
return items.map((item) => {
135+
item.options = [
136+
{
137+
icon: "undo",
138+
text: "Discard",
139+
click: () => this.discard(item)
140+
},
141+
{
142+
icon: "check",
143+
text: "Save",
144+
click: () => this.save(item)
145+
},
146+
"-",
147+
{
148+
icon: "window",
149+
text: "Preview changes",
150+
link: this.$panel.url(item.link + "/preview/changes").toString(),
151+
target: "_blank"
152+
}
153+
];
154+
155+
return item;
156+
});
157+
},
158+
preview(model) {
159+
this.$panel.view.open(model.link + "/preview/changes");
160+
},
161+
async save(model) {
162+
try {
163+
await this.$panel.api.post(model.link + "/changes/publish");
164+
this.$panel.dialog.refresh();
165+
} catch (e) {
166+
this.$panel.notification.error(e);
167+
}
168+
},
125169
async saveAll(type) {
126170
try {
127171
await this.$panel.api.post("/changes/publish/" + type);

0 commit comments

Comments
 (0)