From 609c13efbf9ec856350ec83b03a3143d23ee84ce Mon Sep 17 00:00:00 2001 From: Joan Date: Tue, 30 May 2017 08:06:14 +0200 Subject: [PATCH 01/12] Service mailer --- services/mailer/.gitignore | 1 + .../mailer/Application/Route/manuscript.js | 30 ++++++++++++ .../mailer/Application/Route/notification.js | 8 ++++ .../Application/Template/paymentUpdate.html | 35 ++++++++++++++ services/mailer/Application/Util/system.js | 11 +++++ services/mailer/Application/Util/terminal.js | 13 +++++ services/mailer/Application/database.js | 26 ++++++++++ services/mailer/Application/language.js | 0 services/mailer/Application/logger.js | 28 +++++++++++ services/mailer/Application/mail.js | 48 +++++++++++++++++++ services/mailer/Application/router.js | 16 +++++++ services/mailer/Application/settings.js | 2 + services/mailer/Application/template.js | 48 +++++++++++++++++++ services/mailer/package.json | 13 +++++ services/mailer/server.js | 38 +++++++++++++++ 15 files changed, 317 insertions(+) create mode 100644 services/mailer/.gitignore create mode 100644 services/mailer/Application/Route/manuscript.js create mode 100644 services/mailer/Application/Route/notification.js create mode 100644 services/mailer/Application/Template/paymentUpdate.html create mode 100644 services/mailer/Application/Util/system.js create mode 100644 services/mailer/Application/Util/terminal.js create mode 100644 services/mailer/Application/database.js create mode 100644 services/mailer/Application/language.js create mode 100644 services/mailer/Application/logger.js create mode 100644 services/mailer/Application/mail.js create mode 100644 services/mailer/Application/router.js create mode 100644 services/mailer/Application/settings.js create mode 100644 services/mailer/Application/template.js create mode 100644 services/mailer/package.json create mode 100644 services/mailer/server.js diff --git a/services/mailer/.gitignore b/services/mailer/.gitignore new file mode 100644 index 0000000000..b512c09d47 --- /dev/null +++ b/services/mailer/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/services/mailer/Application/Route/manuscript.js b/services/mailer/Application/Route/manuscript.js new file mode 100644 index 0000000000..a229fd499d --- /dev/null +++ b/services/mailer/Application/Route/manuscript.js @@ -0,0 +1,30 @@ +var express = require('express'); +var router = new express.Router(); +var mail = require('../mail.js'); +var database = require('../database.js'); +var template = require('../template.js'); + +// Escrito de cambios en méto de pago del cliente +router.post('/paymentUpdate', function(request, response) { + database.pool.query('SELECT Cliente, `e-mail` AS email FROM Clientes WHERE Id_Cliente = ?', [request.body.user], function(error, rs) { + var params = { + clientName: rs[0].Cliente + }; + + template.getTemplate('paymentUpdate', params, function(body) { + var data = { + recipient: rs[0].email, + subject: 'Cambios en las condiciones de pago', + body: body + }; + + if (mail.send(data)) { + response.json({status: "OK"}); + } else { + response.json({status: "ERROR"}); + } + }); + }); +}); + +module.exports = router; diff --git a/services/mailer/Application/Route/notification.js b/services/mailer/Application/Route/notification.js new file mode 100644 index 0000000000..5ec515dd1a --- /dev/null +++ b/services/mailer/Application/Route/notification.js @@ -0,0 +1,8 @@ +var express = require('express'); +var router = new express.Router(); + +router.get('/test', function(request, response) { + response.send("test"); +}); + +module.exports = router; diff --git a/services/mailer/Application/Template/paymentUpdate.html b/services/mailer/Application/Template/paymentUpdate.html new file mode 100644 index 0000000000..203db80478 --- /dev/null +++ b/services/mailer/Application/Template/paymentUpdate.html @@ -0,0 +1,35 @@ +
+
+ +
+ Verdnatura Levante SL, B97367486 + Avda. Espioca 100, 46460 Silla (Valencia) +
+
+
+
+

CAMBIOS EN CONDICIONES DE PAGO

+
+ +

+ Estimado cliente {{clientName}} +

+ +

+ Se han cambiado las condiciones de pago, estas son las nuevas: + +

+
+
+

Este mensaje es privado y confidencial, y debe ser utilizado exclusivamente por la persona destinataria del mismo. + Si usted ha recibido este mensaje por error, le rogamos lo comunique al remitente y borre dicho mensaje y cualquier + documento adjunto que pudiera contener. Verdnatura Levante SL no renuncia a la confidencialidad ni a ningún privilegio + por causa de transmisión errónea o mal funcionamiento. Igualmente no se hace responsable de los cambios, alteraciones, + errores u omisiones que pudieran hacerse al mensaje una vez enviado.

+ +

En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de Datos de Carácter Personal, le comunicamos + que los datos personales que facilite se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L., pudiendo en todo momento + ejercitar los derechos de acceso, rectificación, cancelación y oposición, comunicándolo por escrito al domicilio social de la entidad. + La finalidad del fichero es la gestión administrativa, contabilidad, y facturación.

+
+
\ No newline at end of file diff --git a/services/mailer/Application/Util/system.js b/services/mailer/Application/Util/system.js new file mode 100644 index 0000000000..08092ad5c0 --- /dev/null +++ b/services/mailer/Application/Util/system.js @@ -0,0 +1,11 @@ +module.exports = { + + /** + * Obtiene las variables de entorno + * @param {String} env - Nombre de la variable de entorno + * @return {String} Valor de la variable de entorno + */ + getEnv: function(env) { + return process.env[env]; + } +}; diff --git a/services/mailer/Application/Util/terminal.js b/services/mailer/Application/Util/terminal.js new file mode 100644 index 0000000000..d897671e7a --- /dev/null +++ b/services/mailer/Application/Util/terminal.js @@ -0,0 +1,13 @@ +var Settings = require('../Settings.js'); + +module.exports = { + + /** + * Imprimir cabecera + */ + printHeader: function() { + console.log('##########################################################'); + console.log('## ' + Settings.name + ' ##'); + console.log('##########################################################'); + } +}; diff --git a/services/mailer/Application/database.js b/services/mailer/Application/database.js new file mode 100644 index 0000000000..979867a330 --- /dev/null +++ b/services/mailer/Application/database.js @@ -0,0 +1,26 @@ +var mysql = require('mysql'); +var settings = require('./Settings.js'); +var logger = require('./Logger.js'); + +module.exports = { + + /** + * Variable de instancia del pool + */ + pool: null, + + /** + * Iniciar pool de conexión con la base de datos + */ + init: function() { + this.pool = mysql.createPool(settings.mysql); + + this.pool.getConnection(function(error, connection) { + if (error) { + logger.print(__LOG_ERROR, 'No se ha podido establecer la conexión con la base de datos. ' + error.code); + } else { + logger.print(__LOG_INFO, 'Conexión con la base de datos establecida'); + } + }); + } +}; diff --git a/services/mailer/Application/language.js b/services/mailer/Application/language.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/services/mailer/Application/logger.js b/services/mailer/Application/logger.js new file mode 100644 index 0000000000..c7442c33f4 --- /dev/null +++ b/services/mailer/Application/logger.js @@ -0,0 +1,28 @@ + +// Tipos de advertencias +global.__LOG_INFO = 1; +global.__LOG_WARNING = 2; +global.__LOG_ERROR = 3; + +module.exports = { + + /** + * Imprimir advertencia directamente en consola + * @param {Integer} type - Constante tipo de advertencia + */ + print: function(type, message) + { + if (type == __LOG_INFO) + { + console.log('[INFORMACIÓN] -> ' + message); + } + else if(type == __LOG_WARNING) + { + console.log('[ADVERTENCIA] -> ' + message); + } + else if(type == __LOG_ERROR) + { + console.log('[ERROR] -> ' + message); + } + } +} \ No newline at end of file diff --git a/services/mailer/Application/mail.js b/services/mailer/Application/mail.js new file mode 100644 index 0000000000..3390425fe0 --- /dev/null +++ b/services/mailer/Application/mail.js @@ -0,0 +1,48 @@ +var nodemailer = require('nodemailer'); +var settings = require('./Settings.js'); +var logger = require('./Logger.js'); + +// Módulo para el envío de emails +module.exports = { + + transporter: null, + + /** + * Si todavía no está inicializada la configuración, + * carga el fichero de configuración. + */ + init: function() { + this.transporter = nodemailer.createTransport(settings.smtp); + + this.transporter.verify(function(error, success) { + if (error) { + logger.print(__LOG_ERROR, error); + } else { + logger.print(__LOG_INFO, 'Conexión SMTP establecida'); + } + }); + }, + +/** + * Envia un email con los datos recibidos desde un vector. + * @param {Object} data - Datos para el envío del email + */ + send: function(data) { + let mailOptions = { + from: '"' + settings.senderName + '" <' + settings.senderMail + '>', + to: data.recipient, + subject: data.subject, + html: data.body + }; + + this.transporter.sendMail(mailOptions, (error, info) => { + if (error) { + logger.print(__LOG_ERROR, error); + } else if (Settings.debug) { + logger.print(__LOG_INFO, 'Se ha enviado el email ' + info.messageId + ' [' + info.response + ']'); + + return true; + } + }); + }, +} \ No newline at end of file diff --git a/services/mailer/Application/router.js b/services/mailer/Application/router.js new file mode 100644 index 0000000000..6bc5e60bfa --- /dev/null +++ b/services/mailer/Application/router.js @@ -0,0 +1,16 @@ +var express = require('express'); +var router = new express.Router(); +var settings = require('./settings.js'); + +// Página por defecto +router.get('/', function(request, response) { + response.send(Settings.name + ' v' + settings.version); +}); + +// Rutas de los escritos. +router.use('/manuscript', require('./Route/Manuscript.js')); + +// Rutas de las notificaciones. +router.use('/notification', require('./Route/Notification.js')); + +module.exports = router; diff --git a/services/mailer/Application/settings.js b/services/mailer/Application/settings.js new file mode 100644 index 0000000000..f2a22d5d3e --- /dev/null +++ b/services/mailer/Application/settings.js @@ -0,0 +1,2 @@ +// Módulo de configuración +module.exports = require('./config.json'); diff --git a/services/mailer/Application/template.js b/services/mailer/Application/template.js new file mode 100644 index 0000000000..3424c0dd26 --- /dev/null +++ b/services/mailer/Application/template.js @@ -0,0 +1,48 @@ +var fs = require('fs'); +var mustache = require('mustache'); +var database = require('./database.js'); +var logger = require('./logger.js'); + +var Template = { + + /** + * Obtiene la plantilla + * @param {String} name - Nombre de la plantilla + * @param {Object} params - Datos a reemplazar. + * @param {Object} callback - Callback + */ + getTemplate: function(name, params, callback) { + database.pool.query('SELECT name, attachmentPath FROM vn.mailTemplates WHERE name = ?', [name], function(error, rs) + { + if (rs.length == 0) { + logger.print(__LOG_ERROR, 'La plantilla ' + name + ' no existe'); + return; + } + + var path = './Application/Template/' + rs[0].name + '.html'; + + if (!fs.existsSync(path)) { + logger.print(__LOG_ERROR, 'No se ha podido cargar la plantilla ' + name + '.html'); + } else { + Template.render(path, params, function(body) { + callback(body); + }); + } + }); + }, + + /** + * Renderiza las plantillas + * @param {String} path - Ruta de la plantilla + * @param {Object} params - Listado de parámetros a remplazar + * @param {Object} callback - Callback + */ + render: function(path, params, callback) { + fs.readFile(path, 'utf8', function(error, body) { + mustache.parse(body); + callback(mustache.render(body, params)); + }); + } +}; + +module.exports = Template; diff --git a/services/mailer/package.json b/services/mailer/package.json new file mode 100644 index 0000000000..c78bfc567a --- /dev/null +++ b/services/mailer/package.json @@ -0,0 +1,13 @@ +{ + "name": "MailServer", + "version": "0.0.1", + "description": "Servidor de envío de correos", + "main": "server.js", + "dependencies": { + "mysql": "^2.13.0", + "express": "^4.15.3", + "body-parser": "^1.17.2", + "nodemailer": "^4.0.1", + "mustache": "^2.3.0" + } +} \ No newline at end of file diff --git a/services/mailer/server.js b/services/mailer/server.js new file mode 100644 index 0000000000..aa7da128c8 --- /dev/null +++ b/services/mailer/server.js @@ -0,0 +1,38 @@ +/** + * Módulos necesarios + */ +var express = require('express'); +var app = express(); +var bodyParser = require('body-parser'); + +var settings = require('./Application/settings.js'); +var mail = require('./Application/mail.js'); +var logger = require('./Application/logger.js'); +var database = require('./Application/database.js'); +var terminal = require('./Application/Util/terminal.js'); + +// Middleware +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded({extended: true})); + +// Cargar rutas +app.use('/', require('./Application/router.js')); + +// Iniciar escucha del servidor +app.listen(settings.port, function() { + // Imprimir cabecera + terminal.printHeader(); + + // Escucha SMTP + mail.init(); + + // Iniciar base de datos + database.init(); + + logger.print(__LOG_INFO, 'Servidor de correo iniciado en el puerto ' + settings.port); + + if (settings.debug) { + logger.print(__LOG_WARNING, 'El modo debug está activado'); + } +}); + From 65cc23b2806060064c1bed6984f76fa0c95ec0f8 Mon Sep 17 00:00:00 2001 From: Vicente Falco Date: Tue, 30 May 2017 08:50:16 +0200 Subject: [PATCH 02/12] gulp services y service mailer --- gulpfile.js | 2 ++ services/mailer/package.json | 24 ++++++++++++------------ services/mailer/server.js | 31 +++++++++++++++---------------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 5b2b0823c1..540c05d6e5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -158,8 +158,10 @@ gulp.task('services', function() { var auth = require('./services/auth/server/server.js'); var client = require('./services/client/server/server.js'); var server = require('./services/salix/server/server.js'); + var mailer = require('./services/mailer/server.js'); auth.start(); client.start(); server.start(); + mailer.start(); }); diff --git a/services/mailer/package.json b/services/mailer/package.json index c78bfc567a..87aced84ea 100644 --- a/services/mailer/package.json +++ b/services/mailer/package.json @@ -1,13 +1,13 @@ { - "name": "MailServer", - "version": "0.0.1", - "description": "Servidor de envío de correos", - "main": "server.js", - "dependencies": { - "mysql": "^2.13.0", - "express": "^4.15.3", - "body-parser": "^1.17.2", - "nodemailer": "^4.0.1", - "mustache": "^2.3.0" - } -} \ No newline at end of file + "name": "MailServer", + "version": "0.0.1", + "description": "Servidor de envío de correos", + "main": "server.js", + "dependencies": { + "body-parser": "^1.17.2", + "express": "^4.15.3", + "mustache": "^2.3.0", + "mysql": "^2.13.0", + "nodemailer": "^4.0.1" + } +} diff --git a/services/mailer/server.js b/services/mailer/server.js index aa7da128c8..448c9b922f 100644 --- a/services/mailer/server.js +++ b/services/mailer/server.js @@ -2,7 +2,7 @@ * Módulos necesarios */ var express = require('express'); -var app = express(); +var app = module.exports = express(); var bodyParser = require('body-parser'); var settings = require('./Application/settings.js'); @@ -18,21 +18,20 @@ app.use(bodyParser.urlencoded({extended: true})); // Cargar rutas app.use('/', require('./Application/router.js')); -// Iniciar escucha del servidor -app.listen(settings.port, function() { - // Imprimir cabecera - terminal.printHeader(); - // Escucha SMTP - mail.init(); +app.start = function() { + return app.listen(settings.port, function() { + terminal.printHeader(); + mail.init(); + database.init(); + logger.print(__LOG_INFO, 'Servidor de correo iniciado en el puerto ' + settings.port); + if (settings.debug) { + logger.print(__LOG_WARNING, 'El modo debug está activado'); + } + }); +}; - // Iniciar base de datos - database.init(); - - logger.print(__LOG_INFO, 'Servidor de correo iniciado en el puerto ' + settings.port); - - if (settings.debug) { - logger.print(__LOG_WARNING, 'El modo debug está activado'); - } -}); +if (require.main === module) { + app.start(); +} From 9ce12b2e530693c5b3059a59e81f2afda3e906da Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Tue, 30 May 2017 09:06:11 +0200 Subject: [PATCH 03/12] =?UTF-8?q?nuevo=20home=20con=20acceso=20directo=20a?= =?UTF-8?q?=20los=20m=C3=B3dulos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client/routes.json | 2 ++ client/salix/src/components/home/home.html | 20 +++++++++-- client/salix/src/components/home/home.js | 20 +++++++++-- client/salix/src/components/home/style.scss | 39 ++++++++++++++++++--- client/salix/src/locale/en.json | 4 ++- client/salix/src/locale/es.json | 4 ++- 6 files changed, 78 insertions(+), 11 deletions(-) diff --git a/client/client/routes.json b/client/client/routes.json index 91eae4c989..f9fb09a068 100644 --- a/client/client/routes.json +++ b/client/client/routes.json @@ -1,5 +1,7 @@ { "module": "client", + "name": "clients", + "icon": "person", "routes": [ { "url": "/clients", diff --git a/client/salix/src/components/home/home.html b/client/salix/src/components/home/home.html index 9d08cb2864..9716548738 100644 --- a/client/salix/src/components/home/home.html +++ b/client/salix/src/components/home/home.html @@ -1,3 +1,17 @@ - -
Push on applications menu
-
\ No newline at end of file + + +
+
+ + + + +

