cambio de enabled y default por isEnabled y isDefaultAddress

This commit is contained in:
Javi Gallego 2017-09-29 14:41:30 +02:00
parent 1662c9d241
commit 19e7e0d76b
9 changed files with 12 additions and 12 deletions

View File

@ -10,7 +10,7 @@
<vn-vertical pad-large>
<vn-title>Address</vn-title>
<vn-horizontal>
<vn-check vn-one label="Default" field="$ctrl.address.default"></vn-check>
<vn-check vn-one label="Default" field="$ctrl.address.isDefaultAddress"></vn-check>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Consignee" field="$ctrl.address.consignee" vn-focus></vn-textfield>

View File

@ -4,7 +4,7 @@ export default class Controller {
constructor($state) {
this.address = {
clientFk: parseInt($state.params.id),
enabled: true
isEnabled: true
};
}
}

View File

@ -19,7 +19,7 @@ describe('Client', () => {
let controller = $componentController('vnAddressCreate', {$state});
expect(controller.address.clientFk).toBe(1234);
expect(controller.address.enabled).toBe(true);
expect(controller.address.isEnabled).toBe(true);
});
});
});

View File

@ -11,7 +11,7 @@
<vn-vertical pad-large>
<vn-title>Address</vn-title>
<vn-horizontal>
<vn-check vn-one label="Enabled" field="$ctrl.address.enabled"></vn-check>
<vn-check vn-one label="enabled" field="$ctrl.address.isEnabled"></vn-check>
<vn-check vn-one label="Is equalizated" field="$ctrl.address.isEqualizated"></vn-check>
</vn-horizontal>
<vn-horizontal>

View File

@ -7,11 +7,11 @@
</vn-horizontal>
<vn-horizontal ng-repeat="i in index.model track by i.id" class="pad-medium-top" style="align-items: center;">
<vn-auto style="border-radius: .5em;" class="pad-small border-solid"
ng-class="{'bg-dark-item': i.default,'bg-opacity-item': !i.enabled && !i.default}">
ng-class="{'bg-dark-item': i.isDefaultAddress,'bg-opacity-item': !i.isEnabled && !i.isDefaultAddress}">
<vn-horizontal style="align-items: center;">
<vn-none pad-medium-h style="color:#FFA410;">
<i class="material-icons" ng-if="i.default">star</i>
<i class="material-icons pointer" ng-if="!i.default&&i.enabled" vn-tooltip="Set as default" tooltip-position="left" ng-click="$ctrl.setDefault(i.id)">star_border</i>
<i class="material-icons" ng-if="i.isDefaultAddress">star</i>
<i class="material-icons pointer" ng-if="!i.isDefaultAddress&&i.isEnabled" vn-tooltip="Set as default" tooltip-position="left" ng-click="$ctrl.setDefault(i.id)">star_border</i>
</vn-none>
<vn-auto>
<div><b>{{::i.consignee}}</b></div>

View File

@ -6,7 +6,7 @@ class ClientAddresses {
this.$scope = $scope;
}
setDefault(id) {
this.$http.patch(`/client/api/Addresses/${id}`, {id: id, default: 1}).then(() => {
this.$http.patch(`/client/api/Addresses/${id}`, {id: id, isDefaultAddress: true}).then(() => {
this.$scope.index.accept();
});
}

View File

@ -38,7 +38,7 @@ module.exports = function(Client) {
},
skip: (params.page - 1) * params.size,
limit: params.size,
order: ['default DESC', 'enabled DESC']
order: ['isDefaultAddress DESC', 'isEnabled DESC']
};
Client.app.models.Address.find(filter, function(err, instances) {

View File

@ -1,7 +1,7 @@
module.exports = function(Address) {
Address.validate('default',isEnabled,{message: 'No se puede poner predeterminado un consignatario desactivado'});
function isEnabled(err) {
if (!this.enabled && this.default) err();
if (!this.isEnabled && this.default) err();
}
Address.beforeRemote('create',function(ctx, modelInstance, next){

View File

@ -29,10 +29,10 @@
"mobile": {
"type": "string"
},
"enabled": {
"isEnabled": {
"type": "boolean"
},
"default": {
"isDefaultAddress": {
"type": "boolean"
},
"longitude": {