Overview

In #3537595: AI should use only necessary history/comments for each task, it is observed that that the fix to alter the default values before the component is added propSource.default_values.resolved = value; is not an optimal solution - it can have issues with things like undo and preview behavior and needs to have custom logic for every possible prop shape despite that logic already existing in ourcodebase.
See- https://git.drupalcode.org/project/experience_builder/-/merge_requests/1...

Proposed resolution

Create a means of doing the following in a non-convoluted manner

  • Update addNewComponentToLayout will now accept an optional withValues in the payload so the newly added component will add it with those values. It will also be aware of the current selection and use that to determine where the component is placed. Internal uses of addNewComponentToLayout are changed to use _addNewComponentToLayout which adds a component based on the "drop" position
  • Add a new updateExistingComponentValues action that will update the values of a given component in redux and ensure the form updates as well.

User interface changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

narendrar created an issue. See original summary.

wim leers’s picture

Component: AI » Extensions API

I believe you meant to use this issue queue component?

narendrar’s picture

100% @wim leers, Thanks. 🙏

tim.plunkett’s picture

@wim leers That's my fault, thanks for fixing it!

bnjmnm made their first commit to this issue’s fork.

bnjmnm’s picture

Assigned: Unassigned » bnjmnm
bnjmnm’s picture

MR 3538576-stage-1-split-input-behaviors makes no functionality changes - it's just splitting inputBehaviors so the form-specific parts are in dedicated files. It should make the next step easier to review, so perhaps that can get in quickly and we'll focus on the next functionality-impacting MR.

  • bnjmnm committed 385c78fd on 1.x
    Issue #3538576 by bnjmnm, hooroomoo: Formalize an API for...
bnjmnm’s picture

Got a +1 from @hooroomoo to merge the 3538576-stage-1-split-input-behaviors branch. With that in, the MR that actually implements the requested functionality should be easier to review. (it will definitely be easier to implement)

bnjmnm changed the visibility of the branch 3538576-programatically-update-model-values to hidden.

bnjmnm changed the visibility of the branch 3538576-stage-1-split-input-behaviors to hidden.

bnjmnm’s picture

addNewComponentToLayout was updated to address the use case that led to this issue being filed. This makes it relatively easy to programatically add new components with custom values.

This still needs a way to update the values of existing components - which is on the way...

wim leers’s picture

Question: this sounds like it's the start of a formal API, so we probably also want explicit docs, rather than the docs-by-example approach originally taken in #3485692: Create extendibility proof of concept that also serves as documentation-by-example (extensions)?

bnjmnm’s picture

Assigned: bnjmnm » Unassigned
Status: Active » Needs review
bnjmnm’s picture

Title: Formalize an API for programmatically updating prop values » Provide a way to programmatically add component with custom values + update values of an existing component
Issue summary: View changes

I've updated the issue summary to make it clear this is more of a feature request.

Re #16 The term Formalize in the issue title is misleading. There's a need to support the specific functionality mentioned in the IS asap, but we agreed at standup (@balintbrews in particular) that this should not be mistaken for formalization, which is something that should be tackled far more holistically. There was a preference that this remain informal.

hooroomoo changed the visibility of the branch 3538576-two-add-components-to-layout to hidden.

hooroomoo changed the visibility of the branch 3538576-two-add-components-to-layout to active.

hooroomoo’s picture

Status: Needs review » Needs work
wim leers’s picture

Status: Needs work » Needs review
Issue tags: +JavaScript

Per @bnjmnm, this needs review.

hooroomoo’s picture

Issue tags: -JavaScript +JavaScript

  • hooroomoo committed cadcf8a5 on 1.x authored by bnjmnm
    Issue #3538576 by bnjmnm, hooroomoo, narendrar: Provide a way to...
hooroomoo’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.