salix/modules/client/front/address/index/index.js

31 lines
858 B
JavaScript
Raw Normal View History

2018-05-23 12:26:51 +00:00
import ngModule from '../../module';
2018-05-23 12:26:51 +00:00
class Controller {
2018-07-16 06:00:04 +00:00
constructor($http, $scope, $stateParams) {
2017-09-28 12:34:18 +00:00
this.$http = $http;
this.$scope = $scope;
2018-07-16 06:00:04 +00:00
this.$stateParams = $stateParams;
this.filter = {
include: {
observations: 'observationType'
},
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC']
};
2017-09-28 12:34:18 +00:00
}
2018-07-16 06:00:04 +00:00
2018-02-08 08:04:29 +00:00
setDefault(address) {
if (address.isActive) {
let params = {isDefaultAddress: true};
this.$http.patch(`/client/api/Addresses/${address.id}`, params).then(
2018-07-16 06:00:04 +00:00
() => this.$scope.model.refresh()
2018-02-08 08:04:29 +00:00
);
}
2017-09-28 12:34:18 +00:00
}
}
2018-07-16 06:00:04 +00:00
Controller.$inject = ['$http', '$scope', '$stateParams'];
2017-09-28 12:34:18 +00:00
2018-05-23 12:26:51 +00:00
ngModule.component('vnClientAddressIndex', {
template: require('./index.html'),
controller: Controller
2017-06-03 11:01:47 +00:00
});