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 {
|
2018-09-18 07:37:54 +00:00
|
|
|
constructor($scope, $state, $translate) {
|
2018-07-24 07:35:23 +00:00
|
|
|
this.$scope = $scope;
|
2018-09-18 07:37:54 +00:00
|
|
|
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-20 07:01:38 +00:00
|
|
|
|
2018-08-21 11:38:16 +00:00
|
|
|
preview(event, item) {
|
|
|
|
event.preventDefault();
|
2018-08-20 07:01:38 +00:00
|
|
|
this.$scope.pricesPopover.show(event, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
onDescriptorLoad() {
|
|
|
|
this.$scope.popover.relocate();
|
|
|
|
}
|
2018-09-18 07:37:54 +00:00
|
|
|
|
|
|
|
$onChanges() {
|
|
|
|
if (this.order && this.order.isConfirmed) {
|
|
|
|
this.$state.go('order.card.line');
|
|
|
|
}
|
|
|
|
}
|
2018-07-24 07:35:23 +00:00
|
|
|
}
|
|
|
|
|
2018-09-18 07:37:54 +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: '<'
|
|
|
|
}
|
|
|
|
});
|