Skip to content

Commit

Permalink
Merge pull request #59 from heseya/SK-922
Browse files Browse the repository at this point in the history
manufacturers
  • Loading branch information
KrystianEscolaSoft authored Dec 2, 2024
2 parents f18292d + bca1966 commit 5ca01a7
Show file tree
Hide file tree
Showing 13 changed files with 584 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"postinstall": "patch-package"
},
"dependencies": {
"@heseya/store-core": "7.1.0-beta.2",
"@heseya/store-core": "7.1.0-beta.3",
"@sentry/tracing": "^7.6.0",
"@sentry/vue": "^7.6.0",
"ant-design-vue": "^1.7.8",
Expand Down
134 changes: 134 additions & 0 deletions src/components/modules/manufacturers/Form.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<template>
<div class="manufacturers">
<div class="manufacturers__fields">
<validated-input
v-model="form.name"
:disabled="disabled"
rules="required"
name="name"
:label="$t('name')"
/>
<validated-input
v-model="form.email"
:disabled="disabled"
rules="required|email"
name="email"
:label="$t('email')"
/>
<validated-input
v-model="form.first_name"
:disabled="disabled"
name="first_name"
:label="$t('firstName')"
/>
<validated-input
v-model="form.last_name"
:disabled="disabled"
name="last_name"
:label="$t('lastName')"
/>
</div>
<hr />
<div>
<h2 class="manufacturers__title">{{ $t('relatedProducts') }}</h2>
<autocomplete-input
key="product_ids"
v-model="form.product_ids"
:label="`${$t('products')}`"
model-url="products"
prop-mode="id"
:disabled="disabled"
:rules="{ required: form.product_ids && form.product_ids.length === 0 }"
class="sale-configurator__autocomplete"
>
<template #option="product">
{{ product.name }}&nbsp;<small>(/{{ product.slug }})</small>
</template>
</autocomplete-input>
</div>
<hr />
<h2 class="manufacturers__title">{{ $t('manufactureAddress') }}</h2>
<div class="manufacturers__address-fields">
<address-form v-model="form.address" />
</div>
</div>
</template>
<i18n lang="json">
{
"pl": {
"name": "Nazwa",
"email": "Email",
"lastName": "Nazwisko",
"firstName": "Imię",
"products": "Produkty",
"manufactureAddress": "Adres Producenta",
"relatedProducts": "Produkty powiązane"
},
"en": {
"name": "Name",
"email": "Email",
"lastName": "Last Name",
"firstName": "First Name",
"products": "Products",
"manufactureAddress": "Manufacture address",
"relatedProducts": "Related products"
}
}
</i18n>
<script lang="ts">
import { defineComponent, PropType } from 'vue'
import { ManufacturerDto } from '@heseya/store-core'
import AutocompleteInput from '@/components/AutocompleteInput.vue'
import AddressForm from '@/components/modules/orders/AddressForm.vue'
export type ManufacturerForm = ManufacturerDto & { id?: string }
export default defineComponent({
components: {
AutocompleteInput,
AddressForm,
},
props: {
value: {
type: Object as PropType<ManufacturerForm>,
required: true,
},
disabled: {
type: Boolean,
default: false,
},
},
computed: {
form: {
get(): ManufacturerDto {
console.log('form', this.value)

Check warning on line 104 in src/components/modules/manufacturers/Form.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement

Check warning on line 104 in src/components/modules/manufacturers/Form.vue

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
return this.value
},
set(v: ManufacturerDto) {
this.$emit('input', v)
},
},
},
methods: {},
})
</script>
<style lang="scss" scoped>
.manufacturers {
&__fields {
display: grid;
gap: 6px;
grid-template-areas:
'name email'
'first_name last_name';
}
&__address-fields {
display: grid;
gap: 6px;
}
&__title {
margin-right: 12px;
font-size: 1.1em;
font-weight: 500;
}
}
</style>
38 changes: 35 additions & 3 deletions src/components/modules/products/view/ProductBasicDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@
:label="$t('form.shortDescription').toString()"
:disabled="disabled"
/>
<AppTextarea
v-if="!loading"
v-model="form.safety_information"
:label="$t('form.safetyInformation').toString()"
:disabled="disabled"
/>
<autocomplete-input
key="product_ids"
v-model="form.manufacturer_id"
:label="`${$t('form.manufacturer')}`"
model-url="manufacturers"
prop-mode="id"
mode="single"
:disabled="disabled"
:rules="{ required: form.manufacturer_id }"
class="sale-configurator__autocomplete"
>
<template #option="manufacturer">
{{ manufacturer.name }}&nbsp;<small>({{ manufacturer.email }})</small>
</template>
</autocomplete-input>
</div>
</template>

Expand All @@ -39,13 +60,17 @@
"pl": {
"form": {
"vatRate": "Stawka VAT (%)",
"shortDescription": "Krótki opis"
"shortDescription": "Krótki opis",
"safetyInformation": "informacje dotyczące bezpieczeństwa",
"manufacturer": "Producent"
}
},
"en": {
"form": {
"vatRate": "VAT rate (%)",
"shortDescription": "Short description"
"shortDescription": "Short description",
"safetyInformation": "Safety information",
"manufacturer": "Manufacturer"
}
}
}
Expand All @@ -60,11 +85,18 @@ import ProductSetSelect from '../ProductSetSelect.vue'
import Textarea from '@/components/form/Textarea.vue'
import TagsSelect from '@/components/TagsSelect.vue'
import CurrencyPriceForm from '@/components/CurrencyPriceForm.vue'
import AutocompleteInput from '@/components/AutocompleteInput.vue'
import { generateSlug } from '@/utils/generateSlug'
export default defineComponent({
components: { ProductSetSelect, AppTextarea: Textarea, TagsSelect, CurrencyPriceForm },
components: {
ProductSetSelect,
AppTextarea: Textarea,
TagsSelect,
CurrencyPriceForm,
AutocompleteInput,
},
props: {
value: {
type: Object as PropType<ProductComponentForm>,
Expand Down
2 changes: 2 additions & 0 deletions src/consts/featureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export const FEATURE_FLAGS = {
* If true, product images on every list will be shown as object-fit: contain, otherwise they will be shown as object-fit: cover
*/
ProductContain: 'dashboard_products_contain',

manufacturers: 'Manufacturers_enabled',
}

export const SETTINGS_KEYS = {
Expand Down
10 changes: 10 additions & 0 deletions src/consts/menuItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ export const MENU_ITEMS: MenuItem[] = [
can: PERMISSIONS_TREE.Pages.Show,
section: SettingsSection.Shop,
},
{
id: nextId(),
type: MenuItemType.Link,
to: '/manufacturers',
iconClass: 'bx bxs-bot',
label: 'models.manufacturers',
can: PERMISSIONS_TREE.Webhooks.Show,
hidden: () => accessor.config.env[FEATURE_FLAGS.manufacturers] !== '1',
section: SettingsSection.Shop,
},
{
id: nextId(),
type: MenuItemType.Link,
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"attributes": "Attributes",
"media": "Media",
"currencies": "Currencies",
"salesChannels": "Sales channels"
"salesChannels": "Sales channels",
"manufacturers": "Manufacturers"
},
"attributeTypes": {
"single-option": "Text single choice",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"attributes": "Atrybuty",
"media": "Media",
"currencies": "Waluty",
"salesChannels": "Kanały sprzedaży"
"salesChannels": "Kanały sprzedaży",
"manufacturers": "Producenci"
},
"attributeTypes": {
"single-option": "Tekstowy jednokrotnego wyboru",
Expand Down
19 changes: 19 additions & 0 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,25 @@ const router = new VueRouter({
permissions: [Permissions.Pages.ShowDetails],
},
},
{
path: '/manufacturers',
name: 'Manufacturers',
component: () => import('./views/manufacturers/index.vue'),
meta: {
requiresAuth: true,
permissions: [Permissions.Manufacturers.Show],
},
},
{
path: '/manufacturers/:id',
name: 'ManufacturersView',
component: () => import('./views/manufacturers/view.vue'),
meta: {
returnUrl: '/manufacturers',
requiresAuth: true,
permissions: [Permissions.Manufacturers.ShowDetails],
},
},
{
path: '/settings/banners',
name: 'Banners',
Expand Down
2 changes: 2 additions & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { menuItems } from './menuItems'
import { providers } from './providers'
import { salesChannels } from './salesChannels'
import { redirects } from './redirects'
import { manufacturers } from './manufacturers'

Vue.use(Vuex)

Expand Down Expand Up @@ -96,6 +97,7 @@ const storeModules = {
salesChannels,
menuItems,
redirects,
manufacturers,
}

const storePattern = {
Expand Down
19 changes: 19 additions & 0 deletions src/store/manufacturers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Manufacturer, ManufacturerDto } from '@heseya/store-core'
import { GLOBAL_QUERY_PARAMS, createVuexCRUD } from './generator'

export const manufacturers = createVuexCRUD<Manufacturer, ManufacturerDto, ManufacturerDto>()(
'manufacturers',
{
state: {},
getters: {},
mutations: {},
actions: {},
},
{
get: { lang_fallback: 'any' },
getOne: GLOBAL_QUERY_PARAMS,
add: GLOBAL_QUERY_PARAMS,
edit: GLOBAL_QUERY_PARAMS,
update: GLOBAL_QUERY_PARAMS,
},
)
Loading

0 comments on commit 5ca01a7

Please sign in to comment.