Skip to content

Commit

Permalink
Merge branch 'release/v6.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
demtario committed Apr 10, 2024
2 parents 64160ef + 28a1aa2 commit 9aaacfb
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 36 deletions.
15 changes: 5 additions & 10 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
Options +FollowSymLinks +ExecCGI
Options -MultiViews
RewriteEngine on

RewriteRule sitemap.xml sitemap.xml [L]
RewriteRule robots.txt robots.txt [L]
RewriteRule manifest.json manifest.json [L]

RewriteCond %{REQUEST_URI} !(\.svg|\.png|\.jpg|\.gif|\.jpeg|\.bmp|\.ico|\.css|\.js|\.txt|\.mp4|\.map|\.woff2|\.woff|\.ttf|\.eot)$
RewriteRule (.*) index.html [QSA]
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.html [QSA,L]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "store-admin",
"version": "6.0.2",
"version": "6.0.3",
"private": true,
"description": "Admin panel for Heseya Store API",
"author": "Heseya",
Expand Down
4 changes: 2 additions & 2 deletions src/components/PaginatedList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ export default defineComponent({
const queryFilters = formatFilters(this.filters)
await this.$accessor[this.storeKey].fetch({
page: this.page,
limit: this.itemsPerPage,
...queryFilters,
...this.params,
page: this.page,
limit: this.itemsPerPage,
})
this.isLoading = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,13 @@ export default defineComponent({
},
deleteAttribute(id: UUID) {
this.attributes = this.attributes.filter((a) => a.id !== id)
const removedAttribute = this.attributes.find((a) => a.id === id)
// When Global attribute is removed, value is removed, not the attribute itself
if (removedAttribute?.global) {
removedAttribute.selected_options = [undefined as any]
} else {
this.attributes = this.attributes.filter((a) => a.id !== id)
}
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@
v-model="selectedOption[0].value_date"
class="date-input__input"
type="date"
name="value_date"
:name="`${attribute.id}_value_date`"
/>
</div>
<div v-else-if="type === AttributeType.Number" class="number-input">
<app-input
:value="getOptionName(selectedOption[0])"
class="number-input__input"
name="name"
:name="`${attribute.id}_name`"
:label="$t('displayName').toString()"
:placeholder="$t('namePlaceholder').toString()"
@input="setOptionName(selectedOption[0], $event)"
/>
<app-input
<validated-input
v-model="selectedOption[0].value_number"
class="number-input__input"
type="number"
step="0.00001"
name="value_number"
step="0.0001"
:name="`${attribute.id}_value_number`"
:rules="isRequired ? 'required' : null"
:label="$t('value').toString()"
:placeholder="$t('valuePlaceholder').toString()"
/>
Expand Down Expand Up @@ -96,6 +97,10 @@ export default defineComponent({
},
},
isRequired(): boolean {
return !!this.getOptionName(this.selectedOption[0])
},
AttributeType(): typeof AttributeType {
return AttributeType
},
Expand Down Expand Up @@ -171,7 +176,6 @@ export default defineComponent({
@media ($viewport-6) {
max-width: 185px;
margin-top: -20px;
}
}
}
Expand Down
16 changes: 13 additions & 3 deletions src/components/modules/attributes/configurator/Item.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<list-item no-hover>
<ListItem no-hover>
<div class="product-attribute">
<a-tooltip>
<div class="product-attribute__title">
Expand Down Expand Up @@ -31,7 +31,8 @@
</icon-button>

<icon-button
v-if="!disabled && !attribute.global"
v-if="isRemovable"
:disabled="disabled"
size="small"
type="danger"
@click="deleteAttribute(attribute.id)"
Expand All @@ -42,7 +43,7 @@
</icon-button>
</div>
</template>
</list-item>
</ListItem>
</template>

<i18n lang="json">
Expand All @@ -61,6 +62,7 @@
<script lang="ts">
import { defineComponent, PropType } from 'vue'
import { AttributeType, Attribute, ProductAttribute } from '@heseya/store-core'
import isNil from 'lodash/isNil'
import Empty from '@/components/layout/Empty.vue'
import List from '@/components/layout/List.vue'
Expand Down Expand Up @@ -105,6 +107,14 @@ export default defineComponent({
this.$emit('input', val)
},
},
isRemovable(): boolean {
const hasValue = this.attribute.selected_options.some(
(v) => !isNil(v?.value_date) || !isNil(v?.value_number),
)
// Global value can be removed only if it has value (value is removed, not the attribute itself)
return !this.attribute.global || hasValue
},
},
methods: {
deleteAttribute(id: UUID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
allow-clear
:loading="isLoading"
:placeholder="$t('placeholder').toString()"
:name="`${attribute.id}_value`"
@search="onSearch"
@input-keydown="onInputKeydown"
@change="setValue"
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"INTERNAL_SERVER_ERROR": "Internal server error"
},
"CLIENT_ERROR": {
"ERR_NETWORK": "No internet access",
"ERR_NETWORK": "No internet access, or server connection error",
"UNPROCESSABLE_ENTITY": "Unprocessable entity",
"CDN_NOT_ALLOWED_TO_CHANGE_ALT": "You cannot change alt attribute of this image.",
"CLIENT_INVALID_INSTALLATION_RESPONSE": "App has invalid installation response.",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"INTERNAL_SERVER_ERROR": "Wewnętrzny błąd serwera"
},
"CLIENT_ERROR": {
"ERR_NETWORK": "Brak dostępu do internetu",
"ERR_NETWORK": "No internet access, or connection error to the server",
"CLIENT_INVALID_INSTALLATION_RESPONSE": "Aplikacja ma nieprawidłową odpowiedź dotyczącą instalacji.",
"CDN_NOT_ALLOWED_TO_CHANGE_ALT": "Nie możesz zmienić tekstu alternatywnego tego zdjęcia.",
"CLIENT_FAILED_TO_CONNECT_WITH_APP": "Nie udało połączyć się z aplikacją.",
Expand Down
2 changes: 2 additions & 0 deletions src/views/orders/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ export default defineComponent({
(this.$route.query.digital_shipping_method_id as string) || ALL_FILTER_VALUE,
paid: (this.$route.query.paid as string) || ALL_FILTER_VALUE,
sort: (this.$route.query.sort as string) || '',
sales_channel_id: (this.$route.query.sales_channel_id as string) || ALL_FILTER_VALUE,
payment_method_id: (this.$route.query.payment_method_id as string) || ALL_FILTER_VALUE,
}
},
methods: {
Expand Down
4 changes: 3 additions & 1 deletion src/views/products/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PaginatedList
:title="$t('title').toString()"
:filters="filters"
store-key="products"
:table="listView ? tableConfig : undefined"
:xlsx-file-config="fileConfig"
store-key="products"
@search="makeSearch"
@clear-filters="clearFilters"
>
Expand Down Expand Up @@ -217,6 +217,7 @@ export default defineComponent({
created() {
Object.entries(this.$route.query).forEach(([key, value]) => {
if (key === 'page') return
this.filters[key] = value as any
})
Expand Down Expand Up @@ -244,6 +245,7 @@ export default defineComponent({
},
methods: {
makeSearch(filters: ProductFilers) {
console.log('🚀 ~ makeSearch ~ filters:', filters)

Check warning on line 248 in src/views/products/Index.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement

Check warning on line 248 in src/views/products/Index.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement

Check warning on line 248 in src/views/products/Index.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
this.filters = filters
const queryFilters = formatFilters(filters)
Expand Down
33 changes: 23 additions & 10 deletions src/views/products/View.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div :key="$route.params.id" class="product-page-wrapper">
<Loading :active="isLoading" />
<AbsoluteContentLangSwitch :value="editedLang" @input="setEditedLang" />

<TopNav>
Expand Down Expand Up @@ -46,7 +47,7 @@
</PopConfirm>
</TopNav>

<ValidationObserver v-slot="{ handleSubmit }">
<ValidationObserver ref="form">
<form class="product-page" @submit.stop.prevent="handleSubmit(saveProduct)">
<Card class="product-page__main">
<h2 class="product-page__subtitle">{{ $t('baseFormTitle') }}</h2>
Expand Down Expand Up @@ -175,6 +176,7 @@
"removed": "Produkt został usunięty.",
"created": "Produkt został utworzony.",
"updated": "Produkt został zaktualizowany.",
"validationError": "Formularz zawiera błędy. Uzupełnij brakujące pola.",
"error": "Wystąpił błąd podczas zapisywania produktu.",
"highlightedAttributeCopySuccess": "Wartość atrybutu została skopiowana!"
},
Expand All @@ -193,6 +195,7 @@
"removed": "Product has been removed.",
"created": "Product has been created.",
"updated": "Product has been updated.",
"validationError": "The form contains errors. Fill in the missing fields.",
"error": "An error occurred while saving the product.",
"highlightedAttributeCopySuccess": "Highlighted attribute value has been copied!"
},
Expand Down Expand Up @@ -227,6 +230,7 @@ import ProductAttachments from '@/components/modules/products/attachments/List.v
import ProductRelatedSets from '@/components/modules/products/related/List.vue'
import DescriptionAccordion from '@/components/DescriptionAccordion.vue'
import ProductBannerForm from '@/components/modules/products/BannerForm.vue'
import Loading from '@/components/layout/Loading.vue'
// import preventLeavingPage from '@/mixins/preventLeavingPage'
Expand Down Expand Up @@ -274,6 +278,7 @@ const EMPTY_FORM: ProductComponentForm = {
export default defineComponent({
components: {
Loading,
TopNav,
Gallery,
Card,
Expand Down Expand Up @@ -304,16 +309,14 @@ export default defineComponent({
}
},
data: () => ({
isLoading: false,
editedLang: '',
form: cloneDeep(EMPTY_FORM),
}),
computed: {
id(): UUID {
return this.$route.params.id
},
isLoading(): boolean {
return this.$accessor.products.isLoading
},
isNew(): boolean {
return this.id === 'create'
},
Expand Down Expand Up @@ -383,6 +386,16 @@ export default defineComponent({
this.setEditedLang(this.$accessor.languages.apiLanguage?.id || '')
},
methods: {
handleSubmit(callback: Function) {
;(this.$refs.form as any).validate().then((success: boolean) => {
if (!success) {
this.$toast.error(this.$t('messages.validationError') as string)
return
}
callback()
})
},
setEditedLang(langId: string) {
this.editedLang = langId
Expand All @@ -395,26 +408,26 @@ export default defineComponent({
async fetch() {
this.form = cloneDeep(EMPTY_FORM)
if (this.isNew) return
this.$accessor.startLoading()
this.isLoading = true
await this.$accessor.products.get(this.$route.params.id)
// isFormPrefilled should be set to true after form was prefilled
// this.isFormPrefilled = true
this.$accessor.stopLoading()
this.isLoading = false
},
async deleteProduct() {
this.$accessor.startLoading()
this.isLoading = true
const success = await this.$accessor.products.remove(this.id)
if (success) {
this.$toast.success(this.$t('messages.removed') as string)
this.$router.push('/products')
}
this.$accessor.stopLoading()
this.isLoading = false
},
async saveProduct() {
this.$accessor.startLoading()
this.isLoading = true
try {
const attributes = await updateProductAttributeOptions(
this.form.attributes.filter((v) => v.selected_options),
Expand Down Expand Up @@ -479,7 +492,7 @@ export default defineComponent({
this.$toast.error(this.$t('messages.error') as string)
}
this.$accessor.stopLoading()
this.isLoading = false
},
async saveMetadata(id: string) {
Expand Down

0 comments on commit 9aaacfb

Please sign in to comment.