-
Notifications
You must be signed in to change notification settings - Fork 725
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
field.template(..., true) doesn't work in Embedded Entities view #1158
Comments
The edit.hml and create.html templates where fields are instantiated use a "compile" directive to replace the row with the "template()" of the field, if "template(..., true)" has been called on that field:
The corresponding code in maEmbeddedListField.js does not, hence this bug:
However, the obvious fix of applying "compile" in both places has a problem in that the "default" template string differs between the two contexts. In the first context, the default template is the "<ma-field" string as seen above and listed in the docs. In the second context, the default template is similar, but has different attribute values. I think this will make "template()" tricky to use correctly. However, fixing that issue is much harder and feels out of scope here. |
I have created a PR which applies the obvious fix here. As noted above, there is still a bit of an ugly API here, as the the "default" template string differs between the two contexts. If I want to be able to show / hide edit rows based on the entity values, like http://stackoverflow.com/questions/35934085/ng-admin-how-to-show-different-fields-according-to-users-selection then I need to change the template based on whether the field is "embedded" or not. Let's say I want to write a decorator named "showEditCreateIf" which will show/hide an edit/create field based on a field value. Using the same example as the the Field Configuration doc page:
Here's a decorator I'm currently using that lets me write code like that, but it's ugly for the reason discussed above:
Any ideas? Maybe the template() API needs a rethink, or do we need a native "showEditCreateIf" on fields? |
When using the "Embedded Entities" edit form, the
field.template(x)
function works fine to set a custom value template, but thefield.template(x, true)
function appears to have no effect.To reproduce:
open this Plunkr demo: http://plnkr.co/edit/YeOBmuIqqAGEcBGINtIw?p=preview
click on "John" on the dashboard
click "add new children"
I have added the following fields to "user" and "child" (see script.js lines 45 - 58)):
Expected behaviour:
I'd expect both the "user" form and the "child" form to have:
Observed behaviour:
The user form has the above behaviour, but the child form has:
The text was updated successfully, but these errors were encountered: