Skip to content

Commit dad42dd

Browse files
committed
[wip] move ghosting, widget operations skipping, breadcrumb operations stub
1 parent d5163ea commit dad42dd

8 files changed

Lines changed: 482 additions & 94 deletions

File tree

modules/@apostrophecms/area/ui/apos/components/AposAreaWidget.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,15 @@
7676
/>
7777
</li>
7878
</ol>
79-
<!-- TODO add support for breadcrumb aside horizontal controls -->
79+
<!-- FIXME Bring widget controls data from the widget config -->
80+
<ol
81+
class="apos-area-widget__breadcrumbs"
82+
style="margin-left: 10px;"
83+
>
84+
<li class="apos-area-widget__breadcrumb">
85+
Look 'ma, horizontal controls!
86+
</li>
87+
</ol>
8088
</div>
8189
<div
8290
v-if="!controlsDisabled"
@@ -832,7 +840,8 @@ export default {
832840
.apos-area-widget__label {
833841
position: absolute;
834842
top: 0;
835-
right: 0;
843+
left: 0; // switch the root label position from right to left
844+
// right: 0;
836845
display: flex;
837846
transform: translateY(-100%);
838847
transition: opacity 300ms ease;

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ export default {
141141
}))
142142
);
143143
144-
return controls;
144+
return controls.filter(control => (
145+
!this.widgetSkipControlsMap.get(control.action) &&
146+
!this.widgetSkipControlsMap.get(control.name)
147+
));
145148
},
146149
widgetSecondaryControls() {
147150
const controls = [];
@@ -179,7 +182,10 @@ export default {
179182
// Custom widget operations displayed in the secondary controls
180183
controls.push(...this.widgetSecondaryOperations);
181184
182-
return controls;
185+
return controls.filter(control => (
186+
!this.widgetSkipControlsMap.get(control.action) &&
187+
!this.widgetSkipControlsMap.get(control.name)
188+
));
183189
},
184190
widgetRemoveControl() {
185191
return {
@@ -194,17 +200,25 @@ export default {
194200
action: 'remove'
195201
};
196202
},
203+
widgetSkipControlsMap() {
204+
return new Map(
205+
(this.moduleOptions.skipOperations || [])
206+
.map(operation => [ operation, true ])
207+
);
208+
},
197209
widgetPrimaryOperations() {
198210
return this.getOperations({ secondaryLevel: false });
199211
},
200212
widgetSecondaryOperations() {
201213
return this.getOperations({ secondaryLevel: true });
214+
},
215+
moduleOptions() {
216+
return apos.modules[apos.area.widgetManagers[this.modelValue.type]] ?? {};
202217
}
203218
},
204219
methods: {
205220
getOperations({ secondaryLevel }) {
206-
const moduleOptions = apos.modules[apos.area.widgetManagers[this.modelValue.type]];
207-
const { widgetOperations = [] } = moduleOptions || {};
221+
const { widgetOperations = [] } = this.moduleOptions;
208222
return widgetOperations.filter(operation => {
209223
if (operation.if) {
210224
if (!checkIfConditions(this.modelValue, operation.if)) {

modules/@apostrophecms/layout-widget/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module.exports = {
22
extend: '@apostrophecms/widget-type',
33
options: {
44
label: 'apostrophe:layout',
5+
initialModal: false,
6+
skipOperations: [ 'edit' ],
57
columns: 12,
68
minSpan: 2,
79
defaultSpan: 4,

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

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -200,33 +200,39 @@ export default {
200200
return this.layoutModes.device.data || 'desktop';
201201
}
202202
},
203-
watch: {
204-
layoutManageMode(newMode, oldMode) {
205-
if (newMode === 'view' && oldMode !== 'view') {
206-
this.layoutSort();
207-
}
208-
}
209-
},
210203
mounted() {
211204
if (!this.hasLayoutMeta) {
212205
this.onCreateProvision();
213206
}
214207
},
215208
methods: {
216209
// Sort by the desktop order so that the auto-layout works correctly.
217-
layoutSort() {
218-
const sorted = this.layoutColumnWidgets.sort((a, b) => {
219-
return (a.desktop.order || 0) - (b.desktop.order || 0);
220-
});
210+
// FIXME: not working, not supported by the backend somehow.
211+
layoutSortAll() {
212+
// const sorted = this.next.filter(w => w.type === this.layoutColumnWidgetName);
221213
222-
// FIXME: this doesn't work, the array is never updated in the DB.
223-
this.next = [ this.layoutMeta, ...sorted ].filter(Boolean);
224-
},
225-
onResizeEnd(patchArr) {
226-
if (!patchArr?.length) {
227-
return;
228-
}
229-
this.layoutPatchMany(patchArr);
214+
// sorted.sort((a, b) => {
215+
// return (a.desktop.order || 0) - (b.desktop.order || 0);
216+
// });
217+
218+
// if (this.docId === window.apos.adminBar.contextId) {
219+
// No need to clone - the event handler will do that.
220+
// const patch = {
221+
// $pullAllById: {
222+
// [`@${this.id}.items`]: [
223+
// sorted.map(w => w._id)
224+
// ]
225+
// },
226+
// $push: {
227+
// [`@${this.id}.items`]: {
228+
// $each: [ ...sorted ]
229+
// }
230+
// }
231+
// };
232+
// apos.bus.$emit('context-edited', patch);
233+
// }
234+
235+
// this.next = [ this.layoutMeta, ...sorted ];
230236
},
231237
onCreateProvision() {
232238
if (!this.layoutMetaWidgetName) {
@@ -255,6 +261,12 @@ export default {
255261
this.insert(insert);
256262
return insert;
257263
},
264+
onResizeEnd(patchArr) {
265+
if (!patchArr?.length) {
266+
return;
267+
}
268+
this.layoutPatchMany(patchArr);
269+
},
258270
onAddFitItem(patchArr) {
259271
const widgetName = this.layoutColumnWidgetName;
260272
if (!widgetName) {
@@ -265,13 +277,15 @@ export default {
265277
});
266278
this.onAddItem(insert);
267279
this.layoutPatchMany(patchArr);
280+
this.layoutSortAll();
268281
},
269282
onRemoveItem({ _id, patches }) {
270283
const index = this.next.findIndex(w => w._id === _id);
271284
if (index !== -1 && this.next[index].type === this.layoutColumnWidgetName) {
272285
this.remove(index);
273286
}
274287
this.layoutPatchMany(patches);
288+
this.layoutSortAll();
275289
},
276290
layoutPatchDevice({
277291
_id, device, patch

0 commit comments

Comments
 (0)