0

NOTE: This scenario is the same as the one from this question: Data binding parent-child relationships in Aurelia

The Code:

usage:

<form role="form" id="formShipment" breeze-validation.bind="shipment">
    <widget-picker widget.bind="shipment.widget" widgets.bind="widgets"></widget-picker>
</form>

widget-picker.js

import {bindable, bindingMode} from 'aurelia-framework';

export class WidgetPicker {
  @bindable({ defaultBindingMode: bindingMode.twoWay }) widget;
  @bindable widgets;
}

widget-picker.html

<select value.bind="widget">
  <option repeat.for="widget of widgets" model.bind="widget">${widget.name}</option>
</select>

<!-- Some other UI stuff that I would rather not turn red if the above fails validation-->

The Problem:

I am trying to build a componentized UI and have a single control/element that controls selecting a Widget (widget-picker).

But I also need to have breeze know that shipment.widget is required (and show it on the widget control.)

But there are two things blocking this.

  1. In aurelia-validation.js the subscribe method only looks at the bindings on the view that has the breeze-validation custom attribute. This could easily be fixed by looking at the view's controllers views (and get the bindings on that):

this.view.controllers.forEach(function (controller) { if (controller.view) controller.view.bindings.forEach(function (binding) { existingListOfCurrentViewsBindings.push(binding) }) })

  1. But because shipment.widget passes through an @bindable it does not have a source property. This means that even if aurelia-validation had looked at the child custom elements, the current method of finding the breeze property would fail.

The Question:

Is there a way to get aurelia-breeze to support validating into custom elements (on the control that failed)?

NOTE: I could just have the validation show up in a general validation area, but since most of my UI runs as custom-elements, I would have almost all my UI that way. This is not nearly as user friendly as something near the control that has failed.

Community
  • 1
  • 1
Vaccano
  • 78,325
  • 149
  • 468
  • 850
  • aurelia-validation is in the middle of a rewrite that will enable this type of scenario. Much of the validation presentation logic in the aurelia-breeze plugin will be removed and instead you'll be able to "plug" breeze validation into aurelia-validation – Jeremy Danyow Feb 28 '16 at 13:27
  • @JeremyDanyow cool, good to know. any rough estimate when validation lib will be ready? – fops Mar 11 '16 at 10:41
  • we're targeting having it ready within the next week or two – Jeremy Danyow Mar 11 '16 at 13:02
  • @JeremyDanyow - Now that the validation stuff is out, do you know if this is supported? – Vaccano Aug 20 '16 at 17:20

0 Answers0