client.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const { register, Sequelize } = require('@alancnet/material-framework/auto-crud')
  2. register({
  3. camelName: 'client',
  4. iconAsset: 'userIcon',
  5. appPrefix: '/clients/:terminal',
  6. apiPrefix: '/api/clients/:terminal',
  7. titles: {
  8. details: ctrl => ctrl.isNew
  9. ? `New ${ctrl.$routeParams.terminal == 'all' ? '' : ctrl.$routeParams.terminal} Client`
  10. : `${ctrl.$routeParams.terminal == 'all' ? '' : ctrl.$routeParams.terminal} Client Details`,
  11. list: ctrl => `${ctrl.$routeParams.terminal == 'all' ? 'All' : ctrl.$routeParams.terminal} Clients`
  12. },
  13. showNav: false,
  14. schema: {
  15. id: {
  16. type: Sequelize.UUID,
  17. defaultValue: Sequelize.UUIDV1,
  18. primaryKey: true
  19. },
  20. name: Sequelize.STRING,
  21. key: {
  22. type: Sequelize.STRING,
  23. unique: true
  24. },
  25. address: Sequelize.STRING,
  26. terminalId: Sequelize.UUID,
  27. distanceMiles: Sequelize.DOUBLE
  28. },
  29. options: {
  30. paranoid: true,
  31. indexes: [
  32. {
  33. unique: true,
  34. fields: ['key']
  35. }
  36. ]
  37. },
  38. columns: [
  39. { camelName: 'key' },
  40. { camelName: 'name' },
  41. { camelName: 'address', inList: false },
  42. { camelName: 'terminalId', titleName: 'terminal', type: 'autocomplete', apiPrefix: '/api/terminals', routeParam: 'terminal' },
  43. { camelName: 'distanceMiles', titleName: 'Distance in Miles', type: 'number' }
  44. ],
  45. layout: [
  46. {
  47. section: 'Details',
  48. rows: [
  49. [ 'name', 'key' ],
  50. [ 'address' ],
  51. [ 'terminalId', 'distanceMiles' ]
  52. ]
  53. }
  54. ]
  55. })