@@ -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