-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rename settings-i18n to view-settings
- Loading branch information
Showing
3 changed files
with
67 additions
and
38 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { computed } from 'vue' | ||
import { useI18n } from 'vue-i18n' | ||
const SORT_ORDER_KEY = Object.freeze({ | ||
ASC: 'asc', | ||
DESC: 'desc' | ||
}) | ||
const SORT_TYPE_KEY = Object.freeze({ | ||
DEFAULT: 'default', | ||
ALPHA: 'alpha', | ||
NUMBER: 'number', | ||
QUANTITY: 'quantity', | ||
DATE: 'date' | ||
}) | ||
|
||
export function useViewSettings() { | ||
const { t } = useI18n() | ||
const sortByLabel = computed(() => t('viewSettings.sortBy.label')) | ||
const visiblePropertiesLabel = computed(() => t('viewSettings.properties')) | ||
|
||
function tSortByOption(name, order = SORT_ORDER_KEY.ASC, type = SORT_TYPE_KEY.DEFAULT) { | ||
return computed(() => | ||
t(`viewSettings.sortBy.format`, { | ||
name: t(`viewSettings.options.${name}`), | ||
order: t(`viewSettings.order.${type}.${order}`) | ||
}) | ||
) | ||
} | ||
const tLayout = { | ||
label: computed((_) => t('viewSettings.view.label')), | ||
grid: computed((_) => t('viewSettings.view.grid')), | ||
table: computed((_) => t('viewSettings.view.table')) | ||
} | ||
const perPageLabel = (titleKey) => computed((_) => t('viewSettings.perPage', { title: t(titleKey) })) | ||
return { SORT_ORDER_KEY, SORT_TYPE_KEY, tSortByOption, sortByLabel, visiblePropertiesLabel, tLayout, perPageLabel } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters