getBlastHistoryGridColumns()

in client/client/app/components/ngbBlastSearchPanel/ngbBlastHistory/ngbBlastHistoryTable.service.js [169:277]


    getBlastHistoryGridColumns() {
        const actionsCell = require('./ngbBlastHistoryTable_actions.tpl.html');
        const headerCells = require('./ngbBlastHistoryTable_header.tpl.html');

        const result = [];
        const columnsList = this.blastHistoryColumns;
        for (let i = 0; i < columnsList.length; i++) {
            let sortDirection = 0;
            let sortingPriority = 0;
            let columnSettings = null;
            const column = columnsList[i];
            if (this.orderByHistory) {
                const fieldName = (DEFAULT_ORDERBY_HISTORY_COLUMNS[column] || column);
                const [columnSortingConfiguration] = this.orderByHistory.filter(o => o.field === fieldName);
                if (columnSortingConfiguration) {
                    sortingPriority = this.orderByHistory.indexOf(columnSortingConfiguration);
                    sortDirection = columnSortingConfiguration.ascending ? 'asc' : 'desc';
                }
            }
            switch (column) {
                case 'id': {
                    columnSettings = {
                        cellTemplate: `<div class="ui-grid-cell-contents"
                                        ng-class="row.entity.isResult
                                        ? 'search-result-link'
                                        : 'search-result-not-link'"
                                       >{{row.entity.id}}</div>`,
                        enableHiding: false,
                        field: 'id',
                        headerCellTemplate: headerCells,
                        minWidth: 60,
                        maxWidth: 80,
                        name: this.historyColumnTitleMap[column]
                    };
                    break;
                }
                case 'currentState': {
                    columnSettings = {
                        cellTemplate: `<div class="ui-grid-cell-contents">
                                        {{grid.appScope.$ctrl.statusViews[row.entity.currentState]}}
                                       </div>`,
                        enableHiding: false,
                        field: 'currentState',
                        headerCellTemplate: headerCells,
                        minWidth: 40,
                        name: this.historyColumnTitleMap[column]
                    };
                    break;
                }
                case 'submitted': {
                    columnSettings = {
                        cellFilter: 'date:"short"',
                        enableHiding: false,
                        field: 'submitted',
                        headerCellTemplate: headerCells,
                        minWidth: 40,
                        name: this.historyColumnTitleMap[column]
                    };
                    break;
                }
                case 'duration': {
                    columnSettings = {
                        cellFilter: 'duration:this',
                        enableHiding: false,
                        enableSorting: false,
                        enableColumnMenu: false,
                        field: 'duration',
                        headerCellTemplate: headerCells,
                        minWidth: 40,
                        name: this.historyColumnTitleMap[column]
                    };
                    break;
                }
                case 'actions': {
                    columnSettings = {
                        cellTemplate: actionsCell,
                        enableSorting: false,
                        field: 'actions',
                        headerCellTemplate: '<span></span>',
                        maxWidth: 70,
                        minWidth: 60,
                        name: this.historyColumnTitleMap[column]
                    };
                    break;
                }
                default: {
                    columnSettings = {
                        enableHiding: false,
                        field: column,
                        headerCellTemplate: headerCells,
                        minWidth: 40,
                        name: this.historyColumnTitleMap[column],
                        width: '*'
                    };
                    break;
                }
            }
            if (columnSettings) {
                if (sortDirection) {
                    columnSettings.sort = {
                        direction: sortDirection,
                        priority: sortingPriority
                    };
                }
                result.push(columnSettings);
            }
        }
        return result;
    }