Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ngOnInit() {
- const config = {
- appendTo: this.elementRef.nativeElement.firstElementChild,
- resizeToFitIncludesHeader: false,
- store: this.wbsList,
- columns: [
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Company',
- field: 'company_name',
- id: 'wbsListCompanyName',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- headerRenderer: (renderData) => {
- renderData.headerElement.firstChild.style.whiteSpace = 'pre-wrap';
- return renderData.column.text;
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Category',
- field: 'category_name',
- id: 'wbsListWbsCategoryName',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Division',
- field: 'division_name',
- id: 'wbsListWbsDivisionName',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Name',
- field: 'wbs_path_with_names',
- id: 'wbsListName',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Ref number',
- field: 'ref_number',
- id: 'wbsListRefNumber',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'POI TIN',
- field: 'poi_tin',
- id: 'wbsListPoiTin',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Status',
- field: 'wbs_status',
- id: 'wbsListStatusName',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- type: 'date',
- format: 'DD/MM/YYYY',
- text: 'From date',
- field: 'wbs_from_date',
- id: 'wbsListFromDate',
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- type: 'date',
- format: 'DD/MM/YYYY',
- placeholder: 'dd/mm/yyyy'
- },
- filterFn: ({ record, value }) => {
- if (record.data.wbs_from_date) {
- const date = new Date(record.data.wbs_from_date);
- return (
- date.setHours(0, 0, 0, 0) === new Date(value).getTime()
- );
- } else {
- return false;
- }
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- type: 'date',
- format: 'DD/MM/YYYY',
- text: 'To date',
- field: 'wbs_to_date',
- id: 'wbsListToDate',
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- type: 'date',
- format: 'DD/MM/YYYY',
- placeholder: 'dd/mm/yyyy'
- },
- filterFn: ({ record, value }) => {
- if (record.data.wbs_to_date) {
- const date = new Date(record.data.wbs_to_date);
- return (
- date.setHours(0, 0, 0, 0) === new Date(value).getTime()
- );
- } else {
- return false;
- }
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Budget',
- field: 'reported_budget',
- id: 'wbsListReportedBudget',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: false
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Percentage completed (%)',
- field: 'percentage_completed',
- id: 'wbsListPercentageCompleted',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: false
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Short description',
- field: 'short_description',
- id: 'wbsListShortDescription',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: false
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Detailed description',
- field: 'description',
- id: 'wbsListDetailedDescription',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: false
- },
- {
- id: 'wbsListAddress',
- text: 'POI data',
- children: [
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Name',
- field: 'poi_name',
- id: 'wbsListPoiName',
- headerRenderer: (renderData) => {
- renderData.headerElement.firstChild.style.whiteSpace =
- 'pre-wrap';
- return renderData.column.text;
- },
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- },
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Street',
- field: 'poi_street',
- id: 'wbsListPoiStreet',
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- },
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Street Nr',
- field: 'poi_street_nr',
- id: 'wbsListPoiStreetNr',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Post code',
- field: 'poi_post_code',
- id: 'wbsListPoiPostCode',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'City',
- field: 'poi_location',
- id: 'wbsListPoiLocation',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Country',
- field: 'poi_country',
- id: 'wbsListPoiCountry',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Mobility zone',
- field: 'poi_mobility_zone',
- id: 'wbsListMobilityZone',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: false
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Mobility short code',
- field: 'poi_mobility_zone_id',
- id: 'wbsListMobilityZoneId',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: false
- }
- ]
- },
- {
- id: 'wbsListFirstContact',
- text: 'First contact',
- children: [
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Name',
- field: 'poi_first_contact_name',
- id: 'wbsListFCName',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Phone',
- field: 'poi_first_contact_phone',
- id: 'wbsListFCPhone',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Email',
- field: 'poi_first_contact_email',
- id: 'wbsListFCEmail',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- }
- ]
- },
- {
- id: 'wbsListSecondContact',
- text: 'Second contact',
- children: [
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Name',
- field: 'poi_second_contact_name',
- id: 'wbsListSCName',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Phone',
- field: 'poi_second_contact_phone',
- id: 'wbsListSCPhone',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Email',
- field: 'poi_second_contact_email',
- id: 'wbsListSCEmail',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- }
- ]
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Contact comment',
- field: 'contact_comment',
- id: 'wbsListContactComment',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Geocoded?',
- field: 'can_be_geocoded',
- id: 'wbsListCanBeGeoc',
- type: 'threestatecheckbox',
- listeners: {
- beforeToggle: () => false
- },
- groupable: false,
- sortable: true,
- filterable: false
- },
- {
- id: 'wbsListResponsible',
- text: 'Responsible',
- children: [
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Op 1',
- field: 'val_op1_str',
- id: 'wbsListValOp1',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Op 2',
- field: 'val_op2_str',
- id: 'wbsListValOp2',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Gestionaire',
- field: 'gestionaire_str',
- id: 'wbsListGestion',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- }
- ]
- },
- {
- id: 'columnsLastModification',
- text: 'Last modification',
- children: [
- {
- enableCellContextMenu: false,
- editor: false,
- text: 'Name',
- field: 'lm_name',
- id: 'wbsListLmName',
- renderer: (text) => {
- return text.value ? `${text.value}` : '';
- },
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- autoComplete: 'new-password'
- }
- }
- },
- {
- enableCellContextMenu: false,
- editor: false,
- type: 'date',
- format: 'DD/MM/YYYY HH:mm',
- text: 'Date',
- field: 'lm_date',
- id: 'wbsListLmDate',
- groupable: false,
- sortable: true,
- filterable: {
- filterField: {
- type: 'date',
- format: 'DD/MM/YYYY',
- placeholder: 'dd/mm/yyyy'
- },
- filterFn: ({ record, value }) => {
- if (record.data.lm_date) {
- const date = new Date(record.data.lm_date);
- return (
- date.setHours(0, 0, 0, 0) === new Date(value).getTime()
- );
- } else {
- return false;
- }
- }
- }
- }
- ]
- }
- ],
- features: {
- sort: true,
- filterBar: true,
- cellTooltip: {
- hoverDelay: 500,
- hideDelay: 0
- },
- headerMenu: { items: { saveColumns: null, resetColumns: null } },
- search: true
- },
- rowHeight: 30
- }; // eo config
- this.applyDefaultConfig(config);
- this.gridName = 'LISTWBSGRID';
- this.handleDefaultColumnsState(config);
- this.grid = new Grid(config);
- this.applySchedulerLocale(this.i18NextService.language);
- this.grid.mask('Loading...');
- this.handleGridState();
- // free search
- this.makeFreeSearch('freesearchlistwbs');
- // select another wbs in grid
- this.grid.addListener({
- selectionchange: () => {
- if (this.grid.selectedRecord) {
- this.wbsService.updateCurrentWbs(this.grid.selectedRecord);
- this.wbsComponent.selectedWbs = this.grid.selectedRecord;
- }
- }
- });
- // double click on row link to the edition of the selected object
- this.grid.addListener({
- celldblclick: () => {
- this.wbsService.updateCurrentWbs(this.grid.selectedRecord);
- this.router.navigateByUrl('/wbs/editwbs');
- }
- });
- // default filter
- this.grid.store.filter({
- id: 'showactivewbs',
- filterBy: (wbs) => wbs.wbs_status_id !== null && wbs.wbs_status_id === 0
- });
- this.subscription = this.wbsService.wbsList$.subscribe((wbsList) => {
- this.wbsList = wbsList;
- this.grid.unmask();
- }
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement