From 9d9b8822a3f37267d82592e5c968fe5bb88a5828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Wed, 2 Feb 2022 09:38:45 +0100 Subject: [PATCH 001/204] Basic languages crud --- src/components/modules/languages/Form.vue | 85 +++++++++++ src/consts/permissions.ts | 2 + src/enums/permissions.ts | 7 + src/interfaces/Language.ts | 13 ++ src/interfaces/Permissions.ts | 2 + src/locales/en.json | 3 +- src/locales/pl.json | 3 +- src/router.ts | 10 ++ src/store/index.ts | 2 + src/store/languages.ts | 9 ++ src/views/languages/index.vue | 170 ++++++++++++++++++++++ src/views/settings/Index.vue | 1 + 12 files changed, 305 insertions(+), 2 deletions(-) create mode 100644 src/components/modules/languages/Form.vue create mode 100644 src/interfaces/Language.ts create mode 100644 src/store/languages.ts create mode 100644 src/views/languages/index.vue diff --git a/src/components/modules/languages/Form.vue b/src/components/modules/languages/Form.vue new file mode 100644 index 00000000..b4312206 --- /dev/null +++ b/src/components/modules/languages/Form.vue @@ -0,0 +1,85 @@ + + + +{ + "pl": { + "form": { + "iso": "Kod ISO", + "default": "Język domyślny", + "hidden": "Ukryty" + } + }, + "en": { + "form": { + "iso": "ISO code", + "default": "Default language", + "hidden": "Hidden" + } + } +} + + + diff --git a/src/consts/permissions.ts b/src/consts/permissions.ts index 5c80bac3..07f125b8 100644 --- a/src/consts/permissions.ts +++ b/src/consts/permissions.ts @@ -26,6 +26,7 @@ import { RolesPermission, SeoPermission, WebhooksPermission, + LanguagesPermission, } from '@/enums/permissions' export const PERMISSIONS_TREE = { @@ -55,6 +56,7 @@ export const PERMISSIONS_TREE = { Roles: RolesPermission, Seo: SeoPermission, Webhooks: WebhooksPermission, + Languages: LanguagesPermission, } export const ALL_PERMISSIONS: Permission[] = Object.values(PERMISSIONS_TREE) diff --git a/src/enums/permissions.ts b/src/enums/permissions.ts index ebbd5b27..2259b824 100644 --- a/src/enums/permissions.ts +++ b/src/enums/permissions.ts @@ -175,3 +175,10 @@ export enum WebhooksPermission { Edit = 'webhooks.edit', Remove = 'webhooks.remove', } + +export enum LanguagesPermission { + ShowHidden = 'languages.show_hidden', + Add = 'languages.add', + Edit = 'languages.edit', + Remove = 'languages.remove', +} diff --git a/src/interfaces/Language.ts b/src/interfaces/Language.ts new file mode 100644 index 00000000..38138fc8 --- /dev/null +++ b/src/interfaces/Language.ts @@ -0,0 +1,13 @@ +import { UUID } from './UUID' + +export interface Language { + id: UUID + iso: string // de, fr-CA, de-DE-1996 + name: string + default: boolean + hidden: boolean +} + +export interface LanguageDto extends Omit { + id?: UUID +} diff --git a/src/interfaces/Permissions.ts b/src/interfaces/Permissions.ts index 610ef90b..0b65b81d 100644 --- a/src/interfaces/Permissions.ts +++ b/src/interfaces/Permissions.ts @@ -25,6 +25,7 @@ import { RolesPermission, SeoPermission, WebhooksPermission, + LanguagesPermission, } from '@/enums/permissions' export type Permission = @@ -53,6 +54,7 @@ export type Permission = | RolesPermission | WebhooksPermission | SeoPermission + | LanguagesPermission export interface PermissionObject { id: UUID diff --git a/src/locales/en.json b/src/locales/en.json index aa476d00..8fa1467e 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -45,7 +45,8 @@ "users": "Users", "roles": "Roles", "apps": "Apps", - "webhooks": "Webhooks" + "webhooks": "Webhooks", + "languages": "Languages" }, "schemaTypes": { diff --git a/src/locales/pl.json b/src/locales/pl.json index ba4507c0..1ecc17c1 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -45,7 +45,8 @@ "users": "Użytkownicy", "roles": "Role", "apps": "Aplikacje", - "webhooks": "Webhooki" + "webhooks": "Webhooki", + "languages": "Języki" }, "schemaTypes": { diff --git a/src/router.ts b/src/router.ts index 679fa168..356750a2 100644 --- a/src/router.ts +++ b/src/router.ts @@ -260,6 +260,16 @@ const router = new VueRouter({ permissions: [Permissions.Seo.Show], }, }, + { + path: '/settings/languages', + name: 'Languages', + component: () => import('./views/languages/index.vue'), + meta: { + requiresAuth: true, + // all authenticated users can show languages + // permissions: [Permissions.Languages.Show], + }, + }, { path: '/settings/roles', name: 'Roles', diff --git a/src/store/index.ts b/src/store/index.ts index a9b92d46..1e5cb321 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -27,6 +27,7 @@ import { webhooks } from './webhooks' import { discounts } from './discounts' import { tags } from './tags' import { productSets } from './productSets' +import { languages } from './languages' Vue.use(Vuex) @@ -87,6 +88,7 @@ const storeModules = { webhooks, tags, productSets, + languages, } const storePattern = { diff --git a/src/store/languages.ts b/src/store/languages.ts new file mode 100644 index 00000000..6a74d2e7 --- /dev/null +++ b/src/store/languages.ts @@ -0,0 +1,9 @@ +import { createVuexCRUD } from './generator' +import { Language, LanguageDto } from '@/interfaces/Language' + +export const languages = createVuexCRUD()('languages', { + state: {}, + getters: {}, + mutations: {}, + actions: {}, +}) diff --git a/src/views/languages/index.vue b/src/views/languages/index.vue new file mode 100644 index 00000000..3b89e06a --- /dev/null +++ b/src/views/languages/index.vue @@ -0,0 +1,170 @@ + + + +{ + "pl": { + "title": "Języki", + "add": "Dodaj język", + "editTitle": "Edycja jęzka", + "newTitle": "Nowy język", + "deleteText": "Czy na pewno chcesz usunąć ten język?", + "form": { + "iso": "Kod ISO", + "default": "Język domyślny", + "hidden": "Ukryty" + } + }, + "en": { + "title": "Languages", + "add": "Add language", + "editTitle": "Edit language", + "newTitle": "New language", + "deleteText": "Are you sure you want to delete this language?", + "form": { + "iso": "ISO code", + "default": "Default language", + "hidden": "Hidden" + } + } +} + + + diff --git a/src/views/settings/Index.vue b/src/views/settings/Index.vue index 92c8eb22..52186009 100644 --- a/src/views/settings/Index.vue +++ b/src/views/settings/Index.vue @@ -11,6 +11,7 @@ url="/pages" icon="bx bxs-copy-alt" /> +

{{ $t('models.products') }} From b29645bc80aa8c0c7115f2b384761909b78c7632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Wed, 2 Feb 2022 11:03:13 +0100 Subject: [PATCH 002/204] Improved crud --- src/components/BooleanTagValue.vue | 37 ++++++++++++++ src/components/modules/languages/Form.vue | 22 ++++++--- src/views/languages/index.vue | 59 +++++++++++++++++------ 3 files changed, 95 insertions(+), 23 deletions(-) create mode 100644 src/components/BooleanTagValue.vue diff --git a/src/components/BooleanTagValue.vue b/src/components/BooleanTagValue.vue new file mode 100644 index 00000000..f375a366 --- /dev/null +++ b/src/components/BooleanTagValue.vue @@ -0,0 +1,37 @@ + + + diff --git a/src/components/modules/languages/Form.vue b/src/components/modules/languages/Form.vue index b4312206..a3ff1a2d 100644 --- a/src/components/modules/languages/Form.vue +++ b/src/components/modules/languages/Form.vue @@ -21,12 +21,15 @@ :label="$t('form.hidden')" /> - + + + @@ -37,19 +40,22 @@ "iso": "Kod ISO", "default": "Język domyślny", "hidden": "Ukryty" - } + }, + "changeDefaultTooltip": "TODO" }, "en": { "form": { "iso": "ISO code", "default": "Default language", "hidden": "Hidden" - } + }, + "changeDefaultTooltip": "TODO" } } diff --git a/src/views/languages/index.vue b/src/views/languages/index.vue index 92b996bd..b3f11b14 100644 --- a/src/views/languages/index.vue +++ b/src/views/languages/index.vue @@ -20,10 +20,10 @@ {{ value }} @@ -112,7 +112,6 @@ import { UUID } from '@/interfaces/UUID' import { TableConfig } from '@/interfaces/CmsTable' import { Language, LanguageDto } from '@/interfaces/Language' import CmsTableRow from '@/components/cms/CmsTableRow.vue' -import BooleanTagValue from '@/components/BooleanTagValue.vue' const EMPTY_FORM: LanguageDto = { name: '', @@ -131,7 +130,6 @@ export default Vue.extend({ PaginatedList, LanguagesForm, CmsTableRow, - BooleanTagValue, }, beforeRouteLeave(_to, _from, next) { if (this.isModalActive) { From 5fb04b8cb5f0542c62e669196ac9c7226ce5b255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Tue, 22 Feb 2022 10:56:32 +0100 Subject: [PATCH 005/204] Default language cannot be hidden validation --- src/components/modules/languages/Form.vue | 53 +++++++++++++++-------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/src/components/modules/languages/Form.vue b/src/components/modules/languages/Form.vue index a3ff1a2d..703a5598 100644 --- a/src/components/modules/languages/Form.vue +++ b/src/components/modules/languages/Form.vue @@ -14,22 +14,25 @@ :label="$t('form.iso')" /> - +
+ + + - - - + + + +
@@ -41,7 +44,8 @@ "default": "Język domyślny", "hidden": "Ukryty" }, - "changeDefaultTooltip": "TODO" + "changeDefaultTooltip": "Tylko jeden język jest domyślny. W przypadku gdy użytkownik nie wybierze języka samodzielnie, treść zostanie wyświetlona w języku domyślnym.", + "hiddenWhenDefaultTooltip": "Język domyślny nie może być ukryty." }, "en": { "form": { @@ -49,13 +53,13 @@ "default": "Default language", "hidden": "Hidden" }, - "changeDefaultTooltip": "TODO" + "changeDefaultTooltip": "Only one language is default. In case the user does not choose a language manually, the content will be displayed in the default language.", + "hiddenWhenDefaultTooltip": "The default language cannot be hidden." } } + + From 709ee3de4b649147e9ed0bf6aa1c29c101539e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Fri, 25 Feb 2022 14:06:16 +0100 Subject: [PATCH 006/204] Moved config properties to own store --- src/App.vue | 3 +- src/components/MediaElement.vue | 2 +- src/components/layout/CartItem.vue | 4 +- .../modules/productSets/SetProductsList.vue | 4 +- .../modules/products/ProductListItem.vue | 4 +- .../modules/products/ProductTile.vue | 4 +- src/components/root/Header.vue | 2 +- src/components/root/NavStoreLogo.vue | 4 +- src/store/config.ts | 50 +++++++++++++++++++ src/store/index.ts | 19 ++----- src/views/Home.vue | 4 +- src/views/discounts/index.vue | 2 +- src/views/orders/Index.vue | 2 +- src/views/orders/view.vue | 4 +- src/views/settings/Settings.vue | 2 +- 15 files changed, 75 insertions(+), 35 deletions(-) create mode 100644 src/store/config.ts diff --git a/src/App.vue b/src/App.vue index c2cdd64a..5a6ce96e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -71,7 +71,8 @@ export default Vue.extend({ }, created() { initMicroApps() - this.$accessor.fetchEnv() + this.$accessor.config.fetchEnv() + // this.$accessor.config.initLanguages() if (this.$accessor.auth.isLogged) this.$accessor.auth.fetchProfile() // MicroFrontend Events Start diff --git a/src/components/MediaElement.vue b/src/components/MediaElement.vue index a74cc878..c216594c 100644 --- a/src/components/MediaElement.vue +++ b/src/components/MediaElement.vue @@ -47,7 +47,7 @@ export default Vue.extend({ return CdnMediaType }, objectFit(): string { - return +this.$accessor.env.dashboard_products_contain ? 'contain' : 'cover' + return +this.$accessor.config.env.dashboard_products_contain ? 'contain' : 'cover' }, }, }) diff --git a/src/components/layout/CartItem.vue b/src/components/layout/CartItem.vue index 76cbc57c..0f5b3f29 100644 --- a/src/components/layout/CartItem.vue +++ b/src/components/layout/CartItem.vue @@ -82,7 +82,7 @@ export default Vue.extend({ return this.item?.product?.cover?.url }, objectFit(): string { - return +this.$accessor.env.dashboard_products_contain ? 'contain' : 'cover' + return +this.$accessor.config.env.dashboard_products_contain ? 'contain' : 'cover' }, discountedPrice(): number { if (!this.discount) return this.item.price @@ -95,7 +95,7 @@ export default Vue.extend({ }, methods: { formatCurrency(amount: number) { - return formatCurrency(amount, this.$accessor.currency) + return formatCurrency(amount, this.$accessor.config.currency) }, }, }) diff --git a/src/components/modules/productSets/SetProductsList.vue b/src/components/modules/productSets/SetProductsList.vue index 88eea0d1..2ce99eb8 100644 --- a/src/components/modules/productSets/SetProductsList.vue +++ b/src/components/modules/productSets/SetProductsList.vue @@ -112,7 +112,7 @@ export default Vue.extend({ }), computed: { objectFit(): string { - return +this.$accessor.env.dashboard_products_contain ? 'contain' : 'cover' + return +this.$accessor.config.env.dashboard_products_contain ? 'contain' : 'cover' }, }, watch: { @@ -122,7 +122,7 @@ export default Vue.extend({ }, methods: { formatCurrency(amount: number) { - return formatCurrency(amount, this.$accessor.currency) + return formatCurrency(amount, this.$accessor.config.currency) }, addProduct(product: Product) { this.products.push(product) diff --git a/src/components/modules/products/ProductListItem.vue b/src/components/modules/products/ProductListItem.vue index ee950a85..dcebbefe 100644 --- a/src/components/modules/products/ProductListItem.vue +++ b/src/components/modules/products/ProductListItem.vue @@ -61,7 +61,7 @@ export default Vue.extend({ }, computed: { objectFit(): string { - return +this.$accessor.env.dashboard_products_contain ? 'contain' : 'cover' + return +this.$accessor.config.env.dashboard_products_contain ? 'contain' : 'cover' }, }, mounted() { @@ -69,7 +69,7 @@ export default Vue.extend({ }, methods: { formatCurrency(amount: number) { - return formatCurrency(amount, this.$accessor.currency) + return formatCurrency(amount, this.$accessor.config.currency) }, onClick() { // @ts-ignore diff --git a/src/components/modules/products/ProductTile.vue b/src/components/modules/products/ProductTile.vue index f9def104..07cd6356 100644 --- a/src/components/modules/products/ProductTile.vue +++ b/src/components/modules/products/ProductTile.vue @@ -46,7 +46,7 @@ export default Vue.extend({ }, computed: { objectFit(): string { - return +this.$accessor.env.dashboard_products_contain ? 'contain' : 'cover' + return +this.$accessor.config.env.dashboard_products_contain ? 'contain' : 'cover' }, }, mounted() { @@ -54,7 +54,7 @@ export default Vue.extend({ }, methods: { formatCurrency(amount: number) { - return formatCurrency(amount, this.$accessor.currency) + return formatCurrency(amount, this.$accessor.config.currency) }, onClick() { // @ts-ignore diff --git a/src/components/root/Header.vue b/src/components/root/Header.vue index 8d762055..86bdef5e 100644 --- a/src/components/root/Header.vue +++ b/src/components/root/Header.vue @@ -65,7 +65,7 @@ export default Vue.extend({ return !!this.$route.meta?.hiddenNav || false }, storeName(): string { - return this.$accessor.env.store_name + return this.$accessor.config.env.store_name }, returnUrl(): string | null { return this.$route.meta?.returnUrl || null diff --git a/src/components/root/NavStoreLogo.vue b/src/components/root/NavStoreLogo.vue index cabdf196..c848a5f4 100644 --- a/src/components/root/NavStoreLogo.vue +++ b/src/components/root/NavStoreLogo.vue @@ -59,10 +59,10 @@ export default Vue.extend({ }), computed: { storeName(): string { - return this.$accessor.env.store_name + return this.$accessor.config.env.store_name }, envStoreLogo(): string { - return this.$accessor.env[ENV_NAME] + return this.$accessor.config.env[ENV_NAME] }, canModify(): boolean { return this.$can(this.$p.Settings.Edit) diff --git a/src/store/config.ts b/src/store/config.ts new file mode 100644 index 00000000..bf3e960b --- /dev/null +++ b/src/store/config.ts @@ -0,0 +1,50 @@ +/* eslint-disable camelcase */ +import axios from 'axios' +import { actionTree, getterTree, mutationTree } from 'typed-vuex' + +// import { accessor } from './index' +import { getApiURL } from '@/utils/api' + +const state = () => ({ + currency: 'PLN', + apiLanguage: 'pl', + env: {} as Record, +}) + +const getters = getterTree(state, {}) + +const mutations = mutationTree(state, { + SET_ENV(state, newEnv: Record) { + state.env = newEnv + }, + SET_API_LANGUAGE(state, language: string) { + state.apiLanguage = language + }, +}) + +const actions = actionTree( + { state, getters, mutations }, + { + async fetchEnv({ commit }) { + // Fetch setting wtihout authorization, so it wont crash when auth is invalid + const { data } = await axios.get>(`${getApiURL()}/settings?array`) + commit('SET_ENV', data) + }, + + // async initLanguages({ commit }) { + // const languages = await accessor.languages.fetch() + // if (languages) { + // const defaultLang = languages.find((l) => l.default) + // if (defaultLang) commit('SET_API_LANGUAGE', defaultLang.iso) + // } + // }, + }, +) + +export const config = { + namespaced: true, + state, + getters, + mutations, + actions, +} diff --git a/src/store/index.ts b/src/store/index.ts index 1e5cb321..855c484b 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,12 +1,10 @@ import Vue from 'vue' import Vuex from 'vuex' import VuexPersistence from 'vuex-persist' -import axios from 'axios' import { useAccessor, getterTree, mutationTree, actionTree } from 'typed-vuex' -import { getApiURL } from '@/utils/api' - +import { config } from './config' import { auth } from './auth' import { globalSeo } from './globalSeo' import { users } from './users' @@ -33,8 +31,6 @@ Vue.use(Vuex) const state = () => ({ loading: false, - currency: 'PLN', - env: {} as Record, }) export type RootState = ReturnType @@ -42,9 +38,6 @@ export type RootState = ReturnType const getters = getterTree(state, {}) const mutations = mutationTree(state, { - SET_ENV(state, newEnv: Record) { - state.env = newEnv - }, SET_LOADING(state, loading: boolean) { state.loading = loading }, @@ -53,11 +46,6 @@ const mutations = mutationTree(state, { const actions = actionTree( { state, getters, mutations }, { - async fetchEnv({ commit }) { - // Fetch setting wtihout authorization, so it wont crash when auth is invalid - const { data } = await axios.get>(`${getApiURL()}/settings?array`) - commit('SET_ENV', data) - }, startLoading({ commit, state }) { if (!state.loading) commit('SET_LOADING', true) }, @@ -68,6 +56,7 @@ const actions = actionTree( ) const storeModules = { + config, auth, globalSeo, users, @@ -101,14 +90,14 @@ const storePattern = { const store = new Vuex.Store({ ...storePattern, - plugins: [new VuexPersistence({ modules: ['auth'] }).plugin], + plugins: [new VuexPersistence({ modules: ['auth', 'config'] }).plugin], }) export const accessor = useAccessor(store, storePattern) export type AccessorType = typeof accessor export type StoreModulesKeys = keyof typeof storeModules -export type GeneratedStoreModulesKeys = Exclude +export type GeneratedStoreModulesKeys = Exclude Vue.prototype.$accessor = accessor diff --git a/src/views/Home.vue b/src/views/Home.vue index 0f4a5413..bae32daa 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -138,7 +138,7 @@ export default Vue.extend({ }), computed: { storeName(): string { - return this.$accessor.env.store_name ?? 'Heseya Store' + return this.$accessor.config.env.store_name ?? 'Heseya Store' }, orders(): Order[] { return this.$accessor.orders.getData @@ -177,7 +177,7 @@ export default Vue.extend({ return getRelativeDate(date, this.$i18n.locale) }, formatCurrency(amount: number) { - return formatCurrency(amount, this.$accessor.currency) + return formatCurrency(amount, this.$accessor.config.currency) }, async getOrders() { await this.$accessor.orders.fetch({ diff --git a/src/views/discounts/index.vue b/src/views/discounts/index.vue index e78e808d..021fb7b2 100644 --- a/src/views/discounts/index.vue +++ b/src/views/discounts/index.vue @@ -175,7 +175,7 @@ export default Vue.extend({ }, methods: { formatCurrency(amount: number) { - return formatCurrency(amount, this.$accessor.currency) + return formatCurrency(amount, this.$accessor.config.currency) }, formatDateTime(date: string) { return formatDate(date) diff --git a/src/views/orders/Index.vue b/src/views/orders/Index.vue index f36f9d90..2e7eb1d2 100644 --- a/src/views/orders/Index.vue +++ b/src/views/orders/Index.vue @@ -163,7 +163,7 @@ export default Vue.extend({ this.makeSearch({ ...EMPTY_ORDER_FILTERS }) }, formatCurrency(value: number) { - return formatCurrency(value, this.$accessor.currency) + return formatCurrency(value, this.$accessor.config.currency) }, }, }) diff --git a/src/views/orders/view.vue b/src/views/orders/view.vue index 05b5a3c7..f4068f08 100644 --- a/src/views/orders/view.vue +++ b/src/views/orders/view.vue @@ -340,7 +340,7 @@ export default Vue.extend({ return this.order.created_at && formatDate(this.order.created_at) }, storefrontPaymentUrl(): string | undefined { - return this.$accessor.env.storefront_payment_url || undefined + return this.$accessor.config.env.storefront_payment_url || undefined }, }, watch: { @@ -365,7 +365,7 @@ export default Vue.extend({ }, methods: { formatCurrency(amount: number) { - return formatCurrency(amount, this.$accessor.currency) + return formatCurrency(amount, this.$accessor.config.currency) }, async setStatus(newStatus: OrderStatus) { this.isLoading = true diff --git a/src/views/settings/Settings.vue b/src/views/settings/Settings.vue index eb28ed44..cbddd030 100644 --- a/src/views/settings/Settings.vue +++ b/src/views/settings/Settings.vue @@ -176,7 +176,7 @@ export default Vue.extend({ } else { await this.$accessor.settings.add(this.editedItem) } - await this.$accessor.fetchEnv() + await this.$accessor.config.fetchEnv() this.$accessor.stopLoading() this.isModalActive = false }, From b03ee73ba44cb409751c2775a153aeeb44f2bde6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Fri, 25 Feb 2022 14:15:37 +0100 Subject: [PATCH 007/204] Moved ui interface to config store --- src/App.vue | 2 +- src/api.ts | 1 + src/components/LangSwitch.vue | 3 +-- src/consts/i18n.ts | 1 - src/i18n.ts | 11 +++-------- src/store/config.ts | 23 ++++++++++++++--------- src/store/generator.ts | 2 +- src/utils/i18n.ts | 5 +++++ 8 files changed, 26 insertions(+), 22 deletions(-) delete mode 100644 src/consts/i18n.ts create mode 100644 src/utils/i18n.ts diff --git a/src/App.vue b/src/App.vue index 5a6ce96e..fb4a539e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -72,7 +72,7 @@ export default Vue.extend({ created() { initMicroApps() this.$accessor.config.fetchEnv() - // this.$accessor.config.initLanguages() + this.$accessor.config.initLanguages() if (this.$accessor.auth.isLogged) this.$accessor.auth.fetchProfile() // MicroFrontend Events Start diff --git a/src/api.ts b/src/api.ts index e1aad642..280f2c79 100644 --- a/src/api.ts +++ b/src/api.ts @@ -39,6 +39,7 @@ export const createApiInstance = (baseURL: string, useAccessToken = true) => { } config.headers['X-Core-Url'] = CORE_API_URL + if (accessor.config.apiLanguage) config.headers['Accept-Language'] = accessor.config.apiLanguage return config }) diff --git a/src/components/LangSwitch.vue b/src/components/LangSwitch.vue index 418a7c68..f15d50c1 100644 --- a/src/components/LangSwitch.vue +++ b/src/components/LangSwitch.vue @@ -31,12 +31,11 @@ diff --git a/src/components/LangSwitch.vue b/src/components/UiLangSwitch.vue similarity index 100% rename from src/components/LangSwitch.vue rename to src/components/UiLangSwitch.vue diff --git a/src/components/modules/settings/UserPreferences.vue b/src/components/modules/settings/UserPreferences.vue index 74ed30cb..a1d3e82b 100644 --- a/src/components/modules/settings/UserPreferences.vue +++ b/src/components/modules/settings/UserPreferences.vue @@ -1,6 +1,8 @@ diff --git a/src/store/generator.ts b/src/store/generator.ts index dbab8861..e5dd5682 100644 --- a/src/store/generator.ts +++ b/src/store/generator.ts @@ -63,6 +63,11 @@ interface CrudParams { export const createVuexCRUD = , UpdateItemDTO = Partial>() => (endpoint: string, extend: ExtendStore, queryParams: CrudParams = {}) => { + const GLOBAL_QUERY_PARAMS: QueryPayload = { + lang_fallback: 'any', + translations: 1, + } + const privateState = { fetchAbortController: null as null | AbortController, } @@ -168,9 +173,9 @@ export const createVuexCRUD = privateState.fetchAbortController = new AbortController() const filteredQuery = Object.fromEntries( - Object.entries({ ...(queryParams.get || {}), ...(query || {}) }).filter( - ([, value]) => !isNil(value), - ), + Object.entries( + assign({}, GLOBAL_QUERY_PARAMS, queryParams.get || {}, query || {}), + ).filter(([, value]) => !isNil(value)), ) commit(StoreMutations.SetQueryParams, filteredQuery) @@ -199,7 +204,9 @@ export const createVuexCRUD = commit(StoreMutations.SetError, null) commit(StoreMutations.SetLoading, true) try { - const stringQuery = stringifyQuery(queryParams.get || {}) + const stringQuery = stringifyQuery( + assign({}, GLOBAL_QUERY_PARAMS, queryParams.get || {}), + ) const { data } = await api.get<{ data: Item }>(`/${endpoint}/id:${id}${stringQuery}`) // @ts-ignore type is correct, but TS is screaming commit(StoreMutations.SetSelected, data.data) @@ -216,7 +223,9 @@ export const createVuexCRUD = commit(StoreMutations.SetError, null) commit(StoreMutations.SetLoading, true) try { - const stringQuery = stringifyQuery(queryParams.add || {}) + const stringQuery = stringifyQuery( + assign({}, GLOBAL_QUERY_PARAMS, queryParams.add || {}), + ) const { data } = await api.post<{ data: Item }>(`/${endpoint}${stringQuery}`, item) // @ts-ignore type is correct, but TS is screaming commit(StoreMutations.AddData, data.data) @@ -233,7 +242,9 @@ export const createVuexCRUD = commit(StoreMutations.SetLoading, true) commit(StoreMutations.SetError, null) try { - const stringQuery = stringifyQuery(queryParams.edit || {}) + const stringQuery = stringifyQuery( + assign({}, GLOBAL_QUERY_PARAMS, queryParams.edit || {}), + ) const { data } = await api.put<{ data: Item }>( `/${endpoint}/id:${id}${stringQuery}`, item, @@ -252,7 +263,9 @@ export const createVuexCRUD = commit(StoreMutations.SetLoading, true) commit(StoreMutations.SetError, null) try { - const stringQuery = stringifyQuery(queryParams.update || {}) + const stringQuery = stringifyQuery( + assign({}, GLOBAL_QUERY_PARAMS, queryParams.update || {}), + ) const { data } = await api.patch<{ data: Item }>( `/${endpoint}/id:${id}${stringQuery}`, item, @@ -273,7 +286,9 @@ export const createVuexCRUD = commit(StoreMutations.SetLoading, true) commit(StoreMutations.SetError, null) try { - const stringQuery = stringifyQuery(queryParams.update || {}) + const stringQuery = stringifyQuery( + assign({}, GLOBAL_QUERY_PARAMS, queryParams.update || {}), + ) const { data } = await api.patch<{ data: Item }>( `/${endpoint}/${value}${stringQuery}`, item, @@ -296,7 +311,7 @@ export const createVuexCRUD = const id = typeof payload === 'string' ? payload : payload.value const payloadParams = typeof payload === 'string' ? {} : payload.params || {} - const params = assign({}, queryParams.remove || {}, payloadParams) + const params = assign({}, GLOBAL_QUERY_PARAMS, queryParams.remove || {}, payloadParams) const stringQuery = stringifyQuery(params) await api.delete(`/${endpoint}/id:${id}${stringQuery}`) @@ -313,7 +328,9 @@ export const createVuexCRUD = commit(StoreMutations.SetLoading, true) commit(StoreMutations.SetError, null) try { - const stringQuery = stringifyQuery(queryParams.remove || {}) + const stringQuery = stringifyQuery( + assign({}, GLOBAL_QUERY_PARAMS, queryParams.remove || {}), + ) await api.delete(`/${endpoint}/${value}${stringQuery}`) commit(StoreMutations.RemoveData, { key, value }) commit(StoreMutations.SetLoading, false) @@ -330,7 +347,9 @@ export const createVuexCRUD = commit(StoreMutations.SetError, null) commit(StoreMutations.SetLoading, true) try { - const stringQuery = stringifyQuery(queryParams.get || {}) + const stringQuery = stringifyQuery( + assign({}, GLOBAL_QUERY_PARAMS, queryParams.get || {}), + ) const { data } = await api.get<{ data: AuditEntry[] }>( `/audits/${endpoint}/id:${id}${stringQuery}`, ) From 6e330dad8102b1771095245ff6c6dd960697dcbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Mon, 28 Feb 2022 10:58:19 +0100 Subject: [PATCH 009/204] Adjusted api lang change --- src/App.vue | 5 +- src/components/ApiLangSwitch.vue | 42 +++++++++------ src/components/UiLangSwitch.vue | 5 -- .../modules/settings/UserPreferences.vue | 5 +- src/components/root/Header.vue | 54 ++++++++++++------- src/store/config.ts | 11 +++- 6 files changed, 74 insertions(+), 48 deletions(-) diff --git a/src/App.vue b/src/App.vue index fb4a539e..e454c02c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -7,7 +7,7 @@
- +
@@ -46,6 +46,9 @@ export default Vue.extend({ SwUpdatePopup, }, computed: { + viewKey(): string { + return `${this.$route.path}-${this.$accessor.config.apiLanguage}` + }, isLoading(): boolean { return this.$accessor.loading }, diff --git a/src/components/ApiLangSwitch.vue b/src/components/ApiLangSwitch.vue index be1d2bc7..f96d51ea 100644 --- a/src/components/ApiLangSwitch.vue +++ b/src/components/ApiLangSwitch.vue @@ -1,15 +1,14 @@ @@ -41,11 +40,22 @@ export default Vue.extend({ }, }, }, - watch: { - apiLanguage(locale: string) { - // TODO: API LANG CHANGE SIDEEFFECTS - console.log('🚀 ~ file: ApiLangSwitch.vue ~ line 48 ~ apiLanguage changed', locale) - }, - }, }) + + diff --git a/src/components/UiLangSwitch.vue b/src/components/UiLangSwitch.vue index f15d50c1..2fd976bd 100644 --- a/src/components/UiLangSwitch.vue +++ b/src/components/UiLangSwitch.vue @@ -42,8 +42,3 @@ export default Vue.extend({ }, }) - - diff --git a/src/components/modules/settings/UserPreferences.vue b/src/components/modules/settings/UserPreferences.vue index a1d3e82b..3058a643 100644 --- a/src/components/modules/settings/UserPreferences.vue +++ b/src/components/modules/settings/UserPreferences.vue @@ -2,8 +2,6 @@
- -
@@ -16,10 +14,9 @@ import Vue from 'vue' import UiLangSwitch from '@/components/UiLangSwitch.vue' -import ApiLangSwitch from '@/components/ApiLangSwitch.vue' export default Vue.extend({ - components: { UiLangSwitch, ApiLangSwitch }, + components: { UiLangSwitch }, }) diff --git a/src/components/root/Header.vue b/src/components/root/Header.vue index 86bdef5e..c76aba24 100644 --- a/src/components/root/Header.vue +++ b/src/components/root/Header.vue @@ -18,21 +18,25 @@
{{ storeName }}
-
-
{{ userRole }}
- - - - - - +
+ + +
+
{{ userRole }}
+ + + + + + +
@@ -57,9 +61,11 @@ import Vue from 'vue' import last from 'lodash/last' import { User } from '@/interfaces/User' +import ApiLangSwitch from '../ApiLangSwitch.vue' export default Vue.extend({ name: 'AppHeader', + components: { ApiLangSwitch }, computed: { isHidden(): boolean { return !!this.$route.meta?.hiddenNav || false @@ -103,7 +109,11 @@ export default Vue.extend({ justify-content: space-between; } - &__return-btn { + &__right-side { + display: flex; + align-items: center; + justify-content: flex-end; + margin-left: auto; } &--hidden { @@ -116,16 +126,20 @@ export default Vue.extend({ font-size: 0.9em; } + &__lang-select { + margin-right: 8px; + + ::v-deep .app-input { + margin-bottom: 0; + } + } + @media ($max-viewport-4) { &__text, &__return-btn { display: none; } } - - &__user { - margin-left: auto; - } } .user { diff --git a/src/store/config.ts b/src/store/config.ts index deef1552..05ad55df 100644 --- a/src/store/config.ts +++ b/src/store/config.ts @@ -1,4 +1,3 @@ -/* eslint-disable camelcase */ import axios from 'axios' import { actionTree, getterTree, mutationTree } from 'typed-vuex' @@ -38,7 +37,15 @@ const actions = actionTree( async initLanguages({ state, commit }) { const languages = await accessor.languages.fetch() - if (languages && !state.apiLanguage) { + if (!languages) { + // eslint-disable-next-line no-console + console.error('Failed to fetch languages') + return + } + + const apiLanguage = languages.find(({ iso }) => iso === state.apiLanguage) + + if (!state.apiLanguage || !apiLanguage) { const defaultLang = languages.find((l) => l.default) if (defaultLang) commit('SET_API_LANGUAGE', defaultLang.iso) } From 7f88bf40a9ac92797956bebf898c6dd04667440a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Mon, 28 Feb 2022 12:30:04 +0100 Subject: [PATCH 010/204] renamed function --- src/App.vue | 3 ++- src/i18n.ts | 6 +++--- src/store/config.ts | 4 ++-- src/utils/i18n.ts | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/App.vue b/src/App.vue index e454c02c..f7e00983 100644 --- a/src/App.vue +++ b/src/App.vue @@ -6,6 +6,7 @@
+ {{ viewKey }} @@ -47,7 +48,7 @@ export default Vue.extend({ }, computed: { viewKey(): string { - return `${this.$route.path}-${this.$accessor.config.apiLanguage}` + return `${this.$accessor.config.apiLanguage}:${this.$route.path}` }, isLoading(): boolean { return this.$accessor.loading diff --git a/src/i18n.ts b/src/i18n.ts index f74c6119..4ee580ca 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -1,7 +1,7 @@ import Vue from 'vue' import VueI18n, { LocaleMessages } from 'vue-i18n' import { accessor } from './store' -import { getDefaultLanguage } from './utils/i18n' +import { getDefaultUiLanguage } from './utils/i18n' Vue.use(VueI18n) @@ -19,8 +19,8 @@ function loadLocaleMessages(): LocaleMessages { } export default new VueI18n({ - locale: accessor.config.uiLanguage || getDefaultLanguage(), - fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'pl', // TODO: change to 'en' when all translations are done + locale: accessor.config.uiLanguage || getDefaultUiLanguage(), + fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en', messages: loadLocaleMessages(), fallbackRoot: true, silentFallbackWarn: true, diff --git a/src/store/config.ts b/src/store/config.ts index 05ad55df..888dd521 100644 --- a/src/store/config.ts +++ b/src/store/config.ts @@ -3,12 +3,12 @@ import { actionTree, getterTree, mutationTree } from 'typed-vuex' import { accessor } from './index' import { getApiURL } from '@/utils/api' -import { getDefaultLanguage } from '@/utils/i18n' +import { getDefaultUiLanguage } from '@/utils/i18n' const state = () => ({ currency: 'PLN', apiLanguage: null as null | string, - uiLanguage: getDefaultLanguage(), + uiLanguage: getDefaultUiLanguage(), env: {} as Record, }) diff --git a/src/utils/i18n.ts b/src/utils/i18n.ts index ff5af14e..8fe23266 100644 --- a/src/utils/i18n.ts +++ b/src/utils/i18n.ts @@ -1,4 +1,4 @@ -export const getDefaultLanguage = () => { +export const getDefaultUiLanguage = () => { const browserLang = window.navigator.language if (browserLang.includes('pl')) return 'pl' return 'en' From 81e435806836152cc258f74f0d059c2a32c7e31d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Mon, 28 Feb 2022 13:50:06 +0100 Subject: [PATCH 011/204] lang select fixes --- src/App.vue | 1 - src/components/ApiLangSwitch.vue | 24 ++++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/App.vue b/src/App.vue index f7e00983..2461ec25 100644 --- a/src/App.vue +++ b/src/App.vue @@ -6,7 +6,6 @@
- {{ viewKey }} diff --git a/src/components/ApiLangSwitch.vue b/src/components/ApiLangSwitch.vue index f96d51ea..fed6412b 100644 --- a/src/components/ApiLangSwitch.vue +++ b/src/components/ApiLangSwitch.vue @@ -45,10 +45,24 @@ export default Vue.extend({ From a5724cc204bd91f2af7d1efe99f089a6b4a1e340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Fri, 4 Mar 2022 09:49:31 +0100 Subject: [PATCH 012/204] cart post merge fix --- src/components/modules/orders/Cart.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/modules/orders/Cart.vue b/src/components/modules/orders/Cart.vue index cb2210d2..7bbf7e3b 100644 --- a/src/components/modules/orders/Cart.vue +++ b/src/components/modules/orders/Cart.vue @@ -131,7 +131,7 @@ export default Vue.extend({ }, methods: { formatCurrency(amount: number) { - return formatCurrency(amount, this.$accessor.currency) + return formatCurrency(amount, this.$accessor.config.currency) }, }, }) From 17d4fc96f466e0db89369b8cbe58f12bf32cb67c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Tue, 8 Mar 2022 13:57:53 +0100 Subject: [PATCH 013/204] changed api url --- src/utils/api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/api.ts b/src/utils/api.ts index ba049f69..87ccfddc 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -21,7 +21,7 @@ export const getApiURL = () => { case '***REMOVED***': return '***REMOVED***' case 'store-admin-git-feature-languages-***REMOVED***': - return 'https://sandbox.***REMOVED***' + return 'https://feature-languages.***REMOVED***' default: return process.env.VUE_APP_API_URL || '***REMOVED***' } From cef1748df1bb51f9cc4df228864466bed284f87a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Tue, 8 Mar 2022 14:00:30 +0100 Subject: [PATCH 014/204] orders fix --- src/components/modules/orders/Summary.vue | 2 +- src/components/modules/orders/SummaryPayment.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/modules/orders/Summary.vue b/src/components/modules/orders/Summary.vue index 5491d735..94129651 100644 --- a/src/components/modules/orders/Summary.vue +++ b/src/components/modules/orders/Summary.vue @@ -134,7 +134,7 @@ export default Vue.extend({ }, methods: { formatCurrency(amount: number) { - return formatCurrency(amount, this.$accessor.currency) + return formatCurrency(amount, this.$accessor.config.currency) }, updateWidth(): void { this.viewportWidth = window.innerWidth diff --git a/src/components/modules/orders/SummaryPayment.vue b/src/components/modules/orders/SummaryPayment.vue index a5bb3f06..e3448176 100644 --- a/src/components/modules/orders/SummaryPayment.vue +++ b/src/components/modules/orders/SummaryPayment.vue @@ -105,7 +105,7 @@ export default Vue.extend({ }, methods: { formatCurrency(amount: number) { - return formatCurrency(amount, this.$accessor.currency) + return formatCurrency(amount, this.$accessor.config.currency) }, async payOffline() { this.$accessor.startLoading() From 2dbbb1cf61b01301afa4052474eb6985b71cc811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Tue, 8 Mar 2022 14:12:22 +0100 Subject: [PATCH 015/204] updated icons --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d0ffe83e..6b607311 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "ant-design-vue": "^1.7.8", "axios": "^0.24.0", "bout": "^0.2.0", - "boxicons": "2.0.9", + "boxicons": "2.1.2", "broadcast-channel": "^4.7.0", "core-js": "^3.19.1", "date-fns": "^2.26.0", diff --git a/yarn.lock b/yarn.lock index dbee49b1..6baf9295 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3086,10 +3086,10 @@ bout@^0.2.0: resolved "https://registry.yarnpkg.com/bout/-/bout-0.2.0.tgz#42a8e7fba7a33dc104f0a916e3cdfe9d9776eec8" integrity sha512-YedZnY1pdg/5euKxD5pOtMiy2cmohER1S71CiJm81QVwE1k4MTy+giYNWrjoypIy187NGh1IJTQdwEm0Yx20KQ== -boxicons@2.0.9: - version "2.0.9" - resolved "https://registry.yarnpkg.com/boxicons/-/boxicons-2.0.9.tgz#7ffbcdab6eb19fe1b53a4044dbca5849905d9714" - integrity sha512-nsXBqNgtEtEu/TYuOlH4mZ8sdM4ol1/6q4Sb9i0SubhOxbW9SqDemaN1D4yZHC8TfMWGM2tIW0y4YWbDMmuBYg== +boxicons@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/boxicons/-/boxicons-2.1.2.tgz#38e4a1368b1f07320425508ab6949aefd951fe64" + integrity sha512-NAEj0xmE64Hv6q7yjvyEVsdA+XIESHLe/S/bkCd2A197LQNpZ5ftopxmD3DMatZ1lndGIzxxqqFnWrD1oB3IIg== dependencies: "@webcomponents/webcomponentsjs" "^2.0.2" prop-types "^15.6.0" From f77a489040175eb6a457c46035bbd6c1a437d87a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Thu, 23 Jun 2022 13:10:31 +0200 Subject: [PATCH 016/204] Post merge fixes --- src/components/modules/orders/OrderDiscountSummary.vue | 2 +- src/components/modules/productSets/ProductSet.vue | 2 +- src/components/modules/products/ProductPrice.vue | 2 +- src/consts/menuItems.ts | 8 ++++++++ src/store/index.ts | 7 ------- src/views/coupons/index.vue | 2 +- src/views/sales/index.vue | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/components/modules/orders/OrderDiscountSummary.vue b/src/components/modules/orders/OrderDiscountSummary.vue index 1aa353be..4cbf4da8 100644 --- a/src/components/modules/orders/OrderDiscountSummary.vue +++ b/src/components/modules/orders/OrderDiscountSummary.vue @@ -65,7 +65,7 @@ export default Vue.extend({ }, methods: { formatCurrency(amount: number) { - return formatCurrency(amount, this.$accessor.currency) + return formatCurrency(amount, this.$accessor.config.currency) }, }, }) diff --git a/src/components/modules/productSets/ProductSet.vue b/src/components/modules/productSets/ProductSet.vue index b1fcca73..32ba226f 100644 --- a/src/components/modules/productSets/ProductSet.vue +++ b/src/components/modules/productSets/ProductSet.vue @@ -177,7 +177,7 @@ export default Vue.extend({ return this.children.length < this.childrenQuantity }, isFetchAllChildren(): boolean { - return this.$accessor.env.autoload_all_product_set_children === '1' + return this.$accessor.config.env.autoload_all_product_set_children === '1' }, }, created() { diff --git a/src/components/modules/products/ProductPrice.vue b/src/components/modules/products/ProductPrice.vue index 0b202f19..a8b7ecaa 100644 --- a/src/components/modules/products/ProductPrice.vue +++ b/src/components/modules/products/ProductPrice.vue @@ -47,7 +47,7 @@ export default Vue.extend({ }, methods: { formatCurrency(amount: number) { - return formatCurrency(amount, this.$accessor.currency) + return formatCurrency(amount, this.$accessor.config.currency) }, }, }) diff --git a/src/consts/menuItems.ts b/src/consts/menuItems.ts index 98b58d2b..af9ea4a3 100644 --- a/src/consts/menuItems.ts +++ b/src/consts/menuItems.ts @@ -67,6 +67,14 @@ export const MENU_ITEMS: MenuItem[] = [ can: PERMISSIONS_TREE.Pages.Show, section: SettingsSection.Shop, }, + { + id: '5-2', + type: MenuItemType.Link, + to: '/settings/languages', + iconClass: 'bx bx-text', + label: 'models.languages', + section: SettingsSection.Shop, + }, { id: '6', type: MenuItemType.Link, diff --git a/src/store/index.ts b/src/store/index.ts index 5289b0c2..f681ffce 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -51,13 +51,6 @@ const mutations = mutationTree(state, { const actions = actionTree( { state, getters, mutations }, { - async fetchEnv({ commit }) { - // Fetch setting wtihout authorization, so it wont crash when auth is invalid - const { data } = await axios.get>('/settings?array', { - baseURL: getApiURL(), - }) - commit('SET_ENV', data) - }, startLoading({ commit, state }) { if (!state.loading) commit('SET_LOADING', true) }, diff --git a/src/views/coupons/index.vue b/src/views/coupons/index.vue index 01b90a5f..fad6ca07 100644 --- a/src/views/coupons/index.vue +++ b/src/views/coupons/index.vue @@ -105,7 +105,7 @@ export default Vue.extend({ methods: { formatCurrency(amount: number) { - return formatCurrency(amount, this.$accessor.currency) + return formatCurrency(amount, this.$accessor.config.currency) }, }, }) diff --git a/src/views/sales/index.vue b/src/views/sales/index.vue index d46cbf4d..7f0808ca 100644 --- a/src/views/sales/index.vue +++ b/src/views/sales/index.vue @@ -99,7 +99,7 @@ export default Vue.extend({ methods: { formatCurrency(amount: number) { - return formatCurrency(amount, this.$accessor.currency) + return formatCurrency(amount, this.$accessor.config.currency) }, }, }) From 62dc198d9cc0d66e5d8dde95f56acdd58a24ac1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Mon, 22 Aug 2022 09:29:14 +0200 Subject: [PATCH 017/204] fix --- src/store/config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/store/config.ts b/src/store/config.ts index a2a448ba..6185de4b 100644 --- a/src/store/config.ts +++ b/src/store/config.ts @@ -34,6 +34,7 @@ const actions = actionTree( // Fetch setting wtihout authorization, so it wont crash when auth is invalid const { data } = await axios.get>(`${getApiURL()}/settings?array`) commit('SET_SETTINGS', data) + }, async initLanguages({ state, commit }) { const languages = await accessor.languages.fetch() From e5770b06b80910ee150148fba98c7773a41265f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Wed, 12 Oct 2022 14:53:05 +0200 Subject: [PATCH 018/204] languages generator fix --- src/store/generator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/generator.ts b/src/store/generator.ts index d1de34c2..194de147 100644 --- a/src/store/generator.ts +++ b/src/store/generator.ts @@ -57,7 +57,7 @@ export const createVuexCRUD = }, queryParams: VuexDefaultCrudParams = {}, ) => { - const GLOBAL_QUERY_PARAMS: QueryPayload = { + const GLOBAL_QUERY_PARAMS = { lang_fallback: 'any', translations: 1, } From 003162f4e673b88b9a91efb711e7d802d00ed9fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Mon, 10 Jul 2023 16:35:51 +0200 Subject: [PATCH 019/204] feat: moved to SDK interfaces --- package.json | 2 +- src/interfaces/Language.ts | 13 ------------- src/store/languages.ts | 17 ++++++++++------- src/views/languages/index.vue | 21 +++++++++++++-------- yarn.lock | 8 ++++---- 5 files changed, 28 insertions(+), 33 deletions(-) delete mode 100644 src/interfaces/Language.ts diff --git a/package.json b/package.json index 32727af4..cdb23520 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "lint:eslint:fix": "eslint --ext .js,.ts,.vue --fix ./src" }, "dependencies": { - "@heseya/store-core": "5.1.0", + "@heseya/store-core": "6.0.0-lang.1", "@sentry/tracing": "^7.6.0", "@sentry/vue": "^7.6.0", "ant-design-vue": "^1.7.8", diff --git a/src/interfaces/Language.ts b/src/interfaces/Language.ts deleted file mode 100644 index 38138fc8..00000000 --- a/src/interfaces/Language.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { UUID } from './UUID' - -export interface Language { - id: UUID - iso: string // de, fr-CA, de-DE-1996 - name: string - default: boolean - hidden: boolean -} - -export interface LanguageDto extends Omit { - id?: UUID -} diff --git a/src/store/languages.ts b/src/store/languages.ts index 6a74d2e7..2c4c385e 100644 --- a/src/store/languages.ts +++ b/src/store/languages.ts @@ -1,9 +1,12 @@ +import { Language, LanguageCreateDto, LanguageUpdateDto } from '@heseya/store-core' import { createVuexCRUD } from './generator' -import { Language, LanguageDto } from '@/interfaces/Language' -export const languages = createVuexCRUD()('languages', { - state: {}, - getters: {}, - mutations: {}, - actions: {}, -}) +export const languages = createVuexCRUD()( + 'languages', + { + state: {}, + getters: {}, + mutations: {}, + actions: {}, + }, +) diff --git a/src/views/languages/index.vue b/src/views/languages/index.vue index b3f11b14..0dfa4fef 100644 --- a/src/views/languages/index.vue +++ b/src/views/languages/index.vue @@ -1,6 +1,11 @@ - - - - - - - - - -
- - -
- - - - -
- - - - - - -
- -
-
+
@@ -182,41 +91,23 @@ diff --git a/src/components/lang/ContentLangSwitch.vue b/src/components/lang/ContentLangSwitch.vue index 921a00d0..8e4a4150 100644 --- a/src/components/lang/ContentLangSwitch.vue +++ b/src/components/lang/ContentLangSwitch.vue @@ -1,28 +1,26 @@ @@ -50,6 +48,10 @@ export default defineComponent({ type: String, required: true, }, + vertical: { + type: Boolean, + default: false, + }, }, emits: ['input'], computed: { @@ -71,18 +73,8 @@ export default defineComponent({ diff --git a/yarn.lock b/yarn.lock index c4457f14..7588c987 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1224,10 +1224,10 @@ dependencies: "@hapi/hoek" "^9.0.0" -"@heseya/store-core@6.0.0-lang.12": - version "6.0.0-lang.12" - resolved "https://registry.yarnpkg.com/@heseya/store-core/-/store-core-6.0.0-lang.12.tgz#d2a172cff9228ec39beaf7723306e66d49ed22d4" - integrity sha512-KnlLNFomq8nGYXWfn+2F8TjmzUNwWiA+amPcLykfRRP7O4FkimZH07C0uKPujaZxgxdOsLZQlgfHRO/2AE8XTg== +"@heseya/store-core@6.0.0-dev.1": + version "6.0.0-dev.1" + resolved "https://registry.yarnpkg.com/@heseya/store-core/-/store-core-6.0.0-dev.1.tgz#b38e0bc471ff01aae9cd4164dfc9741e2f46ec97" + integrity sha512-KzIqC5zqkfpMXUVPR3k1U5xubKbmEO95cfgZI096yJQ66sEPV+/twr94iutP2S1bWrD82N6ayQ5avz8+j75WMA== dependencies: "@types/flat" "^5.0.2" array-to-tree "^3.3.2" From 8975bdb1418842e41623d4b680a727e876ee604f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Fri, 4 Aug 2023 16:55:49 +0200 Subject: [PATCH 044/204] feat: changed price ranges form in shipping methods --- .../modules/shippingMethods/Form.vue | 31 ++++++++----- .../shippingMethods/PriceRangesForm.vue | 40 ++++++++++------- src/plugins/validation-rules.ts | 15 ++++--- src/utils/currency.ts | 7 +++ src/views/settings/ShippingMethods.vue | 43 +++++++++++++------ 5 files changed, 93 insertions(+), 43 deletions(-) diff --git a/src/components/modules/shippingMethods/Form.vue b/src/components/modules/shippingMethods/Form.vue index 9e9d5421..ef8edbb2 100644 --- a/src/components/modules/shippingMethods/Form.vue +++ b/src/components/modules/shippingMethods/Form.vue @@ -9,11 +9,11 @@ :label="$t('form.shippingType').toString()" > - {{ $t(`shippingTypes.${type}`) }} + {{ $t(`shippingTypes.${shippingType}`) }}
@@ -46,9 +46,20 @@
- - - + + +
@@ -141,7 +152,7 @@ "form": { "shippingType": "Typ dostawy", "paymentMethods": "Dostępne metody płatności", - "public": "Widoczność opcji dostawy", + "public": "Widoczność metody dostawy", "deliveryTime": "Czas dostawy", "minDeliveryDays": "Minimalna ilość dni dostawy", "maxDeliveryDays": "Maksymalna ilość dni dostawy", @@ -157,7 +168,7 @@ "form": { "shippingType": "Shipping type", "paymentMethods": "Available payment methods", - "public": "Shipping option visibility", + "public": "Shipping method visibility", "deliveryTime": "Delivery time", "minDeliveryDays": "Minimal number of days of delivery", "maxDeliveryDays": "Maximum number of days of delivery", @@ -246,7 +257,7 @@ export default defineComponent({ deep: true, handler() { // @ts-ignore - this.$refs.priceRange.validate() + this.$refs.priceRange.forEach((slot) => slot.validate()) }, }, }, diff --git a/src/components/modules/shippingMethods/PriceRangesForm.vue b/src/components/modules/shippingMethods/PriceRangesForm.vue index 345c3cb5..1f96e702 100644 --- a/src/components/modules/shippingMethods/PriceRangesForm.vue +++ b/src/components/modules/shippingMethods/PriceRangesForm.vue @@ -1,8 +1,7 @@