|
1 | 1 | <script lang="ts" setup>
|
2 |
| -import { NFlex } from 'naive-ui'; |
| 2 | +import { NSelect, NSwitch } from 'naive-ui'; |
3 | 3 |
|
4 |
| -import { useExtensionSettingsStore } from '~/stores/settings/extension.store'; |
| 4 | +import { ref } from 'vue'; |
5 | 5 |
|
6 |
| -const { progressTab } = useExtensionSettingsStore(); |
| 6 | +import SettingsFormItem from '~/components/views/settings/SettingsFormItem.vue'; |
| 7 | +import { pageSizeOptions } from '~/models/page-size.model'; |
| 8 | +import { Route } from '~/router'; |
| 9 | +import { useHistoryStoreRefs } from '~/stores/data/history.store'; |
| 10 | +import { useListStoreRefs } from '~/stores/data/list.store'; |
| 11 | +import { useSearchStoreRefs } from '~/stores/data/search.store'; |
| 12 | +import { |
| 13 | + useExtensionSettingsStore, |
| 14 | + useExtensionSettingsStoreRefs, |
| 15 | +} from '~/stores/settings/extension.store'; |
| 16 | +import { useI18n } from '~/utils'; |
| 17 | +
|
| 18 | +const i18n = useI18n('settings', 'tabs'); |
| 19 | +
|
| 20 | +const { enabledTabs, restoreRoute, routeDictionary } = useExtensionSettingsStoreRefs(); |
| 21 | +const { toggleTab } = useExtensionSettingsStore(); |
| 22 | +
|
| 23 | +const { pageSize: historyPageSize } = useHistoryStoreRefs(); |
| 24 | +const { pageSize: listPageSize } = useListStoreRefs(); |
| 25 | +const { pageSize: searchPageSize } = useSearchStoreRefs(); |
| 26 | +
|
| 27 | +const container = ref(); |
7 | 28 | </script>
|
8 | 29 |
|
9 | 30 | <template>
|
10 |
| - <NFlex> This is the tabs card : {{ progressTab }} </NFlex> |
| 31 | + <div ref="container" class="tabs-container"> |
| 32 | + <!-- Restore tab --> |
| 33 | + <SettingsFormItem :label="i18n('label_restore_tab')"> |
| 34 | + <NSwitch v-model:value="restoreRoute" class="form-switch"> |
| 35 | + <template #checked>{{ i18n('on', 'common', 'button') }}</template> |
| 36 | + <template #unchecked>{{ i18n('off', 'common', 'button') }}</template> |
| 37 | + </NSwitch> |
| 38 | + </SettingsFormItem> |
| 39 | + |
| 40 | + <!-- Enable tabs --> |
| 41 | + <SettingsFormItem |
| 42 | + v-for="[route, state] of enabledTabs" |
| 43 | + :key="route" |
| 44 | + :label="i18n(`label_route_${ route }`)" |
| 45 | + :warning=" |
| 46 | + state && route === Route.Progress |
| 47 | + ? i18n(`label_route_${ route }_warning`) |
| 48 | + : undefined |
| 49 | + " |
| 50 | + > |
| 51 | + <NSwitch :value="state" class="form-switch" @click="toggleTab(route)"> |
| 52 | + <template #checked>{{ i18n('on', 'common', 'button') }}</template> |
| 53 | + <template #unchecked>{{ i18n('off', 'common', 'button') }}</template> |
| 54 | + </NSwitch> |
| 55 | + </SettingsFormItem> |
| 56 | + |
| 57 | + <!-- Page Size --> |
| 58 | + <SettingsFormItem :label="i18n('label_history_page_size')"> |
| 59 | + <NSelect |
| 60 | + v-model:value="historyPageSize" |
| 61 | + :disabled="!routeDictionary.history" |
| 62 | + class="form-select" |
| 63 | + :to="container" |
| 64 | + :options="pageSizeOptions" |
| 65 | + /> |
| 66 | + </SettingsFormItem> |
| 67 | + |
| 68 | + <SettingsFormItem :label="i18n('label_list_page_size')"> |
| 69 | + <NSelect |
| 70 | + v-model:value="listPageSize" |
| 71 | + :disabled="!routeDictionary.watchlist" |
| 72 | + class="form-select" |
| 73 | + :to="container" |
| 74 | + :options="pageSizeOptions" |
| 75 | + /> |
| 76 | + </SettingsFormItem> |
| 77 | + |
| 78 | + <SettingsFormItem :label="i18n('label_search_page_size')"> |
| 79 | + <NSelect |
| 80 | + v-model:value="searchPageSize" |
| 81 | + :disabled="!routeDictionary.search" |
| 82 | + class="form-select" |
| 83 | + :to="container" |
| 84 | + :options="pageSizeOptions" |
| 85 | + /> |
| 86 | + </SettingsFormItem> |
| 87 | + </div> |
11 | 88 | </template>
|
| 89 | + |
| 90 | +<style lang="scss" scoped> |
| 91 | +.tabs-container { |
| 92 | + display: flex; |
| 93 | + flex-direction: column; |
| 94 | + gap: 1.5rem; |
| 95 | +
|
| 96 | + .form-switch { |
| 97 | + display: flex; |
| 98 | + flex: 1 1 auto; |
| 99 | + justify-content: flex-end; |
| 100 | + min-width: 4rem; |
| 101 | + padding: 0 0.5rem; |
| 102 | + font-size: 0.75rem; |
| 103 | + } |
| 104 | +} |
| 105 | +
|
| 106 | +.form-select { |
| 107 | + min-width: 5.5rem; |
| 108 | +} |
| 109 | +</style> |
0 commit comments