Skip to content

Commit 61a10a7

Browse files
authored
Fix native actions params (#5128)
* fixes native actions params * gets back operations label (cause use in tests) * adds payload to widget controls apos bus event
1 parent e4ee8b2 commit 61a10a7

5 files changed

Lines changed: 24 additions & 16 deletions

File tree

‎modules/@apostrophecms/area/ui/apos/components/AposWidgetControls.vue‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,19 +215,20 @@ export default {
215215
}
216216
return;
217217
}
218+
const payload = {
219+
widgetId: this.modelValue._id,
220+
index: this.index
221+
};
218222
if (nativeAction) {
219223
this.$emit('operation', {
220224
name: nativeAction,
221-
payload: {
222-
widgetId: this.modelValue._id,
223-
index: this.index
224-
}
225+
payload
225226
});
226227
return;
227228
}
228229
229230
if (action) {
230-
apos.bus.$emit(action);
231+
apos.bus.$emit(action, payload);
231232
}
232233
}
233234
}

‎modules/@apostrophecms/area/ui/apos/logic/AposAreaEditor.js‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export default {
212212
return;
213213
}
214214

215-
this.copy(this.focusedWidgetIndex);
215+
this.copy({ index: this.focusedWidgetIndex });
216216
},
217217
handleCut() {
218218
if (
@@ -223,7 +223,7 @@ export default {
223223
return;
224224
}
225225

226-
this.cut(this.focusedWidgetIndex);
226+
this.cut({ index: this.focusedWidgetIndex });
227227
},
228228
handleDuplicate() {
229229
if (
@@ -234,7 +234,7 @@ export default {
234234
return;
235235
}
236236

237-
this.clone(this.focusedWidgetIndex);
237+
this.clone({ index: this.focusedWidgetIndex });
238238
},
239239
handlePaste() {
240240
if (
@@ -245,7 +245,7 @@ export default {
245245
return;
246246
}
247247

248-
this.paste(Math.max(this.focusedWidgetIndex, 0));
248+
this.paste({ index: Math.max(this.focusedWidgetIndex, 0) });
249249
},
250250
handleRemove() {
251251
if (
@@ -256,7 +256,7 @@ export default {
256256
return;
257257
}
258258

259-
this.remove(this.focusedWidgetIndex);
259+
this.remove({ index: this.focusedWidgetIndex });
260260
},
261261
areaUpdatedHandler(area) {
262262
for (const item of this.next) {
@@ -328,7 +328,7 @@ export default {
328328
},
329329
async cut({ index }) {
330330
apos.area.widgetClipboard.set(this.next[index]);
331-
await this.remove(index);
331+
await this.remove({ index });
332332
apos.notify('Widget cut to clipboard', {
333333
type: 'success',
334334
icon: 'content-cut-icon',
@@ -409,14 +409,14 @@ export default {
409409
}
410410
}
411411
},
412-
clone(index) {
412+
clone({ index }) {
413413
const widget = cloneWidget(this.next[index]);
414414
this.insert({
415415
widget,
416416
index: index + 1
417417
});
418418
},
419-
async paste(index) {
419+
async paste({ index }) {
420420
const clipboard = apos.area.widgetClipboard.get();
421421
if (clipboard) {
422422
const widget = clipboard;
@@ -559,7 +559,7 @@ export default {
559559
...this.next.slice(index)
560560
];
561561
if (this.widgetIsContextual(widget.type)) {
562-
this.edit(index);
562+
this.edit({ index });
563563
}
564564
this.setFocusedWidget(widget._id, this.areaId, { scrollTo: true });
565565
},

‎modules/@apostrophecms/layout-widget/ui/apos/components/AposAreaLayoutEditor.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ export default {
367367
onRemoveItem({ _id, patches }) {
368368
const index = this.next.findIndex(w => w._id === _id);
369369
if (index !== -1 && this.next[index].type === this.layoutColumnWidgetName) {
370-
this.remove(index);
370+
this.remove({ index });
371371
}
372372
this.layoutPatchMany(patches);
373373
},

‎modules/@apostrophecms/widget-type/index.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ module.exports = {
219219
return {
220220
add: {
221221
nudgeUp: {
222+
label: 'apostrophe:nudgeUp',
222223
icon: 'arrow-up-icon',
223224
tooltip: 'apostrophe:nudgeUp',
224225
nativeAction: 'up',
@@ -227,6 +228,7 @@ module.exports = {
227228
}
228229
},
229230
nudgeDown: {
231+
label: 'apostrophe:nudgeDown',
230232
icon: 'arrow-down-icon',
231233
tooltip: 'apostrophe:nudgeDown',
232234
nativeAction: 'down',
@@ -236,12 +238,14 @@ module.exports = {
236238
},
237239
...!options.contextual && {
238240
edit: {
241+
label: 'apostrophe:edit',
239242
icon: 'pencil-icon',
240243
tootip: 'apostrophe:editWidget',
241244
nativeAction: 'edit'
242245
}
243246
},
244247
remove: {
248+
label: 'apostrophe:remove',
245249
icon: 'trash-can-outline-icon',
246250
tooltip: 'apostrophe:delete',
247251
nativeAction: 'remove'

‎modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,10 @@ export default {
271271
return;
272272
}
273273
if (this.preview.create) {
274-
this.preview.area.remove(this.getPreviewWidgetIndex(), { autosave: false });
274+
this.preview.area.remove(
275+
{ index: this.getPreviewWidgetIndex() },
276+
{ autosave: false }
277+
);
275278
} else if (!this.saving) {
276279
this.preview.area.update(this.previewSnapshot, {
277280
autosave: false,

0 commit comments

Comments
 (0)