ngx-metaui / rules

One Framework to build a highly declarative and customizable UI without using templates.
Other
38 stars 8 forks source link

Enable MetaUI Routing support (Material) #31

Closed fkolar closed 5 years ago

fkolar commented 5 years ago

Enable MatButton to be renderable inside FormField. Its common usecase when you show your form in read-only (view) mode where one of the complex field value can be wrap with a buton or anchor to take to the object detail page.

e.g.: In editable mode you might want to render a select or autocomple and when you switch to read-only mode you might want to just render some text wrapped with anchor that actives some routing functionality.

Todo this FormField needs to be flexible in what goes in. Just like we had to wrap select or radio buttons that did not implement MatFormControl the same needs to be done with a button.

Button components needs to be programatically instantiable !

fkolar commented 5 years ago

Once this is done we can also show another usecase where you can create a trait that can look like this:

 trait=toOneRelationship {
        editable=false {
            component:Button;
            bindings: {
                click: ${
                    this.set("object", value);
                    this.set("actionCategory", "General");
                    this.set("action", "Inspect");
                    meta.fireAction(this, true)
                };
                ngcontent: $value;
            }
        }
    }

Ify ou assign this trait to a field it will wrap the rendered value with a button, placing field value into button's ngContent and when button is clicked it will execute set of stact operation that shows a detail page.

When defining a rule for a class field you might just assign a trait like this:

  field=prefAirline {
        label:"My airlines";
        trait:asSelect, toOneRelationship;
        choices:${controller.airlines};
}

or like this:

field=prefAirline#asSelect,toOneRelationship {
        label:"My airlines";
        choices:${controller.airlines};
}
fkolar commented 5 years ago

closed with 4696298e357028d38c956ebabc15fd1fff6d9eea