salix/client/order/src/catalog/index.js

74 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-07-24 07:35:23 +00:00
import ngModule from '../module';
2018-09-14 07:10:30 +00:00
import './style.scss';
2018-07-24 07:35:23 +00:00
class Controller {
constructor($scope, $state, $translate) {
2018-07-24 07:35:23 +00:00
this.$scope = $scope;
this.$state = $state;
2018-09-14 07:10:30 +00:00
this.orderList = [
{
order: 'relevancy DESC, name',
name: $translate.instant('Default order')
},
{
order: 'name',
name: $translate.instant('Ascendant name')
},
{
order: 'name DESC',
name: $translate.instant('Descendant name')
},
{
order: 'price',
name: $translate.instant('Ascendant price')
},
{
order: 'price DESC',
name: $translate.instant('Descendant price')
}
];
2018-09-14 07:37:54 +00:00
this.orderBy = this.orderList[0].order;
2018-09-14 07:10:30 +00:00
this.filter = {
2018-09-14 07:37:54 +00:00
order: this.orderBy
2018-09-14 07:10:30 +00:00
};
2018-07-24 07:35:23 +00:00
}
2018-09-14 07:10:30 +00:00
get orderBy() {
return this._orderBy;
2018-07-24 07:35:23 +00:00
}
2018-09-14 07:10:30 +00:00
set orderBy(value) {
this._orderBy = value;
2018-07-24 07:35:23 +00:00
}
2018-09-14 07:10:30 +00:00
setOrder(order) {
this.$scope.model.filter.order = order;
this.$scope.model.refresh();
2018-07-24 07:35:23 +00:00
}
2018-08-21 11:38:16 +00:00
preview(event, item) {
event.preventDefault();
this.$scope.pricesPopover.show(event, item);
}
onDescriptorLoad() {
this.$scope.popover.relocate();
}
$onChanges() {
if (this.order && this.order.isConfirmed) {
this.$state.go('order.card.line');
}
}
2018-07-24 07:35:23 +00:00
}
Controller.$inject = ['$scope', '$state', '$translate'];
2018-07-24 07:35:23 +00:00
2018-08-21 11:38:16 +00:00
ngModule.component('vnOrderCatalog', {
2018-07-24 07:35:23 +00:00
template: require('./index.html'),
controller: Controller,
bindings: {
order: '<'
}
});