staff-member-pages.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. const { pages } = require('@alancnet/material-framework/app/crud')
  2. const { dollarIcon } = require('../assets')
  3. pages({
  4. camelName: 'staffMember',
  5. apiPrefix: '/api/staff-members/:terminal',
  6. appPrefix: '/staff-members/:terminal',
  7. titles: {
  8. details: ctrl => ctrl.isNew
  9. ? `New ${ctrl.$routeParams.terminal == 'all' ? '' : ctrl.$routeParams.terminal} Staff Member`
  10. : `${ctrl.$routeParams.terminal == 'all' ? '' : ctrl.$routeParams.terminal} Staff Member Details`,
  11. list: ctrl => `${ctrl.$routeParams.terminal == 'all' ? 'All' : ctrl.$routeParams.terminal} Staff Members`
  12. },
  13. columns: [
  14. { camelName: 'name', row: 1 },
  15. { camelName: 'title', row: 2 },
  16. {
  17. titleName: 'Category',
  18. camelName: 'laborCategoryId',
  19. type: 'autocomplete',
  20. apiPrefix: '/api/labor-categories'
  21. },
  22. {
  23. titleName: 'terminal',
  24. camelName: 'terminalId',
  25. routeParam: 'terminal',
  26. type: 'autocomplete',
  27. apiPrefix: '/api/terminals'
  28. },
  29. {
  30. titleName: 'Staffing Agency',
  31. camelName: 'staffingAgencyId',
  32. type: 'autocomplete',
  33. apiPrefix: '/api/staffing-agencies'
  34. },
  35. {
  36. inList: false,
  37. camelName: 'wage',
  38. type: 'currency',
  39. field: html`
  40. <md-input-container flex ng-if="$ctrl.api.claims['INCOME_' + $ctrl.laborCategoryKey + '_VIEW']">
  41. <label>Wage</label>
  42. <input type="number" step="0.01" ng-model="model.wage" />
  43. <md-icon md-svg-src="${dollarIcon}"></md-icon>
  44. </md-input-container>
  45. `
  46. },
  47. {
  48. inList: false,
  49. camelName: 'salary',
  50. type: 'currency',
  51. field: html`
  52. <md-input-container flex ng-if="$ctrl.api.claims['INCOME_' + $ctrl.laborCategoryKey + '_VIEW']">
  53. <label>Salary</label>
  54. <input type="number" step="0.01" ng-model="model.salary" />
  55. <md-icon md-svg-src="${dollarIcon}"></md-icon>
  56. </md-input-container>
  57. `
  58. }
  59. ],
  60. controllers: {
  61. details: function() {
  62. this.loadingPromise.then(async () => {
  63. const cats = await this.api.laborCategoryDictionary()
  64. const unwatch = this.$scope.$watch('model.laborCategoryId', (laborCategoryId) => {
  65. if (laborCategoryId) {
  66. this.laborCategoryKey = cats[laborCategoryId].key
  67. } else {
  68. this.laborCategoryKey = null
  69. }
  70. })
  71. this.$scope.$on('$destroy', unwatch)
  72. })
  73. }
  74. },
  75. layout: [
  76. {
  77. section: null,
  78. rows: [
  79. [ 'name', 'title', ],
  80. [ 'laborCategoryId', 'terminalId' ]
  81. ]
  82. },
  83. {
  84. section: 'Staffing information',
  85. rows: [
  86. [ 'wage', 'salary', 'staffingAgencyId' ]
  87. ]
  88. }
  89. ]
  90. })