tarea Añadir email y user al formulario de creación de clientes
This commit is contained in:
parent
e43e3211d0
commit
e2d1103607
|
@ -1,4 +1,4 @@
|
|||
<mg-ajax path="/client/api/Clients" options="vnPost"></mg-ajax>
|
||||
<mg-ajax path="/client/api/Clients/createNew" options="vnPost"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.client"
|
||||
|
@ -9,20 +9,24 @@
|
|||
<div style="max-width: 70em; margin: 0 auto;">
|
||||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
<vn-title>Crear Cliente</vn-title>
|
||||
<vn-title>Create client</vn-title>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Nombre" field="$ctrl.client.name" vn-focus></vn-textfield>
|
||||
<vn-textfield vn-one label="NIF/CIF" field="$ctrl.client.fi"></vn-textfield>
|
||||
<vn-textfield vn-one label="Name" field="$ctrl.client.name" vn-focus></vn-textfield>
|
||||
<vn-textfield vn-one label="Tax number" field="$ctrl.client.fi"></vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Razón social" field="$ctrl.client.socialName"></vn-textfield>
|
||||
<vn-textfield vn-one label="Business name" field="$ctrl.client.socialName"></vn-textfield>
|
||||
<vn-textfield vn-one label="User name" field="$ctrl.client.userName"></vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Email" field="$ctrl.client.email"></vn-textfield>
|
||||
<vn-one></vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Crear y continuar"></vn-submit>
|
||||
<vn-button label="Crear" ng-click="watcher.submitBack()"></vn-button>
|
||||
<vn-submit label="Create and edit"></vn-submit>
|
||||
<vn-button label="Create" ng-click="watcher.submitBack()"></vn-button>
|
||||
</vn-button-bar>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"Name": "Nombre",
|
||||
"Tax number": "NIF/CIF",
|
||||
"Business name": "Razón social",
|
||||
"User name": "Nombre de usuario",
|
||||
"Email": "Correo electrónico",
|
||||
"Create and edit": "Crear y editar",
|
||||
"Create": "Crear"
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
var app = require('../../../server/server');
|
||||
|
||||
module.exports = function(Client){
|
||||
Client.remoteMethod('createNew', {
|
||||
description: 'Creates a new client',
|
||||
accepts: {
|
||||
arg: 'data',
|
||||
type: 'object',
|
||||
http: { source: 'body' }
|
||||
},
|
||||
returns: {
|
||||
root: true,
|
||||
type: 'boolean'
|
||||
},
|
||||
http: {
|
||||
verb: 'post',
|
||||
path: '/createNew'
|
||||
}
|
||||
});
|
||||
|
||||
Client.createNew = (data, cb) => {
|
||||
let user = {
|
||||
name: data.userName,
|
||||
email: data.email,
|
||||
password: parseInt(Math.random() * 100000000000000)
|
||||
};
|
||||
app.models.Account.create (user, (err, obj) => {
|
||||
if (err) {
|
||||
cb(err);
|
||||
} else {
|
||||
let client = {
|
||||
name: data.name,
|
||||
fi: data.fi,
|
||||
socialName: data.socialName,
|
||||
id: obj.id
|
||||
};
|
||||
Client.create (client, (err, obj) => {
|
||||
if (err)
|
||||
cb(err);
|
||||
else
|
||||
cb(null, true);
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
|
@ -5,12 +5,13 @@ module.exports = function(Client) {
|
|||
|
||||
// Methods
|
||||
|
||||
require('../methods/client/card.js')(Client);
|
||||
require('../methods/client/activate.js')(Client);
|
||||
require('../methods/client/addresses.js')(Client);
|
||||
require('../methods/client/filter.js')(Client);
|
||||
require('../methods/client/before-save.js')(Client);
|
||||
require('../methods/client/card.js')(Client);
|
||||
require('../methods/client/create.js')(Client);
|
||||
require('../methods/client/employee.js')(Client);
|
||||
require('../methods/client/filter.js')(Client);
|
||||
|
||||
// Validations
|
||||
|
||||
|
@ -55,7 +56,6 @@ module.exports = function(Client) {
|
|||
if(this.payMethod && !this.salesPerson)
|
||||
err();
|
||||
}
|
||||
|
||||
Client.validateAsync('payMethodFk', hasIban, {
|
||||
message: 'El método de pago seleccionado requiere que se especifique el IBAN'
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue