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

Identifier is not set

Open mintu19 opened this issue 8 years ago • 0 comments

ng-admin is expected to use identifier and present it as detailLink in listview. However identifier is not set when i try to use custom identifier for an entity

module.exports = function (nga, admin) {

  var payeesList = nga.entity('payees').label('Payees').url('/info/payees').identifier(nga.field('payeeId'));

  payeesList.creationView().fields([
    nga.field('payeeId', 'string').label('Payee ID').attributes({ placeholder: 'Payee ID in 5-12 char' }).validation({ required: true, minlength: 5, maxlength: 12 }),
    nga.field('payeeName', 'string').label('Payee Name').attributes({ placeholder: 'Payee Name in 50 char' }).validation({ required: true, minlength: 3, maxlength: 50 })
  ]);

  payeesList.listView().fields([
    payeesList.creationView().fields(),
    nga.field('valid', 'boolean').label('Valid').validation({ required: true }),
    nga.field('added', 'datetime').label('Added'),
    nga.field('modified', 'datetime').label('Modified')
  ])
  .infinitePagination(true)
  .batchActions([]);
  // identifier is not highlighted

  /*payeesList.showView().fields([
    payeesList.listView().fields()
  ]);*/
  payeesList.showView().disable();
  // showview not recognising identifier nor able to set curtum url
  // as entityId is undefined for custom url

  payeesList.editionView().fields([
    nga.field('valid', 'boolean').label('Valid').validation({ required: true })
  ]);

  payeesList.deletionView().disable();

  admin.addEntity(payeesList);

  return payeesList;
};

Workaround: If i use field configuration and use isDetailLink(true) then i can set to show payeeId as identifier(and as link) but again for showView or EditionView identifier is not defined and they are shown empty. But when I use custom url for editionView and explicitly use entityId to append to base url then it works. But in that too showView doesn't set entityId.

Now I understand that identifier must have been set in order to generate list. Because listView is not populated if identifier is not there. But then why all these issues arises? Am i doing anything wrong? or is it a bug?

Also #1262 for other reference.

mintu19 avatar Dec 09 '16 19:12 mintu19