ng-admin icon indicating copy to clipboard operation
ng-admin copied to clipboard

In "creationView" I can't use two fields of type "reference" related to the same entity.

Open vcenturion opened this issue 10 years ago • 10 comments

In "creationView" I can't use two fields of type "reference" related to the same entity. If I use two fields the data is duplicated in the select input, if I used three fields the data are tripled, and so on.

Entity Wallet:

"wallets": [{
    "id": 1,
    "currency": "ZZ",
    "owner": 1,
    "balance": "123123",
    "country": "ASD",
    "modification": "2015-10-13T15:20:43.366371Z",
    "creation": "2015-10-13T15:20:43.366371Z"
}]


"charges": [{
    ...
    "source_wallet": 5
    "beneficiary_wallet": 8
    ...
}]

The Create View

charges.creationView()
    .title('Create new Charge')
    .fields([
        ...
        nga.field('source_wallet', 'reference')
            .label('Source Wallet')
            .targetEntity(admin.getEntity('wallets'))
            .targetField(nga.field('id'))
            .singleApiCall(ids => ({ 'id': ids })),
        nga.field('beneficiary_wallet', 'reference')
            .label('Beneficiary Wallet')
            .targetEntity(admin.getEntity('wallets'))
            .targetField(nga.field('id'))
            .singleApiCall(ids => ({ 'id': ids })),
        ...
    ]);

vcenturion avatar Nov 06 '15 21:11 vcenturion

Anybody can help me about this? Is there something I'm doing wrong?

Thanks

vcenturion avatar Nov 10 '15 18:11 vcenturion

I also have the same problem

huvber avatar Nov 11 '15 17:11 huvber

+1

kinnrot avatar Nov 24 '15 16:11 kinnrot

I also have the same problem. +1

ace-han avatar Nov 28 '15 15:11 ace-han

+1 the same =(

maximk-1 avatar Dec 13 '15 22:12 maximk-1

+1 the same problem

kane-chen avatar Jan 23 '16 22:01 kane-chen

+1 My workaround for that is to create different variables to use as reference in .targetEntity().

...
var usera = nga.entity('users');
var userb = nga.entity('users');
...
nga.field('usera_id', 'reference').targetEntity(usera),
nga.field('userb_id', 'reference').targetEntity(userb),
...

I even use .permanentFilters() to show different values for each field.

orgito avatar Feb 16 '16 11:02 orgito

i use diff-entity to resove it, detail: [https://github.com/kane-chen/mview/blob/master/mview.adminui/src/main/webapp/admin/js/app1/definitions/widgets.js] like:
defines: ----------------------------------------------------------------------------------------------- var template_css = nga.entity('templates/type/css').identifier(nga.field('vkey')); admin.addEntity(template_css); var template_js = nga.entity('templates/type/js').identifier(nga.field('vkey')); admin.addEntity(template_js); ...... use: ---------------------------------------------------------------------------------------------- nga.field('cssDefKey','reference').label('cssDefinition') .targetEntity(admin.getEntity('templates/type/css')) .targetField(nga.field('vkey')) .validation({required:true}) .perPage(10), nga.field('jsDefKey','reference').label('jsDefinition') .targetEntity(admin.getEntity('templates/type/js')) .targetField(nga.field('vkey')) .perPage(10),

kane-chen avatar Feb 26 '16 17:02 kane-chen

+1 Facing the same issue.

jotadepicas avatar Mar 17 '16 20:03 jotadepicas

👍

yogipatel avatar Aug 12 '16 19:08 yogipatel