Merge branch 'dev' of https://git.verdnatura.es/salix into dev

This commit is contained in:
Dani Herrero 2017-10-03 07:10:52 +02:00
commit ff6801c8e8
15 changed files with 36 additions and 28 deletions

View File

@ -10,7 +10,7 @@
<vn-vertical pad-large> <vn-vertical pad-large>
<vn-title>Address</vn-title> <vn-title>Address</vn-title>
<vn-horizontal> <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-horizontal> <vn-horizontal>
<vn-textfield vn-one label="Consignee" field="$ctrl.address.consignee" vn-focus></vn-textfield> <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) { constructor($state) {
this.address = { this.address = {
clientFk: parseInt($state.params.id), clientFk: parseInt($state.params.id),
enabled: true isEnabled: true
}; };
} }
} }

View File

@ -19,7 +19,7 @@ describe('Client', () => {
let controller = $componentController('vnAddressCreate', {$state}); let controller = $componentController('vnAddressCreate', {$state});
expect(controller.address.clientFk).toBe(1234); 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-vertical pad-large>
<vn-title>Address</vn-title> <vn-title>Address</vn-title>
<vn-horizontal> <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-check vn-one label="Is equalizated" field="$ctrl.address.isEqualizated"></vn-check>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>

View File

@ -7,11 +7,11 @@
</vn-horizontal> </vn-horizontal>
<vn-horizontal ng-repeat="i in index.model track by i.id" class="pad-medium-top" style="align-items: center;"> <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" <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-horizontal style="align-items: center;">
<vn-none pad-medium-h style="color:#FFA410;"> <vn-none pad-medium-h style="color:#FFA410;">
<i class="material-icons" ng-if="i.default">star</i> <i class="material-icons" ng-if="i.isDefaultAddress">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 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-none>
<vn-auto> <vn-auto>
<div><b>{{::i.consignee}}</b></div> <div><b>{{::i.consignee}}</b></div>

View File

@ -6,7 +6,7 @@ class ClientAddresses {
this.$scope = $scope; this.$scope = $scope;
} }
setDefault(id) { 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(); this.$scope.index.accept();
}); });
} }

View File

@ -41,7 +41,7 @@ export default class Controller {
} }
returnDialog(response) { returnDialog(response) {
if (response === 'ACCEPT') { if (response === 'ACCEPT') {
this.$http.post(`/mailer/manuscript/${this.client.id}/payment-update`).then( this.$http.post(`/mailer/manuscript/payment-update/${this.client.id}`).then(
() => this.vnApp.showMessage(this.translate.instant('Notification sent!')) () => this.vnApp.showMessage(this.translate.instant('Notification sent!'))
); );
} }

View File

@ -75,8 +75,8 @@ describe('Client', () => {
it('should request to send notification email', () => { it('should request to send notification email', () => {
let controller = $componentController('vnClientBillingData', {$scope: $scope}); let controller = $componentController('vnClientBillingData', {$scope: $scope});
controller.client = {id: '123'}; controller.client = {id: '123'};
$httpBackend.when('POST', `/mailer/manuscript/${controller.client.id}/payment-update`).respond('done'); $httpBackend.when('POST', `/mailer/manuscript/payment-update/${controller.client.id}`).respond('done');
$httpBackend.expectPOST(`/mailer/manuscript/${controller.client.id}/payment-update`); $httpBackend.expectPOST(`/mailer/manuscript/payment-update/${controller.client.id}`);
controller.returnDialog('ACCEPT'); controller.returnDialog('ACCEPT');
$httpBackend.flush(); $httpBackend.flush();
}); });

View File

@ -36,10 +36,13 @@ module.exports = function(Client) {
let filter = {where: {clientFk: client.id}, fields: ['started', 'ended']}; let filter = {where: {clientFk: client.id}, fields: ['started', 'ended']};
app.models.CreditClassification.findOne(filter, function(err, data) { app.models.CreditClassification.findOne(filter, function(error, data) {
if (error)
return;
let currentDate = new Date(); let currentDate = new Date();
if (client.active && data.ended >= currentDate) { if (data && client.active && (data.ended >= currentDate || data.ended == null)) {
let host = ctx.req.headers.host.split(':')[0]; let host = ctx.req.headers.host.split(':')[0];
var options = { var options = {
url: `http://${host}:5000/mailer/notification/client-deactivate/${client.id}`, url: `http://${host}:5000/mailer/notification/client-deactivate/${client.id}`,

View File

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

View File

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

View File

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

View File

@ -1,10 +1,16 @@
var express = require('express'); var express = require('express');
var router = new express.Router(); var router = new express.Router();
var mail = require('../mail.js'); var mail = require('../mail.js');
var auth = require('../auth.js');
// Auth middleware
var requestToken = function(request, response, next) {
auth.init(request, response, next);
};
// Payment method changes // Payment method changes
router.post('/:recipient/payment-update', function(request, response, next) { router.post('/payment-update/:clientId', requestToken, function(request, response, next) {
mail.sendWithTemplate('payment-update', {recipient: request.params.recipient}, result => { mail.sendWithTemplate('payment-update', {recipient: request.params.clientId}, result => {
return response.json(result); return response.json(result);
}); });
}); });

View File

@ -3,6 +3,13 @@ var router = new express.Router();
var mail = require('../mail.js'); var mail = require('../mail.js');
var database = require('../database.js'); var database = require('../database.js');
var settings = require('../settings.js'); var settings = require('../settings.js');
var auth = require('../auth.js');
// Auth middleware
var requestToken = function(request, response, next) {
auth.init(request, response, next);
};
// Single user notification // Single user notification
/* router.post('/:recipient/noticeUserSend', function(request, response) { /* router.post('/:recipient/noticeUserSend', function(request, response) {
var params = { var params = {
@ -64,7 +71,7 @@ var settings = require('../settings.js');
}); */ }); */
// Send notification to alias solunion on client deactivate // Send notification to alias solunion on client deactivate
router.post('/client-deactivate/:clientId', function(request, response) { router.post('/client-deactivate/:clientId', requestToken, function(request, response) {
var params = { var params = {
alias: 'solunion', alias: 'solunion',
code: 'clientDeactivate', code: 'clientDeactivate',

View File

@ -7,19 +7,11 @@ var bodyParser = require('body-parser');
var settings = require('./application/settings.js'); var settings = require('./application/settings.js');
var mail = require('./application/mail.js'); var mail = require('./application/mail.js');
var database = require('./application/database.js'); var database = require('./application/database.js');
var auth = require('./application/auth.js');
// Body parser middleware // Body parser middleware
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true})); app.use(bodyParser.urlencoded({extended: true}));
// Auth middleware
var requestToken = function(request, response, next) {
auth.init(request, response, next);
};
app.use(requestToken);
// Load routes // Load routes
app.use('/', require('./application/router.js')); app.use('/', require('./application/router.js'));