Advertisement
psi_mmobile

Untitled

Feb 21st, 2024
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.20 KB | None | 0 0
  1. ngOnInit() {
  2. const config = {
  3. appendTo: this.elementRef.nativeElement.firstElementChild,
  4. resizeToFitIncludesHeader: false,
  5. store: this.wbsList,
  6. columns: [
  7. {
  8. enableCellContextMenu: false,
  9. editor: false,
  10. text: 'Company',
  11. field: 'company_name',
  12. id: 'wbsListCompanyName',
  13. renderer: (text) => {
  14. return text.value ? `${text.value}` : '';
  15. },
  16. headerRenderer: (renderData) => {
  17. renderData.headerElement.firstChild.style.whiteSpace = 'pre-wrap';
  18. return renderData.column.text;
  19. },
  20. groupable: false,
  21. sortable: true,
  22. filterable: {
  23. filterField: {
  24. autoComplete: 'new-password'
  25. }
  26. }
  27. },
  28. {
  29. enableCellContextMenu: false,
  30. editor: false,
  31. text: 'Category',
  32. field: 'category_name',
  33. id: 'wbsListWbsCategoryName',
  34. renderer: (text) => {
  35. return text.value ? `${text.value}` : '';
  36. },
  37. groupable: false,
  38. sortable: true,
  39. filterable: {
  40. filterField: {
  41. autoComplete: 'new-password'
  42. }
  43. }
  44. },
  45. {
  46. enableCellContextMenu: false,
  47. editor: false,
  48. text: 'Division',
  49. field: 'division_name',
  50. id: 'wbsListWbsDivisionName',
  51. renderer: (text) => {
  52. return text.value ? `${text.value}` : '';
  53. },
  54. groupable: false,
  55. sortable: true,
  56. filterable: {
  57. filterField: {
  58. autoComplete: 'new-password'
  59. }
  60. }
  61. },
  62. {
  63. enableCellContextMenu: false,
  64. editor: false,
  65. text: 'Name',
  66. field: 'wbs_path_with_names',
  67. id: 'wbsListName',
  68. renderer: (text) => {
  69. return text.value ? `${text.value}` : '';
  70. },
  71. groupable: false,
  72. sortable: true,
  73. filterable: {
  74. filterField: {
  75. autoComplete: 'new-password'
  76. }
  77. }
  78. },
  79. {
  80. enableCellContextMenu: false,
  81. editor: false,
  82. text: 'Ref number',
  83. field: 'ref_number',
  84. id: 'wbsListRefNumber',
  85. renderer: (text) => {
  86. return text.value ? `${text.value}` : '';
  87. },
  88. groupable: false,
  89. sortable: true,
  90. filterable: {
  91. filterField: {
  92. autoComplete: 'new-password'
  93. }
  94. }
  95. },
  96. {
  97. enableCellContextMenu: false,
  98. editor: false,
  99. text: 'POI TIN',
  100. field: 'poi_tin',
  101. id: 'wbsListPoiTin',
  102. renderer: (text) => {
  103. return text.value ? `${text.value}` : '';
  104. },
  105. groupable: false,
  106. sortable: true,
  107. filterable: {
  108. filterField: {
  109. autoComplete: 'new-password'
  110. }
  111. }
  112. },
  113. {
  114. enableCellContextMenu: false,
  115. editor: false,
  116. text: 'Status',
  117. field: 'wbs_status',
  118. id: 'wbsListStatusName',
  119. renderer: (text) => {
  120. return text.value ? `${text.value}` : '';
  121. },
  122. groupable: false,
  123. sortable: true,
  124. filterable: {
  125. filterField: {
  126. autoComplete: 'new-password'
  127. }
  128. }
  129. },
  130. {
  131. enableCellContextMenu: false,
  132. editor: false,
  133. type: 'date',
  134. format: 'DD/MM/YYYY',
  135. text: 'From date',
  136. field: 'wbs_from_date',
  137. id: 'wbsListFromDate',
  138. groupable: false,
  139. sortable: true,
  140. filterable: {
  141. filterField: {
  142. type: 'date',
  143. format: 'DD/MM/YYYY',
  144. placeholder: 'dd/mm/yyyy'
  145. },
  146. filterFn: ({ record, value }) => {
  147. if (record.data.wbs_from_date) {
  148. const date = new Date(record.data.wbs_from_date);
  149. return (
  150. date.setHours(0, 0, 0, 0) === new Date(value).getTime()
  151. );
  152. } else {
  153. return false;
  154. }
  155. }
  156. }
  157. },
  158. {
  159. enableCellContextMenu: false,
  160. editor: false,
  161. type: 'date',
  162. format: 'DD/MM/YYYY',
  163. text: 'To date',
  164. field: 'wbs_to_date',
  165. id: 'wbsListToDate',
  166. groupable: false,
  167. sortable: true,
  168. filterable: {
  169. filterField: {
  170. type: 'date',
  171. format: 'DD/MM/YYYY',
  172. placeholder: 'dd/mm/yyyy'
  173. },
  174. filterFn: ({ record, value }) => {
  175. if (record.data.wbs_to_date) {
  176. const date = new Date(record.data.wbs_to_date);
  177. return (
  178. date.setHours(0, 0, 0, 0) === new Date(value).getTime()
  179. );
  180. } else {
  181. return false;
  182. }
  183. }
  184. }
  185. },
  186. {
  187. enableCellContextMenu: false,
  188. editor: false,
  189. text: 'Budget',
  190. field: 'reported_budget',
  191. id: 'wbsListReportedBudget',
  192. renderer: (text) => {
  193. return text.value ? `${text.value}` : '';
  194. },
  195. groupable: false,
  196. sortable: true,
  197. filterable: false
  198. },
  199. {
  200. enableCellContextMenu: false,
  201. editor: false,
  202. text: 'Percentage completed (%)',
  203. field: 'percentage_completed',
  204. id: 'wbsListPercentageCompleted',
  205. renderer: (text) => {
  206. return text.value ? `${text.value}` : '';
  207. },
  208. groupable: false,
  209. sortable: true,
  210. filterable: false
  211. },
  212. {
  213. enableCellContextMenu: false,
  214. editor: false,
  215. text: 'Short description',
  216. field: 'short_description',
  217. id: 'wbsListShortDescription',
  218. renderer: (text) => {
  219. return text.value ? `${text.value}` : '';
  220. },
  221. groupable: false,
  222. sortable: true,
  223. filterable: false
  224. },
  225. {
  226. enableCellContextMenu: false,
  227. editor: false,
  228. text: 'Detailed description',
  229. field: 'description',
  230. id: 'wbsListDetailedDescription',
  231. renderer: (text) => {
  232. return text.value ? `${text.value}` : '';
  233. },
  234. groupable: false,
  235. sortable: true,
  236. filterable: false
  237. },
  238. {
  239. id: 'wbsListAddress',
  240. text: 'POI data',
  241. children: [
  242. {
  243. enableCellContextMenu: false,
  244. editor: false,
  245. text: 'Name',
  246. field: 'poi_name',
  247. id: 'wbsListPoiName',
  248. headerRenderer: (renderData) => {
  249. renderData.headerElement.firstChild.style.whiteSpace =
  250. 'pre-wrap';
  251. return renderData.column.text;
  252. },
  253. filterable: {
  254. filterField: {
  255. autoComplete: 'new-password'
  256. }
  257. },
  258. renderer: (text) => {
  259. return text.value ? `${text.value}` : '';
  260. },
  261. groupable: false
  262. },
  263. {
  264. enableCellContextMenu: false,
  265. editor: false,
  266. text: 'Street',
  267. field: 'poi_street',
  268. id: 'wbsListPoiStreet',
  269. filterable: {
  270. filterField: {
  271. autoComplete: 'new-password'
  272. }
  273. },
  274. renderer: (text) => {
  275. return text.value ? `${text.value}` : '';
  276. },
  277. groupable: false
  278. },
  279. {
  280. enableCellContextMenu: false,
  281. editor: false,
  282. text: 'Street Nr',
  283. field: 'poi_street_nr',
  284. id: 'wbsListPoiStreetNr',
  285. renderer: (text) => {
  286. return text.value ? `${text.value}` : '';
  287. },
  288. groupable: false,
  289. sortable: true,
  290. filterable: {
  291. filterField: {
  292. autoComplete: 'new-password'
  293. }
  294. }
  295. },
  296. {
  297. enableCellContextMenu: false,
  298. editor: false,
  299. text: 'Post code',
  300. field: 'poi_post_code',
  301. id: 'wbsListPoiPostCode',
  302. renderer: (text) => {
  303. return text.value ? `${text.value}` : '';
  304. },
  305. groupable: false,
  306. sortable: true,
  307. filterable: {
  308. filterField: {
  309. autoComplete: 'new-password'
  310. }
  311. }
  312. },
  313. {
  314. enableCellContextMenu: false,
  315. editor: false,
  316. text: 'City',
  317. field: 'poi_location',
  318. id: 'wbsListPoiLocation',
  319. renderer: (text) => {
  320. return text.value ? `${text.value}` : '';
  321. },
  322. groupable: false,
  323. sortable: true,
  324. filterable: {
  325. filterField: {
  326. autoComplete: 'new-password'
  327. }
  328. }
  329. },
  330. {
  331. enableCellContextMenu: false,
  332. editor: false,
  333. text: 'Country',
  334. field: 'poi_country',
  335. id: 'wbsListPoiCountry',
  336. renderer: (text) => {
  337. return text.value ? `${text.value}` : '';
  338. },
  339. groupable: false,
  340. sortable: true,
  341. filterable: {
  342. filterField: {
  343. autoComplete: 'new-password'
  344. }
  345. }
  346. },
  347. {
  348. enableCellContextMenu: false,
  349. editor: false,
  350. text: 'Mobility zone',
  351. field: 'poi_mobility_zone',
  352. id: 'wbsListMobilityZone',
  353. renderer: (text) => {
  354. return text.value ? `${text.value}` : '';
  355. },
  356. groupable: false,
  357. sortable: true,
  358. filterable: false
  359. },
  360. {
  361. enableCellContextMenu: false,
  362. editor: false,
  363. text: 'Mobility short code',
  364. field: 'poi_mobility_zone_id',
  365. id: 'wbsListMobilityZoneId',
  366. renderer: (text) => {
  367. return text.value ? `${text.value}` : '';
  368. },
  369. groupable: false,
  370. sortable: true,
  371. filterable: false
  372. }
  373. ]
  374. },
  375. {
  376. id: 'wbsListFirstContact',
  377. text: 'First contact',
  378. children: [
  379. {
  380. enableCellContextMenu: false,
  381. editor: false,
  382. text: 'Name',
  383. field: 'poi_first_contact_name',
  384. id: 'wbsListFCName',
  385. renderer: (text) => {
  386. return text.value ? `${text.value}` : '';
  387. },
  388. groupable: false,
  389. sortable: true,
  390. filterable: {
  391. filterField: {
  392. autoComplete: 'new-password'
  393. }
  394. }
  395. },
  396. {
  397. enableCellContextMenu: false,
  398. editor: false,
  399. text: 'Phone',
  400. field: 'poi_first_contact_phone',
  401. id: 'wbsListFCPhone',
  402. renderer: (text) => {
  403. return text.value ? `${text.value}` : '';
  404. },
  405. groupable: false,
  406. sortable: true,
  407. filterable: {
  408. filterField: {
  409. autoComplete: 'new-password'
  410. }
  411. }
  412. },
  413. {
  414. enableCellContextMenu: false,
  415. editor: false,
  416. text: 'Email',
  417. field: 'poi_first_contact_email',
  418. id: 'wbsListFCEmail',
  419. renderer: (text) => {
  420. return text.value ? `${text.value}` : '';
  421. },
  422. groupable: false,
  423. sortable: true,
  424. filterable: {
  425. filterField: {
  426. autoComplete: 'new-password'
  427. }
  428. }
  429. }
  430. ]
  431. },
  432. {
  433. id: 'wbsListSecondContact',
  434. text: 'Second contact',
  435. children: [
  436. {
  437. enableCellContextMenu: false,
  438. editor: false,
  439. text: 'Name',
  440. field: 'poi_second_contact_name',
  441. id: 'wbsListSCName',
  442. renderer: (text) => {
  443. return text.value ? `${text.value}` : '';
  444. },
  445. groupable: false,
  446. sortable: true,
  447. filterable: {
  448. filterField: {
  449. autoComplete: 'new-password'
  450. }
  451. }
  452. },
  453. {
  454. enableCellContextMenu: false,
  455. editor: false,
  456. text: 'Phone',
  457. field: 'poi_second_contact_phone',
  458. id: 'wbsListSCPhone',
  459. renderer: (text) => {
  460. return text.value ? `${text.value}` : '';
  461. },
  462. groupable: false,
  463. sortable: true,
  464. filterable: {
  465. filterField: {
  466. autoComplete: 'new-password'
  467. }
  468. }
  469. },
  470. {
  471. enableCellContextMenu: false,
  472. editor: false,
  473. text: 'Email',
  474. field: 'poi_second_contact_email',
  475. id: 'wbsListSCEmail',
  476. renderer: (text) => {
  477. return text.value ? `${text.value}` : '';
  478. },
  479. groupable: false,
  480. sortable: true,
  481. filterable: {
  482. filterField: {
  483. autoComplete: 'new-password'
  484. }
  485. }
  486. }
  487. ]
  488. },
  489. {
  490. enableCellContextMenu: false,
  491. editor: false,
  492. text: 'Contact comment',
  493. field: 'contact_comment',
  494. id: 'wbsListContactComment',
  495. renderer: (text) => {
  496. return text.value ? `${text.value}` : '';
  497. },
  498. groupable: false,
  499. sortable: true,
  500. filterable: {
  501. filterField: {
  502. autoComplete: 'new-password'
  503. }
  504. }
  505. },
  506. {
  507. enableCellContextMenu: false,
  508. editor: false,
  509. text: 'Geocoded?',
  510. field: 'can_be_geocoded',
  511. id: 'wbsListCanBeGeoc',
  512. type: 'threestatecheckbox',
  513. listeners: {
  514. beforeToggle: () => false
  515. },
  516. groupable: false,
  517. sortable: true,
  518. filterable: false
  519. },
  520. {
  521. id: 'wbsListResponsible',
  522. text: 'Responsible',
  523. children: [
  524. {
  525. enableCellContextMenu: false,
  526. editor: false,
  527. text: 'Op 1',
  528. field: 'val_op1_str',
  529. id: 'wbsListValOp1',
  530. renderer: (text) => {
  531. return text.value ? `${text.value}` : '';
  532. },
  533. groupable: false,
  534. sortable: true,
  535. filterable: {
  536. filterField: {
  537. autoComplete: 'new-password'
  538. }
  539. }
  540. },
  541. {
  542. enableCellContextMenu: false,
  543. editor: false,
  544. text: 'Op 2',
  545. field: 'val_op2_str',
  546. id: 'wbsListValOp2',
  547. renderer: (text) => {
  548. return text.value ? `${text.value}` : '';
  549. },
  550. groupable: false,
  551. sortable: true,
  552. filterable: {
  553. filterField: {
  554. autoComplete: 'new-password'
  555. }
  556. }
  557. },
  558. {
  559. enableCellContextMenu: false,
  560. editor: false,
  561. text: 'Gestionaire',
  562. field: 'gestionaire_str',
  563. id: 'wbsListGestion',
  564. renderer: (text) => {
  565. return text.value ? `${text.value}` : '';
  566. },
  567. groupable: false,
  568. sortable: true,
  569. filterable: {
  570. filterField: {
  571. autoComplete: 'new-password'
  572. }
  573. }
  574. }
  575. ]
  576. },
  577. {
  578. id: 'columnsLastModification',
  579. text: 'Last modification',
  580. children: [
  581. {
  582. enableCellContextMenu: false,
  583. editor: false,
  584. text: 'Name',
  585. field: 'lm_name',
  586. id: 'wbsListLmName',
  587. renderer: (text) => {
  588. return text.value ? `${text.value}` : '';
  589. },
  590. groupable: false,
  591. sortable: true,
  592. filterable: {
  593. filterField: {
  594. autoComplete: 'new-password'
  595. }
  596. }
  597. },
  598. {
  599. enableCellContextMenu: false,
  600. editor: false,
  601. type: 'date',
  602. format: 'DD/MM/YYYY HH:mm',
  603. text: 'Date',
  604. field: 'lm_date',
  605. id: 'wbsListLmDate',
  606. groupable: false,
  607. sortable: true,
  608. filterable: {
  609. filterField: {
  610. type: 'date',
  611. format: 'DD/MM/YYYY',
  612. placeholder: 'dd/mm/yyyy'
  613. },
  614. filterFn: ({ record, value }) => {
  615. if (record.data.lm_date) {
  616. const date = new Date(record.data.lm_date);
  617. return (
  618. date.setHours(0, 0, 0, 0) === new Date(value).getTime()
  619. );
  620. } else {
  621. return false;
  622. }
  623. }
  624. }
  625. }
  626. ]
  627. }
  628. ],
  629. features: {
  630. sort: true,
  631. filterBar: true,
  632. cellTooltip: {
  633. hoverDelay: 500,
  634. hideDelay: 0
  635. },
  636. headerMenu: { items: { saveColumns: null, resetColumns: null } },
  637. search: true
  638. },
  639. rowHeight: 30
  640. }; // eo config
  641. this.applyDefaultConfig(config);
  642. this.gridName = 'LISTWBSGRID';
  643. this.handleDefaultColumnsState(config);
  644. this.grid = new Grid(config);
  645. this.applySchedulerLocale(this.i18NextService.language);
  646. this.grid.mask('Loading...');
  647. this.handleGridState();
  648.  
  649. // free search
  650. this.makeFreeSearch('freesearchlistwbs');
  651.  
  652. // select another wbs in grid
  653. this.grid.addListener({
  654. selectionchange: () => {
  655. if (this.grid.selectedRecord) {
  656. this.wbsService.updateCurrentWbs(this.grid.selectedRecord);
  657. this.wbsComponent.selectedWbs = this.grid.selectedRecord;
  658. }
  659. }
  660. });
  661.  
  662. // double click on row link to the edition of the selected object
  663. this.grid.addListener({
  664. celldblclick: () => {
  665. this.wbsService.updateCurrentWbs(this.grid.selectedRecord);
  666. this.router.navigateByUrl('/wbs/editwbs');
  667. }
  668. });
  669.  
  670. // default filter
  671. this.grid.store.filter({
  672. id: 'showactivewbs',
  673. filterBy: (wbs) => wbs.wbs_status_id !== null && wbs.wbs_status_id === 0
  674. });
  675.  
  676. this.subscription = this.wbsService.wbsList$.subscribe((wbsList) => {
  677. this.wbsList = wbsList;
  678. this.grid.unmask();
  679. }
  680. );
  681. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement