kanban: asociar envío escrito con cambio de valor

This commit is contained in:
Dani Herrero 2017-05-31 12:56:37 +02:00
parent 11a402e18c
commit 528dcac06f
5 changed files with 74 additions and 3 deletions

View File

@ -5,7 +5,7 @@
form="form"
save="put">
</vn-watcher>
<form name="form" ng-submit="watcher.submit()" pad-medium>
<form name="form" ng-submit="bill.checkChanges() && watcher.submit()" pad-medium>
<vn-card margin-small-bottom>
<vn-vertical pad-large>
<vn-title>Información de facturación</vn-title>
@ -40,4 +40,18 @@
<vn-button-bar>
<vn-submit label="Guardar"></vn-submit>
</vn-button-bar>
</form>
</form>
<vn-dialog
vn-id="send-mail"
on-response="bill.returnDialog(response)">
<tpl-body>
<vn-vertical>
<vn-one text-center translate>Changed terms</vn-one>
<vn-one text-center translate>Notify customer?</vn-one>
</vn-vertical>
</tpl-body>
<tpl-buttons>
<button response="CANCEL" translate>No</button>
<button response="ACCEPT" translate>Yes, notify</button>
</tpl-buttons>
</vn-dialog>

View File

@ -1,8 +1,56 @@
import {module} from '../module';
export const NAME = 'vnClientBillingData';
class billingData {
constructor($scope, $http, $timeout) {
this.$ = $scope;
this.http = $http;
this.timeout = $timeout;
this.payId = null;
this.dueDay = null;
this.copyData();
}
$onChanges(changes) {
this.copyData();
}
copyData() {
if (this.client) {
this.payId = this.client.payMethod ? this.client.payMethod.id : null;
this.dueDay = this.client.dueDay ? this.client.dueDay : null;
}
}
checkChanges() {
let payId = this.client.payMethodFk || null;
let dueDay = this.client.dueDay || null;
let dialog = this.$.sendMail;
if (dialog && (this.payId !== payId || this.dueDay !== dueDay)) {
dialog.show();
return false;
}
return true;
}
returnDialog(response) {
if (response === 'ACCEPT') {
this.sendMail();
}
this.timeout(() => this.$.watcher.submit());
}
sendMail() {
this.http.post(`/mailer/manuscript/paymentUpdate`, {user: this.client.id});
}
}
billingData.$inject = ['$scope', '$http', '$timeout'];
export const COMPONENT = {
template: require('./billing-data.html'),
controller: billingData,
controllerAs: 'bill',
bindings: {
client: '<'

View File

@ -0,0 +1,6 @@
{
"Changed terms": "Has modificado las condiciones de pago",
"Notify customer?" : "¿Deseas notificar al cliente con dichos cambios?",
"No": "No",
"Yes, notify": "Sí, notificar"
}

View File

@ -26,4 +26,7 @@ html [fixed-bottom-right] {
vn-button-bar {
display: block;
margin-top: $margin-small;
}
html [text-center], .text-center {
text-align: center;
}

View File

@ -4,7 +4,7 @@ var settings = require('./settings.js');
// Página por defecto
router.get('/', function(request, response) {
response.send(Settings.name + ' v' + settings.version);
response.send(settings.name + ' v' + settings.version);
});
// Rutas de los escritos.