+
+ + + +
+
+
+
\ No newline at end of file diff --git a/client/salix/src/components/home/home.js b/client/salix/src/components/home/home.js index bbb9a61635..e30e73bf9f 100644 --- a/client/salix/src/components/home/home.js +++ b/client/salix/src/components/home/home.js @@ -4,11 +4,27 @@ import './style.scss'; export const NAME = 'vnHome'; export default class vnHome { - constructor() { + constructor(aclService) { this.modules = []; + this.aclService = aclService; + this.init(); + } + + init() { + for (let file in routes) { + let card = { + name: routes[file].name, + icon: routes[file].icon + }; + let fileRoutes = routes[file].routes; + if (fileRoutes.length && this.aclService.routeHasPermission(fileRoutes[0])) { + card.route = fileRoutes[0]; + this.modules.push(card); + } + } } } -vnHome.$inject = []; +vnHome.$inject = ['aclService']; export const COMPONENT = { template: require('./home.html'), diff --git a/client/salix/src/components/home/style.scss b/client/salix/src/components/home/style.scss index 1ddc08763b..6d35004f13 100644 --- a/client/salix/src/components/home/style.scss +++ b/client/salix/src/components/home/style.scss @@ -1,7 +1,38 @@ vn-home { - & > .default { - text-align: center; - font-size: 1.3em; - padding: 2em; + padding: 2em; + vn-horizontal{ + margin-bottom: 15px; + } + h6{ + color: #3C393B; + text-align: center; + } + vn-module{ + display: flex; + flex: none; + padding: 2em; + border-radius: 4px; + box-sizing: border-box; + cursor: pointer; + transition: opacity 0.7s ease; + h4{ + text-transform: capitalize; } + vn-one{ + text-align: center; + } + + i{ + font-size: 50px !important; + margin: 0 auto; + } + + &.clients{ + background-color: #ffa410; + color: #ffffff; + } + &:hover{ + opacity: 0.8; + } + } } \ No newline at end of file diff --git a/client/salix/src/locale/en.json b/client/salix/src/locale/en.json index a589c5a3f2..a3962d5d45 100644 --- a/client/salix/src/locale/en.json +++ b/client/salix/src/locale/en.json @@ -6,5 +6,7 @@ "Profile": "Profile", "Data saved!": "Data saved!", "Can't contact with server": "Can't contact with server", - "Push on applications menu": "To open a module push on applications menu" + "Push on applications menu": "To open a module push on applications menu", + "clients": "clients", + "Modules access": "Modules access" } \ No newline at end of file diff --git a/client/salix/src/locale/es.json b/client/salix/src/locale/es.json index ea9d57354b..de6f9711af 100644 --- a/client/salix/src/locale/es.json +++ b/client/salix/src/locale/es.json @@ -6,5 +6,7 @@ "Profile": "Perfil", "Data saved!": "¡Datos guardados!", "Can't contact with server": "No se pudo contactar con el servidor", - "Push on applications menu": "Para abrir un módulo pulsa en el menú de aplicaciones" + "Push on applications menu": "Para abrir un módulo pulsa en el menú de aplicaciones", + "clients": "clientes", + "Modules access" : "Acceso a módulos" } \ No newline at end of file From 49999b62f2b147c89beddd32d9a6fdf9db0dccc0 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Tue, 30 May 2017 09:54:35 +0200 Subject: [PATCH 04/12] creada factoria q retorna los modulos disponibles para el usuario, ACL --- client/client/routes.json | 2 +- client/core/src/label/label.mdl.html | 2 +- client/salix/src/app.js | 1 + client/salix/src/components/home/home.html | 2 +- client/salix/src/components/home/home.js | 23 +++--------- client/salix/src/components/home/style.scss | 2 +- .../src/components/main-menu/main-menu.html | 18 +++++----- .../src/components/main-menu/main-menu.js | 5 +-- client/salix/src/locale/en.json | 2 +- client/salix/src/locale/es.json | 2 +- client/salix/src/modulesFactory.js | 36 +++++++++++++++++++ 11 files changed, 60 insertions(+), 35 deletions(-) create mode 100644 client/salix/src/modulesFactory.js diff --git a/client/client/routes.json b/client/client/routes.json index f9fb09a068..bd49efb494 100644 --- a/client/client/routes.json +++ b/client/client/routes.json @@ -1,6 +1,6 @@ { "module": "client", - "name": "clients", + "name": "Clients", "icon": "person", "routes": [ { diff --git a/client/core/src/label/label.mdl.html b/client/core/src/label/label.mdl.html index 9f95f13b3c..2f33b3a1aa 100644 --- a/client/core/src/label/label.mdl.html +++ b/client/core/src/label/label.mdl.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/client/salix/src/app.js b/client/salix/src/app.js index 8ec2c5df70..92caaf50cd 100644 --- a/client/salix/src/app.js +++ b/client/salix/src/app.js @@ -6,3 +6,4 @@ import './config'; import './run'; import './components'; import './styles/index'; +import './modulesFactory'; diff --git a/client/salix/src/components/home/home.html b/client/salix/src/components/home/home.html index 9716548738..5f6db683a3 100644 --- a/client/salix/src/components/home/home.html +++ b/client/salix/src/components/home/home.html @@ -1,4 +1,4 @@ - +
diff --git a/client/salix/src/components/home/home.js b/client/salix/src/components/home/home.js index e30e73bf9f..66002ae9fc 100644 --- a/client/salix/src/components/home/home.js +++ b/client/salix/src/components/home/home.js @@ -4,27 +4,12 @@ import './style.scss'; export const NAME = 'vnHome'; export default class vnHome { - constructor(aclService) { - this.modules = []; - this.aclService = aclService; - this.init(); - } - - init() { - for (let file in routes) { - let card = { - name: routes[file].name, - icon: routes[file].icon - }; - let fileRoutes = routes[file].routes; - if (fileRoutes.length && this.aclService.routeHasPermission(fileRoutes[0])) { - card.route = fileRoutes[0]; - this.modules.push(card); - } - } + constructor(modulesFactory, $state) { + this.modules = modulesFactory.getModules(); + this.state = $state; } } -vnHome.$inject = ['aclService']; +vnHome.$inject = ['modulesFactory', '$state']; export const COMPONENT = { template: require('./home.html'), diff --git a/client/salix/src/components/home/style.scss b/client/salix/src/components/home/style.scss index 6d35004f13..a5cc444468 100644 --- a/client/salix/src/components/home/style.scss +++ b/client/salix/src/components/home/style.scss @@ -27,7 +27,7 @@ vn-home { margin: 0 auto; } - &.clients{ + &.Clients{ background-color: #ffa410; color: #ffffff; } diff --git a/client/salix/src/components/main-menu/main-menu.html b/client/salix/src/components/main-menu/main-menu.html index 75100c1b23..da5047c633 100644 --- a/client/salix/src/components/main-menu/main-menu.html +++ b/client/salix/src/components/main-menu/main-menu.html @@ -6,14 +6,16 @@ diff --git a/client/salix/src/components/main-menu/main-menu.js b/client/salix/src/components/main-menu/main-menu.js index 4340c85e9f..f2bc6e5d19 100644 --- a/client/salix/src/components/main-menu/main-menu.js +++ b/client/salix/src/components/main-menu/main-menu.js @@ -2,9 +2,10 @@ import ngModule from '../../module'; import './style.scss'; export default class Controller { - constructor($translate, $window) { + constructor($translate, $window, modulesFactory) { this.$translate = $translate; this.$window = $window; + this.modules = modulesFactory.getModules(); } onLogoutClick() { this.$window.location = 'salix/logout'; @@ -15,7 +16,7 @@ export default class Controller { console.log(`Locale changed: ${lang}`); } } -Controller.$inject = ['$translate', '$window']; +Controller.$inject = ['$translate', '$window', 'modulesFactory']; ngModule.component('vnMainMenu', { template: require('./main-menu.html'), diff --git a/client/salix/src/locale/en.json b/client/salix/src/locale/en.json index a3962d5d45..70dabcc3a9 100644 --- a/client/salix/src/locale/en.json +++ b/client/salix/src/locale/en.json @@ -7,6 +7,6 @@ "Data saved!": "Data saved!", "Can't contact with server": "Can't contact with server", "Push on applications menu": "To open a module push on applications menu", - "clients": "clients", + "Clients": "Clients", "Modules access": "Modules access" } \ No newline at end of file diff --git a/client/salix/src/locale/es.json b/client/salix/src/locale/es.json index de6f9711af..5ff53c91d3 100644 --- a/client/salix/src/locale/es.json +++ b/client/salix/src/locale/es.json @@ -7,6 +7,6 @@ "Data saved!": "¡Datos guardados!", "Can't contact with server": "No se pudo contactar con el servidor", "Push on applications menu": "Para abrir un módulo pulsa en el menú de aplicaciones", - "clients": "clientes", + "Clients": "Clientes", "Modules access" : "Acceso a módulos" } \ No newline at end of file diff --git a/client/salix/src/modulesFactory.js b/client/salix/src/modulesFactory.js new file mode 100644 index 0000000000..a36b301aca --- /dev/null +++ b/client/salix/src/modulesFactory.js @@ -0,0 +1,36 @@ +import ngModule from './module'; + +function modulesFactory(aclService) { + function _getMainRoute(routeCollection) { + let cant = routeCollection.length; + for (let i = 0; i < cant; i++) { + if (!routeCollection[i].abstract) { + return routeCollection[i]; + } + } + return null; + } + + function getModules() { + let modules = []; + for (let file in window.routes) { + let card = { + name: routes[file].name || routes[file].module, + icon: routes[file].icon || '' + }; + let mainRoute = _getMainRoute(window.routes[file].routes); + if (mainRoute && aclService.routeHasPermission(mainRoute)) { + card.route = mainRoute; + modules.push(card); + } + } + return modules; + } + + return { + getModules: getModules + }; +} +modulesFactory.$inject = ['aclService']; + +ngModule.factory('modulesFactory', modulesFactory); From cadbb2b6c22d00192cc75b43f21a807cd8b2af86 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Tue, 30 May 2017 14:17:01 +0200 Subject: [PATCH 05/12] =?UTF-8?q?A=C3=B1adidos=20ACLs=20del=20servicio=20c?= =?UTF-8?q?lient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/salix/src/components/home/home.html | 4 ++-- client/salix/src/components/home/style.scss | 15 +++++++++------ services/client/common/models/Address.json | 8 ++++---- services/client/common/models/Client.json | 8 ++++---- .../client/common/models/ClientObservation.json | 8 ++++---- services/client/common/models/Country.json | 14 +++++++++++++- services/client/common/models/Employee.json | 8 ++++---- services/client/common/models/PayMethod.json | 6 ++++++ services/client/common/models/Province.json | 14 +++++++++++++- 9 files changed, 59 insertions(+), 26 deletions(-) diff --git a/client/salix/src/components/home/home.html b/client/salix/src/components/home/home.html index 5f6db683a3..b92bedb4d5 100644 --- a/client/salix/src/components/home/home.html +++ b/client/salix/src/components/home/home.html @@ -3,7 +3,7 @@
- +

@@ -12,6 +12,6 @@
-
+
\ No newline at end of file diff --git a/client/salix/src/components/home/style.scss b/client/salix/src/components/home/style.scss index a5cc444468..76c6cd4020 100644 --- a/client/salix/src/components/home/style.scss +++ b/client/salix/src/components/home/style.scss @@ -7,13 +7,15 @@ vn-home { color: #3C393B; text-align: center; } - vn-module{ + a:link{ + text-decoration: none; + } + .vn-module{ display: flex; flex: none; padding: 2em; border-radius: 4px; box-sizing: border-box; - cursor: pointer; transition: opacity 0.7s ease; h4{ text-transform: capitalize; @@ -26,13 +28,14 @@ vn-home { font-size: 50px !important; margin: 0 auto; } - + &:hover{ + opacity: 0.7; + } + &.Clients{ background-color: #ffa410; color: #ffffff; } - &:hover{ - opacity: 0.8; - } + } } \ No newline at end of file diff --git a/services/client/common/models/Address.json b/services/client/common/models/Address.json index 66ffed9de4..c4ba3dbff4 100644 --- a/services/client/common/models/Address.json +++ b/services/client/common/models/Address.json @@ -64,14 +64,14 @@ { "accessType": "*", "principalType": "ROLE", - "principalId": "$authenticated", - "permission": "ALLOW" + "principalId": "$everyone", + "permission": "DENY" }, { "accessType": "*", "principalType": "ROLE", - "principalId": "$everyone", - "permission": "DENY" + "principalId": "root", + "permission": "ALLOW" } ] } diff --git a/services/client/common/models/Client.json b/services/client/common/models/Client.json index f407542631..da955b23fa 100644 --- a/services/client/common/models/Client.json +++ b/services/client/common/models/Client.json @@ -144,14 +144,14 @@ { "accessType": "*", "principalType": "ROLE", - "principalId": "$authenticated", - "permission": "ALLOW" + "principalId": "$everyone", + "permission": "DENY" }, { "accessType": "*", "principalType": "ROLE", - "principalId": "$everyone", - "permission": "DENY" + "principalId": "root", + "permission": "ALLOW" } ], "validations": [], diff --git a/services/client/common/models/ClientObservation.json b/services/client/common/models/ClientObservation.json index 1f648735f6..6046f5083d 100644 --- a/services/client/common/models/ClientObservation.json +++ b/services/client/common/models/ClientObservation.json @@ -37,14 +37,14 @@ { "accessType": "*", "principalType": "ROLE", - "principalId": "$authenticated", - "permission": "ALLOW" + "principalId": "$everyone", + "permission": "DENY" }, { "accessType": "*", "principalType": "ROLE", - "principalId": "$everyone", - "permission": "DENY" + "principalId": "root", + "permission": "ALLOW" } ], "scope": { diff --git a/services/client/common/models/Country.json b/services/client/common/models/Country.json index 09b96d858b..9814e4966f 100644 --- a/services/client/common/models/Country.json +++ b/services/client/common/models/Country.json @@ -33,10 +33,22 @@ }, "acls": [ { - "accessType": "*", + "accessType": "READ", "principalType": "ROLE", "principalId": "$everyone", "permission": "ALLOW" + }, + { + "accessType": "WRITE", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "DENY" + }, + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "root", + "permission": "ALLOW" } ] } \ No newline at end of file diff --git a/services/client/common/models/Employee.json b/services/client/common/models/Employee.json index e11d5df678..80bf06ebb0 100644 --- a/services/client/common/models/Employee.json +++ b/services/client/common/models/Employee.json @@ -28,14 +28,14 @@ { "accessType": "*", "principalType": "ROLE", - "principalId": "$authenticated", - "permission": "ALLOW" + "principalId": "$everyone", + "permission": "DENY" }, { "accessType": "*", "principalType": "ROLE", - "principalId": "$everyone", - "permission": "DENY" + "principalId": "root", + "permission": "ALLOW" } ] } \ No newline at end of file diff --git a/services/client/common/models/PayMethod.json b/services/client/common/models/PayMethod.json index c555891371..4e16d2b93a 100644 --- a/services/client/common/models/PayMethod.json +++ b/services/client/common/models/PayMethod.json @@ -27,6 +27,12 @@ "accessType": "*", "principalType": "ROLE", "principalId": "$everyone", + "permission": "DENY" + }, + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "root", "permission": "ALLOW" } ] diff --git a/services/client/common/models/Province.json b/services/client/common/models/Province.json index b285bd4195..b6dd16b2ec 100644 --- a/services/client/common/models/Province.json +++ b/services/client/common/models/Province.json @@ -32,10 +32,22 @@ }, "acls": [ { - "accessType": "*", + "accessType": "READ", "principalType": "ROLE", "principalId": "$everyone", "permission": "ALLOW" + }, + { + "accessType": "WRITE", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "DENY" + }, + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "root", + "permission": "ALLOW" } ] } \ No newline at end of file From 9cea151f4d96a37d59f6ede59afc90cec5b46e18 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Wed, 31 May 2017 09:46:05 +0200 Subject: [PATCH 06/12] renombrado de archivos parte 1 --- client/auth/src/auth.js | 2 +- .../auth/src/login/{index.html => login.html} | 0 client/auth/src/login/{index.js => login.js} | 2 +- .../{index.html => address-create.html} | 0 .../{index.js => address-create.js} | 2 +- .../{index.html => address-edit.html} | 0 .../{index.js => address-edit.js} | 2 +- .../addresses/{index.html => addresses.html} | 0 .../src/addresses/{index.js => addresses.js} | 2 +- .../{index.html => basic-data.html} | 0 .../basic-data/{index.js => basic-data.js} | 2 +- .../{index.html => billing-data.html} | 0 .../{index.js => billing-data.js} | 2 +- .../client/src/card/{index.html => card.html} | 0 client/client/src/card/{index.js => card.js} | 2 +- client/client/src/client.js | 26 +++---- .../src/create/{index.html => create.html} | 0 .../client/src/create/{index.js => create.js} | 2 +- .../{index.html => descriptor.html} | 0 .../descriptor/{index.js => descriptor.js} | 2 +- .../{index.html => fiscal-data.html} | 0 .../fiscal-data/{index.js => fiscal-data.js} | 2 +- .../new-note/{index.html => new-note.html} | 0 .../src/new-note/{index.js => new-note.js} | 2 +- .../src/notes/{index.html => notes.html} | 0 .../client/src/notes/{index.js => notes.js} | 2 +- .../{index.html => search-panel.html} | 0 .../{index.js => search-panel.js} | 2 +- client/client/src/web-access/index.js | 48 ------------- .../{index.html => web-access.html} | 0 client/client/src/web-access/web-access.js | 46 +++++++++++++ .../{index.html => autocomplete.html} | 0 .../{index.js => autocomplete.js} | 2 +- client/core/src/components.js | 9 +-- .../src/confirm/{index.html => confirm.html} | 0 .../core/src/confirm/{index.js => confirm.js} | 4 +- .../src/dialog/{index.html => dialog.html} | 0 .../core/src/dialog/{index.js => dialog.js} | 2 +- client/core/src/directives/dialog.js | 2 +- client/core/src/icon/{index.js => icon.js} | 2 +- .../icon/{index.mdl.html => icon.mdl.html} | 0 .../src/icon/{index.mdl.js => icon.mdl.js} | 2 +- client/salix/src/aclService.js | 10 ++- client/salix/src/bootstrap.js | 4 +- client/salix/src/components/app/app.js | 4 +- client/salix/src/config.js | 4 +- client/salix/src/module.js | 3 +- .../client/common/scopes/client/card.json | 68 +++++++++++-------- services/salix/server/boot/routes.js | 2 +- 49 files changed, 143 insertions(+), 123 deletions(-) rename client/auth/src/login/{index.html => login.html} (100%) mode change 100755 => 100644 rename client/auth/src/login/{index.js => login.js} (98%) rename client/client/src/address-create/{index.html => address-create.html} (100%) rename client/client/src/address-create/{index.js => address-create.js} (92%) rename client/client/src/address-edit/{index.html => address-edit.html} (100%) rename client/client/src/address-edit/{index.js => address-edit.js} (88%) rename client/client/src/addresses/{index.html => addresses.html} (100%) rename client/client/src/addresses/{index.js => addresses.js} (73%) rename client/client/src/basic-data/{index.html => basic-data.html} (100%) rename client/client/src/basic-data/{index.js => basic-data.js} (78%) rename client/client/src/billing-data/{index.html => billing-data.html} (100%) rename client/client/src/billing-data/{index.js => billing-data.js} (82%) rename client/client/src/card/{index.html => card.html} (100%) rename client/client/src/card/{index.js => card.js} (87%) rename client/client/src/create/{index.html => create.html} (100%) rename client/client/src/create/{index.js => create.js} (92%) rename client/client/src/descriptor/{index.html => descriptor.html} (100%) rename client/client/src/descriptor/{index.js => descriptor.js} (92%) rename client/client/src/fiscal-data/{index.html => fiscal-data.html} (100%) rename client/client/src/fiscal-data/{index.js => fiscal-data.js} (82%) rename client/client/src/new-note/{index.html => new-note.html} (100%) rename client/client/src/new-note/{index.js => new-note.js} (94%) rename client/client/src/notes/{index.html => notes.html} (100%) rename client/client/src/notes/{index.js => notes.js} (96%) rename client/client/src/search-panel/{index.html => search-panel.html} (100%) rename client/client/src/search-panel/{index.js => search-panel.js} (95%) delete mode 100644 client/client/src/web-access/index.js rename client/client/src/web-access/{index.html => web-access.html} (100%) create mode 100644 client/client/src/web-access/web-access.js rename client/core/src/autocomplete/{index.html => autocomplete.html} (100%) rename client/core/src/autocomplete/{index.js => autocomplete.js} (99%) rename client/core/src/confirm/{index.html => confirm.html} (100%) rename client/core/src/confirm/{index.js => confirm.js} (78%) rename client/core/src/dialog/{index.html => dialog.html} (100%) rename client/core/src/dialog/{index.js => dialog.js} (98%) rename client/core/src/icon/{index.js => icon.js} (95%) rename client/core/src/icon/{index.mdl.html => icon.mdl.html} (100%) rename client/core/src/icon/{index.mdl.js => icon.mdl.js} (83%) diff --git a/client/auth/src/auth.js b/client/auth/src/auth.js index 703c81193c..8b7c022dd5 100644 --- a/client/auth/src/auth.js +++ b/client/auth/src/auth.js @@ -1,3 +1,3 @@ import './ngModule'; import './config'; -import './login/index'; +import './login/login'; diff --git a/client/auth/src/login/index.html b/client/auth/src/login/login.html old mode 100755 new mode 100644 similarity index 100% rename from client/auth/src/login/index.html rename to client/auth/src/login/login.html diff --git a/client/auth/src/login/index.js b/client/auth/src/login/login.js similarity index 98% rename from client/auth/src/login/index.js rename to client/auth/src/login/login.js index 7c7447d739..229c1a345a 100644 --- a/client/auth/src/login/index.js +++ b/client/auth/src/login/login.js @@ -76,6 +76,6 @@ export default class Controller { Controller.$inject = ['$element', '$scope', '$window', '$http']; ngModule.component('vnLogin', { - template: require('./index.html'), + template: require('./login.html'), controller: Controller }); diff --git a/client/client/src/address-create/index.html b/client/client/src/address-create/address-create.html similarity index 100% rename from client/client/src/address-create/index.html rename to client/client/src/address-create/address-create.html diff --git a/client/client/src/address-create/index.js b/client/client/src/address-create/address-create.js similarity index 92% rename from client/client/src/address-create/index.js rename to client/client/src/address-create/address-create.js index 7626ea5a82..8e23af6ea0 100644 --- a/client/client/src/address-create/index.js +++ b/client/client/src/address-create/address-create.js @@ -19,7 +19,7 @@ Controller.$inject = ['$scope', '$state']; export const NAME = 'vnAddressCreate'; export const COMPONENT = { - template: require('./index.html'), + template: require('./address-create.html'), controller: Controller }; module.component(NAME, COMPONENT); diff --git a/client/client/src/address-edit/index.html b/client/client/src/address-edit/address-edit.html similarity index 100% rename from client/client/src/address-edit/index.html rename to client/client/src/address-edit/address-edit.html diff --git a/client/client/src/address-edit/index.js b/client/client/src/address-edit/address-edit.js similarity index 88% rename from client/client/src/address-edit/index.js rename to client/client/src/address-edit/address-edit.js index 70f609d2df..1e4fdb6001 100644 --- a/client/client/src/address-edit/index.js +++ b/client/client/src/address-edit/address-edit.js @@ -11,7 +11,7 @@ Controller.$inject = ['$stateParams']; export const NAME = 'vnAddressEdit'; export const COMPONENT = { - template: require('./index.html'), + template: require('./address-edit.html'), controllerAs: 'addressData', controller: Controller }; diff --git a/client/client/src/addresses/index.html b/client/client/src/addresses/addresses.html similarity index 100% rename from client/client/src/addresses/index.html rename to client/client/src/addresses/addresses.html diff --git a/client/client/src/addresses/index.js b/client/client/src/addresses/addresses.js similarity index 73% rename from client/client/src/addresses/index.js rename to client/client/src/addresses/addresses.js index 0c0dc08465..be0e6f3989 100644 --- a/client/client/src/addresses/index.js +++ b/client/client/src/addresses/addresses.js @@ -1,6 +1,6 @@ import {module} from '../module'; export const component = { - template: require('./index.html') + template: require('./addresses.html') }; module.component('vnClientAddresses', component); diff --git a/client/client/src/basic-data/index.html b/client/client/src/basic-data/basic-data.html similarity index 100% rename from client/client/src/basic-data/index.html rename to client/client/src/basic-data/basic-data.html diff --git a/client/client/src/basic-data/index.js b/client/client/src/basic-data/basic-data.js similarity index 78% rename from client/client/src/basic-data/index.js rename to client/client/src/basic-data/basic-data.js index 2e3dececc1..de05dd81ab 100644 --- a/client/client/src/basic-data/index.js +++ b/client/client/src/basic-data/basic-data.js @@ -1,7 +1,7 @@ import {module} from '../module'; export const component = { - template: require('./index.html'), + template: require('./basic-data.html'), bindings: { client: '<' } diff --git a/client/client/src/billing-data/index.html b/client/client/src/billing-data/billing-data.html similarity index 100% rename from client/client/src/billing-data/index.html rename to client/client/src/billing-data/billing-data.html diff --git a/client/client/src/billing-data/index.js b/client/client/src/billing-data/billing-data.js similarity index 82% rename from client/client/src/billing-data/index.js rename to client/client/src/billing-data/billing-data.js index 7c6c6ffeb1..7c70b46afd 100644 --- a/client/client/src/billing-data/index.js +++ b/client/client/src/billing-data/billing-data.js @@ -2,7 +2,7 @@ import {module} from '../module'; export const NAME = 'vnClientBillingData'; export const COMPONENT = { - template: require('./index.html'), + template: require('./billing-data.html'), controllerAs: 'bill', bindings: { client: '<' diff --git a/client/client/src/card/index.html b/client/client/src/card/card.html similarity index 100% rename from client/client/src/card/index.html rename to client/client/src/card/card.html diff --git a/client/client/src/card/index.js b/client/client/src/card/card.js similarity index 87% rename from client/client/src/card/index.js rename to client/client/src/card/card.js index 107aa9815a..43d19facf5 100644 --- a/client/client/src/card/index.js +++ b/client/client/src/card/card.js @@ -11,7 +11,7 @@ export default class vnClientCard { module.component(NAME, { - template: require('./index.html'), + template: require('./card.html'), controllerAs: 'card', controller: vnClientCard }); diff --git a/client/client/src/client.js b/client/client/src/client.js index 4bc8220597..1ae857fa45 100644 --- a/client/client/src/client.js +++ b/client/client/src/client.js @@ -1,27 +1,27 @@ export * from './module'; export {NAME as CLIENT_CARD, - COMPONENT as CLIENT_CARD_COMPONENT} from './card/index'; + COMPONENT as CLIENT_CARD_COMPONENT} from './card/card'; export {NAME as CLIENTS, COMPONENT as CLIENTS_COMPONENT} from './index/index'; export {NAME as CLIENT_FISCAL_DATA_INDEX, - COMPONENT as CLIENT_FISCAL_DATA_INDEX_COMPONENT} from './fiscal-data/index'; + COMPONENT as CLIENT_FISCAL_DATA_INDEX_COMPONENT} from './fiscal-data/fiscal-data'; export {NAME as CLIENT_BILLING_DATA_INDEX, - COMPONENT as CLIENT_BILLINGL_DATA_INDEX_COMPONENT} from './billing-data/index'; + COMPONENT as CLIENT_BILLINGL_DATA_INDEX_COMPONENT} from './billing-data/billing-data'; export {NAME as CLIENT_DESCRIPTOR, - COMPONENT as CLIENT_DESCRIPTOR_COMPONENT} from './descriptor/index'; + COMPONENT as CLIENT_DESCRIPTOR_COMPONENT} from './descriptor/descriptor'; export {NAME as CLIENT_NOTES, - COMPONENT as CLIENT_NOTES_COMPONENT} from './notes/index'; + COMPONENT as CLIENT_NOTES_COMPONENT} from './notes/notes'; export {NAME as CLIENT_SEARCH_PANEL, - COMPONENT as CLIENT_SEARCH_PANEL_COMPONENT} from './search-panel/index'; + COMPONENT as CLIENT_SEARCH_PANEL_COMPONENT} from './search-panel/search-panel'; export {NAME as CLIENT_CREATE, - COMPONENT as CLIENT_CREATE_COMPONENT} from './create/index'; + COMPONENT as CLIENT_CREATE_COMPONENT} from './create/create'; export {NAME as CLIENT_ADDRESS_EDIT_INDEX, - COMPONENT as CLIENT_ADDRESS_EDIT_INDEX_COMPONENT} from './address-edit/index'; + COMPONENT as CLIENT_ADDRESS_EDIT_INDEX_COMPONENT} from './address-edit/address-edit'; export {NAME as NEW_NOTE_INDEX, - COMPONENT as NEW_NOTE_INDEX_COMPONENT} from './new-note/index'; + COMPONENT as NEW_NOTE_INDEX_COMPONENT} from './new-note/new-note'; -import './addresses/index'; -import './address-create/index'; -import './basic-data/index'; -import './web-access/index'; +import './addresses/addresses'; +import './address-create/address-create'; +import './basic-data/basic-data'; +import './web-access/web-access'; diff --git a/client/client/src/create/index.html b/client/client/src/create/create.html similarity index 100% rename from client/client/src/create/index.html rename to client/client/src/create/create.html diff --git a/client/client/src/create/index.js b/client/client/src/create/create.js similarity index 92% rename from client/client/src/create/index.js rename to client/client/src/create/create.js index f42583d259..bdf8254818 100644 --- a/client/client/src/create/index.js +++ b/client/client/src/create/create.js @@ -17,7 +17,7 @@ class Controller { Controller.$inject = ['$scope', '$state']; export const component = { - template: require('./index.html'), + template: require('./create.html'), controller: Controller }; module.component('vnClientCreate', component); diff --git a/client/client/src/descriptor/index.html b/client/client/src/descriptor/descriptor.html similarity index 100% rename from client/client/src/descriptor/index.html rename to client/client/src/descriptor/descriptor.html diff --git a/client/client/src/descriptor/index.js b/client/client/src/descriptor/descriptor.js similarity index 92% rename from client/client/src/descriptor/index.js rename to client/client/src/descriptor/descriptor.js index 8c2da74045..a9c5722ecd 100644 --- a/client/client/src/descriptor/index.js +++ b/client/client/src/descriptor/descriptor.js @@ -3,7 +3,7 @@ import './style.css'; export const NAME = 'vnDescriptor'; export const COMPONENT = { - template: require('./index.html'), + template: require('./descriptor.html'), controllerAs: 'descriptor', bindings: { client: '<', diff --git a/client/client/src/fiscal-data/index.html b/client/client/src/fiscal-data/fiscal-data.html similarity index 100% rename from client/client/src/fiscal-data/index.html rename to client/client/src/fiscal-data/fiscal-data.html diff --git a/client/client/src/fiscal-data/index.js b/client/client/src/fiscal-data/fiscal-data.js similarity index 82% rename from client/client/src/fiscal-data/index.js rename to client/client/src/fiscal-data/fiscal-data.js index d6ece60200..db96d82a50 100644 --- a/client/client/src/fiscal-data/index.js +++ b/client/client/src/fiscal-data/fiscal-data.js @@ -2,7 +2,7 @@ import {module} from '../module'; export const NAME = 'vnClientFiscalData'; export const COMPONENT = { - template: require('./index.html'), + template: require('./fiscal-data.html'), controllerAs: 'fiscal', bindings: { client: '<' diff --git a/client/client/src/new-note/index.html b/client/client/src/new-note/new-note.html similarity index 100% rename from client/client/src/new-note/index.html rename to client/client/src/new-note/new-note.html diff --git a/client/client/src/new-note/index.js b/client/client/src/new-note/new-note.js similarity index 94% rename from client/client/src/new-note/index.js rename to client/client/src/new-note/new-note.js index d69fa470e5..8138990b51 100644 --- a/client/client/src/new-note/index.js +++ b/client/client/src/new-note/new-note.js @@ -1,4 +1,4 @@ -import template from './index.html'; +import template from './new-note.html'; import {module} from '../module'; class Controller { diff --git a/client/client/src/notes/index.html b/client/client/src/notes/notes.html similarity index 100% rename from client/client/src/notes/index.html rename to client/client/src/notes/notes.html diff --git a/client/client/src/notes/index.js b/client/client/src/notes/notes.js similarity index 96% rename from client/client/src/notes/index.js rename to client/client/src/notes/notes.js index d7fc78bf1d..d5482bcb10 100644 --- a/client/client/src/notes/index.js +++ b/client/client/src/notes/notes.js @@ -1,5 +1,5 @@ import './style.css'; -import template from './index.html'; +import template from './notes.html'; import {module} from '../module'; export const NAME = 'vnClientNotes'; diff --git a/client/client/src/search-panel/index.html b/client/client/src/search-panel/search-panel.html similarity index 100% rename from client/client/src/search-panel/index.html rename to client/client/src/search-panel/search-panel.html diff --git a/client/client/src/search-panel/index.js b/client/client/src/search-panel/search-panel.js similarity index 95% rename from client/client/src/search-panel/index.js rename to client/client/src/search-panel/search-panel.js index bf8af3c039..c809bc6151 100644 --- a/client/client/src/search-panel/index.js +++ b/client/client/src/search-panel/search-panel.js @@ -2,7 +2,7 @@ import {module} from '../module'; export const NAME = 'vnClientSearchPanel'; export const COMPONENT = { - template: require('./index.html'), + template: require('./search-panel.html'), controller: function($scope, $window) { this.filter = {id: null, fi: null, name: null, socialName: null, city: null, postcode: null, email: null, phone: null}; this.formVisibility = true; diff --git a/client/client/src/web-access/index.js b/client/client/src/web-access/index.js deleted file mode 100644 index d7f444af44..0000000000 --- a/client/client/src/web-access/index.js +++ /dev/null @@ -1,48 +0,0 @@ -import {module} from '../module'; - -class Controller { - constructor($scope, $http, vnAppLogger) { - this.$scope = $scope; - this.$http = $http; - this.vnAppLogger = vnAppLogger; - } - $onChanges() { - if(this.client) - this.account = this.client.account; - } - onPassOpen() { - this.newPassword = ''; - this.repeatPassword = ''; - this.$scope.$apply(); - } - onPassChange(response) { - if(response == 'ACCEPT') - try { - if(!this.newPassword) - throw new Error(`Passwords can't be empty`); - if(this.newPassword != this.repeatPassword) - throw new Error(`Passwords don't match`); - - let account = { - password: this.newPassword - }; - - this.$http.put(`/client/api/Accounts/${this.client.id}`, account); - } - catch(e) { - this.vnAppLogger.showError(e.message); - return false; - } - - return true; - } -} -Controller.$inject = ['$scope', '$http', 'vnAppLogger']; - -module.component('vnClientWebAccess', { - template: require('./index.html'), - bindings: { - client: '<' - }, - controller: Controller -}); diff --git a/client/client/src/web-access/index.html b/client/client/src/web-access/web-access.html similarity index 100% rename from client/client/src/web-access/index.html rename to client/client/src/web-access/web-access.html diff --git a/client/client/src/web-access/web-access.js b/client/client/src/web-access/web-access.js new file mode 100644 index 0000000000..413d80059b --- /dev/null +++ b/client/client/src/web-access/web-access.js @@ -0,0 +1,46 @@ +import {module} from '../module'; + +class Controller { + constructor($scope, $http, vnAppLogger) { + this.$scope = $scope; + this.$http = $http; + this.vnAppLogger = vnAppLogger; + } + $onChanges() { + if (this.client) + this.account = this.client.account; + } + onPassOpen() { + this.newPassword = ''; + this.repeatPassword = ''; + this.$scope.$apply(); + } + onPassChange(response) { + if (response == 'ACCEPT') + try { + if (!this.newPassword) + throw new Error(`Passwords can't be empty`); + if (this.newPassword != this.repeatPassword) + throw new Error(`Passwords don't match`); + let account = { + password: this.newPassword + }; + + this.$http.put(`/client/api/Accounts/${this.client.id}`, account); + } catch (e) { + this.vnAppLogger.showError(e.message); + return false; + } + + return true; + } +} +Controller.$inject = ['$scope', '$http', 'vnAppLogger']; + +module.component('vnClientWebAccess', { + template: require('./web-access.html'), + bindings: { + client: '<' + }, + controller: Controller +}); diff --git a/client/core/src/autocomplete/index.html b/client/core/src/autocomplete/autocomplete.html similarity index 100% rename from client/core/src/autocomplete/index.html rename to client/core/src/autocomplete/autocomplete.html diff --git a/client/core/src/autocomplete/index.js b/client/core/src/autocomplete/autocomplete.js similarity index 99% rename from client/core/src/autocomplete/index.js rename to client/core/src/autocomplete/autocomplete.js index 2cd088c9bc..c46fcebf76 100644 --- a/client/core/src/autocomplete/index.js +++ b/client/core/src/autocomplete/autocomplete.js @@ -400,7 +400,7 @@ export default class Autocomplete extends Component { Autocomplete.$inject = ['$element', '$scope', '$http', 'vnPopover', '$transclude']; module.component('vnAutocomplete', { - template: require('./index.html'), + template: require('./autocomplete.html'), bindings: { url: '@', showField: '@?', diff --git a/client/core/src/components.js b/client/core/src/components.js index 5c631ab049..074434bd90 100644 --- a/client/core/src/components.js +++ b/client/core/src/components.js @@ -4,11 +4,12 @@ import './styles/fonts/mdi-override.css'; import './textfield/index'; import './watcher/index'; import './paging/index'; -import './icon/index'; -import './autocomplete/index'; +import './icon/icon'; +import './autocomplete/autocomplete'; import './popover/index'; -import './dialog/index'; -import './confirm/index'; +import './dialog/dialog'; + +import './confirm/confirm'; import './title/index'; import './subtitle/index'; import './spinner/index'; diff --git a/client/core/src/confirm/index.html b/client/core/src/confirm/confirm.html similarity index 100% rename from client/core/src/confirm/index.html rename to client/core/src/confirm/confirm.html diff --git a/client/core/src/confirm/index.js b/client/core/src/confirm/confirm.js similarity index 78% rename from client/core/src/confirm/index.js rename to client/core/src/confirm/confirm.js index 0d7c56cc0d..f629fe7885 100644 --- a/client/core/src/confirm/index.js +++ b/client/core/src/confirm/confirm.js @@ -1,12 +1,12 @@ import {module} from '../module'; -import Dialog from '../dialog/index'; +import Dialog from '../dialog/dialog'; import './style.css'; export default class Confirm extends Dialog {} Dialog.$inject = ['$element']; module.component('vnConfirm', { - template: require('./index.html'), + template: require('./confirm.html'), bindings: { onResponse: '&', question: '@', diff --git a/client/core/src/dialog/index.html b/client/core/src/dialog/dialog.html similarity index 100% rename from client/core/src/dialog/index.html rename to client/core/src/dialog/dialog.html diff --git a/client/core/src/dialog/index.js b/client/core/src/dialog/dialog.js similarity index 98% rename from client/core/src/dialog/index.js rename to client/core/src/dialog/dialog.js index e45f66b930..e2be657991 100644 --- a/client/core/src/dialog/index.js +++ b/client/core/src/dialog/dialog.js @@ -98,7 +98,7 @@ export default class Dialog extends Component { Dialog.$inject = ['$element']; module.component('vnDialog', { - template: require('./index.html'), + template: require('./dialog.html'), transclude: { tplBody: 'tplBody', tplButtons: 'tplButtons' diff --git a/client/core/src/directives/dialog.js b/client/core/src/directives/dialog.js index b4baac7f35..d4ac65b45d 100644 --- a/client/core/src/directives/dialog.js +++ b/client/core/src/directives/dialog.js @@ -1,5 +1,5 @@ import {module} from '../module'; -import Dialog from '../dialog/index'; +import Dialog from '../dialog/dialog'; import {kebabToCamel} from '../lib/string'; /** diff --git a/client/core/src/icon/index.js b/client/core/src/icon/icon.js similarity index 95% rename from client/core/src/icon/index.js rename to client/core/src/icon/icon.js index 7e36fab97f..31e9ca5658 100644 --- a/client/core/src/icon/index.js +++ b/client/core/src/icon/icon.js @@ -1,5 +1,5 @@ import {module} from '../module'; -import './index.mdl'; +import './icon.mdl'; import './style.css'; import * as resolveFactory from '../lib/resolveDefaultComponents'; diff --git a/client/core/src/icon/index.mdl.html b/client/core/src/icon/icon.mdl.html similarity index 100% rename from client/core/src/icon/index.mdl.html rename to client/core/src/icon/icon.mdl.html diff --git a/client/core/src/icon/index.mdl.js b/client/core/src/icon/icon.mdl.js similarity index 83% rename from client/core/src/icon/index.mdl.js rename to client/core/src/icon/icon.mdl.js index 3084fdd12c..ce3f82856d 100644 --- a/client/core/src/icon/index.mdl.js +++ b/client/core/src/icon/icon.mdl.js @@ -1,5 +1,5 @@ import {module} from '../module'; -import template from './index.mdl.html'; +import template from './icon.mdl.html'; export const NAME = 'vnIconMdlFactory'; export function factory() { diff --git a/client/salix/src/aclService.js b/client/salix/src/aclService.js index aeb8b0129a..63e75278cf 100644 --- a/client/salix/src/aclService.js +++ b/client/salix/src/aclService.js @@ -1,10 +1,14 @@ import ngModule from './module'; -function aclService() { - this.roles = window.Salix.acl.roles; +aclService.$inject = ['aclConstant']; +function aclService(aclConstant) { + this.roles = aclConstant.roles || undefined; + this.routeHasPermission = function(route) { let hasPermission; - if (!route.acl) + if (!this.roles) + hasPermission = false; + else if (!route.acl) hasPermission = true; else if (!this.roles || !Object.keys(this.roles).length) hasPermission = false; diff --git a/client/salix/src/bootstrap.js b/client/salix/src/bootstrap.js index b0a57a2156..dd7a61388f 100644 --- a/client/salix/src/bootstrap.js +++ b/client/salix/src/bootstrap.js @@ -1,5 +1,5 @@ import {ng} from 'vendor'; -import './module'; +import appName from './module'; export const bootstrap = () => { const selector = 'selector'; @@ -13,5 +13,5 @@ export const bootstrap = () => { if (!_element) { throw new Error('Element is not defined'); } - ng.bootstrap(_element, ['salix']); + ng.bootstrap(_element, [appName]); }; diff --git a/client/salix/src/components/app/app.js b/client/salix/src/components/app/app.js index c20c448ee3..18742e9f4f 100644 --- a/client/salix/src/components/app/app.js +++ b/client/salix/src/components/app/app.js @@ -1,4 +1,4 @@ -import ngModule from '../../module'; +import ngModule, {appName} from '../../module'; import './style.scss'; export const NAME = 'vnApp'; @@ -76,4 +76,6 @@ function interceptorConfig($httpProvider) { } ngModule.config(interceptorConfig); +var acl = window[appName] ? window[appName].acl : {}; +ngModule.constant('aclConstant', acl); diff --git a/client/salix/src/config.js b/client/salix/src/config.js index 92b8f5efdd..877d167301 100644 --- a/client/salix/src/config.js +++ b/client/salix/src/config.js @@ -1,8 +1,8 @@ -import ngModule from './module'; +import ngModule, {appName} from './module'; config.$inject = ['$translatePartialLoaderProvider']; export function config($translatePartialLoaderProvider) { - $translatePartialLoaderProvider.addPart('salix'); + $translatePartialLoaderProvider.addPart(appName); } ngModule.config(config); diff --git a/client/salix/src/module.js b/client/salix/src/module.js index d0c4657a96..568a43d69b 100644 --- a/client/salix/src/module.js +++ b/client/salix/src/module.js @@ -1,5 +1,6 @@ import {ng} from 'vendor'; import 'core'; -const ngModule = ng.module('salix', ['vnCore']); +export const appName = 'salix'; +const ngModule = ng.module(appName, ['vnCore']); export default ngModule; diff --git a/services/client/common/scopes/client/card.json b/services/client/common/scopes/client/card.json index 84ca960d65..332a0409b3 100644 --- a/services/client/common/scopes/client/card.json +++ b/services/client/common/scopes/client/card.json @@ -1,43 +1,57 @@ [ { - "relation": "salesPerson", - "scope":{ - "fields": { - "id": true, "name": true - } + "relation": "salesPerson", + "scope": { + "fields": [ + "id", + "name" + ] } }, { - "relation": "contactChannel", - "scope":{ - "fields": { - "id": true, "name": true - } + "relation": "contactChannel", + "scope": { + "fields": [ + "id", + "name" + ] } }, { - "relation": "province", - "scope":{ - "fields": { - "id": true, "name": true - } + "relation": "province", + "scope": { + "fields": [ + "id", + "name" + ] } }, { - "relation": "country", - "scope":{ - "fields": { - "id": true, "name": true - } + "relation": "country", + "scope": { + "fields": [ + "id", + "name" + ] } }, { - "relation": "payMethod", - "scope":{ - "fields": { - "id": true, "name": true - } + "relation": "payMethod", + "scope": { + "fields": [ + "id", + "name" + ] + } + }, + { + "relation": "account", + "scope": { + "fields": [ + "id", + "name", + "active" + ] } } -] - +] \ No newline at end of file diff --git a/services/salix/server/boot/routes.js b/services/salix/server/boot/routes.js index 10ce5dd4bd..cbd83d2c18 100644 --- a/services/salix/server/boot/routes.js +++ b/services/salix/server/boot/routes.js @@ -113,7 +113,7 @@ module.exports = function (app) { function sendACL(res, acl){ let aclStr = JSON.stringify(acl); res.header('Content-Type', 'application/javascript; charset=UTF-8'); - res.send(`(function(window){window.Salix = window.Salix || {}; window.Salix.acl = window.Salix.acl || {}; window.Salix.acl = ${aclStr}; })(window)`); + res.send(`(function(window){window.salix = window.salix || {}; window.salix.acl = window.salix.acl || {}; window.salix.acl = ${aclStr}; })(window)`); } }; From 11a402e18cf45c07b7ffc680fba54b30fd73d0f4 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Wed, 31 May 2017 10:28:39 +0200 Subject: [PATCH 07/12] renombrado de archivos parte 2 --- client/core/src/components.js | 16 ++++++++-------- .../core/src/paging/{index.html => paging.html} | 0 client/core/src/paging/{index.js => paging.js} | 2 +- client/core/src/popover/{index.js => popover.js} | 0 .../src/snackbar/{index.html => snackbar.html} | 0 .../core/src/snackbar/{index.js => snackbar.js} | 2 +- .../src/spinner/{index.html => spinner.html} | 0 client/core/src/spinner/{index.js => spinner.js} | 2 +- .../src/subtitle/{index.html => subtitle.html} | 0 .../core/src/subtitle/{index.js => subtitle.js} | 2 +- .../src/textfield/{index.js => textfield.js} | 2 +- .../{index.mdl.html => textfield.mdl.html} | 0 .../textfield/{index.mdl.js => textfield.mdl.js} | 2 +- client/core/src/title/{index.html => title.html} | 0 client/core/src/title/{index.js => title.js} | 2 +- .../src/watcher/{index.html => watcher.html} | 0 client/core/src/watcher/{index.js => watcher.js} | 2 +- 17 files changed, 16 insertions(+), 16 deletions(-) rename client/core/src/paging/{index.html => paging.html} (100%) rename client/core/src/paging/{index.js => paging.js} (96%) rename client/core/src/popover/{index.js => popover.js} (100%) rename client/core/src/snackbar/{index.html => snackbar.html} (100%) rename client/core/src/snackbar/{index.js => snackbar.js} (93%) rename client/core/src/spinner/{index.html => spinner.html} (100%) rename client/core/src/spinner/{index.js => spinner.js} (96%) rename client/core/src/subtitle/{index.html => subtitle.html} (100%) rename client/core/src/subtitle/{index.js => subtitle.js} (68%) rename client/core/src/textfield/{index.js => textfield.js} (98%) rename client/core/src/textfield/{index.mdl.html => textfield.mdl.html} (100%) rename client/core/src/textfield/{index.mdl.js => textfield.mdl.js} (85%) rename client/core/src/title/{index.html => title.html} (100%) rename client/core/src/title/{index.js => title.js} (69%) rename client/core/src/watcher/{index.html => watcher.html} (100%) rename client/core/src/watcher/{index.js => watcher.js} (99%) diff --git a/client/core/src/components.js b/client/core/src/components.js index 074434bd90..2c8a096300 100644 --- a/client/core/src/components.js +++ b/client/core/src/components.js @@ -1,19 +1,19 @@ import './mdl-override.css'; import './styles/fonts/mdi-override.css'; -import './textfield/index'; -import './watcher/index'; -import './paging/index'; +import './textfield/textfield'; +import './watcher/watcher'; +import './paging/paging'; import './icon/icon'; import './autocomplete/autocomplete'; -import './popover/index'; +import './popover/popover'; import './dialog/dialog'; import './confirm/confirm'; -import './title/index'; -import './subtitle/index'; -import './spinner/index'; -import './snackbar/index'; +import './title/title'; +import './subtitle/subtitle'; +import './spinner/spinner'; +import './snackbar/snackbar'; export {NAME as BUTTON, directive as ButtonDirective} from './button/button'; export {NAME as BUTTON_MDL, factory as buttonMdl} from './button/button.mdl'; diff --git a/client/core/src/paging/index.html b/client/core/src/paging/paging.html similarity index 100% rename from client/core/src/paging/index.html rename to client/core/src/paging/paging.html diff --git a/client/core/src/paging/index.js b/client/core/src/paging/paging.js similarity index 96% rename from client/core/src/paging/index.js rename to client/core/src/paging/paging.js index fd17b994ee..8e0b86aa17 100644 --- a/client/core/src/paging/index.js +++ b/client/core/src/paging/paging.js @@ -36,7 +36,7 @@ Paging.$inject = ['$http', '$scope']; export const NAME = 'vnPaging'; export const COMPONENT = { - template: require('./index.html'), + template: require('./paging.html'), bindings: { index: '<', total: '<' diff --git a/client/core/src/popover/index.js b/client/core/src/popover/popover.js similarity index 100% rename from client/core/src/popover/index.js rename to client/core/src/popover/popover.js diff --git a/client/core/src/snackbar/index.html b/client/core/src/snackbar/snackbar.html similarity index 100% rename from client/core/src/snackbar/index.html rename to client/core/src/snackbar/snackbar.html diff --git a/client/core/src/snackbar/index.js b/client/core/src/snackbar/snackbar.js similarity index 93% rename from client/core/src/snackbar/index.js rename to client/core/src/snackbar/snackbar.js index ce76c1ba30..20a7e93747 100644 --- a/client/core/src/snackbar/index.js +++ b/client/core/src/snackbar/snackbar.js @@ -20,6 +20,6 @@ export default class Controller { Controller.$inject = ['$element']; module.component('vnSnackbar', { - template: require('./index.html'), + template: require('./snackbar.html'), controller: Controller }); diff --git a/client/core/src/spinner/index.html b/client/core/src/spinner/spinner.html similarity index 100% rename from client/core/src/spinner/index.html rename to client/core/src/spinner/spinner.html diff --git a/client/core/src/spinner/index.js b/client/core/src/spinner/spinner.js similarity index 96% rename from client/core/src/spinner/index.js rename to client/core/src/spinner/spinner.js index daf694e1de..ae6a69ede3 100644 --- a/client/core/src/spinner/index.js +++ b/client/core/src/spinner/spinner.js @@ -49,7 +49,7 @@ export default class Spinner extends Component { Spinner.$inject = ['$element', '$scope']; export const component = { - template: require('./index.html'), + template: require('./spinner.html'), bindings: { enable: '=' }, diff --git a/client/core/src/subtitle/index.html b/client/core/src/subtitle/subtitle.html similarity index 100% rename from client/core/src/subtitle/index.html rename to client/core/src/subtitle/subtitle.html diff --git a/client/core/src/subtitle/index.js b/client/core/src/subtitle/subtitle.js similarity index 68% rename from client/core/src/subtitle/index.js rename to client/core/src/subtitle/subtitle.js index 941e8eb546..c98c259941 100644 --- a/client/core/src/subtitle/index.js +++ b/client/core/src/subtitle/subtitle.js @@ -1,6 +1,6 @@ import {module} from '../module'; module.component('vnSubtitle', { - template: require('./index.html'), + template: require('./subtitle.html'), transclude: true }); diff --git a/client/core/src/textfield/index.js b/client/core/src/textfield/textfield.js similarity index 98% rename from client/core/src/textfield/index.js rename to client/core/src/textfield/textfield.js index af4d7c4ab4..e278c13a53 100644 --- a/client/core/src/textfield/index.js +++ b/client/core/src/textfield/textfield.js @@ -3,7 +3,7 @@ import Component from '../lib/component'; import * as resolveFactory from '../lib/resolveDefaultComponents'; import * as normalizerFactory from '../lib/inputAttrsNormalizer'; import './style.scss'; -import './index.mdl'; +import './textfield.mdl'; export default class Textfield extends Component { constructor($element, $scope, $attrs) { diff --git a/client/core/src/textfield/index.mdl.html b/client/core/src/textfield/textfield.mdl.html similarity index 100% rename from client/core/src/textfield/index.mdl.html rename to client/core/src/textfield/textfield.mdl.html diff --git a/client/core/src/textfield/index.mdl.js b/client/core/src/textfield/textfield.mdl.js similarity index 85% rename from client/core/src/textfield/index.mdl.js rename to client/core/src/textfield/textfield.mdl.js index 64e156885f..e97d38d28a 100644 --- a/client/core/src/textfield/index.mdl.js +++ b/client/core/src/textfield/textfield.mdl.js @@ -4,7 +4,7 @@ export const NAME = 'vnTextfieldMdlFactory'; export function factory() { return { - template: require('./index.mdl.html'), + template: require('./textfield.mdl.html'), default: { label: 'text', className: 'mdl-textfield--floating-label', diff --git a/client/core/src/title/index.html b/client/core/src/title/title.html similarity index 100% rename from client/core/src/title/index.html rename to client/core/src/title/title.html diff --git a/client/core/src/title/index.js b/client/core/src/title/title.js similarity index 69% rename from client/core/src/title/index.js rename to client/core/src/title/title.js index 3fb71f567c..3420738e12 100644 --- a/client/core/src/title/index.js +++ b/client/core/src/title/title.js @@ -1,6 +1,6 @@ import {module} from '../module'; module.component('vnTitle', { - template: require('./index.html'), + template: require('./title.html'), transclude: true }); diff --git a/client/core/src/watcher/index.html b/client/core/src/watcher/watcher.html similarity index 100% rename from client/core/src/watcher/index.html rename to client/core/src/watcher/watcher.html diff --git a/client/core/src/watcher/index.js b/client/core/src/watcher/watcher.js similarity index 99% rename from client/core/src/watcher/index.js rename to client/core/src/watcher/watcher.js index d421405df5..aec3bc0a8d 100644 --- a/client/core/src/watcher/index.js +++ b/client/core/src/watcher/watcher.js @@ -149,7 +149,7 @@ export default class Watcher extends Component { Watcher.$inject = ['$element', '$scope', '$state', '$transitions', '$http', 'vnAppLogger', '$translate']; module.component('vnWatcher', { - template: require('./index.html'), + template: require('./watcher.html'), bindings: { url: '@?', idField: '@?', From 9e550e746aa2b6c537ac2c3ef75c01c8fb53159e Mon Sep 17 00:00:00 2001 From: nelo Date: Wed, 31 May 2017 10:58:48 +0200 Subject: [PATCH 08/12] =?UTF-8?q?paginaci=C3=B3n=20en=20clientes=20arregla?= =?UTF-8?q?do=20problema=20de=20b=C3=BAsqueda?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client/src/index/index.html | 10 ++--- client/client/src/index/index.js | 16 +++++-- .../src/components/searchbar/searchbar.html | 2 +- .../src/components/searchbar/searchbar.js | 4 +- services/client/common/models/Client.js | 39 +---------------- services/client/common/models/MyModel.js | 42 +++++++++++++++---- .../common/scopes/client/before-save.js | 18 ++++++++ .../client/common/scopes/client/filter.js | 39 +++++++++++++++++ 8 files changed, 116 insertions(+), 54 deletions(-) create mode 100644 services/client/common/scopes/client/before-save.js create mode 100644 services/client/common/scopes/client/filter.js diff --git a/client/client/src/index/index.html b/client/client/src/index/index.html index 2ead0c2b4c..96338af36e 100644 --- a/client/client/src/index/index.html +++ b/client/client/src/index/index.html @@ -3,19 +3,19 @@
- - + - +
diff --git a/client/client/src/index/index.js b/client/client/src/index/index.js index e69d354815..1f7060077d 100644 --- a/client/client/src/index/index.js +++ b/client/client/src/index/index.js @@ -2,6 +2,16 @@ import {module} from '../module'; import './style.css'; import './item-client'; -module.component('vnClientIndex', { - template: require('./index.html') -}); +class Controller { + search(index) { + index.filter.search = this.model.search; + index.accept(); + } +} + +export const NAME = 'vnClientIndex'; +export const COMPONENT = { + template: require('./index.html'), + controller: Controller +}; +module.component(NAME, COMPONENT); diff --git a/client/salix/src/components/searchbar/searchbar.html b/client/salix/src/components/searchbar/searchbar.html index 50ccac05d6..0ca47a768b 100644 --- a/client/salix/src/components/searchbar/searchbar.html +++ b/client/salix/src/components/searchbar/searchbar.html @@ -1,6 +1,6 @@
- + { - let filter = removeEmpty(filterCb(params)); - this.find(filter, function(err, instances) { - if(!err) - cb(null, instances); - }) - }; + this[methodName] = (params, cb) => { + let filter = removeEmpty(filterCb(params)); + var response = {} + + function returnValues(){ + if(response.instances !== undefined && response.count !== undefined) + cb(null, response); + } + + function error(){ + cb(null, response); + } + + this.find(filter, function(err, instances) { + if(!err){ + response.instances = instances; + returnValues(); + } + else{ + error(); + } + + }) + + this.count(filter.where, function(err, totalCount){ + if(!err){ + response.count = totalCount; + returnValues(); + } + else{ + error(); + } + + }) + }; }; diff --git a/services/client/common/scopes/client/before-save.js b/services/client/common/scopes/client/before-save.js new file mode 100644 index 0000000000..9a0c82cdd7 --- /dev/null +++ b/services/client/common/scopes/client/before-save.js @@ -0,0 +1,18 @@ +module.exports = function(Client){ + Client.observe('before save', function(ctx, next) { + if (ctx.instance) { + if (!ctx.instance.dueDay) + ctx.instance.dueDay = 5; + next(); + } else { + Client.findById(ctx.where.id, function(err, instance) { + if (instance + && instance.payMethodFk != ctx.data.payMethodFk + && instance.dueDay == ctx.data.dueDay) + ctx.data.dueDay = 5; + next(); + }); + } + }); + +} \ No newline at end of file diff --git a/services/client/common/scopes/client/filter.js b/services/client/common/scopes/client/filter.js new file mode 100644 index 0000000000..d60f4c21c9 --- /dev/null +++ b/services/client/common/scopes/client/filter.js @@ -0,0 +1,39 @@ +module.exports = function(Client){ + Client.installMethod('filter', filterClients); + function filterClients(p) { + if(p.search && p.search !== "") + return searchWhere(p); + return andWhere(p); + } + + function searchWhere(p){ + return { + where: { + or:[ + {id: p.search,}, + {name: {regexp: p.search}} + ] + + }, + skip: (p.page - 1) * p.size, + limit: p.size + } + } + + function andWhere(p){ + return { + where: { + id: p.id, + name: {regexp: p.name}, + cif: p.cif, + socialName: {regexp: p.socialName}, + city: {regexp: p.city}, + postcode: p.postcode, + email: {regexp: p.email}, + phone: p.phone + }, + skip: (p.page - 1) * p.size, + limit: p.size + } + } +} \ No newline at end of file From 528dcac06fdcc3b60f753537c8308743b1bd5b10 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Wed, 31 May 2017 12:56:37 +0200 Subject: [PATCH 09/12] =?UTF-8?q?kanban:=20asociar=20env=C3=ADo=20escrito?= =?UTF-8?q?=20con=20cambio=20de=20valor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/src/billing-data/billing-data.html | 18 ++++++- .../client/src/billing-data/billing-data.js | 48 +++++++++++++++++++ client/client/src/billing-data/locale/es.json | 6 +++ client/salix/src/styles/misc.scss | 3 ++ services/mailer/Application/router.js | 2 +- 5 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 client/client/src/billing-data/locale/es.json diff --git a/client/client/src/billing-data/billing-data.html b/client/client/src/billing-data/billing-data.html index a001ba49e0..74180d36e9 100644 --- a/client/client/src/billing-data/billing-data.html +++ b/client/client/src/billing-data/billing-data.html @@ -5,7 +5,7 @@ form="form" save="put"> - + Información de facturación @@ -40,4 +40,18 @@ - \ No newline at end of file + + + + + Changed terms + Notify customer? + + + + + + + \ No newline at end of file diff --git a/client/client/src/billing-data/billing-data.js b/client/client/src/billing-data/billing-data.js index 7c70b46afd..c5b99cf092 100644 --- a/client/client/src/billing-data/billing-data.js +++ b/client/client/src/billing-data/billing-data.js @@ -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: '<' diff --git a/client/client/src/billing-data/locale/es.json b/client/client/src/billing-data/locale/es.json new file mode 100644 index 0000000000..5c4e720d71 --- /dev/null +++ b/client/client/src/billing-data/locale/es.json @@ -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" +} \ No newline at end of file diff --git a/client/salix/src/styles/misc.scss b/client/salix/src/styles/misc.scss index 6b8523aab5..1146d9c0fd 100644 --- a/client/salix/src/styles/misc.scss +++ b/client/salix/src/styles/misc.scss @@ -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; } \ No newline at end of file diff --git a/services/mailer/Application/router.js b/services/mailer/Application/router.js index 6bc5e60bfa..c18f908a98 100644 --- a/services/mailer/Application/router.js +++ b/services/mailer/Application/router.js @@ -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. From fae56408bb4de9432550a5c815b0509183f7e2f4 Mon Sep 17 00:00:00 2001 From: Vicente Falco Date: Wed, 31 May 2017 12:57:18 +0200 Subject: [PATCH 10/12] merge --- client/auth/src/auth.js | 2 +- .../auth/src/login/{index.html => login.html} | 0 client/auth/src/login/{index.js => login.js} | 2 +- client/client/src/address-create/index.html | 46 -- client/client/src/address-create/index.js | 25 -- client/client/src/address-edit/index.html | 48 -- client/client/src/address-edit/index.js | 18 - client/client/src/addresses/index.html | 32 -- client/client/src/addresses/index.js | 6 - client/client/src/basic-data/index.html | 48 -- client/client/src/basic-data/index.js | 9 - client/client/src/billing-data/index.html | 43 -- client/client/src/billing-data/index.js | 11 - client/client/src/card/index.html | 10 - client/client/src/card/index.js | 17 - client/client/src/create/index.html | 28 -- client/client/src/create/index.js | 23 - client/client/src/descriptor/index.html | 15 - client/client/src/descriptor/index.js | 21 - client/client/src/fiscal-data/index.html | 45 -- client/client/src/fiscal-data/index.js | 11 - client/client/src/new-note/index.html | 18 - client/client/src/new-note/index.js | 27 -- client/client/src/notes/index.html | 17 - client/client/src/notes/index.js | 34 -- client/client/src/search-panel/index.html | 26 -- client/client/src/search-panel/index.js | 28 -- client/client/src/web-access/index.html | 42 -- client/client/src/web-access/index.js | 48 -- client/core/src/autocomplete/index.html | 10 - client/core/src/autocomplete/index.js | 418 ------------------ client/core/src/confirm/index.html | 23 - client/core/src/confirm/index.js | 16 - client/core/src/dialog/index.html | 13 - client/core/src/dialog/index.js | 111 ----- client/core/src/icon/index.js | 19 - client/core/src/icon/index.mdl.html | 1 - client/core/src/icon/index.mdl.js | 12 - client/core/src/paging/index.html | 10 - client/core/src/paging/index.js | 46 -- client/core/src/popover/index.js | 98 ---- client/core/src/snackbar/index.html | 4 - client/core/src/snackbar/index.js | 25 -- client/core/src/spinner/index.html | 2 - client/core/src/spinner/index.js | 58 --- client/core/src/subtitle/index.html | 2 - client/core/src/subtitle/index.js | 6 - client/core/src/textfield/index.js | 82 ---- client/core/src/textfield/index.mdl.html | 18 - client/core/src/textfield/index.mdl.js | 16 - client/core/src/title/index.html | 2 - client/core/src/title/index.js | 6 - client/core/src/watcher/index.html | 6 - client/core/src/watcher/index.js | 162 ------- services/mailer/.gitignore | 3 +- 55 files changed, 4 insertions(+), 1865 deletions(-) rename client/auth/src/login/{index.html => login.html} (100%) mode change 100755 => 100644 rename client/auth/src/login/{index.js => login.js} (98%) delete mode 100644 client/client/src/address-create/index.html delete mode 100644 client/client/src/address-create/index.js delete mode 100644 client/client/src/address-edit/index.html delete mode 100644 client/client/src/address-edit/index.js delete mode 100644 client/client/src/addresses/index.html delete mode 100644 client/client/src/addresses/index.js delete mode 100644 client/client/src/basic-data/index.html delete mode 100644 client/client/src/basic-data/index.js delete mode 100644 client/client/src/billing-data/index.html delete mode 100644 client/client/src/billing-data/index.js delete mode 100644 client/client/src/card/index.html delete mode 100644 client/client/src/card/index.js delete mode 100644 client/client/src/create/index.html delete mode 100644 client/client/src/create/index.js delete mode 100644 client/client/src/descriptor/index.html delete mode 100644 client/client/src/descriptor/index.js delete mode 100644 client/client/src/fiscal-data/index.html delete mode 100644 client/client/src/fiscal-data/index.js delete mode 100644 client/client/src/new-note/index.html delete mode 100644 client/client/src/new-note/index.js delete mode 100644 client/client/src/notes/index.html delete mode 100644 client/client/src/notes/index.js delete mode 100644 client/client/src/search-panel/index.html delete mode 100644 client/client/src/search-panel/index.js delete mode 100644 client/client/src/web-access/index.html delete mode 100644 client/client/src/web-access/index.js delete mode 100644 client/core/src/autocomplete/index.html delete mode 100644 client/core/src/autocomplete/index.js delete mode 100644 client/core/src/confirm/index.html delete mode 100644 client/core/src/confirm/index.js delete mode 100644 client/core/src/dialog/index.html delete mode 100644 client/core/src/dialog/index.js delete mode 100644 client/core/src/icon/index.js delete mode 100644 client/core/src/icon/index.mdl.html delete mode 100644 client/core/src/icon/index.mdl.js delete mode 100644 client/core/src/paging/index.html delete mode 100644 client/core/src/paging/index.js delete mode 100644 client/core/src/popover/index.js delete mode 100644 client/core/src/snackbar/index.html delete mode 100644 client/core/src/snackbar/index.js delete mode 100644 client/core/src/spinner/index.html delete mode 100644 client/core/src/spinner/index.js delete mode 100644 client/core/src/subtitle/index.html delete mode 100644 client/core/src/subtitle/index.js delete mode 100644 client/core/src/textfield/index.js delete mode 100644 client/core/src/textfield/index.mdl.html delete mode 100644 client/core/src/textfield/index.mdl.js delete mode 100644 client/core/src/title/index.html delete mode 100644 client/core/src/title/index.js delete mode 100644 client/core/src/watcher/index.html delete mode 100644 client/core/src/watcher/index.js diff --git a/client/auth/src/auth.js b/client/auth/src/auth.js index 703c81193c..8b7c022dd5 100644 --- a/client/auth/src/auth.js +++ b/client/auth/src/auth.js @@ -1,3 +1,3 @@ import './ngModule'; import './config'; -import './login/index'; +import './login/login'; diff --git a/client/auth/src/login/index.html b/client/auth/src/login/login.html old mode 100755 new mode 100644 similarity index 100% rename from client/auth/src/login/index.html rename to client/auth/src/login/login.html diff --git a/client/auth/src/login/index.js b/client/auth/src/login/login.js similarity index 98% rename from client/auth/src/login/index.js rename to client/auth/src/login/login.js index 7c7447d739..229c1a345a 100644 --- a/client/auth/src/login/index.js +++ b/client/auth/src/login/login.js @@ -76,6 +76,6 @@ export default class Controller { Controller.$inject = ['$element', '$scope', '$window', '$http']; ngModule.component('vnLogin', { - template: require('./index.html'), + template: require('./login.html'), controller: Controller }); diff --git a/client/client/src/address-create/index.html b/client/client/src/address-create/index.html deleted file mode 100644 index f014ceb364..0000000000 --- a/client/client/src/address-create/index.html +++ /dev/null @@ -1,46 +0,0 @@ - - -
- - - Consignatario - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/client/client/src/address-create/index.js b/client/client/src/address-create/index.js deleted file mode 100644 index 7626ea5a82..0000000000 --- a/client/client/src/address-create/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import {module} from '../module'; - -class Controller { - constructor($scope, $state) { - this.$ = $scope; - this.$state = $state; - this.address = { - clientFk: parseInt($state.params.id), - enabled: true - }; - } - onSubmit() { - this.$.watcher.submit().then( - () => this.$state.go('clientCard.addresses') - ); - } -} -Controller.$inject = ['$scope', '$state']; - -export const NAME = 'vnAddressCreate'; -export const COMPONENT = { - template: require('./index.html'), - controller: Controller -}; -module.component(NAME, COMPONENT); diff --git a/client/client/src/address-edit/index.html b/client/client/src/address-edit/index.html deleted file mode 100644 index c2086ff2a0..0000000000 --- a/client/client/src/address-edit/index.html +++ /dev/null @@ -1,48 +0,0 @@ - - -
- - - Consignatario - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/client/client/src/address-edit/index.js b/client/client/src/address-edit/index.js deleted file mode 100644 index 70f609d2df..0000000000 --- a/client/client/src/address-edit/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import {module} from '../module'; - -class Controller { - constructor($stateParams) { - this.address = { - id: $stateParams.addressId - }; - } -} -Controller.$inject = ['$stateParams']; - -export const NAME = 'vnAddressEdit'; -export const COMPONENT = { - template: require('./index.html'), - controllerAs: 'addressData', - controller: Controller -}; -module.component(NAME, COMPONENT); diff --git a/client/client/src/addresses/index.html b/client/client/src/addresses/index.html deleted file mode 100644 index 1b11b19317..0000000000 --- a/client/client/src/addresses/index.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - Consignatario - - - - - -
{{i.consignee}}
-
{{i.street}}
-
{{i.city}}, {{i.province}}
-
{{i.phone}}, {{i.mobile}}
-
-
- - - - - -
- - - - - diff --git a/client/client/src/addresses/index.js b/client/client/src/addresses/index.js deleted file mode 100644 index 0c0dc08465..0000000000 --- a/client/client/src/addresses/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import {module} from '../module'; - -export const component = { - template: require('./index.html') -}; -module.component('vnClientAddresses', component); diff --git a/client/client/src/basic-data/index.html b/client/client/src/basic-data/index.html deleted file mode 100644 index 4a4e7c3919..0000000000 --- a/client/client/src/basic-data/index.html +++ /dev/null @@ -1,48 +0,0 @@ - - - -
- - - Datos básicos - - - - - - - - - - - - - - - {{::i.name}} {{::i.surname}} - - - - - - - - - - -
diff --git a/client/client/src/basic-data/index.js b/client/client/src/basic-data/index.js deleted file mode 100644 index 2e3dececc1..0000000000 --- a/client/client/src/basic-data/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import {module} from '../module'; - -export const component = { - template: require('./index.html'), - bindings: { - client: '<' - } -}; -module.component('vnClientBasicData', component); diff --git a/client/client/src/billing-data/index.html b/client/client/src/billing-data/index.html deleted file mode 100644 index a001ba49e0..0000000000 --- a/client/client/src/billing-data/index.html +++ /dev/null @@ -1,43 +0,0 @@ - - - -
- - - Información de facturación - - - - - - - - - - - - - - - - Documentación - - - - - - - - - - -
\ No newline at end of file diff --git a/client/client/src/billing-data/index.js b/client/client/src/billing-data/index.js deleted file mode 100644 index 7c6c6ffeb1..0000000000 --- a/client/client/src/billing-data/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import {module} from '../module'; - -export const NAME = 'vnClientBillingData'; -export const COMPONENT = { - template: require('./index.html'), - controllerAs: 'bill', - bindings: { - client: '<' - } -}; -module.component(NAME, COMPONENT); diff --git a/client/client/src/card/index.html b/client/client/src/card/index.html deleted file mode 100644 index 589deb1525..0000000000 --- a/client/client/src/card/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/client/client/src/card/index.js b/client/client/src/card/index.js deleted file mode 100644 index 107aa9815a..0000000000 --- a/client/client/src/card/index.js +++ /dev/null @@ -1,17 +0,0 @@ -import {module} from '../module'; -import './style.css'; - -export const NAME = 'vnClientCard'; - -export default class vnClientCard { - constructor() { - this.client = null; - } -} - - -module.component(NAME, { - template: require('./index.html'), - controllerAs: 'card', - controller: vnClientCard -}); diff --git a/client/client/src/create/index.html b/client/client/src/create/index.html deleted file mode 100644 index 45b290997d..0000000000 --- a/client/client/src/create/index.html +++ /dev/null @@ -1,28 +0,0 @@ - - - -
-
- - - Crear Cliente - - - - - - - - - - - - - - -
-
diff --git a/client/client/src/create/index.js b/client/client/src/create/index.js deleted file mode 100644 index f42583d259..0000000000 --- a/client/client/src/create/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import {module} from '../module'; - -class Controller { - constructor($scope, $state) { - this.$scope = $scope; - this.$state = $state; - this.client = { - active: true - }; - } - onSubmit() { - this.$scope.watcher.submit().then( - json => this.$state.go('clientCard.basicData', {id: json.data.id}) - ); - } -} -Controller.$inject = ['$scope', '$state']; - -export const component = { - template: require('./index.html'), - controller: Controller -}; -module.component('vnClientCreate', component); diff --git a/client/client/src/descriptor/index.html b/client/client/src/descriptor/index.html deleted file mode 100644 index 3338030516..0000000000 --- a/client/client/src/descriptor/index.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - person - - -
{{descriptor.client.id}}
-
{{descriptor.client.name}}
-
{{descriptor.client.phone}}
- -
-
-
-
diff --git a/client/client/src/descriptor/index.js b/client/client/src/descriptor/index.js deleted file mode 100644 index 8c2da74045..0000000000 --- a/client/client/src/descriptor/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import {module} from '../module'; -import './style.css'; - -export const NAME = 'vnDescriptor'; -export const COMPONENT = { - template: require('./index.html'), - controllerAs: 'descriptor', - bindings: { - client: '<', - active: '<' - }, - controller: function($http, $scope) { - var self = this; - $scope.$watch('descriptor.active', function(newValue, oldValue) { - if (oldValue !== undefined) - $http.put(`/client/api/Clients/${self.client.id}/activate`); - }); - } -}; -COMPONENT.controller.$inject = ['$http', '$scope']; -module.component(NAME, COMPONENT); diff --git a/client/client/src/fiscal-data/index.html b/client/client/src/fiscal-data/index.html deleted file mode 100644 index 7e9b2a7e99..0000000000 --- a/client/client/src/fiscal-data/index.html +++ /dev/null @@ -1,45 +0,0 @@ - - - -
- - - Datos fiscales y de facturación - - - - - - - - - - - - - - - - - - - - - -
diff --git a/client/client/src/fiscal-data/index.js b/client/client/src/fiscal-data/index.js deleted file mode 100644 index d6ece60200..0000000000 --- a/client/client/src/fiscal-data/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import {module} from '../module'; - -export const NAME = 'vnClientFiscalData'; -export const COMPONENT = { - template: require('./index.html'), - controllerAs: 'fiscal', - bindings: { - client: '<' - } -}; -module.component(NAME, COMPONENT); diff --git a/client/client/src/new-note/index.html b/client/client/src/new-note/index.html deleted file mode 100644 index 2e05ec2442..0000000000 --- a/client/client/src/new-note/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - -
- - - Nueva nota - - - - - - -
\ No newline at end of file diff --git a/client/client/src/new-note/index.js b/client/client/src/new-note/index.js deleted file mode 100644 index d69fa470e5..0000000000 --- a/client/client/src/new-note/index.js +++ /dev/null @@ -1,27 +0,0 @@ -import template from './index.html'; -import {module} from '../module'; - -class Controller { - constructor($element, $state) { - this.element = $element[0]; - this.$state = $state; - this.note = { - clientFk: $state.params.id, - text: null - }; - } - onSubmit() { - this.element.querySelector('vn-watcher').$ctrl.submit().then( - () => this.$state.go('clientCard.notes') - ); - } -} -Controller.$inject = ['$element', '$state']; - -export const NAME = 'vnNewNote'; -export const COMPONENT = { - template: template, - controllerAs: 'newNote', - controller: Controller -}; -module.component(NAME, COMPONENT); diff --git a/client/client/src/notes/index.html b/client/client/src/notes/index.html deleted file mode 100644 index a671a353e6..0000000000 --- a/client/client/src/notes/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - Notas - - -
{{n.created | date:'dd/MM/yyyy HH:mm'}}
-
{{n.employee.name}}
-
{{n.text}}
-
-
-
-
- - \ No newline at end of file diff --git a/client/client/src/notes/index.js b/client/client/src/notes/index.js deleted file mode 100644 index d7fc78bf1d..0000000000 --- a/client/client/src/notes/index.js +++ /dev/null @@ -1,34 +0,0 @@ -import './style.css'; -import template from './index.html'; -import {module} from '../module'; - -export const NAME = 'vnClientNotes'; -export const COMPONENT = { - template: template, - controllerAs: 'observation', - bindings: { - client: '<' - }, - controller: function($http, $state) { - this.$onChanges = function(changes) { - if (this.client) { - this.getObservation(this.client.id); - } - }; - - this.getObservation = function(clientId) { - let json = JSON.stringify({where: {clientFk: this.client.id}, order: 'created DESC'}); - $http.get(`/client/api/clientObservations?filter=${json}`).then( - json => { - this.observations = json.data; - } - ); - }; - - this.newObservation = () => { - $state.go("clientCard.notes.create", {id: this.client.id}); - }; - } -}; -COMPONENT.controller.$inject = ['$http', '$state']; -module.component(NAME, COMPONENT); diff --git a/client/client/src/search-panel/index.html b/client/client/src/search-panel/index.html deleted file mode 100644 index 60385efc56..0000000000 --- a/client/client/src/search-panel/index.html +++ /dev/null @@ -1,26 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - - - - - -
-
- diff --git a/client/client/src/search-panel/index.js b/client/client/src/search-panel/index.js deleted file mode 100644 index bf8af3c039..0000000000 --- a/client/client/src/search-panel/index.js +++ /dev/null @@ -1,28 +0,0 @@ -import {module} from '../module'; - -export const NAME = 'vnClientSearchPanel'; -export const COMPONENT = { - template: require('./index.html'), - controller: function($scope, $window) { - this.filter = {id: null, fi: null, name: null, socialName: null, city: null, postcode: null, email: null, phone: null}; - this.formVisibility = true; - this.onSearch = () => { - this.setStorageValue(); - this.onSubmit(this.filter); - }; - this.getKeyPressed = function(event) { - if (event.which === 27) - this.formVisibility = false; - }; - this.$onChanges = () => { - var value = JSON.parse($window.sessionStorage.getItem('filter')); - if (value !== undefined) - this.filter = value; - }; - this.setStorageValue = () => { - $window.sessionStorage.setItem('filter', JSON.stringify(this.filter)); - }; - } -}; - -module.component(NAME, COMPONENT); diff --git a/client/client/src/web-access/index.html b/client/client/src/web-access/index.html deleted file mode 100644 index d2e0390248..0000000000 --- a/client/client/src/web-access/index.html +++ /dev/null @@ -1,42 +0,0 @@ - - -
- - - Web access - - - - - - - - -
- - - - - - - - - - - - diff --git a/client/client/src/web-access/index.js b/client/client/src/web-access/index.js deleted file mode 100644 index d7f444af44..0000000000 --- a/client/client/src/web-access/index.js +++ /dev/null @@ -1,48 +0,0 @@ -import {module} from '../module'; - -class Controller { - constructor($scope, $http, vnAppLogger) { - this.$scope = $scope; - this.$http = $http; - this.vnAppLogger = vnAppLogger; - } - $onChanges() { - if(this.client) - this.account = this.client.account; - } - onPassOpen() { - this.newPassword = ''; - this.repeatPassword = ''; - this.$scope.$apply(); - } - onPassChange(response) { - if(response == 'ACCEPT') - try { - if(!this.newPassword) - throw new Error(`Passwords can't be empty`); - if(this.newPassword != this.repeatPassword) - throw new Error(`Passwords don't match`); - - let account = { - password: this.newPassword - }; - - this.$http.put(`/client/api/Accounts/${this.client.id}`, account); - } - catch(e) { - this.vnAppLogger.showError(e.message); - return false; - } - - return true; - } -} -Controller.$inject = ['$scope', '$http', 'vnAppLogger']; - -module.component('vnClientWebAccess', { - template: require('./index.html'), - bindings: { - client: '<' - }, - controller: Controller -}); diff --git a/client/core/src/autocomplete/index.html b/client/core/src/autocomplete/index.html deleted file mode 100644 index 4d25b25c10..0000000000 --- a/client/core/src/autocomplete/index.html +++ /dev/null @@ -1,10 +0,0 @@ -
- - -
diff --git a/client/core/src/autocomplete/index.js b/client/core/src/autocomplete/index.js deleted file mode 100644 index 2cd088c9bc..0000000000 --- a/client/core/src/autocomplete/index.js +++ /dev/null @@ -1,418 +0,0 @@ -import {module} from '../module'; -import Component from '../lib/component'; -import './style.scss'; - -/** - * Combobox like component with search and partial data loading features. - */ -export default class Autocomplete extends Component { - constructor($element, $scope, $http, vnPopover, $transclude) { - super($element); - this.input = $element[0].querySelector('input'); - this.item = null; - this.data = null; - this.popover = null; - this.displayData = null; - this.timeoutId = null; - this.lastSearch = null; - this.lastRequest = null; - this.currentRequest = null; - this.moreData = false; - this.activeOption = -1; - this.locked = false; - this.$http = $http; - this.$scope = $scope; - this.vnPopover = vnPopover; - this.$transclude = $transclude; - this.scopes = null; - - Object.assign(this, { - maxRows: 10, - requestDelay: 350, - showField: 'name', - valueField: 'id', - itemAs: 'i' - }); - - componentHandler.upgradeElement($element[0].firstChild); - } - set field(value) { - this.locked = true; - this.setValue(value); - this.locked = false; - } - get field() { - return this.value; - } - set initialData(value) { - if (value) { - if (!this.data) - this.data = []; - this.data.push(value); - } - } - set selectFields(value) { - this._selectFields = []; - - if (!value) - return; - - let res = value.split(','); - for (let i of res) - this._selectFields.push(i.trim()); - } - mdlUpdate() { - let mdlField = this.element.firstChild.MaterialTextfield; - if (mdlField) - mdlField.updateClasses_(); - } - loadData(textFilter) { - textFilter = textFilter ? textFilter : ''; - - if (this.lastSearch === textFilter) { - this.showPopoverIfFocus(); - return; - } - - this.lastSearch = textFilter; - - let lastRequest = this.lastRequest; - let requestWillSame = lastRequest !== null - && !this.moreData - && textFilter.substr(0, lastRequest.length) === lastRequest; - - if (requestWillSame) - this.localFilter(textFilter); - else - this.requestData(textFilter, false); - } - getRequestFields() { - let fields = {}; - fields[this.valueField] = true; - fields[this.showField] = true; - - if (this._selectFields) - for (let field of this._selectFields) - fields[field] = true; - - return fields; - } - requestData(textFilter, append) { - let where = {}; - let skip = 0; - - if (textFilter) - where[this.showField] = {regexp: textFilter}; - if (append && this.data) - skip = this.data.length; - - let filter = { - fields: this.getRequestFields(), - where: where, - order: `${this.showField} ASC`, - skip: skip, - limit: this.maxRows - }; - - this.lastRequest = textFilter ? textFilter : ''; - let json = JSON.stringify(filter); - - if (this.currentRequest) - this.currentRequest.resolve(); - - this.currentRequest = this.$http.get(`${this.url}?filter=${json}`); - this.currentRequest.then( - json => this.onRequest(json.data, append), - json => this.onRequest([]) - ); - } - onRequest(data, append) { - this.currentRequest = null; - this.moreData = data.length >= this.maxRows; - - if (!append || !this.data) - this.data = data; - else - this.data = this.data.concat(data); - - this.setDisplayData(this.data); - } - localFilter(textFilter) { - let regex = new RegExp(textFilter, 'i'); - let data = this.data.filter(item => { - return regex.test(item[this.showField]); - }); - this.setDisplayData(data); - } - setDisplayData(data) { - this.displayData = data; - this.showPopoverIfFocus(); - } - showPopoverIfFocus() { - if (this.hasFocus) - this.showPopover(); - } - destroyScopes() { - if (this.scopes) - for (let scope of this.scopes) - scope.$destroy(); - } - showPopover() { - let data = this.displayData; - - if (!data) - return; - - let fragment = this.document.createDocumentFragment(); - this.destroyScopes(); - this.scopes = []; - - let hasTemplate = this.$transclude.isSlotFilled('tplItem'); - - for (let i = 0; i < data.length; i++) { - let li = this.document.createElement('li'); - fragment.appendChild(li); - - if (hasTemplate) { - this.$transclude((clone, scope) => { - scope[this.itemAs] = data[i]; - li.appendChild(clone[0]); - this.scopes[i] = scope; - }, null, 'tplItem'); - } else { - let text = this.document.createTextNode(data[i][this.showField]); - li.appendChild(text); - } - } - - if (this.moreData) { - let li = this.document.createElement('li'); - li.appendChild(this.document.createTextNode('Load more')); - li.className = 'load-more'; - fragment.appendChild(li); - } - - if (this.popover) { - this.popover.innerHTML = ''; - this.popover.appendChild(fragment); - } else { - let popover = this.document.createElement('ul'); - popover.addEventListener('click', - e => this.onPopoverClick(e)); - popover.addEventListener('mousedown', - e => this.onPopoverMousedown(e)); - popover.className = 'vn-autocomplete'; - popover.appendChild(fragment); - this.vnPopover.show(popover, this.input); - this.popover = popover; - } - } - hidePopover() { - if (!this.popover) return; - this.activeOption = -1; - this.vnPopover.hide(); - this.destroyScopes(); - this.popover = null; - } - selectPopoverOption(index) { - if (!this.popover || index === -1) return; - if (index < this.displayData.length) { - this.selectOptionByDataIndex(this.displayData, index); - this.hidePopover(); - } else - this.requestData(this.lastRequest, true); - } - onPopoverClick(event) { - let target = event.target; - let childs = this.popover.childNodes; - - if (target === this.popover) - return; - - while (target.parentNode !== this.popover) - target = target.parentNode; - - for (let i = 0; i < childs.length; i++) - if (childs[i] === target) { - this.selectPopoverOption(i); - break; - } - } - onPopoverMousedown(event) { - // Prevents input from loosing focus - event.preventDefault(); - } - onClick(event) { - if (!this.popover) - this.showPopover(); - } - onFocus() { - this.hasFocus = true; - this.input.select(); - - this.loadData(); - } - onBlur() { - this.hasFocus = false; - this.restoreShowValue(); - this.hidePopover(); - } - onKeydown(event) { - switch (event.keyCode) { - case 13: // Enter - this.selectPopoverOption(this.activeOption); - break; - case 27: // Escape - this.restoreShowValue(); - this.input.select(); - break; - case 38: // Arrow up - this.activateOption(this.activeOption - 1); - break; - case 40: // Arrow down - this.activateOption(this.activeOption + 1); - break; - default: - return; - } - - event.preventDefault(); - } - onKeyup(event) { - if (!this.isKeycodePrintable(event.keyCode)) return; - if (this.timeoutId) clearTimeout(this.timeoutId); - this.timeoutId = setTimeout(() => this.onTimeout(), this.requestDelay); - } - onTimeout() { - this.loadData(this.input.value); - this.timeoutId = null; - } - isKeycodePrintable(keyCode) { - return keyCode === 32 // Spacebar - || keyCode === 8 // Backspace - || (keyCode > 47 && keyCode < 58) // Numbers - || (keyCode > 64 && keyCode < 91) // Letters - || (keyCode > 95 && keyCode < 112) // Numpad - || (keyCode > 185 && keyCode < 193) // ;=,-./` - || (keyCode > 218 && keyCode < 223); // [\]' - } - restoreShowValue() { - this.putItem(this.item); - } - requestItem() { - if (!this.value) return; - - let where = {}; - where[this.valueField] = this.value; - - let filter = { - fields: this.getRequestFields(), - where: where - }; - - let json = JSON.stringify(filter); - - this.$http.get(`${this.url}?filter=${json}`).then( - json => this.onItemRequest(json.data), - json => this.onItemRequest(null) - ); - } - onItemRequest(data) { - if (data && data.length > 0) - this.showItem(data[0]); - else - this.showItem(null); - } - activateOption(index) { - if (!this.popover) - this.showPopover(); - - let popover = this.popover; - let childs = popover.childNodes; - let len = this.displayData.length; - - if (this.activeOption >= 0) - childs[this.activeOption].className = ''; - - if (index >= len) - index = 0; - else if (index < 0) - index = len - 1; - - if (index >= 0) { - let opt = childs[index]; - let top = popover.scrollTop; - let height = popover.clientHeight; - - if (opt.offsetTop + opt.offsetHeight > top + height) - top = opt.offsetTop + opt.offsetHeight - height; - else if (opt.offsetTop < top) - top = opt.offsetTop; - - opt.className = 'active'; - popover.scrollTop = top; - } - - this.activeOption = index; - } - setValue(value) { - this.value = value; - - if (value) { - let data = this.data; - - if (data) - for (let i = 0; i < data.length; i++) - if (data[i][this.valueField] == value) { - this.putItem(data[i]); - return; - } - - this.requestItem(); - } else - this.putItem(null); - } - selectOptionByIndex(index) { - this.selectOptionByDataIndex(this.data, index); - } - selectOptionByDataIndex(data, index) { - if (data && index >= 0 && index < data.length) - this.putItem(data[index]); - else - this.putItem(null); - } - putItem(item) { - this.showItem(item); - let value = item ? item[this.valueField] : undefined; - - if (!this.locked) - this.value = value; - } - showItem(item) { - this.input.value = item ? item[this.showField] : ''; - this.item = item; - this.mdlUpdate(); - } - $onDestroy() { - this.destroyScopes(); - } -} -Autocomplete.$inject = ['$element', '$scope', '$http', 'vnPopover', '$transclude']; - -module.component('vnAutocomplete', { - template: require('./index.html'), - bindings: { - url: '@', - showField: '@?', - valueField: '@?', - selectFields: '@?', - initialData: ' - -
-
- -
- {{$ctrl.question}} -
-
- {{$ctrl.message}} -
-
-
-
- - - - -
-
- diff --git a/client/core/src/confirm/index.js b/client/core/src/confirm/index.js deleted file mode 100644 index 0d7c56cc0d..0000000000 --- a/client/core/src/confirm/index.js +++ /dev/null @@ -1,16 +0,0 @@ -import {module} from '../module'; -import Dialog from '../dialog/index'; -import './style.css'; - -export default class Confirm extends Dialog {} -Dialog.$inject = ['$element']; - -module.component('vnConfirm', { - template: require('./index.html'), - bindings: { - onResponse: '&', - question: '@', - message: '@' - }, - controller: Confirm -}); diff --git a/client/core/src/dialog/index.html b/client/core/src/dialog/index.html deleted file mode 100644 index 4ccb39e008..0000000000 --- a/client/core/src/dialog/index.html +++ /dev/null @@ -1,13 +0,0 @@ -
- -
-
-
-
-
-
\ No newline at end of file diff --git a/client/core/src/dialog/index.js b/client/core/src/dialog/index.js deleted file mode 100644 index e45f66b930..0000000000 --- a/client/core/src/dialog/index.js +++ /dev/null @@ -1,111 +0,0 @@ -import {module} from '../module'; -import Component from '../lib/component'; -import './style.scss'; - -/** - * Dialog component. - */ -export default class Dialog extends Component { - /** - * Contructor. - */ - constructor($element) { - super($element); - $element.addClass('vn-dialog'); - this.dialog = $element[0].firstChild; - this.element.addEventListener('mousedown', - event => this.onBackgroundMouseDown(event)); - } - /** - * Displays the dialog to the user. - */ - show() { - let style = this.dialog.style; - let screenMargin = 20; - - let window = this.window; - let innerWidth = window.innerWidth; - let innerHeight = window.innerHeight; - let width = this.dialog.offsetWidth; - let height = this.dialog.offsetHeight; - - if (width + screenMargin > innerWidth) { - width = innerWidth - dblMargin; - style.width = width + 'px'; - } - if (height + screenMargin > innerHeight) { - height = innerHeight - dblMargin; - style.height = height + 'px'; - } - - this.keypressHandler = - event => this.onKeypress(event); - this.document.addEventListener('keypress', - this.keypressHandler); - this.element.style.display = 'block'; - - if (this.onOpen) - this.onOpen(); - } - /** - * Hides the dialog calling the response handler. - */ - hide() { - this.fireResponse(); - this.realHide(); - } - /** - * Calls the response handler. - */ - fireResponse(response) { - let cancel = false; - if (this.onResponse) - cancel = this.onResponse({response: response}); - return cancel; - } - realHide() { - this.element.style.display = 'none'; - this.document.removeEventListener('keypress', - this.keypressHandler); - this.lastEvent = null; - } - onButtonClick(event) { - let buttonBar = this.element.querySelector('.button-bar'); - let buttons = buttonBar.querySelector('tpl-buttons'); - let node = event.target; - - while (node.parentNode != buttons) { - if (node == buttonBar) return; - node = node.parentNode; - } - - let response = node.getAttribute('response'); - let cancel = this.fireResponse(response); - if (cancel !== false) this.realHide(); - } - onDialogMouseDown(event) { - this.lastEvent = event; - } - onBackgroundMouseDown(event) { - if (event != this.lastEvent) - this.hide(); - } - onKeypress(event) { - if (event.keyCode == 27) // Esc - this.hide(); - } -} -Dialog.$inject = ['$element']; - -module.component('vnDialog', { - template: require('./index.html'), - transclude: { - tplBody: 'tplBody', - tplButtons: 'tplButtons' - }, - bindings: { - onOpen: '&', - onResponse: '&' - }, - controller: Dialog -}); diff --git a/client/core/src/icon/index.js b/client/core/src/icon/index.js deleted file mode 100644 index 7e36fab97f..0000000000 --- a/client/core/src/icon/index.js +++ /dev/null @@ -1,19 +0,0 @@ -import {module} from '../module'; -import './index.mdl'; -import './style.css'; -import * as resolveFactory from '../lib/resolveDefaultComponents'; - -const _NAME = 'icon'; -export const NAME = 'vnIcon'; - -export function directive(resolver) { - return { - restrict: 'E', - template: function(_, attrs) { - return resolver.getTemplate(_NAME, attrs); - } - }; -} -directive.$inject = [resolveFactory.NAME]; - -module.directive(NAME, directive); diff --git a/client/core/src/icon/index.mdl.html b/client/core/src/icon/index.mdl.html deleted file mode 100644 index 865296d9bc..0000000000 --- a/client/core/src/icon/index.mdl.html +++ /dev/null @@ -1 +0,0 @@ -*[icon]* diff --git a/client/core/src/icon/index.mdl.js b/client/core/src/icon/index.mdl.js deleted file mode 100644 index 3084fdd12c..0000000000 --- a/client/core/src/icon/index.mdl.js +++ /dev/null @@ -1,12 +0,0 @@ -import {module} from '../module'; -import template from './index.mdl.html'; - -export const NAME = 'vnIconMdlFactory'; -export function factory() { - return { - template: template, - default: {} - } -} - -module.factory(NAME, factory); diff --git a/client/core/src/paging/index.html b/client/core/src/paging/index.html deleted file mode 100644 index 6e2f56fd31..0000000000 --- a/client/core/src/paging/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - \ No newline at end of file diff --git a/client/core/src/paging/index.js b/client/core/src/paging/index.js deleted file mode 100644 index fd17b994ee..0000000000 --- a/client/core/src/paging/index.js +++ /dev/null @@ -1,46 +0,0 @@ -import {module} from '../module'; -import './style.scss'; - -export default class Paging { - get numPages() { - return Math.ceil(this.numItems / this.numPerPage); - } - constructor($http, $scope) { - this.$http = $http; - this.$scope = $scope; - this.where = this.filter; - this.numPerPage = null; - this.numItems = 0; - $scope.$watch('$ctrl.index.model.length', () => this.onModelUpdated()); - } - $onChanges(changes) { - if (!this.index) return; - this.numPerPage = this.index.filter.size; - if(changes.total) - this.numItems = changes.total.currentValue; - } - onModelUpdated() { - let index = this.index; - let filter = index.filter; - - if (filter.page >= this.numPages - && index.model.length >= this.numPerPage) - this.numItems = filter.page * filter.size + 1; - } - onPageChange(page) { - this.index.filter.page = page; - this.index.accept(); - } -} -Paging.$inject = ['$http', '$scope']; - -export const NAME = 'vnPaging'; -export const COMPONENT = { - template: require('./index.html'), - bindings: { - index: '<', - total: '<' - }, - controller: Paging -}; -module.component(NAME, COMPONENT); diff --git a/client/core/src/popover/index.js b/client/core/src/popover/index.js deleted file mode 100644 index 30a56a633f..0000000000 --- a/client/core/src/popover/index.js +++ /dev/null @@ -1,98 +0,0 @@ -import {module} from '../module'; -import './style.css'; - -directive.$inject = ['vnPopover']; -export function directive(popover) { - return { - restrict: 'A', - link: function($scope, $element, $attrs) { - $element.on('click', function(event) { - popover.showComponent($attrs.vnDialog, $scope, $element); - event.preventDefault(); - }); - } - }; -} -module.directive('vnPopover', directive); - -export class Popover { - constructor($document, $compile) { - this.document = $document[0]; - this.$compile = $compile; - } - show(childElement, parent) { - let popover = this.document.createElement('div'); - popover.className = 'vn-popover'; - popover.addEventListener('mousedown', - event => this.onPopoverMouseDown(event)); - popover.appendChild(childElement); - this.popover = popover; - - let style = popover.style; - - let spacing = 0; - let screenMargin = 20; - let dblMargin = screenMargin * 2; - - let width = popover.offsetWidth; - let height = popover.offsetHeight; - let innerWidth = window.innerWidth; - let innerHeight = window.innerHeight; - - if (width + dblMargin > innerWidth) { - width = innerWidth - dblMargin; - style.width = width + 'px'; - } - if (height + dblMargin > innerHeight) { - height = innerHeight - dblMargin; - style.height = height + 'px'; - } - - if (parent) { - let parentNode = parent; - let rect = parentNode.getBoundingClientRect(); - let left = rect.left; - let top = rect.top + spacing + parentNode.offsetHeight; - - if (left + width > innerWidth) - left -= (left + width) - innerWidth + margin; - if (top + height > innerHeight) - top -= height + parentNode.offsetHeight + spacing * 2; - - if (left < 0) - left = screenMargin; - if (top < 0) - top = screenMargin; - - style.top = (top) + 'px'; - style.left = (left) + 'px'; - style.minWidth = (rect.width) + 'px'; - } - - this.document.body.appendChild(popover); - this.docMouseDownHandler = event => this.onDocMouseDown(event); - this.document.addEventListener('mousedown', this.docMouseDownHandler); - } - showComponent(childComponent, $scope, parent) { - let childElement = this.document.createElement(childComponent); - this.$compile(childElement)($scope); - this.show(childElement, parent); - } - hide() { - if (!this.popover) return; - this.document.removeEventListener('mousedown', this.docMouseDownHandler); - this.document.body.removeChild(this.popover); - this.popover = null; - this.lastEvent = null; - this.docMouseDownHandler = null; - } - onDocMouseDown(event) { - if (event != this.lastEvent) - this.hide(); - } - onPopoverMouseDown(event) { - this.lastEvent = event; - } -} -Popover.$inject = ['$document', '$compile']; -module.service('vnPopover', Popover); diff --git a/client/core/src/snackbar/index.html b/client/core/src/snackbar/index.html deleted file mode 100644 index 6f99d5fdbb..0000000000 --- a/client/core/src/snackbar/index.html +++ /dev/null @@ -1,4 +0,0 @@ -
-
- -
diff --git a/client/core/src/snackbar/index.js b/client/core/src/snackbar/index.js deleted file mode 100644 index ce76c1ba30..0000000000 --- a/client/core/src/snackbar/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import {module} from '../module'; - -/** - * A simple component to show non-obstructive notifications to the user. - */ -export default class Controller { - constructor($element) { - this.snackbar = $element[0].firstChild; - componentHandler.upgradeElement(this.snackbar); - } - /** - * Shows a notification. - * - * @param {Object} data The message data - */ - show(data) { - this.snackbar.MaterialSnackbar.showSnackbar(data); - } -} -Controller.$inject = ['$element']; - -module.component('vnSnackbar', { - template: require('./index.html'), - controller: Controller -}); diff --git a/client/core/src/spinner/index.html b/client/core/src/spinner/index.html deleted file mode 100644 index 47b6e42fef..0000000000 --- a/client/core/src/spinner/index.html +++ /dev/null @@ -1,2 +0,0 @@ -
-
\ No newline at end of file diff --git a/client/core/src/spinner/index.js b/client/core/src/spinner/index.js deleted file mode 100644 index daf694e1de..0000000000 --- a/client/core/src/spinner/index.js +++ /dev/null @@ -1,58 +0,0 @@ -import {module} from '../module'; -import Component from '../lib/component'; -import './style.css'; - -/** - * A spinner to inform the user about loading process. - */ -export default class Spinner extends Component { - constructor($element, $scope) { - super($element); - this._enable = false; - this.spinner = $element[0].firstChild; - componentHandler.upgradeElement(this.spinner); - } - /** - * Enables/disables the spinner. - * - * @param {Boolean} value %true to enable, %false to disable - */ - set enable(value) { - if (value) - this.start(); - else - this.stop(); - } - /** - * Returns the current spinner state. - * - * @return {Boolean} %true if it's enabled, %false otherwise - */ - get enable() { - return this._enable; - } - /** - * Activates the spinner. - */ - start() { - this.spinner.MaterialSpinner.start(); - this._enable = true; - } - /** - * Deactivates the spinner. - */ - stop() { - this.spinner.MaterialSpinner.stop(); - this._enable = false; - } -} -Spinner.$inject = ['$element', '$scope']; - -export const component = { - template: require('./index.html'), - bindings: { - enable: '=' - }, - controller: Spinner -}; -module.component('vnSpinner', component); diff --git a/client/core/src/subtitle/index.html b/client/core/src/subtitle/index.html deleted file mode 100644 index ac00ac0c27..0000000000 --- a/client/core/src/subtitle/index.html +++ /dev/null @@ -1,2 +0,0 @@ -
-
\ No newline at end of file diff --git a/client/core/src/subtitle/index.js b/client/core/src/subtitle/index.js deleted file mode 100644 index 941e8eb546..0000000000 --- a/client/core/src/subtitle/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import {module} from '../module'; - -module.component('vnSubtitle', { - template: require('./index.html'), - transclude: true -}); diff --git a/client/core/src/textfield/index.js b/client/core/src/textfield/index.js deleted file mode 100644 index af4d7c4ab4..0000000000 --- a/client/core/src/textfield/index.js +++ /dev/null @@ -1,82 +0,0 @@ -import {module} from '../module'; -import Component from '../lib/component'; -import * as resolveFactory from '../lib/resolveDefaultComponents'; -import * as normalizerFactory from '../lib/inputAttrsNormalizer'; -import './style.scss'; -import './index.mdl'; - -export default class Textfield extends Component { - constructor($element, $scope, $attrs) { - super($element); - - let input = this.input = this.element.querySelector('input'); - input.addEventListener('input', - () => this.checkValue()); - input.addEventListener('focus', - () => this.checkValue()); - input.addEventListener('blur', - () => this.showClear(false)); - - let clearButton = this.element.querySelector('button'); - clearButton.addEventListener('click', - () => this.onClearClick()); - clearButton.addEventListener('mousedown', - event => event.preventDefault()); - - let div = this.element.firstChild; - componentHandler.upgradeElement(div); - } - link($scope, $attrs) { - let mdlTextField = this.element.firstChild.MaterialTextfield; - mdlTextField.updateClasses_(); - - $scope.$watch($attrs.model, - () => mdlTextField.updateClasses_()); - } - onClearClick() { - this.input.value = ''; - this.checkValue(); - - let event = this.document.createEvent('HTMLEvents'); - event.initEvent('change', false, true); - this.input.dispatchEvent(event); - } - checkValue() { - this.showClear(this.input.value); - } - showClear(show) { - show = show && document.activeElement === this.input; - let clearButton = this.element.querySelector('button'); - clearButton.style.visibility = show ? 'visible' : 'hidden'; - } - /** - * Selects the textfield. - */ - select() { - this.input.select(); - } - /** - * Puts the focus on the textfield. - */ - focus() { - this.input.focus(); - } -} -Textfield.$inject = ['$element', '$scope', '$attrs']; - -directive.$inject = [resolveFactory.NAME, normalizerFactory.NAME]; -export function directive(resolve, normalizer) { - return { - restrict: 'E', - template: function(_, attrs) { - normalizer.normalize(attrs); - return resolve.getTemplate('textfield', attrs); - }, - link: function($scope, $element, $attrs, $ctrl) { - $ctrl.link($scope, $attrs); - }, - controller: Textfield - }; -} - -module.directive('vnTextfield', directive); diff --git a/client/core/src/textfield/index.mdl.html b/client/core/src/textfield/index.mdl.html deleted file mode 100644 index fc4ab00bfb..0000000000 --- a/client/core/src/textfield/index.mdl.html +++ /dev/null @@ -1,18 +0,0 @@ -
- - - -
diff --git a/client/core/src/textfield/index.mdl.js b/client/core/src/textfield/index.mdl.js deleted file mode 100644 index 64e156885f..0000000000 --- a/client/core/src/textfield/index.mdl.js +++ /dev/null @@ -1,16 +0,0 @@ -import {module} from '../module'; - -export const NAME = 'vnTextfieldMdlFactory'; - -export function factory() { - return { - template: require('./index.mdl.html'), - default: { - label: 'text', - className: 'mdl-textfield--floating-label', - type: 'text' - } - }; -} - -module.factory(NAME, factory); diff --git a/client/core/src/title/index.html b/client/core/src/title/index.html deleted file mode 100644 index e8ab561eda..0000000000 --- a/client/core/src/title/index.html +++ /dev/null @@ -1,2 +0,0 @@ -

-

\ No newline at end of file diff --git a/client/core/src/title/index.js b/client/core/src/title/index.js deleted file mode 100644 index 3fb71f567c..0000000000 --- a/client/core/src/title/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import {module} from '../module'; - -module.component('vnTitle', { - template: require('./index.html'), - transclude: true -}); diff --git a/client/core/src/watcher/index.html b/client/core/src/watcher/index.html deleted file mode 100644 index 76315ece8e..0000000000 --- a/client/core/src/watcher/index.html +++ /dev/null @@ -1,6 +0,0 @@ - - \ No newline at end of file diff --git a/client/core/src/watcher/index.js b/client/core/src/watcher/index.js deleted file mode 100644 index d421405df5..0000000000 --- a/client/core/src/watcher/index.js +++ /dev/null @@ -1,162 +0,0 @@ -import {module} from '../module'; -import Component from '../lib/component'; -import getModifiedData from '../lib/modified'; -import copyObject from '../lib/copy'; -import isEqual from '../lib/equals'; - -/** - * Component that checks for changes on a specific model property and - * asks the user to save or discard it when the state changes. - * Also it can save the data to the server when the @url and @idField - * properties are provided. - */ -export default class Watcher extends Component { - constructor($element, $scope, $state, $transitions, $http, vnAppLogger, $translate) { - super($element); - this.$scope = $scope; - this.$state = $state; - this.$http = $http; - this.$translate = $translate; - this.vnAppLogger = vnAppLogger; - - this.state = null; - this.deregisterCallback = $transitions.onStart({}, - transition => this.callback(transition)); - this.copyData(); - } - $onInit() { - if (this.get) { - this.fetchData(); - } - } - $onChanges(changes) { - if (this.data) { - this.copyData(); - } - } - $onDestroy() { - this.deregisterCallback(); - } - fetchData() { - let id = this.data[this.idField]; - return new Promise((resolve, reject) => { - this.$http.get(`${this.url}/${id}`).then( - json => this.writeData(json, resolve), - json => reject(json) - ); - }); - } - /** - * Submits the data and goes back in the history. - */ - submitBack() { - this.submit().then( - () => this.window.history.back() - ); - } - /** - * Submits the data to the server. - * - * @return {Promise} The http request promise - */ - submit() { - if (this.form) { - this.form.$setSubmitted(); - - if (!this.form.$valid) - return new Promise( - (resolve, reject) => this.invalidForm(reject) - ); - } - if (!this.dataChanged()) { - return new Promise( - (resolve, reject) => this.noChanges(reject) - ); - } - let changedData = getModifiedData(this.data, this.orgData); - - if (this.save) { - this.save.model = changedData; - return new Promise((resolve, reject) => { - this.save.accept().then( - json => this.writeData({data: json}, resolve), - json => reject(json) - ); - }); - } - - // XXX: Alternative when mgCrud is not used - - let id = this.orgData[this.idField]; - - if (id) { - return new Promise((resolve, reject) => { - this.$http.put(`${this.url}/${id}`, changedData).then( - json => this.writeData(json, resolve), - json => reject(json) - ); - }); - } - - return new Promise((resolve, reject) => { - this.$http.post(this.url, this.data).then( - json => this.writeData(json, resolve), - json => reject(json) - ); - }); - } - writeData(json, resolve) { - copyObject(json.data, this.data); - this.copyData(); - resolve(json); - } - noChanges(resolve) { - this.vnAppLogger.showMessage( - this.$translate.instant('No changes to save') - ); - resolve(); - } - invalidForm(resolve) { - this.vnAppLogger.showMessage( - this.$translate.instant('Some fields are invalid') - ); - resolve(); - } - copyData() { - this.orgData = copyObject(this.data); - } - callback(transition) { - if (!this.state && this.dataChanged()) { - this.state = transition.to().name; - this.$scope.confirm.show(); - return false; - } - - return true; - } - dataChanged() { - return !isEqual(this.data, this.orgData); - } - onConfirmResponse(response) { - if (response === 'ACCEPT') { - copyObject(this.orgData, this.data); - this.$state.go(this.state); - } else { - this.state = null; - } - } -} -Watcher.$inject = ['$element', '$scope', '$state', '$transitions', '$http', 'vnAppLogger', '$translate']; - -module.component('vnWatcher', { - template: require('./index.html'), - bindings: { - url: '@?', - idField: '@?', - data: '<', - form: '<', - save: '<', - get: '=?' - }, - controller: Watcher -}); diff --git a/services/mailer/.gitignore b/services/mailer/.gitignore index b512c09d47..36420af85d 100644 --- a/services/mailer/.gitignore +++ b/services/mailer/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +config.json \ No newline at end of file From e8c99a959c430d369cd3bfc0748d1dfbd0ad8076 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Wed, 31 May 2017 13:01:15 +0200 Subject: [PATCH 11/12] =?UTF-8?q?correcci=C3=B3n=20errata=20ortogr=C3=A1fi?= =?UTF-8?q?ca?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client/src/billing-data/locale/es.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/client/src/billing-data/locale/es.json b/client/client/src/billing-data/locale/es.json index 5c4e720d71..df26aa2289 100644 --- a/client/client/src/billing-data/locale/es.json +++ b/client/client/src/billing-data/locale/es.json @@ -1,6 +1,6 @@ { "Changed terms": "Has modificado las condiciones de pago", - "Notify customer?" : "¿Deseas notificar al cliente con dichos cambios?", + "Notify customer?" : "¿Deseas notificar al cliente de dichos cambios?", "No": "No", "Yes, notify": "Sí, notificar" } \ No newline at end of file From e061c019469dbd324f0ff973dd2fb92bef2f50dd Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Wed, 31 May 2017 13:47:40 +0200 Subject: [PATCH 12/12] =?UTF-8?q?mensajes=20de=20notificaci=C3=B3n=20envia?= =?UTF-8?q?da=20/=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client/src/billing-data/billing-data.js | 18 +++++++++++------- client/client/src/billing-data/locale/es.json | 4 +++- .../src/components/searchbar/searchbar.js | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/client/client/src/billing-data/billing-data.js b/client/client/src/billing-data/billing-data.js index c5b99cf092..1824a60911 100644 --- a/client/client/src/billing-data/billing-data.js +++ b/client/client/src/billing-data/billing-data.js @@ -3,10 +3,12 @@ import {module} from '../module'; export const NAME = 'vnClientBillingData'; class billingData { - constructor($scope, $http, $timeout) { + constructor($scope, $http, $timeout, vnAppLogger, $translate) { this.$ = $scope; this.http = $http; this.timeout = $timeout; + this.logger = vnAppLogger; + this.translate = $translate; this.payId = null; this.dueDay = null; this.copyData(); @@ -26,10 +28,9 @@ class billingData { 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(); + if (this.payId !== payId || this.dueDay !== dueDay) { + this.$.sendMail.show(); return false; } @@ -37,16 +38,19 @@ class billingData { } returnDialog(response) { if (response === 'ACCEPT') { - this.sendMail(); + this.sendMail().then( + () => this.logger.showMessage(this.translate.instant('Notification sent!')), + () => this.logger.showMessage(this.translate.instant('Notification error')) + ); } this.timeout(() => this.$.watcher.submit()); } sendMail() { - this.http.post(`/mailer/manuscript/paymentUpdate`, {user: this.client.id}); + return this.http.post(`/mailer/manuscript/paymentUpdate`, {user: this.client.id}); } } -billingData.$inject = ['$scope', '$http', '$timeout']; +billingData.$inject = ['$scope', '$http', '$timeout', 'vnAppLogger', '$translate']; export const COMPONENT = { template: require('./billing-data.html'), diff --git a/client/client/src/billing-data/locale/es.json b/client/client/src/billing-data/locale/es.json index df26aa2289..f0b6a12137 100644 --- a/client/client/src/billing-data/locale/es.json +++ b/client/client/src/billing-data/locale/es.json @@ -2,5 +2,7 @@ "Changed terms": "Has modificado las condiciones de pago", "Notify customer?" : "¿Deseas notificar al cliente de dichos cambios?", "No": "No", - "Yes, notify": "Sí, notificar" + "Yes, notify": "Sí, notificar", + "Notification sent!": "¡Notificación enviada!", + "Notification error": "Error al enviar notificación" } \ No newline at end of file diff --git a/client/salix/src/components/searchbar/searchbar.js b/client/salix/src/components/searchbar/searchbar.js index a010e4b86a..2773ef4b4c 100644 --- a/client/salix/src/components/searchbar/searchbar.js +++ b/client/salix/src/components/searchbar/searchbar.js @@ -25,7 +25,7 @@ export default class Controller { Object.assign(this.index.filter, filter); this.onSubmit(); } - + onSubmit() { if (this.onSearch) this.onSearch();