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

31 lines
858 B
JavaScript

import ngModule from '../../module';
class Controller {
constructor($http, $scope, $stateParams) {
this.$http = $http;
this.$scope = $scope;
this.$stateParams = $stateParams;
this.filter = {
include: {
observations: 'observationType'
},
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC']
};
}
setDefault(address) {
if (address.isActive) {
let params = {isDefaultAddress: true};
this.$http.patch(`/client/api/Addresses/${address.id}`, params).then(
() => this.$scope.model.refresh()
);
}
}
}
Controller.$inject = ['$http', '$scope', '$stateParams'];
ngModule.component('vnClientAddressIndex', {
template: require('./index.html'),
controller: Controller
});