Skip to content

Commit

Permalink
refactor(PWA): Handle tab buttons translations
Browse files Browse the repository at this point in the history
  • Loading branch information
cogk committed Oct 17, 2024
1 parent 95a0dee commit 1ba80e4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
8 changes: 5 additions & 3 deletions frontend/src/components/ListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<TabButtons
v-if="props.tabButtons"
class="mt-5"
:buttons="[{ label: tabButtons[0] }, { label: tabButtons[1] }]"
:buttons="props.tabButtons"
v-model="activeTab"
/>
Expand Down Expand Up @@ -186,6 +186,8 @@ const props = defineProps({
},
})
const getButtonKey = (tab) => tab?.key ?? tab
const listItemComponent = {
"Employee Checkin": markRaw(EmployeeCheckinItem),
"Attendance Request": markRaw(AttendanceRequestItem),
Expand All @@ -201,7 +203,7 @@ const dayjs = inject("$dayjs")
const socket = inject("$socket")
const employee = inject("$employee")
const filterMap = reactive({})
const activeTab = ref(props.tabButtons ? props.tabButtons[0] : undefined)
const activeTab = ref(props.tabButtons ? getButtonKey(props.tabButtons[0]) : undefined)
const areFiltersApplied = ref(false)
const appliedFilters = ref([])
const workflowStateField = ref(null)
Expand All @@ -221,7 +223,7 @@ const listOptions = ref({
// computed properties
const isTeamRequest = computed(() => {
return props.tabButtons && activeTab.value === props.tabButtons[1]
return props.tabButtons && activeTab.value === getButtonKey(props.tabButtons[1])
})
const formViewRoute = computed(() => {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/RequestPanel.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="w-full">
<TabButtons
:buttons="[{ label: 'My Requests' }, { label: 'Team Requests' }]"
:buttons="TAB_BUTTONS"
v-model="activeTab"
/>
<RequestList v-if="activeTab == 'My Requests'" :items="myRequests" />
Expand Down Expand Up @@ -33,6 +33,8 @@ import { useListUpdate } from "@/composables/realtime"
const activeTab = ref("My Requests")
const socket = inject("$socket")
const TAB_BUTTONS = ["My Requests", "Team Requests"] // __("My Requests"), __("Team Requests")
const myRequests = computed(() =>
updateRequestDetails(myLeaves, myClaims, myShiftRequests, myAttendanceRequests)
)
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/TabButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
<div class="flex p-1 bg-gray-200 rounded">
<button
v-for="button in buttons"
:key="button.label"
:key="button.key ?? button.label ?? button"
class="px-8 py-2.5 transition-all rounded-[7px] flex-auto font-medium text-base"
:class="
modelValue === button.label
modelValue === (button.key ?? button.label ?? button)
? 'bg-white drop-shadow text-gray-900'
: 'text-gray-600'
"
@click="$emit('update:modelValue', button.label)"
@click="$emit('update:modelValue', button.key ?? button.label ?? button)"
>
{{ __(button.label) }}
{{ button.label ?? __(button) }}
</button>
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/employee_advance/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { IonPage } from "@ionic/vue"
import ListView from "@/components/ListView.vue"
const TAB_BUTTONS = ["My Advances", "Team Advances"]
const TAB_BUTTONS = ["My Advances", "Team Advances"] // __("My Advances"), __("Team Advances")
const EMPLOYEE_ADVANCE_FIELDS = [
"name",
"employee",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/expense_claim/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import { IonPage } from "@ionic/vue"
import ListView from "@/components/ListView.vue"
const TAB_BUTTONS = ["My Claims", "Team Claims"]
const TAB_BUTTONS = ["My Claims", "Team Claims"] // __("My Claims"), __("Team Claims")
const EXPENSE_CLAIM_FIELDS = [
"`tabExpense Claim`.name",
"`tabExpense Claim`.employee",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/leave/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { IonPage } from "@ionic/vue"
import ListView from "@/components/ListView.vue"
const TAB_BUTTONS = ["My Leaves", "Team Leaves"]
const TAB_BUTTONS = ["My Leaves", "Team Leaves"] // __("My Leaves"), __("Team Leaves")
const LEAVE_FIELDS = [
"name",
"employee",
Expand Down

0 comments on commit 1ba80e4

Please sign in to comment.