diff --git a/src/i18n/en-ca/index.ts b/src/i18n/en-ca/index.ts index 5244e35..70e9afa 100644 --- a/src/i18n/en-ca/index.ts +++ b/src/i18n/en-ca/index.ts @@ -9,6 +9,7 @@ export default { role: "Role", supervisor: "Supervisor", company: "Company", + is_supervisor: "is a supervisor", }, }, @@ -36,7 +37,7 @@ export default { usage_description: "You can use roles to enable preset modules, add or remove modules individually, or both", }, filter: { - show_terminated: "Show inactive employees", + hide_terminated: "Hide inactive employees", sort_by_tags: "sort by tags", }, }, diff --git a/src/i18n/fr-ca/index.ts b/src/i18n/fr-ca/index.ts index 541ce21..9e94c73 100644 --- a/src/i18n/fr-ca/index.ts +++ b/src/i18n/fr-ca/index.ts @@ -9,6 +9,7 @@ export default { role: "rôle", supervisor: "superviseur", company: "Compagnie", + is_supervisor: "est un superviseur", }, }, @@ -36,7 +37,7 @@ export default { usage_description: "Vous pouvez utiliser les rôles pour sélectionner des modules prédéfinis, enlever ou ajouter des modules individuellement, ou les deux", }, filter: { - show_terminated: "Afficher les employés inactifs", + hide_terminated: "Cacher les employés inactifs", sort_by_tags: "filtrer par identifiants", }, }, diff --git a/src/modules/employee-list/components/employee-list-table.vue b/src/modules/employee-list/components/employee-list-table.vue index 96ed3cb..2b04a28 100644 --- a/src/modules/employee-list/components/employee-list-table.vue +++ b/src/modules/employee-list/components/employee-list-table.vue @@ -5,11 +5,12 @@ import EmployeeListTableItem from 'src/modules/employee-list/components/employee-list-table-item.vue'; import { onMounted, ref } from 'vue'; + import { date, type QTableColumn } from 'quasar'; import { useUiStore } from 'src/stores/ui-store'; import { useEmployeeStore } from 'src/stores/employee-store'; import { useTimesheetStore } from 'src/stores/timesheet-store'; import { useEmployeeListApi } from 'src/modules/employee-list/composables/use-employee-api'; - import { employee_list_columns } from 'src/modules/employee-list/models/employee-profile.models'; + import { employee_list_columns, type EmployeeProfile, type EmployeeListFilters } from 'src/modules/employee-list/models/employee-profile.models'; const employee_list_api = useEmployeeListApi(); const employee_store = useEmployeeStore(); @@ -17,7 +18,46 @@ const ui_store = useUiStore(); const is_loading_list = ref(true); - const filter = ref(""); + const filters = ref({ + search_bar_string: '', + hide_inactive_users: true, + }); + + const filterEmployeeRows = ( + rows: readonly EmployeeProfile[], + terms: EmployeeListFilters, + _cols: readonly QTableColumn[], + _getCellValue: (col: QTableColumn, row: EmployeeProfile) => unknown + ): EmployeeProfile[] => { + let active_rows: EmployeeProfile[] = Array.from(rows); + console.log('active rows at start: ', active_rows); + + if (terms.hide_inactive_users === true) { + active_rows = active_rows.filter(row => + row.last_work_day === null + // { + // if (row.last_work_day === null) return true; + + // const inactive_date = date.extractDate(row.last_work_day!, 'YYYY-MM-DD'); + // const inactive_date_limit = new Date(); + // inactive_date_limit.setDate(inactive_date.getDate() + 14) + + // return inactive_date_limit > inactive_date + // } + ); + } + + let filtered_rows: EmployeeProfile[] = Array.from(active_rows); + + if (terms.search_bar_string.length > 0) { + console.log('more filtering!!') + const search_terms = terms.search_bar_string.split(','); + + filtered_rows = active_rows.filter(row => Object.values(row).some(value => search_terms.includes(value))); + }; + + return filtered_rows; + } onMounted(async () => { is_loading_list.value = true; @@ -38,7 +78,8 @@ :columns="employee_list_columns" row-key="name" :rows-per-page-options="[0]" - :filter="filter" + :filter="filters" + :filter-method="filterEmployeeRows" class="bg-transparent no-shadow sticky-header-table" :style="$q.screen.lt.md ? '' : 'width: 80vw;'" :table-class="$q.dark.isActive ? 'q-py-none q-mx-md rounded-10 bg-dark shadow-10' : 'q-py-none q-mx-md rounded-10 bg-white shadow-10'" @@ -51,7 +92,6 @@ :no-results-label="$t('shared.error.no_search_results')" :loading-label="$t('shared.label.loading')" :visible-columns="['first_name', 'email', 'company', 'supervisor_full_name', 'company_name', 'job_title']" - @row-click="() => console.log('click!')" >