Skip to content
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

Shared ng-models state for nested models #3612

Closed
spalger opened this issue Apr 16, 2015 · 1 comment
Closed

Shared ng-models state for nested models #3612

spalger opened this issue Apr 16, 2015 · 1 comment
Labels
enhancement New value added to drive a business result Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@spalger
Copy link
Contributor

spalger commented Apr 16, 2015

As noticed in #3518 (comment), our number-list control uses multiple ng-models, causing it to feel like seperate inputs when it should feel like a single input.

Currently This is expressed in the markup by having an ng-model directive on the kbn-number-list directive. The template for that directive though creates several nested ng-models (one for each list item) and they all maintain individual state (valid, invalid, touched, etc.)

<!-- kbn-number-list is a control that should operate on "agg.params.values" -->
<kbn-number-list ng-model="agg.params.percents">
  <!-- kbn-number-list template -->

    <!-- for each item in the list -->
    <div ng-repeat="value in list track by $index">

      <!-- input a single number -->
      <input ng-model="list[$index]" kbn-number-list-input>

    </div>

  <!-- end kbn-number-list template -->
</kbn-number-list>

ngtouched-current

I think we need to make these changes:

  1. sub-ng-models should not be a part of the form, but should control the state of the parent ng-model. This way, the form's "invalid controls" will simply contain a single model, the parent, and not a model for each invalid child model.
  2. sub-ng-models should sync their "touched" state with the parent, which should then propagate the state back to all other children
    unified touch
  3. sub-ng-models should sync their "validity" and "pristine" states with the parent, but the parent should not propagate these states.
    ngtouched-validity-propogation
@spalger spalger changed the title Propagate ng-touch from nested models Shared ng-models state for nested models Apr 16, 2015
@spalger spalger added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc and removed discuss labels Feb 27, 2017
@timroes
Copy link
Contributor

timroes commented Mar 29, 2018

I think we can close that, since we are a) in the process of building a new editor (#17076) and b) replacing everything by React (#16728). Please feel free to reopen if you think this is still an issue, that we need to touch beforehand.

@timroes timroes closed this as completed Mar 29, 2018
@epixa epixa added enhancement New value added to drive a business result and removed release_note:enhancement labels May 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

No branches or pull requests

3 participants