Skip to content

Pro 8230 improve schema#5044

Merged
ValJed merged 14 commits intomainfrom
pro-8230-improve-schema
Oct 8, 2025
Merged

Pro 8230 improve schema#5044
ValJed merged 14 commits intomainfrom
pro-8230-improve-schema

Conversation

@ValJed
Copy link
Copy Markdown
Contributor

@ValJed ValJed commented Aug 27, 2025

PRO-8230

Summary

Simplifies complex and not working code, see ticket for more info.

What are the specific steps to test this change?

Should work like before:
Cypress 🟢

What kind of change does this PR introduce?

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Build-related changes
  • Other

Make sure the PR fulfills these requirements:

  • It includes a) the existing issue ID being resolved, b) a convincing reason for adding this feature, or c) a clear description of the bug it resolves
  • The changelog is updated
  • Related documentation has been updated
  • Related tests have been updated

@linear
Copy link
Copy Markdown

linear Bot commented Aug 27, 2025

@ValJed ValJed self-assigned this Aug 27, 2025
@ValJed ValJed marked this pull request as draft August 27, 2025 17:16
@ValJed ValJed force-pushed the pro-8230-improve-schema branch 2 times, most recently from 6f2c5eb to e38acac Compare September 18, 2025 14:27
:server-error="fields[field.name].serverError"
:doc-id="docId"
:generation="generation"
@update:model-value="updateNextAndEmit"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now watch fieldState instead


this.$emit('submit', {
name: this.subform.name,
values: this.docFields.data
Copy link
Copy Markdown
Contributor Author

@ValJed ValJed Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this change because the old version wasn't resetting triggerValidation to false when no errors.(Probably the modal closes anyway but cleaner).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially we never set triggerValidation back to false if there was no errors. What about all the other places?

Image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.
In the other locations we normally set it back to false after having awaited the nextTick.
You mean resetting the value would allow to submit the form with errors ? I don't think so, triggerValidation and errors are independent, But I agree it's pretty weird that we reset it only if no errors.. it should behave like the function I think:

    triggerValidate() {
      this.triggerValidation = true;
      this.$nextTick(async () => {
        this.triggerValidation = false;
      });
    }

This system is far from ideal thought.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rollbacked

Comment thread package.json
"uploadfs": "^1.25.1",
"void-elements": "^3.1.0",
"vue": "^3.3.8",
"vue": "^3.5.20",
Copy link
Copy Markdown
Contributor Author

@ValJed ValJed Sep 23, 2025

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Comment thread CHANGELOG.md Outdated
* Fixes a bug in the login `uponSubmit` filter where a user could login without meeting the requirement.

### Fixes

Copy link
Copy Markdown
Contributor Author

@ValJed ValJed Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated

},
value: {
data: this.modelValue.data[item.name]
},
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused

@ValJed ValJed requested review from ETLaurent and haroun September 23, 2025 12:15
@ValJed ValJed force-pushed the pro-8230-improve-schema branch from b009bad to eeaf472 Compare September 23, 2025 12:17
@ValJed ValJed marked this pull request as ready for review September 23, 2025 12:18

this.$emit('submit', {
name: this.subform.name,
values: this.docFields.data
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially we never set triggerValidation back to false if there was no errors. What about all the other places?

Image


this.$emit('submit', {
name: this.subform.name,
values: this.docFields.data
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Comment thread modules/@apostrophecms/schema/ui/apos/logic/AposSchema.js
Comment on lines +286 to +287
this.next.fieldState = { ...this.fieldState };
this.$emit('update:model-value', this.next);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those 2 lines equivalent to what we had before with ...this.next?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was already there:

      this.next.fieldState = { ...this.fieldState };

For the emit I removed the spread because it's already done in the parent that spreads value.data and is useless I think. (we can keep it if you have a doubt).

    updateDocFields(value) {
      this.updateFieldErrors(value.fieldState);
      this.docFields.data = {
        ...this.docFields.data,
        ...value.data
      };
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kept the spread

Copy link
Copy Markdown
Contributor Author

@ValJed ValJed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rollbacked what you asked for.


this.$emit('submit', {
name: this.subform.name,
values: this.docFields.data
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rollbacked

@ValJed ValJed requested a review from haroun September 25, 2025 14:19
ETLaurent
ETLaurent previously approved these changes Oct 7, 2025
Comment thread CHANGELOG.md Outdated
* 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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

haroun
haroun previously approved these changes Oct 8, 2025
@ValJed ValJed dismissed stale reviews from haroun and ETLaurent via 498b9e9 October 8, 2025 08:38
@ValJed ValJed force-pushed the pro-8230-improve-schema branch from 498b9e9 to 1451de3 Compare October 8, 2025 08:40
@ValJed ValJed requested review from ETLaurent and haroun October 8, 2025 08:41
@ValJed ValJed merged commit 95626fe into main Oct 8, 2025
9 checks passed
@ValJed ValJed deleted the pro-8230-improve-schema branch October 8, 2025 09:52
haroun added a commit that referenced this pull request Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants