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

Revert "PRO-1555 data.page and data.contextOptions available when widgets are first inserted on the page or edited in the widget editor dialog and saved back to the page" #3170

Merged
merged 2 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ myColorField: {
}
```
* Restored Vue dependency to using semantic versioning now that Vue 2.6.14 has been released with a fix for the bug that required us to pin 2.6.12.
* `data.page` and `data.contextOptions` are now available in `widget.html` templates in most cases. Specifically, they are available when loading the page, (2) when a widget has just been inserted on the page, and (3) when a widget has just been edited and saved back to the page. However, bear in mind that these parameters are never available when a widget is being edited "out of context" via "Page Settings", via the "Edit Piece" dialog box, via a dialog box for a parent widget, etc. Your templates should be written to tolerate the absence of these parameters.
* Double slashes in the slug cannot be used to trick Apostrophe into serving as an open redirect (fix ported to 3.x from 2.92.0).
* The global doc respects the `def` property of schema fields when first inserted at site creation time.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ export default {
}
},
async mounted() {
this.saveResolvers = [];
apos.bus.$on('revert-published-to-previous', this.onRevertPublishedToPrevious);
apos.bus.$on('unpublish', this.onUnpublish);
apos.bus.$on('set-context', this.onSetContext);
Expand Down Expand Up @@ -287,14 +286,7 @@ export default {
e.returnValue = '';
}
},
// Can be awaited if you are interested in knowing when the operation
// completed.
async save() {
if (this.saving) {
return new Promise((resolve, reject) => {
this.saveResolvers.push(resolve);
});
}
// More patches could get pushed during the async call to
// send the previous batch, so keep going until we clear
// the queue
Expand Down Expand Up @@ -329,10 +321,6 @@ export default {
}
this.saving = false;
this.saved = true;
for (const resolver of this.saveResolvers) {
resolver();
}
this.saveResolvers = [];
},
// Switch the mode to 'published' or 'draft'.
//
Expand Down Expand Up @@ -426,32 +414,12 @@ export default {
}
this.rememberLastBaseContext();
},
async onContextEdited(patch) {
onContextEdited(patch) {
this.patchesSinceLoaded.push(patch);
this.patchesSinceSave.push(patch);
this.undone = [];
const noncontextual = findNoncontextualWidget(patch);
if (noncontextual) {
apos.bus.$emit('busy', {
active: true,
name: 'busy'
});
}
await this.save();
if (noncontextual) {
await this.refresh();
apos.bus.$emit('busy', {
active: false,
name: 'busy'
});
}
function findNoncontextualWidget(o) {
if (o.type && !apos.area.widgetIsContextual[o.type]) {
return true;
}
if (o && ((typeof o) === 'object')) {
return Object.values(o).some(findNoncontextualWidget);
}
if (!this.saving) {
this.save();
}
},
async onContentChanged(e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,11 @@ export default {
this.rendered = this.rendering.html;
this.runPlayer();
} else {
if (!this.docId || apos.area.widgetIsContextual[this.type]) {
this.rendered = '...';
this.rendered = await apos.http.post(`${apos.area.action}/render-widget?aposEdit=1&aposMode=draft`, {
busy: true,
body: parameters
});
} else {
// Let TheAposContextBar re-render the entire refreshable zone
// for noncontextual widgets as they may rely on data.page
// or "with" parameters from the page template
}
this.rendered = '...';
this.rendered = await apos.http.post(`${apos.area.action}/render-widget?aposEdit=1&aposMode=draft`, {
busy: true,
body: parameters
});
}
// Wait for reactivity to populate v-html so the
// AposAreas manager can spot any new area divs.
Expand Down