Skip to content

Conversation

@boutell
Copy link
Member

@boutell boutell commented Sep 10, 2024

One implementation of newInstance to bring them all and in the darkness bind them

Thank you for grinding through this with me Etienne! We were basically done I just hadn't saved a file yet

@boutell boutell requested a review from ETLaurent September 10, 2024 16:59
@linear
Copy link

linear bot commented Sep 10, 2024

@ETLaurent
Copy link
Contributor

newWidget(type) {
const schema = apos.modules[apos.area.widgetManagers[type]].schema;
const widget = {
...newInstance(schema),
Copy link
Member Author

Choose a reason for hiding this comment

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

Nice

@@ -1,5 +1,6 @@
import AposInputMixin from 'Modules/@apostrophecms/schema/mixins/AposInputMixin';
import { klona } from 'klona';
Copy link
Member Author

Choose a reason for hiding this comment

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

Do we still need klona?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes:

image

}
},
getDefault() {
const object = {};
Copy link
Member Author

Choose a reason for hiding this comment

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

I totally thought I did this one, thank you

...this.getDefault(),
...docData
};
this.docFields.data = _.merge(
Copy link
Member Author

Choose a reason for hiding this comment

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

Wow yet another one!

CHANGELOG.md Outdated
Comment on lines 4 to 7

### Adds

* Apostrophe now automatically adds the appropriate default values for new properties in the schema, even for existing documents in the database. This is done automatically during the migration phase of startup.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
### Adds
* Apostrophe now automatically adds the appropriate default values for new properties in the schema, even for existing documents in the database. This is done automatically during the migration phase of startup.
### Adds

changelog from #4721

CHANGELOG.md Outdated
Comment on lines 12 to 16

### Fixes

* Apostrophe's migration logic is no longer executed twice on every startup and three times in the migration task. It is executed exactly once, always at the same point in the startup process. This bug did not cause significant performance issues because migrations were only executed once, but there is a small performance improvement.
* Default properties of object fields present in a widget now populate correctly even if never focused in the editor.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
### Fixes
* Apostrophe's migration logic is no longer executed twice on every startup and three times in the migration task. It is executed exactly once, always at the same point in the startup process. This bug did not cause significant performance issues because migrations were only executed once, but there is a small performance improvement.
* Default properties of object fields present in a widget now populate correctly even if never focused in the editor.

changelog from #4721

@ETLaurent ETLaurent self-requested a review September 11, 2024 12:44
@ETLaurent
Copy link
Contributor

waiting for the Cypress tests to finish.

Copy link
Contributor

@ETLaurent ETLaurent left a comment

Choose a reason for hiding this comment

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

image

@boutell boutell merged commit 131acfd into main Sep 11, 2024
@boutell boutell deleted the pro-6576 branch September 11, 2024 17:15
haroun added a commit that referenced this pull request Sep 12, 2024
* main:
  PRO-6578: auto import of inline images (#4723)
  Inline array improvements (#4671)
  take credit for the fix as well as the "change" (#4725)
  PRO-6576 fix default values for object fields in widgets and generally unify newInstance implementations (#4722)
haroun added a commit to haroun/apostrophe that referenced this pull request Sep 16, 2024
* upstream/main: (77 commits)
  PRO-6578: auto import of inline images (apostrophecms#4723)
  Inline array improvements (apostrophecms#4671)
  take credit for the fix as well as the "change" (apostrophecms#4725)
  PRO-6576 fix default values for object fields in widgets and generally unify newInstance implementations (apostrophecms#4722)
  release 4.7.0 (apostrophecms#4717)
  allows to render widgets in published mode (for non localized with pu… (apostrophecms#4709)
  fix subfield imports (it was a bug in fetchRelationships: false) (apostrophecms#4715)
  Add replaces configuration for editor context menus (apostrophecms#4714)
  bump uploadfs dep (apostrophecms#4712)
  add batch operations to pages (apostrophecms#4684)
  PRO-6477 undhandled promise errors (apostrophecms#4700)
  fix slat order (apostrophecms#4710)
  make apostoggle accessible (apostrophecms#4708)
  Improve context menu positions (apostrophecms#4706)
  remove focus blockers in page relationship editor (apostrophecms#4702)
  Release 4.6.1 mergeback (apostrophecms#4703)
  remove z-index bump on area schema fields, boost menu index (apostrophecms#4699)
  Pro 6345 fix deprecated sass (apostrophecms#4640)
  Keep widget focused when menu is open (apostrophecms#4695)
  skipReplace for changeDocIds (apostrophecms#4694)
  ...
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.

3 participants