Web: use title case in status indicator

This commit is contained in:
Sybren A. Stüvel 2022-05-06 12:14:28 +02:00
parent 1cf3cb3344
commit cfab4f5b76
3 changed files with 13 additions and 2 deletions

View File

@ -11,6 +11,7 @@
import { TabulatorFull as Tabulator } from 'tabulator-tables';
import * as datetime from "@/datetime";
import * as API from '@/manager-api'
import { toTitleCase } from '@/strings';
import { apiClient } from '@/stores/api-query-count';
import JobActionsBar from '@/components/JobActionsBar.vue'
@ -29,7 +30,8 @@ export default {
title: 'Status', field: 'status', sorter: 'string',
formatter(cell, formatterParams) { // eslint-disable-line no-unused-vars
const cellValue = cell.getData();
return '<span title="' + cellValue.status + '" class="indicator status-' + cellValue.status + '"></span>';
const label = toTitleCase(cellValue.status);
return `<span title="${label}" class="indicator status-${cellValue.status}"></span>`;
}
},
{ title: 'Name', field: 'name', sorter: 'string' },

View File

@ -9,6 +9,7 @@
import { TabulatorFull as Tabulator } from 'tabulator-tables';
import * as datetime from "@/datetime";
import * as API from '@/manager-api'
import { toTitleCase } from '@/strings';
import { apiClient } from '@/stores/api-query-count';
import { useTasks } from '@/stores/tasks';
@ -31,7 +32,8 @@ export default {
title: 'Status', field: 'status', sorter: 'string',
formatter(cell, formatterParams) { // eslint-disable-line no-unused-vars
const cellValue = cell.getData();
return '<span title="' + cellValue.status + '" class="indicator status-' + cellValue.status + '"></span>';
const label = toTitleCase(cellValue.status);
return `<span title="${label}" class="indicator status-${cellValue.status}"></span>`;
}
},
{ title: 'Name', field: 'name', sorter: 'string' },

7
web/app/src/strings.js Normal file
View File

@ -0,0 +1,7 @@
export function toTitleCase(str) {
return str
.toLowerCase()
.split(' ')
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
}