Advertisement
psi_mmobile

Untitled

Feb 21st, 2024
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.25 KB | None | 0 0
  1. ngOnInit() {
  2. this.subscription = this.wbsService.wbsTreeNewChild$.subscribe(() => {
  3. this.addWbsChildNode();
  4. });
  5. this.subscription.add(
  6. this.wbsService.wbsTreeDeactivateNode$.subscribe(() => {
  7. this.deactivateWbsNode();
  8. })
  9. );
  10. this.subscription.add(
  11. this.wbsService.wbsTreeDeleteNode$.subscribe(() => {
  12. this.deleteWbsNode();
  13. })
  14. );
  15. const config = {
  16. appendTo: this.elementRef.nativeElement.firstElementChild,
  17. resizeToFitIncludesHeader: false,
  18. columns: [
  19. {
  20. enableCellContextMenu: false,
  21. editor: false,
  22. text: 'Name',
  23. type: 'tree',
  24. field: 'name',
  25. id: 'treeWbsName',
  26. renderer: (text) => {
  27. return text.value ? `${text.value}` : '';
  28. },
  29. groupable: false,
  30. sortable: true,
  31. filterable: {
  32. filterField: {
  33. autoComplete: 'new-password'
  34. }
  35. }
  36. },
  37. {
  38. enableCellContextMenu: false,
  39. editor: false,
  40. text: 'Short name',
  41. field: 'short_name',
  42. id: 'treeWbsShortName',
  43. renderer: (text) => {
  44. return text.value ? `${text.value}` : '';
  45. },
  46. headerRenderer: (renderData) => {
  47. renderData.headerElement.firstChild.style.whiteSpace =
  48. 'pre-wrap';
  49. return renderData.column.text;
  50. },
  51. groupable: false,
  52. sortable: true,
  53. filterable: {
  54. filterField: {
  55. autoComplete: 'new-password'
  56. }
  57. }
  58. },
  59. {
  60. enableCellContextMenu: false,
  61. editor: false,
  62. text: 'Ref number',
  63. field: 'ref_number',
  64. id: 'treeWbsRefNum',
  65. renderer: (text) => {
  66. return text.value ? `${text.value}` : '';
  67. },
  68. groupable: false,
  69. sortable: true,
  70. filterable: {
  71. filterField: {
  72. autoComplete: 'new-password'
  73. }
  74. }
  75. },
  76. {
  77. enableCellContextMenu: false,
  78. editor: false,
  79. text: 'Can assign team?',
  80. field: 'can_assign_team',
  81. id: 'treeWbsCanAssignTeam',
  82. type: 'threestatecheckbox',
  83. listeners: {
  84. beforeToggle: () => false
  85. },
  86. htmlEncode: false,
  87. groupable: false,
  88. sortable: true,
  89. filterable: false
  90. },
  91. {
  92. enableCellContextMenu: false,
  93. editor: false,
  94. text: 'Is work time reported?',
  95. field: 'is_work_time_reported',
  96. id: 'treeWbsIsWorkTimeReported',
  97. type: 'threestatecheckbox',
  98. listeners: {
  99. beforeToggle: () => false
  100. },
  101. groupable: false,
  102. sortable: true,
  103. filterable: false
  104. },
  105. {
  106. enableCellContextMenu: false,
  107. editor: false,
  108. text: 'Planned HR',
  109. field: 'planned_hr',
  110. id: 'treeWbsPlannedHr',
  111. renderer: (text) => {
  112. return text.value ? `${text.value}` : '';
  113. },
  114. groupable: false,
  115. sortable: true,
  116. filterable: {
  117. filterField: {
  118. autoComplete: 'new-password'
  119. }
  120. }
  121. },
  122. {
  123. enableCellContextMenu: false,
  124. editor: false,
  125. text: 'Planned quantity',
  126. field: 'planned_quantity',
  127. id: 'treeWbsPlannedQty',
  128. renderer: (text) => {
  129. return text.value ? `${text.value}` : '';
  130. },
  131. groupable: false,
  132. sortable: true,
  133. filterable: {
  134. filterField: {
  135. autoComplete: 'new-password'
  136. }
  137. }
  138. },
  139. {
  140. enableCellContextMenu: false,
  141. editor: false,
  142. text: 'Planned budget',
  143. field: 'planned_budget',
  144. id: 'treeWbsPlannedBudget',
  145. renderer: (text) => {
  146. return text.value ? `${text.value}` : '';
  147. },
  148. groupable: false,
  149. sortable: true,
  150. filterable: {
  151. filterField: {
  152. autoComplete: 'new-password'
  153. }
  154. }
  155. },
  156. {
  157. enableCellContextMenu: false,
  158. editor: false,
  159. text: 'Percentage completed',
  160. field: 'percentage_completed',
  161. id: 'treeWbsPercentageCompleted',
  162. renderer: (text) => {
  163. return text.value ? `${text.value}` : '';
  164. },
  165. groupable: false,
  166. sortable: true,
  167. filterable: {
  168. filterField: {
  169. autoComplete: 'new-password'
  170. }
  171. }
  172. },
  173. {
  174. enableCellContextMenu: false,
  175. editor: false,
  176. type: 'date',
  177. format: 'DD/MM/YYYY',
  178. text: 'Percentage completed date',
  179. field: 'percentageCompletedDate',
  180. id: 'treeWbsPercentageCompletedDate',
  181. groupable: false,
  182. sortable: true,
  183. filterable: {
  184. filterField: {
  185. type: 'date',
  186. format: 'DD/MM/YYYY',
  187. placeholder: 'dd/mm/yyyy'
  188. },
  189. filterFn: ({ record, value }) => {
  190. if (record.data.percentage_completed_date) {
  191. const date = new Date(record.data.percentage_completed_date);
  192. return (
  193. date.setHours(0, 0, 0, 0) === new Date(value).getTime()
  194. );
  195. } else {
  196. return false;
  197. }
  198. }
  199. }
  200. },
  201. {
  202. enableCellContextMenu: false,
  203. editor: false,
  204. text: 'Percentage completed submitted by',
  205. field: 'percentage_completed_person_name',
  206. id: 'treeWbsPercentageCompletedSubmittedBy',
  207. renderer: (text) => {
  208. return text.value ? `${text.value}` : '';
  209. },
  210. groupable: false,
  211. sortable: true,
  212. filterable: {
  213. filterField: {
  214. autoComplete: 'new-password'
  215. }
  216. }
  217. },
  218. {
  219. enableCellContextMenu: false,
  220. editor: false,
  221. text: 'Total reported quantity',
  222. field: 'tot_reported_quantity',
  223. id: 'treeWbsTotReportedQty',
  224. renderer: (text) => {
  225. return text.value ? `${text.value}` : '';
  226. },
  227. groupable: false,
  228. sortable: true,
  229. filterable: {
  230. filterField: {
  231. autoComplete: 'new-password'
  232. }
  233. }
  234. },
  235. {
  236. enableCellContextMenu: false,
  237. editor: false,
  238. type: 'date',
  239. format: 'DD/MM/YYYY',
  240. text: 'Total reported quantity date',
  241. field: 'totReportedQuantityDate',
  242. id: 'treeWbsTotReportedQtyDate',
  243. groupable: false,
  244. sortable: true,
  245. filterable: {
  246. filterField: {
  247. type: 'date',
  248. format: 'DD/MM/YYYY',
  249. placeholder: 'dd/mm/yyyy'
  250. },
  251. filterFn: ({ record, value }) => {
  252. if (record.data.tot_reported_quantity_date) {
  253. const date = new Date(record.data.tot_reported_quantity_date);
  254. return (
  255. date.setHours(0, 0, 0, 0) === new Date(value).getTime()
  256. );
  257. } else {
  258. return false;
  259. }
  260. }
  261. }
  262. },
  263. {
  264. enableCellContextMenu: false,
  265. editor: false,
  266. text: 'Total reported quantity submitted by',
  267. field: 'tot_reported_quantity_person_name',
  268. id: 'treeWbsTotReportedQtySubmittedBy',
  269. renderer: (text) => {
  270. return text.value ? `${text.value}` : '';
  271. },
  272. groupable: false,
  273. sortable: true,
  274. filterable: {
  275. filterField: {
  276. autoComplete: 'new-password'
  277. }
  278. }
  279. },
  280. {
  281. enableCellContextMenu: false,
  282. editor: false,
  283. text: 'Ask for quantity produced?',
  284. field: 'ask_for_quantity_produced',
  285. id: 'treeWbsAskForQuantityProduced',
  286. type: 'threestatecheckbox',
  287. listeners: {
  288. beforeToggle: () => false
  289. },
  290. groupable: false,
  291. sortable: true,
  292. filterable: false
  293. },
  294. {
  295. enableCellContextMenu: false,
  296. editor: false,
  297. text: 'Ask for reported quantity?',
  298. field: 'ask_for_reported_quantity',
  299. id: 'treeWbsAskForReportedQty',
  300. type: 'threestatecheckbox',
  301. listeners: {
  302. beforeToggle: () => false
  303. },
  304. groupable: false,
  305. sortable: true,
  306. filterable: false
  307. },
  308. {
  309. enableCellContextMenu: false,
  310. editor: false,
  311. text: 'Display total reported quantity?',
  312. field: 'display_tot_reported_quantity',
  313. id: 'treeWbsDisplayTotalReportedQty',
  314. type: 'threestatecheckbox',
  315. listeners: {
  316. beforeToggle: () => false
  317. },
  318. groupable: false,
  319. sortable: true,
  320. filterable: false
  321. }
  322. ],
  323. features: {
  324. sort: true,
  325. filterBar: true,
  326. tree: true,
  327. cellTooltip: {
  328. hoverDelay: 500,
  329. hideDelay: 0
  330. },
  331. headerMenu: { items: { saveColumns: null, resetColumns: null } },
  332. search: true
  333. },
  334. rowHeight: 30
  335. }; // eo config
  336. this.applyDefaultConfig(config);
  337. this.gridName = 'WBSTREEGRID';
  338. this.handleDefaultColumnsState(config);
  339. this.grid = new Grid(config);
  340. this.applySchedulerLocale(this.i18NextService.language);
  341. this.grid.mask('Loading...');
  342. this.grid.addListener({
  343. selectionchange: () => {
  344. if (this.grid.selectedRecord) {
  345. this.wbsTreeOutput.emit(this.grid.selectedRecord);
  346. this.wbsService.updateCurrentWbsNode(this.grid.selectedRecord);
  347. }
  348. }
  349. });
  350. this.grid.addListener({
  351. celldblclick: () => {
  352. this.checkChildrenProt(this.grid.selectedRecord,true,'wbs_id');
  353. }
  354. });
  355. this.subscription.add(
  356. this.wbsService.currentWbsTreeListStore$.subscribe((wbsTreeListStore) => {
  357.  
  358. let wbs_id;
  359.  
  360. wbs_id = this.grid.selectedRecord?.wbs_id
  361. this.grid.store = wbsTreeListStore
  362. this.grid.unmask();
  363. this.checkChildrenProt(wbsTreeListStore.first,true,'wbs_id');
  364. if (wbs_id) {
  365. this.grid.selectRow({record: wbsTreeListStore.find((wbs) => wbs.wbs_id === wbs_id).id});
  366. }
  367. else {
  368. this.grid.selectRow({
  369. record: this.grid.topRow.id
  370. });
  371. }
  372. // this.wbsService.updateCurrentWbsNode(this.grid.selectedRecord);
  373. // this.wbsService.updateTopWbsNode(this.grid.selectedRecord);
  374. // select another wbs in grid
  375. })
  376. );
  377. // grid config
  378. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement