diff --git a/.vscode/launch.json b/.vscode/launch.json index 244fe2b49..825c36d56 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "name": "Iniciar", "type": "node", "request": "launch", - "program": "${workspaceRoot}/app.js", + "program": "${workspaceRoot}/services/client/server/server.js", "stopOnEntry": false, "args": [], "cwd": "${workspaceRoot}", diff --git a/Jenkinsfile b/Jenkinsfile index aaced7ee8..db8dcd4bc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,15 +7,16 @@ def branchName = "${env.BRANCH_NAME}"; def branchNameTest = "preprod"; def branchNameProd = "master"; def prefixDocker = "test"; -def dockerNginxName = ["nginx", "-p 80:80 --privileged --link test-auth:auth --link test-salix:salix --link test-client:client --link test-mailer:mailer"] +def dockerNginxName = ["nginx", "-p 80:80 --privileged --link test-auth:auth --link test-salix:salix --link test-client:client --link test-mailer:mailer --link test-production:production"] def dockerAuthName = ["auth", "-p 3000:3000"] def dockerSalixName = ["salix", "-p 3001:3001"] def dockerClientName = ["client", "-p 3002:3002"] def dockerMailerName = ["mailer", "-p 3003:3003"] +def dockerProductionName = ["production", "-p 3004:3004"] def buildNumber = "${env.BUILD_NUMBER}"; -def dockers = [dockerAuthName, dockerSalixName, dockerClientName, dockerMailerName, dockerNginxName] +def dockers = [dockerAuthName, dockerSalixName, dockerClientName, dockerMailerName, dockerNginxName, dockerProductionName] node { diff --git a/client/client/routes.json b/client/client/routes.json index ecfdc4ea7..488c6c104 100644 --- a/client/client/routes.json +++ b/client/client/routes.json @@ -2,6 +2,7 @@ "module": "client", "name": "Clients", "icon": "person", + "validations" : true, "routes": [ { "url": "/clients", diff --git a/client/core/src/drop-down/drop-down.js b/client/core/src/drop-down/drop-down.js index ddde9e9d5..ece781507 100644 --- a/client/core/src/drop-down/drop-down.js +++ b/client/core/src/drop-down/drop-down.js @@ -34,7 +34,9 @@ export default class DropDown { this.search = ''; this.showLoadMore = this.loadMore != null; if (this.filterAction) { - this.filterAction(); + this.filterAction({search: this.search}); + } else { + this.filterItems(); } } } diff --git a/client/core/src/icon-menu/icon-menu.html b/client/core/src/icon-menu/icon-menu.html index 422f8e0a7..f09652178 100644 --- a/client/core/src/icon-menu/icon-menu.html +++ b/client/core/src/icon-menu/icon-menu.html @@ -1,6 +1,6 @@
-
+
-
+
{ this.items = json.data; + this.finding = false; + }, + () => { + this.finding = false; } ); - } else { + } else if (!search && !this.finding) { this.items = []; this.getItems(); } @@ -64,6 +70,8 @@ export default class IconMenu { this.getItems(); } + this.findMore = this.url && this.maxRow; + this.$element.bind('mouseover', e => { this.$timeout(() => { this.showDropDown = true; diff --git a/client/core/src/lib/moduleLoader.js b/client/core/src/lib/moduleLoader.js index 2adfa20ad..8b9952cb3 100644 --- a/client/core/src/lib/moduleLoader.js +++ b/client/core/src/lib/moduleLoader.js @@ -7,7 +7,7 @@ export function factory($translatePartialLoader, $http, $window, $ocLazyLoad, $q constructor() { this._loadedModules = {}; } - load(moduleName) { + load(moduleName, validations) { if (this._loadedModules[moduleName]) return; @@ -20,12 +20,13 @@ export function factory($translatePartialLoader, $http, $window, $ocLazyLoad, $q for (let dep of deps) { this._loadedModules[dep] = true; promises.push(modules[dep]()); - promises.push(new Promise(resolve => { - $http.get(`/${dep}/validations`).then( - json => this.onValidationsReady(json, resolve), - json => resolve() - ); - })); + if (validations) + promises.push(new Promise(resolve => { + $http.get(`/${dep}/validations`).then( + json => this.onValidationsReady(json, resolve), + json => resolve() + ); + })); $translatePartialLoader.addPart(dep); // FIXME: https://github.com/angular-translate/angular-translate/pull/1674 diff --git a/client/core/src/locale/es.json b/client/core/src/locale/es.json index 1206d9157..d3b44a2c0 100644 --- a/client/core/src/locale/es.json +++ b/client/core/src/locale/es.json @@ -3,5 +3,6 @@ "Cancel": "Cancelar", "Close": "Cerrar", "Clear": "Borrar", - "Load More": "Cargar más" + "Load More": "Cargar más", + "Search" : "Buscar" } \ No newline at end of file diff --git a/client/production/routes.json b/client/production/routes.json index 38ab36dc0..a99b910a3 100644 --- a/client/production/routes.json +++ b/client/production/routes.json @@ -2,6 +2,7 @@ "module": "production", "name": "Production", "icon": "group_work", + "validations" : false, "routes": [ { "url": "/production", diff --git a/client/production/src/production-actions/production-actions.html b/client/production/src/production-actions/production-actions.html index ce7301524..4786d9136 100644 --- a/client/production/src/production-actions/production-actions.html +++ b/client/production/src/production-actions/production-actions.html @@ -7,8 +7,7 @@ - + diff --git a/client/production/src/production-filters/production-filters.html b/client/production/src/production-filters/production-filters.html index 77deef6cd..0532cd73a 100644 --- a/client/production/src/production-filters/production-filters.html +++ b/client/production/src/production-filters/production-filters.html @@ -14,6 +14,7 @@ diff --git a/client/salix/src/configroutes.js b/client/salix/src/configroutes.js index c6a5a3402..5b696afac 100644 --- a/client/salix/src/configroutes.js +++ b/client/salix/src/configroutes.js @@ -3,10 +3,10 @@ import deps from 'spliting/modules.json'; import ngModule from './module'; import {splitingRegister} from 'core'; -function loader(moduleName) { +function loader(moduleName, validations) { load.$inject = ['vnModuleLoader']; function load(moduleLoader) { - return moduleLoader.load(moduleName); + return moduleLoader.load(moduleName, validations); } return load; } @@ -40,19 +40,22 @@ function config($stateProvider, $urlRouterProvider, aclServiceProvider) { for (let file in routes) { let fileRoutes = routes[file].routes; let moduleName = routes[file].module; + let validations = routes[file].validations; fileRoutes.forEach(function(route) { if (aclService.routeHasPermission(route)) { - $stateProvider.state(route.state, { + let routeOptions = { url: route.url, abstract: route.abstract || false, template: `<${route.component} ${getParams(route)}>`, resolve: { - loader: loader(moduleName) + loader: loader(moduleName, validations) }, data: { routes: fileRoutes } - }); + }; + + $stateProvider.state(route.state, routeOptions); } }); } diff --git a/component-config.json b/component-config.json new file mode 100644 index 000000000..f36959a48 --- /dev/null +++ b/component-config.json @@ -0,0 +1,5 @@ +{ + "loopback-component-explorer": { + "mountPath": "/explorer" + } +} diff --git a/services/client/common/methods/client/employee.js b/services/client/common/methods/client/employee.js new file mode 100644 index 000000000..2e87ad6e9 --- /dev/null +++ b/services/client/common/methods/client/employee.js @@ -0,0 +1,30 @@ +module.exports = function(Client){ + Client.remoteMethod('employeeList', { + description: 'List employee', + accessType: 'READ', + returns: { + arg: 'data', + type: 'Employee', + root: true + }, + http: { + path: `/employeeList`, + verb: 'get' + } + }); + + Client.employeeList = function(cb) { + var include = {include: { relation: 'user'}, where: { userFk: { neq: null }}}; + Client.app.models.Employee.find(include, function(err, instances) { + (err) ? cb(err, null) : cb(null, generateEmployees(instances)); + }); + }; + + function generateEmployees(instances){ + var emps = []; + instances.forEach(function(e) { + emps.push({id: e.id, name: e.user().name}); + }, this); + return emps; + } +} \ No newline at end of file diff --git a/services/client/common/models/client.js b/services/client/common/models/client.js index ee659a6a2..c6f7c6331 100644 --- a/services/client/common/models/client.js +++ b/services/client/common/models/client.js @@ -10,6 +10,7 @@ module.exports = function(Client) { require('../methods/client/addresses.js')(Client); require('../methods/client/filter.js')(Client); require('../methods/client/before-save.js')(Client); + require('../methods/client/employee.js')(Client); // Validations diff --git a/services/client/server/server.js b/services/client/server/server.js index 57dea83a6..958aeb6b3 100644 --- a/services/client/server/server.js +++ b/services/client/server/server.js @@ -25,6 +25,7 @@ app.start = function() { app.emit('started'); var baseUrl = app.get('url').replace(/\/$/, ''); console.log('Web server listening at: %s', baseUrl); + if (app.get('loopback-component-explorer')) { var explorerPath = app.get('loopback-component-explorer').mountPath; console.log('Browse your REST API at %s%s', baseUrl, explorerPath);