-
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 all 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 |
|---|---|---|
| @@ -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 }); | ||
| }, | ||
| displayComponent({ name, hidden = false }) { | ||
| if (hidden === true) { | ||
|
|
||
| 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", | ||
|
|
||
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.
We now watch
fieldStateinstead