-
Notifications
You must be signed in to change notification settings - Fork 626
Pro 8230 improve schema #5044
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
Pro 8230 improve schema #5044
Changes from 11 commits
4dad71c
cceb2ea
a916437
b89bc3f
01ce89b
799fb95
0114b5c
36f7c5c
3a902fb
c06c7f4
eeaf472
e2d9fda
1451de3
9e72c4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,17 +13,14 @@ | |
|
|
||
| * Fixes a bug in the login `uponSubmit` filter where a user could login without meeting the requirement. | ||
| * Fixes pieces filters when values from optional fields are falsy. | ||
|
|
||
| ### Fixes | ||
|
|
||
| * Resolve inline image URLs correctly when in edit mode and not in the default locale. | ||
|
|
||
| ### Changes | ||
|
|
||
| * Redirects to URLs containing accent marks and other non-ascii characters now behave as expected with Astro. Pre-encoding the URLs exactly the way `res.redirect` would before passing them to Astro prevents an error in Astro and allows the redirect to succeed. | ||
| * Removes the non-functional `uniqueUsername` route from the `user` module | ||
| * Updated dependencies to address deprecation warnings. | ||
|
|
||
| * Refactors complex logic from `AposSchema` that handle data updates to simplifies it. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will need to be placed at the top after the merge of main |
||
|
|
||
| ## 4.21.0 (2025-09-03) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,6 @@ | |
| :server-error="fields[field.name].serverError" | ||
| :doc-id="docId" | ||
| :generation="generation" | ||
| @update:model-value="updateNextAndEmit" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We now watch |
||
| @update-doc-data="onUpdateDocData" | ||
| @validate="emitValidate()" | ||
| /> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| import { detectFieldChange } from 'Modules/@apostrophecms/schema/lib/detectChange'; | ||
|
haroun marked this conversation as resolved.
|
||
| import { getConditionTypesObject } from '../lib/conditionalFields'; | ||
|
|
||
| export default { | ||
|
|
@@ -130,9 +129,6 @@ export default { | |
| ...item, | ||
| required | ||
| }, | ||
| value: { | ||
| data: this.modelValue.data[item.name] | ||
| }, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused |
||
| serverError: this.serverErrors && this.serverErrors[item.name], | ||
| modifiers: this.computeModifiers(item) | ||
| } | ||
|
|
@@ -167,6 +163,13 @@ export default { | |
| } | ||
| }, | ||
| watch: { | ||
| fieldState: { | ||
| deep: 2, | ||
| handler() { | ||
| this.updateNextAndEmit(); | ||
| }, | ||
| flush: 'post' | ||
| }, | ||
| schema() { | ||
| this.populateDocData(); | ||
| }, | ||
|
|
@@ -211,6 +214,7 @@ export default { | |
| created() { | ||
| this.populateDocData(); | ||
| }, | ||
|
|
||
| methods: { | ||
| emitValidate() { | ||
| this.$emit('validate'); | ||
|
|
@@ -269,53 +273,18 @@ export default { | |
| if (!this.schemaReady) { | ||
| return; | ||
| } | ||
| const oldHasErrors = this.next.hasErrors; | ||
| // destructure these for non-linked comparison | ||
| const oldFieldState = { ...this.next.fieldState }; | ||
| const newFieldState = { ...this.fieldState }; | ||
|
|
||
| let changeFound = false; | ||
|
|
||
| this.next.hasErrors = false; | ||
| this.next.fieldState = { ...this.fieldState }; | ||
|
|
||
| this.schema | ||
| .filter(field => this.displayComponent(field)) | ||
| .forEach(field => { | ||
| if (this.fieldState[field.name].error) { | ||
| this.next.hasErrors = true; | ||
| } | ||
| // This simply check if a field has changed since it has been | ||
| // instantiated | ||
| if ( | ||
| this.fieldState[field.name].data !== undefined && | ||
| detectFieldChange( | ||
| field, | ||
| this.next.data[field.name], | ||
| this.fieldState[field.name].data | ||
| ) | ||
| ) { | ||
| changeFound = true; | ||
|
|
||
| // fieldState never gets the relationships postprocessed data | ||
| // that's why it gets seen as different than next all the time | ||
| this.next.data[field.name] = this.fieldState[field.name].data; | ||
| } else { | ||
| this.next.data[field.name] = this.modelValue.data[field.name]; | ||
| } | ||
| this.next.data[field.name] = this.fieldState[field.name].data; | ||
| }); | ||
| if ( | ||
| oldHasErrors !== this.next.hasErrors || | ||
| oldFieldState !== newFieldState | ||
| ) { | ||
| // Otherwise the save button may never unlock | ||
| changeFound = true; | ||
| } | ||
|
|
||
| if (changeFound) { | ||
| // ... removes need for deep watch at parent level | ||
| this.$emit('update:model-value', { ...this.next }); | ||
| } | ||
| this.next.fieldState = { ...this.fieldState }; | ||
| this.$emit('update:model-value', this.next); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are those 2 lines equivalent to what we had before with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line was already there: For the emit I removed the spread because it's already done in the parent that spreads
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. kept the spread |
||
| }, | ||
| displayComponent({ name, hidden = false }) { | ||
| if (hidden === true) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,15 +111,16 @@ export default { | |
| }, | ||
| async submit() { | ||
| this.triggerValidation = true; | ||
| this.$nextTick(async () => { | ||
| if (this.docFields.hasErrors) { | ||
| this.triggerValidation = false; | ||
| return; | ||
| } | ||
| this.$emit('submit', { | ||
| name: this.subform.name, | ||
| values: this.docFields.data | ||
| }); | ||
| await this.$nextTick(); | ||
| this.triggerValidation = false; | ||
|
|
||
| if (this.docFields.hasErrors) { | ||
| return; | ||
| } | ||
|
|
||
| this.$emit('submit', { | ||
| name: this.subform.name, | ||
| values: this.docFields.data | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made this change because the old version wasn't resetting
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm afraid this might say I can submit the form multiple times too if the form is still open.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It wasn't done here I think because the modal was closed right after so not a big deal. This system is far from ideal thought.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rollbacked |
||
| }); | ||
| }, | ||
| async cancel() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,7 +124,7 @@ | |
| "underscore.string": "^3.3.4", | ||
| "uploadfs": "^1.25.1", | ||
| "void-elements": "^3.1.0", | ||
| "vue": "^3.3.8", | ||
| "vue": "^3.5.20", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated for the vue watcher deep feature to be available. Tests are green.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btw our regression tests always do the equivalent of "npm update" (or a fresh install without package lock), so they would not have passed anyway before this if they were incompatible with latest vue 3.x. Your change does make sense however, to force the update of vue to the version you need when clients update apostrophe. |
||
| "vue-advanced-cropper": "^2.8.8", | ||
| "vue-loader": "^17.1.0", | ||
| "vue-style-loader": "^4.1.3", | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated