Skip to content

Commit

Permalink
BO: Update export-import and low stock
Browse files Browse the repository at this point in the history
  • Loading branch information
nihco2 authored and aleeks committed Sep 8, 2017
1 parent 6cc79e8 commit 1f6f8e1
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 12 deletions.
14 changes: 9 additions & 5 deletions admin-dev/themes/new-theme/js/app/pages/stock/components/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div v-if="isReady" id="app" class="stock-app">
<StockHeader />
<Search @search="onSearch" @applyFilter="applyFilter" />
<LowFilter @lowStockChecked="onLowStockChecked" />
<LowFilter v-if="isOverview" :filters="filters" @lowStockChecked="onLowStockChecked" />
<div class="card pa-2">
<router-view class="view" @resetFilters="resetFilters" @fetch="fetch"></router-view>
</div>
Expand Down Expand Up @@ -56,6 +56,9 @@
currentPagination() {
return this.$store.state.pageIndex;
},
isOverview() {
return this.$route.name === 'overview';
},
},
methods: {
onPageChanged(pageIndex) {
Expand All @@ -71,12 +74,14 @@
}
this.$store.dispatch('isLoading');
this.$store.dispatch(action, Object.assign(this.filters, {
this.filters = Object.assign({}, this.filters, {
order: `${this.$store.state.order}${sorting}`,
page_size: this.$store.state.productsPerPage,
page_index: this.$store.state.pageIndex,
keywords: this.$store.state.keywords,
}));
});
this.$store.dispatch(action, this.filters);
},
onSearch(keywords) {
this.$store.dispatch('updateKeywords', keywords);
Expand All @@ -90,8 +95,7 @@
this.filters = {};
},
onLowStockChecked(isChecked) {
console.log(isChecked)
Object.assign(this.filters, {
this.filters = Object.assign({}, this.filters, {
low_stock: isChecked,
});
this.fetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,67 @@
*-->

<template>
<div class="row py-2 container">
<PSCheckbox id="low-filter" class="mt-1 ml-1" @checked="onCheck" />
<p class="ml-2">{{trans('filter_low_stock')}}</p>
<div class="row py-2">
<div class="col row ml-1">
<PSCheckbox ref="low-filter" id="low-filter" class="mt-1" @checked="onCheck" />
<p class="ml-2 low-filter-label" @click="onLabelClick">{{trans('filter_low_stock')}}</p>
</div>
<div class="col">
<a id="desc-product-export" class="float-sm-right ml-2" :href="stockImportUrl">
<span data-toggle="pstooltip" :title="stockImportTitle" data-html="true" data-placement="top">
<i class="material-icons">cloud_download</i>
</span>
</a>
<a id="desc-product-export" class="float-sm-right" :href="stockExporttUrl">
<span data-toggle="pstooltip" :title="stockExportTitle" data-html="true" data-placement="top">
<i class="material-icons">cloud_upload</i>
</span>
</a>
</div>
</div>
</template>

<script>
import PSCheckbox from 'app/widgets/ps-checkbox';
export default {
props: {
filters: {},
},
computed: {
stockImportTitle() {
return this.trans('title_import');
},
stockExportTitle() {
return this.trans('title_export');
},
stockImportUrl() {
return window.data.stockImportUrl;
},
stockExporttUrl() {
const params = $.param(this.filters);
return `${window.data.stockExportUrl}&${params}`;
},
},
methods: {
onLabelClick() {
this.$refs['low-filter'].checked = !this.$refs['low-filter'].checked;
},
onCheck(checkbox) {
const isChecked = checkbox.checked ? 1 : 0;
this.$emit('lowStockChecked', isChecked);
},
},
mounted() {
$('[data-toggle="pstooltip"]').pstooltip();
},
components: {
PSCheckbox,
},
};
</script>

<style lang="sass" scoped>
.low-filter-label {
cursor: pointer;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
.search-button {
float: right;
position: absolute;
right: 15px;
right: 22px;
top: 1px;
margin-top: 28px;
height: 35px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<i class="material-icons">trending_flat</i>
{{availableQtyUpdated}}
</span>
<span v-if="lowStock" class="stock-warning ico ml-4">!</span>
<span v-if="lowStock" rel="tooltip" class="stock-warning ico ml-4" data-toggle="pstooltip" data-placement="top" data-html="true" :title="lowStockLevel">!</span>
</td>
<td class="qty-spinner">
<Spinner :product="product" class="pull-xs-right" @updateProductQty="updateProductQty" />
Expand Down Expand Up @@ -114,6 +114,12 @@
lowStock() {
return this.product.product_low_stock_alert;
},
lowStockLevel() {
return `<div class="text-sm-left">
<p>${this.trans('product_low_stock')}</p>
<p><strong>${this.trans('product_low_stock_level')} ${this.product.product_low_stock_threshold}</strong></p>
</div>`;
},
},
methods: {
productChecked(checkbox) {
Expand Down Expand Up @@ -145,6 +151,7 @@
this.$refs[ref].checked = checked;
}
});
$('[data-toggle="pstooltip"]').pstooltip();
},
data: () => ({
bulkEdition: false,
Expand Down Expand Up @@ -183,6 +190,7 @@
border: 1px solid $danger;
background: lighten($danger, 30%);
padding: 0 5px;
cursor: pointer;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
catalogUrl: '{{ url('admin_product_catalog') }}',
stockUrl: '{{ url('admin_stock_overview') }}',
stockExportUrl: '{{ url('api_stock_list_products_export') }}',
stockImportUrl: '{{ getAdminLink('AdminImport') }}',
stockImportUrl: '{{ getAdminLink('AdminImport')|raw }}',
apiStockUrl: '{{ productId ? url('api_stock_list_product_combinations', {'productId' : productId}) : url('api_stock_list_products') }}',
apiMovementsUrl: '{{ productId ? url('api_stock_product_list_movements', {'productId' : productId}) : url('api_stock_list_movements') }}',
employeesUrl: '{{ url('api_stock_list_movements_employees') }}',
Expand Down
6 changes: 5 additions & 1 deletion src/PrestaShopBundle/Translation/Api/StockApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function getTranslations()
'filter_categories' => $this->translator->trans('Filter by categories', array(), 'Admin.Actions'),
'filter_datepicker_from' => $this->translator->trans('From', array(), 'Admin.Global'),
'filter_datepicker_to' => $this->translator->trans('To', array(), 'Admin.Global'),
'filter_low_stock' => $this->translator->trans('Display products below low level first', array(), 'Admin.Catalog.Feature'),
'filter_low_stock' => $this->translator->trans('Display products below low stock level first', array(), 'Admin.Catalog.Feature'),
'filter_movements_type' => $this->translator->trans('Filter by movement type', array(), 'Admin.Catalog.Feature'),
'filter_movements_employee'=> $this->translator->trans('Filter by employee', array(), 'Admin.Catalog.Feature'),
'filter_movements_period' => $this->translator->trans('Filter by period', array(), 'Admin.Catalog.Feature'),
Expand All @@ -65,11 +65,15 @@ public function getTranslations()
'none' => $this->translator->trans('None', array(), 'Admin.Catalog.Feature'),
'notification_stock_updated' => $this->translator->trans('Stock successfully updated', array(), 'Admin.Catalog.Notification'),
'product_search' => $this->translator->trans('Search products (search by name, reference, supplier)', array(), 'Admin.Catalog.Feature'),
'product_low_stock' => $this->translator->trans('This product is below the low stock level you have defined.', array(), 'Admin.Catalog.Feature'),
'product_low_stock_level' => $this->translator->trans('Low stock level:', array(), 'Admin.Catalog.Feature'),
'title_available' => $this->translator->trans('Available', array(), 'Admin.Global'),
'title_bulk' => $this->translator->trans('Bulk edit quantity', array(), 'Admin.Catalog.Feature'),
'title_date' => $this->translator->trans('Date & Time', array(), 'Admin.Catalog.Feature'),
'title_edit_quantity' => $this->translator->trans('Edit quantity', array(), 'Admin.Catalog.Feature'),
'title_employee' => $this->translator->trans('Employee', array(), 'Admin.Global'),
'title_import' => $this->translator->trans('Go to the import system', array(), 'Admin.Catalog.Feature'),
'title_export' => $this->translator->trans('Export data into CSV', array(), 'Admin.Catalog.Feature'),
'title_movements_type' => $this->translator->trans('Type', array(), 'Admin.Global'),
'title_physical' => $this->translator->trans('Physical', array(), 'Admin.Catalog.Feature'),
'title_product' => $this->translator->trans('Product', array(), 'Admin.Global'),
Expand Down

0 comments on commit 1f6f8e1

Please sign in to comment.