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

AmountField does not work as documented #1341

Open
jrief opened this issue May 10, 2017 · 1 comment
Open

AmountField does not work as documented #1341

jrief opened this issue May 10, 2017 · 1 comment
Labels

Comments

@jrief
Copy link

jrief commented May 10, 2017

It took me quite a while to figure out that the documentation on Adding Custom Types, using the AmountField sample code, seems not to work as described.

What I did: I have set up a project using the same dependencies as provided by the ng-admin-demo. Compiling and running the demo using webpack works well. There is no difference to the online version of it.

Then I started to create a simple project from scratch, using the sample code from Adding Custom Types. Afterwards I added a field of type amount using

	var admin = nga.application("Dashboard");
	admin.baseApiUrl("/my/rest/endpoint/");

	var entity = nga.entity("extra");
	entity.label("Extra");

	entity.listView().fields([
		nga.field("id", "string"),
		nga.field("product_name", "string"),
	]);

	entity.creationView().fields([
		nga.field("id", "string"),
		nga.field("product_name", "string"),
		nga.field("price", "amount")
	]);

	entity.editionView().fields([
		nga.field("id", "string"),
		nga.field("product_name", "string"),
		nga.field("price", "amount")
	]);

	admin.addEntity(entity);

this dashboard display the fields id and product_name but hides the expected field price. When I change the field type to float or number, everything works as expected, but of course that's not the purpose of this exercise.

Then I debugged into the compiled ES5 code and I can confirm that the constructor of the AmoutField is invoked. However, if the field type is set to amount the field is not rendered, only the most outer, but empty wrapper:

<div ng-repeat="field in ::formController.fields track by $index" compile="::field.getTemplateValueWithLabel(entry)" class="ng-scope"></div>

May it be that a customized field also must override the getTemplateValueWithLabel method in order to fill its content?

Since the amount field is working in the demo, I was searching for an error in my setup. However, in the demo, the templates used to render the Catalog > Poster > Detail View are overridden anyway, so there the amount field is not used as described in the documentation.

@albelko
Copy link

albelko commented Oct 26, 2017

I've got the same issue. Any ideas to solve?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants