Skip to content
This repository has been archived by the owner on Apr 22, 2022. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
t13ka committed Apr 16, 2020
2 parents 6f68ce5 + d84aa0b commit cdd7d67
Show file tree
Hide file tree
Showing 19 changed files with 97 additions and 49 deletions.
2 changes: 1 addition & 1 deletion client-app/nswag.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"enumNameGeneratorType": null,
"serviceHost": null,
"serviceSchemes": null,
"output": "src/common/api/api-clients.ts"
"output": "src/core/api/api-clients.ts"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import Vue from "vue";
import Component from "vue-class-component";
import { Validation } from "vuelidate"; //Don't remove this import
import { storeName, locale, orderDraftType, startPageNumber, defaultPageSize } from "core/constants";
import { listClient } from "core/services/api-clients.service";
import { required } from "vuelidate/lib/validators";
import { CartSearchCriteria } from '@core/api/api-clients';

@Component({
validations: {
draftName: { required }
draftName: {
required,
async isUnique(value) {
if (value === '') return true;
const criteria = new CartSearchCriteria({type: orderDraftType, pageNumber: startPageNumber, pageSize: defaultPageSize, name: value});
criteria.keyword = value;
const result = await listClient.searchLists(criteria, storeName, locale);
return result.totalCount == 0;
}
}
}
})
export default class AddDraftModal extends Vue {
Expand All @@ -22,4 +34,5 @@ export default class AddDraftModal extends Vue {
this.$emit("draftAdded", this.draftName);
this.$bvModal.hide("addDraftModal");
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<template>
<b-modal id="addDraftModal"
no-close-on-backdrop
@hide="resetForm">
@hidden="resetForm">
<div slot="modal-title">
{{ $t("account.drafts.add-draft.title") }}
</div>
<b-form>
<b-form id="add-draft-form"
novalidate
@submit.prevent="submitForm">
<b-form-group
:label="$t('account.drafts.add-draft.draft-name-label')"
label-for="draftName">
Expand All @@ -15,10 +17,14 @@
:class="{ 'is-invalid': $v.draftName.$error }"
type="text"
:placeholder="$t('account.drafts.add-draft.draft-name-placeholder')"
:debounce="1000"
@blur="$v.draftName.$touch()"></b-form-input>
<b-form-invalid-feedback v-if="!$v.draftName.required">
{{ $t("account.drafts.add-draft.draft-name-required") }}
</b-form-invalid-feedback>
<b-form-invalid-feedback v-if="!$v.draftName.isUnique">
{{ $t("account.drafts.add-draft.draft-name-unique") }}
</b-form-invalid-feedback>
</b-form-group>
</b-form>
<template v-slot:modal-footer>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<div class="d-flex flex-wrap justify-content-between">
<h5 class="align-self-center m-0 text-break">
<div class="d-flex justify-content-between align-items-start">
<h5 class="m-0 text-break">
{{ title }}
</h5>
<button v-if="cart.itemsCount != 0"
class="btn btn-link px-0"
class="btn btn-link px-0 pt-0 text-nowrap"
@click="onClearCartClicked()">
{{ $t('shopping-cart.clear-cart') }}
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Vue from "vue";
import Component from "vue-class-component";
import { Prop, Emit } from "vue-property-decorator";
import { Prop, Emit, Watch } from "vue-property-decorator";
import { faPlusCircle, faMinusCircle } from "@fortawesome/free-solid-svg-icons";


Expand All @@ -11,6 +11,12 @@ export default class ChangeItemQuantity extends Vue {
@Prop()
quantity!: number;


@Watch("quantity")
watchQuantity(value: number) {
this.model = value;
}

model = 0;

mounted (){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export default class AddToCartButton extends Vue {
@Prop()
productId!: string;

@Prop()
textVisible!: boolean;

@cartModule.Action(ADD_ITEM_TO_CART)
addItemToCart!: (addItem: AddCartItem) => void;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<template>
<button class="app-add-item-to-cart btn btn-outline-primary w-100 h-100 d-flex justify-content-center"
<button class="app-add-item-to-cart btn btn-outline-primary w-100 h-100"
:title="$t('products.general.add_to_cart')"
@click.prevent="onClick">
<i class="fas fa-shopping-cart"></i>
<span v-if="textVisible">{{ $t('products.general.add_to_cart') }}</span>
</button>
</template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export default class AddToDraftButton extends Vue {
@Prop()
productId!: string;

@Prop()
textVisible!: boolean;

@draftModule.Getter("drafts")
drafts!: ShoppingCartSearchResult[];

Expand Down Expand Up @@ -56,4 +59,8 @@ export default class AddToDraftButton extends Vue {
await this.addItemToDraft(addItemToDraft);
}

isItemDisabled(draft: ShoppingCart) {
return draft.items?.some(x => x.productId == this.productId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@
<add-draft-modal @draftAdded="addToNewDraft($event)"></add-draft-modal>
<b-dropdown ref="dropdown"
class="w-100 h-100"
:title="$t('products.general.add_to_order_draft')"
right
variant="outline-primary">
<template v-slot:button-content>
<i class="fas fa-file-alt"></i>
<span v-if="textVisible">{{ $t('products.general.add_to_order_draft') }}</span>
</template>
<b-overlay :show="isLoading"
rounded="sm"
:variant="'white'"
:opacity="0.69">
<b-dropdown-item v-b-modal.addDraftModal>
<font-awesome-icon :icon="plusIcon"></font-awesome-icon> Add to new order draft
<font-awesome-icon :icon="plusIcon"></font-awesome-icon> {{ $t('products.general.add_to_new_order_draft') }}
</b-dropdown-item>
<b-dropdown-divider></b-dropdown-divider>
<b-dropdown-divider v-if="drafts.results.length > 0"></b-dropdown-divider>
<b-dropdown-item v-for="draft in drafts.results"
:key="draft.name"
:disabled="isItemDisabled(draft)"
@click="addToDraft(draft)">
{{ draft.name }}
</b-dropdown-item>
Expand Down
8 changes: 5 additions & 3 deletions client-app/src/libs/user/components/add-user-modal/index.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<template>
<b-modal id="addUserModal"
no-close-on-backdrop
@hide="resetForm">
@hidden="resetForm">
<div slot="modal-title">
{{ $t("account.users.add-user.title") }}
</div>
<b-form>
<b-form id="add-user-form"
novalidate
@submit.prevent="submitForm">
<b-form-group :label="$t('account.users.add-user.email-label')"
label-for="email">
<b-form-input
Expand Down Expand Up @@ -157,7 +159,7 @@
</b-form>
<template v-slot:modal-footer>
<b-button
variant="primary"
variant="outline-primary"
:disabled="$v.user.$invalid"
@click="submitForm">
{{ $t("account.users.add-user.submit") }}
Expand Down
9 changes: 6 additions & 3 deletions client-app/src/libs/user/components/edit-user-modal/index.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<template>
<b-modal id="editUserModal"
no-close-on-backdrop
@hide="resetForm">
@hidden="resetForm">
<div slot="modal-title">
{{ $t("account.users.edit-user-title") }}
</div>
<b-form v-if="userInfo">
<b-form v-if="userInfo"
id="edit-user-form"
novalidate
@submit.prevent="submitForm">
<b-form-group :label="$t('account.users.add-user.email-label')" label-for="email">
<b-form-input
id="email"
Expand Down Expand Up @@ -62,7 +65,7 @@
</b-form>
<template v-slot:modal-footer>
<b-button
variant="primary"
variant="outline-primary"
:disabled="$v.userInfo.$invalid"
@click="submitForm">
{{ $t("account.users.add-user.submit") }}
Expand Down
12 changes: 8 additions & 4 deletions client-app/src/pages/catalog/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,26 @@ const addToCartElements = document.getElementsByClassName("app-add-item-to-cart"

for(const addToCartEl of addToCartElements){
const productId = addToCartEl.attributes.getNamedItem("product-id")!.value
const textVisible = !!addToCartEl.attributes.getNamedItem("text-visible");
new Vue({
i18n,
store,
render ( h ) {
return h(AddToCartButton, {
props: {
productId: productId
productId: productId,
textVisible: textVisible
}
})
}
}).$mount(addToCartEl, true);
}).$mount(addToCartEl);
}

new Vue({
i18n,
store,
render: h => h(CartButton)
}).$mount("#app-cart", true);
}).$mount("#app-cart");



Expand All @@ -61,13 +63,15 @@ const addToDraftElements = document.getElementsByClassName("app-add-item-to-draf

for(const addToDraftEl of addToDraftElements){
const productId = addToDraftEl.attributes.getNamedItem("product-id")!.value
const textVisible = !!addToDraftEl.attributes.getNamedItem("text-visible");
new Vue({
i18n,
store,
render ( h ) {
return h(AddToDraftButton, {
props: {
productId: productId
productId: productId,
textVisible: textVisible
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
@hidden="hide">
<b-overlay :show="isLoading"
rounded="sm"
:opacity="0.33">
<div class="d-flex flex-column">
:opacity="0.33"
class="h-100">
<div v-if="cart" class="d-flex flex-column">
<cart-header
:cart="cart"
:title="$t('shopping-cart.title')"
Expand Down
3 changes: 3 additions & 0 deletions locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@
"general": {
"save_html": "Speichern {0}",
"add_to_cart": "In den Einkaufswagen legen",
"add_to_order_draft": "Zum Auftragsentwurf hinzufügen",
"add_to_new_order_draft": "Zum neuen Auftragsentwurf hinzufügen",
"add_to_quote": "Zum Zitat hinzufügen",
"description_tab": "Produktbeschreibung"
},
Expand Down Expand Up @@ -363,6 +365,7 @@
"draft-name-label": "Entwurfsname",
"draft-name-placeholder": "Entwurfsname",
"draft-name-required": "Entwurfsname ist erforderlich",
"draft-name-unique": "Der Entwurfsname sollte eindeutig sein",
"submit": "Einreichen"
},
"search-label": "Suche",
Expand Down
3 changes: 3 additions & 0 deletions locales/en.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@
"general": {
"save_html": "Save {0}",
"add_to_cart": "Add to cart",
"add_to_order_draft": "Add to order draft",
"add_to_new_order_draft": "Add to new order draft",
"add_to_quote": "Add to quote"
},
"product": {
Expand Down Expand Up @@ -322,6 +324,7 @@
"draft-name-label": "Draft name",
"draft-name-placeholder": "Draft name",
"draft-name-required": "Draft name is required",
"draft-name-unique": "Draft name should be unique",
"submit": "Submit"
},
"search-label": "Search",
Expand Down
2 changes: 1 addition & 1 deletion snippets/content_header.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ul>
<ul class="navbar-nav ml-auto">
<li>
<button id="app-cart" class="btn btn-secondary p-2 m-10"><i class="fas fa-shopping-cart"></i> <span></span></button>
<span id="app-cart"></span>
</li>
<li class="nav-item">
{% if customer.is_registered_user %}
Expand Down
8 changes: 4 additions & 4 deletions snippets/product-grid-item.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@
<div class="form-row">
{% if product.available %}
<div class="col">
<button class="app-add-item-to-cart btn btn-outline-primary col d-flex justify-content-center p-1" title="{{ 'products.general.add_to_cart' | t }}" product-id="{{product.id}}"><i class="fas fa-shopping-cart"></i></button>
<button class="app-add-item-to-cart btn btn-outline-primary col" title="{{ 'products.general.add_to_cart' | t }}" product-id="{{product.id}}"><i class="fas fa-shopping-cart"></i></button>
</div>
<div class="col">
<button class="app-add-item-to-draft btn btn-outline-primary col d-flex justify-content-center p-1" title="{{ 'products.general.add_to_cart' | t }}" product-id="{{product.id}}"><i class="fas fa-file-alt"></i></button>
<button class="app-add-item-to-draft btn btn-outline-primary col" title="{{ 'products.general.add_to_cart' | t }}" product-id="{{product.id}}"><i class="fas fa-file-alt"></i></button>
</div>
{% endif %}
{% if unavailable %}
<button class="btn btn-outline-primary w-100 d-flex justify-content-center p-1" title="{{ 'products.general.add_to_cart' | t }}" disabled>
<button class="btn btn-outline-primary w-100" title="{{ 'products.general.add_to_cart' | t }}" disabled>
<span class="font-weight-bold text-uppercase">{{ 'products.product.unavailable' | t }}</span>
</button>
{% endif %}
{% if sold_out %}
<button class="btn btn-outline-primary w-100 d-flex justify-content-center p-1" title="{{ 'products.general.add_to_cart' | t }}" disabled>
<button class="btn btn-outline-primary w-100" title="{{ 'products.general.add_to_cart' | t }}" disabled>
<span class="font-weight-bold text-uppercase">{{ 'products.product.sold_out' | t }}</span>
</button>
{% endif %}
Expand Down
2 changes: 2 additions & 0 deletions templates/collection.liquid
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{{ paginator = product_search_result.products | paginate }}
{% include 'search-result' %}

<script src="{{ 'bundle/dist/js/catalog.js' | static_asset_url | append_version }}"></script>
Loading

0 comments on commit cdd7d67

Please sign in to comment.