getStructureTableGridColumns()

in client/client/app/components/ngbTargetPanel/ngbIdentificationsTab/ngbStructurePanel/ngbStructureTable/ngbStructureTable.controller.js [158:264]


    getStructureTableGridColumns() {
        this.gridOptions.columnDefs = [];
        const headerCells = require('./ngbStructureTable_header.tpl.html');
        const linkCell = require('./ngbStructureTable_linkCell.tpl.html');

        const result = [];
        const columnsList = this.ngbStructurePanelService.columnsList;
        for (let i = 0; i < columnsList.length; i++) {
            let columnSettings = null;
            const column = columnsList[i];
            columnSettings = {
                name: column,
                enableHiding: false,
                enableColumnMenu: false,
                enableSorting: false,
                enableFiltering: false,
                field: column,
                headerCellTemplate: headerCells,
                headerTooltip: column,
                minWidth: 40,
                width: '*'
            };
            switch (column) {
                case 'id':
                    if (this.sourceModel === this.sourceOptions.LOCAL_FILES) {
                        columnSettings = {
                            ...columnSettings,
                            enableFiltering: true,
                            enableSorting: true,
                            enableColumnMenu: true,
                            cellTemplate: linkCell
                        };
                    }
                    if (this.sourceModel === this.sourceOptions.PROTEIN_DATA_BANK) {
                        columnSettings = {
                            ...columnSettings,
                            enableFiltering: true,
                            enableSorting: true,
                            cellTemplate: linkCell
                        };
                    }
                    break;
                case 'name':
                    if (this.sourceModel === this.sourceOptions.LOCAL_FILES) {
                        columnSettings = {
                            ...columnSettings,
                            enableFiltering: true,
                            enableSorting: true,
                            enableColumnMenu: true,
                            cellTemplate: `<div class="ui-grid-cell-contents ng-binding ng-scope">
                                <md-tooltip>{{row.entity[col.field]}}</md-tooltip>
                                {{row.entity[col.field]}}
                            </div>`
                        };
                    }
                    if (this.sourceModel === this.sourceOptions.PROTEIN_DATA_BANK) {
                        columnSettings = {
                            ...columnSettings,
                            enableFiltering: true,
                            cellTemplate: `<div class="ui-grid-cell-contents ng-binding ng-scope">
                                <md-tooltip>{{row.entity[col.field]}}</md-tooltip>
                                {{row.entity[col.field]}}
                            </div>`
                        };
                    }
                    break;
                case 'method':
                    columnSettings = {
                        ...columnSettings,
                        cellTemplate: `<div class="ui-grid-cell-contents ng-binding ng-scope">
                            <md-tooltip>{{row.entity[col.field]}}</md-tooltip>
                            {{row.entity[col.field]}}
                        </div>`
                    };
                    break;
                case 'owner':
                    columnSettings = {
                        ...columnSettings,
                        enableFiltering: true,
                        enableSorting: true,
                        enableColumnMenu: true,
                    };
                    break;
                case 'chains':
                    columnSettings = {
                        ...columnSettings,
                        width: 80
                    };
                    break;
                case 'resolution':
                    columnSettings = {
                        ...columnSettings,
                        enableSorting: true,
                    };
                    break;
                default:
                    columnSettings = {
                        ...columnSettings,
                    };
                    break;
            }
            if (columnSettings) {
                result.push(columnSettings);
            }
        }
        return result;
    }