From 6cf1e0953d447a0222969541258e615ae1978229 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 30 May 2023 14:49:28 +0200 Subject: [PATCH 01/42] refs #5244 feat: intento de crear el componente workerAutocomplete --- front/core/components/autocomplete/index.html | 4 +- front/core/components/drop-down/index.html | 6 +-- front/core/components/index.js | 1 + .../components/worker-autocomplete/index.html | 9 ++++ .../components/worker-autocomplete/index.js | 49 +++++++++++++++++ .../worker-autocomplete/index.spec.js | 54 +++++++++++++++++++ .../components/worker-autocomplete/style.scss | 30 +++++++++++ modules/ticket/front/tracking/edit/index.html | 17 ++---- 8 files changed, 152 insertions(+), 18 deletions(-) create mode 100755 front/core/components/worker-autocomplete/index.html create mode 100755 front/core/components/worker-autocomplete/index.js create mode 100644 front/core/components/worker-autocomplete/index.spec.js create mode 100755 front/core/components/worker-autocomplete/style.scss diff --git a/front/core/components/autocomplete/index.html b/front/core/components/autocomplete/index.html index 69aac4d43..527ca77e7 100755 --- a/front/core/components/autocomplete/index.html +++ b/front/core/components/autocomplete/index.html @@ -18,7 +18,7 @@ +
- \ No newline at end of file + diff --git a/front/core/components/drop-down/index.html b/front/core/components/drop-down/index.html index ab868f7b5..692b0c87c 100644 --- a/front/core/components/drop-down/index.html +++ b/front/core/components/drop-down/index.html @@ -13,12 +13,12 @@ class="dropdown" ng-click="$ctrl.onContainerClick($event)"> -
{{$ctrl.statusText}}
- \ No newline at end of file + diff --git a/front/core/components/index.js b/front/core/components/index.js index 45d182121..09e0345c7 100644 --- a/front/core/components/index.js +++ b/front/core/components/index.js @@ -51,6 +51,7 @@ import './textarea'; import './th'; import './treeview'; import './wday-picker'; +import './worker-autocomplete'; import './datalist'; import './contextmenu'; import './rating'; diff --git a/front/core/components/worker-autocomplete/index.html b/front/core/components/worker-autocomplete/index.html new file mode 100755 index 000000000..e7a022bc8 --- /dev/null +++ b/front/core/components/worker-autocomplete/index.html @@ -0,0 +1,9 @@ + + diff --git a/front/core/components/worker-autocomplete/index.js b/front/core/components/worker-autocomplete/index.js new file mode 100755 index 000000000..44ffd50e2 --- /dev/null +++ b/front/core/components/worker-autocomplete/index.js @@ -0,0 +1,49 @@ +import ngModule from '../../module'; +import Autocomplete from '../autocomplete'; +import assignProps from '../../lib/assign-props'; +import {mergeWhere} from 'vn-loopback/util/filter'; +import './style.scss'; + +/** + * Input with option selector. + * + * @property {String} showFiled The data field name that should be shown + * @property {String} valueField The data field name that should be used as value + * @property {Array} data Static data for the autocomplete + * @property {Object} intialData An initial data to avoid the server request used to get the selection + * @property {Boolean} multiple Whether to allow multiple selection + * @property {Object} selection Current object selected + * + * @event change Thrown when value is changed + */ +export default class WorkerAutocomplete extends Autocomplete { + constructor($element, $, $compile, $transclude) { + super($element, $, $compile, $transclude); + } + + // $postLink() { + // super.$postLink(); + // this.assignDropdownProps(); + // this.showField = this.$.dropDown.showField; + // this.valueField = this.$.dropDown.valueField; + // this.refreshSelection(); + // } + + // /** + // * @type {any} The autocomplete value. + // */ + // get field() { + // return super.field; + // } + + // set field(value) { + // super.field = value; + // this.refreshSelection(); + // } +} +WorkerAutocomplete.$inject = ['$element', '$scope', '$compile', '$transclude']; + +ngModule.vnComponent('vnWorkerAutocomplete', { + template: require('./index.html'), + controller: WorkerAutocomplete +}); diff --git a/front/core/components/worker-autocomplete/index.spec.js b/front/core/components/worker-autocomplete/index.spec.js new file mode 100644 index 000000000..847761179 --- /dev/null +++ b/front/core/components/worker-autocomplete/index.spec.js @@ -0,0 +1,54 @@ +describe('Component vnAutocomplete', () => { + let $element; + let controller; + let data = {id: 1, name: 'Bruce Wayne'}; + + beforeEach(ngModule('vnCore')); + + beforeEach(inject(($compile, $rootScope) => { + $element = $compile(``)($rootScope); + controller = $element.controller('vnAutocomplete'); + })); + + afterEach(() => { + $element.remove(); + }); + + describe('url() setter', () => { + it(`should set the url property`, () => { + controller.url = '/TestModels'; + + expect(controller.url).toEqual('/TestModels'); + }); + }); + + describe('field() setter/getter', () => { + it(`should set the field property`, () => { + controller.field = 'id'; + + expect(controller.field).toEqual('id'); + }); + }); + + describe('selection property', () => { + beforeEach(() => { + controller.field = data.id; + }); + + it(`should set selection finding an existing item in the initialData property`, () => { + controller.initialData = data; + + expect(controller.selection).toEqual(data); + }); + + it(`should set selection finding an existing item in the data property`, () => { + controller.data = [data]; + + expect(controller.selection).toEqual(data); + }); + + it(`should set selection to null when can't find an existing item in the data property`, () => { + expect(controller.selection).toEqual(null); + }); + }); +}); diff --git a/front/core/components/worker-autocomplete/style.scss b/front/core/components/worker-autocomplete/style.scss new file mode 100755 index 000000000..d76f84f85 --- /dev/null +++ b/front/core/components/worker-autocomplete/style.scss @@ -0,0 +1,30 @@ +@import "effects"; + +.vn-worker-autocomplete { + overflow: hidden; + + & > .container { + cursor: pointer; + + & > .infix > .control { + overflow: hidden; + + & > input { + cursor: pointer; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + text-align: left; + padding-left: 0; + padding-right: 0; + } + } + + & > .icons.pre { + min-width: 22px + } + } + &.readonly > .container > .icons.post { + display: none; + } +} diff --git a/modules/ticket/front/tracking/edit/index.html b/modules/ticket/front/tracking/edit/index.html index c522536b3..18b898012 100644 --- a/modules/ticket/front/tracking/edit/index.html +++ b/modules/ticket/front/tracking/edit/index.html @@ -14,22 +14,13 @@ - - + + @@ -43,4 +34,4 @@ ui-sref="ticket.card.tracking.index"> - \ No newline at end of file + From daeed312d0e403ad7eb00439e01903fcf623e10e Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 30 May 2023 15:16:15 +0200 Subject: [PATCH 02/42] =?UTF-8?q?refs=20#5244=20fix:=20a=C3=B1adido=20vn-d?= =?UTF-8?q?rop-down=20em=20html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/components/worker-autocomplete/index.html | 14 +++++++++++++- modules/ticket/front/tracking/edit/index.html | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/front/core/components/worker-autocomplete/index.html b/front/core/components/worker-autocomplete/index.html index e7a022bc8..fc8ddf640 100755 --- a/front/core/components/worker-autocomplete/index.html +++ b/front/core/components/worker-autocomplete/index.html @@ -2,8 +2,20 @@ vn-one url="Workers/activeWithInheritedRole" ng-model="$ctrl.workerFk" - show-field="nickname" search-function="{firstName: $search}" value-field="id" label="Worker"> + +
+ {{firstName}} {{lastName}} +
+
+ {{nickname}}, {{code}} +
+ + diff --git a/modules/ticket/front/tracking/edit/index.html b/modules/ticket/front/tracking/edit/index.html index 18b898012..3eafed8db 100644 --- a/modules/ticket/front/tracking/edit/index.html +++ b/modules/ticket/front/tracking/edit/index.html @@ -19,7 +19,8 @@ label="State" vn-focus> - + From a539abf3d8bdb959a9cf647deb171278bfd4c6ef Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 31 May 2023 10:15:16 +0200 Subject: [PATCH 03/42] refs #5244 feat: creado back para buscar trabjadores por name. nickname y code --- .../components/worker-autocomplete/index.html | 11 ++-- .../components/worker-autocomplete/index.js | 23 ------- .../components/worker-autocomplete/style.scss | 30 --------- modules/worker/back/methods/worker/search.js | 61 +++++++++++++++++++ modules/worker/back/models/worker.js | 1 + 5 files changed, 69 insertions(+), 57 deletions(-) delete mode 100755 front/core/components/worker-autocomplete/style.scss create mode 100644 modules/worker/back/methods/worker/search.js diff --git a/front/core/components/worker-autocomplete/index.html b/front/core/components/worker-autocomplete/index.html index fc8ddf640..65418aee0 100755 --- a/front/core/components/worker-autocomplete/index.html +++ b/front/core/components/worker-autocomplete/index.html @@ -1,13 +1,16 @@
- {{firstName}} {{lastName}} + {{name}}
{{nickname}}, {{code}} diff --git a/front/core/components/worker-autocomplete/index.js b/front/core/components/worker-autocomplete/index.js index 44ffd50e2..7983f53a5 100755 --- a/front/core/components/worker-autocomplete/index.js +++ b/front/core/components/worker-autocomplete/index.js @@ -1,8 +1,5 @@ import ngModule from '../../module'; import Autocomplete from '../autocomplete'; -import assignProps from '../../lib/assign-props'; -import {mergeWhere} from 'vn-loopback/util/filter'; -import './style.scss'; /** * Input with option selector. @@ -20,26 +17,6 @@ export default class WorkerAutocomplete extends Autocomplete { constructor($element, $, $compile, $transclude) { super($element, $, $compile, $transclude); } - - // $postLink() { - // super.$postLink(); - // this.assignDropdownProps(); - // this.showField = this.$.dropDown.showField; - // this.valueField = this.$.dropDown.valueField; - // this.refreshSelection(); - // } - - // /** - // * @type {any} The autocomplete value. - // */ - // get field() { - // return super.field; - // } - - // set field(value) { - // super.field = value; - // this.refreshSelection(); - // } } WorkerAutocomplete.$inject = ['$element', '$scope', '$compile', '$transclude']; diff --git a/front/core/components/worker-autocomplete/style.scss b/front/core/components/worker-autocomplete/style.scss deleted file mode 100755 index d76f84f85..000000000 --- a/front/core/components/worker-autocomplete/style.scss +++ /dev/null @@ -1,30 +0,0 @@ -@import "effects"; - -.vn-worker-autocomplete { - overflow: hidden; - - & > .container { - cursor: pointer; - - & > .infix > .control { - overflow: hidden; - - & > input { - cursor: pointer; - text-overflow: ellipsis; - white-space: nowrap; - overflow: hidden; - text-align: left; - padding-left: 0; - padding-right: 0; - } - } - - & > .icons.pre { - min-width: 22px - } - } - &.readonly > .container > .icons.post { - display: none; - } -} diff --git a/modules/worker/back/methods/worker/search.js b/modules/worker/back/methods/worker/search.js new file mode 100644 index 000000000..1d1742595 --- /dev/null +++ b/modules/worker/back/methods/worker/search.js @@ -0,0 +1,61 @@ +module.exports = Self => { + Self.remoteMethod('search', { + description: 'Returns an array of search from an specified worker', + accepts: [{ + arg: 'filter', + type: 'Object', + description: 'Filter defining where and paginated data', + required: true + }], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/search`, + verb: 'GET' + } + }); + + Self.search = async filter => { + const models = Self.app.models; + + delete filter.order; + delete filter.fields; + const users = await models.VnUser.find(filter); + + if (filter.where) { + const indexToDelete = 2; + const filterByCode = filter.where.or.splice(indexToDelete, 1)[0]; + + const ids = users.map(user => parseInt(user.id)); + filter.where.or = [ + {id: {inq: ids}}, + filterByCode + ]; + } + + filter.include = { + relation: 'user', + scope: { + fields: ['name', 'nickname'] + } + }; + + const workers = await models.Worker.find(filter); + + const result = workers.map(worker => { + return { + id: worker.id, + code: worker.code, + name: worker.user().name, + nickname: worker.user().nickname + }; + }); + result.sort((a, b) => { + return a.name.localeCompare(b.name); + }); + + return result; + }; +}; diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js index fa17640a8..16e4055bc 100644 --- a/modules/worker/back/models/worker.js +++ b/modules/worker/back/models/worker.js @@ -16,6 +16,7 @@ module.exports = Self => { require('../methods/worker/new')(Self); require('../methods/worker/deallocatePDA')(Self); require('../methods/worker/allocatePDA')(Self); + require('../methods/worker/search')(Self); Self.validatesUniquenessOf('locker', { message: 'This locker has already been assigned' From 3b4626ee7436d0cef4df6fa241cef43d951345c7 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 31 May 2023 13:01:16 +0200 Subject: [PATCH 04/42] a --- front/core/components/worker-autocomplete/index.html | 1 - modules/ticket/front/tracking/edit/index.html | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/front/core/components/worker-autocomplete/index.html b/front/core/components/worker-autocomplete/index.html index 65418aee0..c48a6f8d3 100755 --- a/front/core/components/worker-autocomplete/index.html +++ b/front/core/components/worker-autocomplete/index.html @@ -1,7 +1,6 @@ + vn-one + ng-model="$ctrl.workerFk" + where="{role: 'employee'}"> + + From 874255f2e59ebce40b7c8e1fbff10d07ffdc0399 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 8 Jun 2023 11:07:57 +0200 Subject: [PATCH 05/42] refs #5244 feat: extiende correctamente --- .../components/worker-autocomplete/index.html | 31 ++++---------- .../components/worker-autocomplete/index.js | 34 +++++++-------- modules/worker/back/methods/worker/search.js | 41 +------------------ 3 files changed, 28 insertions(+), 78 deletions(-) diff --git a/front/core/components/worker-autocomplete/index.html b/front/core/components/worker-autocomplete/index.html index c48a6f8d3..95631e8aa 100755 --- a/front/core/components/worker-autocomplete/index.html +++ b/front/core/components/worker-autocomplete/index.html @@ -1,23 +1,8 @@ - - -
- {{name}} -
-
- {{nickname}}, {{code}} -
-
- - + +
+ {{name}} +
+
+ {{nickname}}, {{code}} +
+
diff --git a/front/core/components/worker-autocomplete/index.js b/front/core/components/worker-autocomplete/index.js index 7983f53a5..59a46cc46 100755 --- a/front/core/components/worker-autocomplete/index.js +++ b/front/core/components/worker-autocomplete/index.js @@ -1,26 +1,28 @@ import ngModule from '../../module'; import Autocomplete from '../autocomplete'; -/** - * Input with option selector. - * - * @property {String} showFiled The data field name that should be shown - * @property {String} valueField The data field name that should be used as value - * @property {Array} data Static data for the autocomplete - * @property {Object} intialData An initial data to avoid the server request used to get the selection - * @property {Boolean} multiple Whether to allow multiple selection - * @property {Object} selection Current object selected - * - * @event change Thrown when value is changed - */ export default class WorkerAutocomplete extends Autocomplete { - constructor($element, $, $compile, $transclude) { - super($element, $, $compile, $transclude); + constructor(...args) { + super(...args); + Object.assign(this, { + label: 'Worker', + url: 'Workers/search', + fields: ['id', 'name', 'nickname'], + searchFunction: function($search) { + return {and: [ + {active: {neq: false}}, + {or: [ + {name: $search}, + {nickname: {like: '%' + $search + '%'}}, + {code: {like: $search + '%'}} + ]} + ]}; + } + }); } } -WorkerAutocomplete.$inject = ['$element', '$scope', '$compile', '$transclude']; ngModule.vnComponent('vnWorkerAutocomplete', { - template: require('./index.html'), + slotTemplate: require('./index.html'), controller: WorkerAutocomplete }); diff --git a/modules/worker/back/methods/worker/search.js b/modules/worker/back/methods/worker/search.js index 1d1742595..39bcef4c1 100644 --- a/modules/worker/back/methods/worker/search.js +++ b/modules/worker/back/methods/worker/search.js @@ -18,44 +18,7 @@ module.exports = Self => { }); Self.search = async filter => { - const models = Self.app.models; - - delete filter.order; - delete filter.fields; - const users = await models.VnUser.find(filter); - - if (filter.where) { - const indexToDelete = 2; - const filterByCode = filter.where.or.splice(indexToDelete, 1)[0]; - - const ids = users.map(user => parseInt(user.id)); - filter.where.or = [ - {id: {inq: ids}}, - filterByCode - ]; - } - - filter.include = { - relation: 'user', - scope: { - fields: ['name', 'nickname'] - } - }; - - const workers = await models.Worker.find(filter); - - const result = workers.map(worker => { - return { - id: worker.id, - code: worker.code, - name: worker.user().name, - nickname: worker.user().nickname - }; - }); - result.sort((a, b) => { - return a.name.localeCompare(b.name); - }); - - return result; + const $ = Self.app.models; + return await $.VnUser.find(filter); }; }; From 7dd5a5ac8e0d60dc0c581baf3a3fd6a472949f1b Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 8 Jun 2023 13:12:30 +0200 Subject: [PATCH 06/42] refs #5244 feat: hereda correctamente --- db/changes/232601/00-aclWorker.sql | 3 +++ front/core/components/autocomplete/index.js | 7 +++---- front/core/components/field/index.js | 6 +++--- .../components/worker-autocomplete/index.js | 2 +- front/core/lib/component.js | 7 +++---- front/core/lib/event-emitter.js | 1 - modules/worker/back/methods/worker/search.js | 18 +++++++++++++++++- 7 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 db/changes/232601/00-aclWorker.sql diff --git a/db/changes/232601/00-aclWorker.sql b/db/changes/232601/00-aclWorker.sql new file mode 100644 index 000000000..7e5081530 --- /dev/null +++ b/db/changes/232601/00-aclWorker.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (id, model, property, accessType, permission, principalType, principalId) + VALUES + ('Worker', 'search', 'READ', 'ALLOW', 'ROLE', 'employee'); diff --git a/front/core/components/autocomplete/index.js b/front/core/components/autocomplete/index.js index 2539c4ef4..b8a0617b3 100755 --- a/front/core/components/autocomplete/index.js +++ b/front/core/components/autocomplete/index.js @@ -17,10 +17,9 @@ import './style.scss'; * @event change Thrown when value is changed */ export default class Autocomplete extends Field { - constructor($element, $, $compile, $transclude) { - super($element, $, $compile); + constructor($element, $, $transclude) { + super($element, $, $transclude); this.$transclude = $transclude; - this.$compile = $compile; this._selection = null; this.input = this.element.querySelector('input'); } @@ -282,7 +281,7 @@ export default class Autocomplete extends Field { this.refreshSelection(); } } -Autocomplete.$inject = ['$element', '$scope', '$compile', '$transclude']; +Autocomplete.$inject = ['$element', '$scope', '$transclude']; ngModule.vnComponent('vnAutocomplete', { template: require('./index.html'), diff --git a/front/core/components/field/index.js b/front/core/components/field/index.js index 7ce840555..ff92b6b87 100644 --- a/front/core/components/field/index.js +++ b/front/core/components/field/index.js @@ -3,8 +3,8 @@ import FormInput from '../form-input'; import './style.scss'; export default class Field extends FormInput { - constructor($element, $scope) { - super($element, $scope); + constructor($element, $scope, $transclude) { + super($element, $scope, $transclude); this.prefix = null; this.suffix = null; @@ -197,7 +197,7 @@ export default class Field extends FormInput { }); } } -Field.$inject = ['$element', '$scope']; +Field.$inject = ['$element', '$scope', '$transclude']; ngModule.vnComponent('vnField', { template: require('./index.html'), diff --git a/front/core/components/worker-autocomplete/index.js b/front/core/components/worker-autocomplete/index.js index 59a46cc46..efaa6a4a9 100755 --- a/front/core/components/worker-autocomplete/index.js +++ b/front/core/components/worker-autocomplete/index.js @@ -8,7 +8,7 @@ export default class WorkerAutocomplete extends Autocomplete { label: 'Worker', url: 'Workers/search', fields: ['id', 'name', 'nickname'], - searchFunction: function($search) { + searchFunction: function({$search}) { return {and: [ {active: {neq: false}}, {or: [ diff --git a/front/core/lib/component.js b/front/core/lib/component.js index 5695d9449..6bb83e55a 100644 --- a/front/core/lib/component.js +++ b/front/core/lib/component.js @@ -12,10 +12,9 @@ export default class Component extends EventEmitter { * @param {HTMLElement} $element The main component element * @param {$rootScope.Scope} $scope The element scope * @param {Function} $transclude The transclusion function - * @param {Function} $location The location function */ - constructor($element, $scope, $transclude, $location) { - super($element, $scope, $transclude, $location); + constructor($element, $scope, $transclude) { + super(); this.$ = $scope; if (!$element) return; @@ -165,7 +164,7 @@ export default class Component extends EventEmitter { $transclude.$$boundTransclude.$$slots[slot]; } } -Component.$inject = ['$element', '$scope', '$location', '$state']; +Component.$inject = ['$element', '$scope', '$transclude']; /* * Automatically adds the most used services to the prototype, so they are diff --git a/front/core/lib/event-emitter.js b/front/core/lib/event-emitter.js index 83e361253..0e0ce1872 100644 --- a/front/core/lib/event-emitter.js +++ b/front/core/lib/event-emitter.js @@ -83,4 +83,3 @@ export default class EventEmitter { } } } -EventEmitter.$inject = ['$element', '$scope']; diff --git a/modules/worker/back/methods/worker/search.js b/modules/worker/back/methods/worker/search.js index 39bcef4c1..1e8343fac 100644 --- a/modules/worker/back/methods/worker/search.js +++ b/modules/worker/back/methods/worker/search.js @@ -19,6 +19,22 @@ module.exports = Self => { Self.search = async filter => { const $ = Self.app.models; - return await $.VnUser.find(filter); + + let {where} = filter; + const users = where && await $.VnUser.find({ + fields: ['id'], + where + }); + + const workers = await Self.find({ + fields: ['id'], + where: { + businessFk: {neq: null}, + id: users ? {inq: users.map(u => u.id)} : undefined + } + }); + + where = {id: {inq: workers.map(w => w.id)}}; + return await $.VnUser.find(Object.assign({}, filter, {where})); }; }; From f47a049d7ab55ea7d2baa6574bbbddc5f134fe84 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 8 Jun 2023 13:39:21 +0200 Subject: [PATCH 07/42] =?UTF-8?q?refs=20#5244=20fix:=20cambiada=20descripc?= =?UTF-8?q?i=C3=B3n=20erronea?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/worker/back/methods/worker/activeWithInheritedRole.js | 4 ++-- modules/worker/back/methods/worker/activeWithRole.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/worker/back/methods/worker/activeWithInheritedRole.js b/modules/worker/back/methods/worker/activeWithInheritedRole.js index 9536b0f29..19038405b 100644 --- a/modules/worker/back/methods/worker/activeWithInheritedRole.js +++ b/modules/worker/back/methods/worker/activeWithInheritedRole.js @@ -1,7 +1,7 @@ module.exports = Self => { Self.remoteMethod('activeWithInheritedRole', { - description: 'Returns active workers with a role', + description: 'Returns active workers with an inherited role', accessType: 'READ', accepts: [{ arg: 'filter', @@ -24,7 +24,7 @@ module.exports = Self => { `SELECT DISTINCT w.id, w.firstName, w.lastName, u.name, u.nickname FROM worker w JOIN account.user u ON u.id = w.userFk - JOIN account.roleRole i ON i.role = u.role + JOIN account.roleRole i ON i.role = u.role JOIN account.role r ON r.id = i.inheritsFrom`; return Self.activeWorkers(query, filter); diff --git a/modules/worker/back/methods/worker/activeWithRole.js b/modules/worker/back/methods/worker/activeWithRole.js index 392416458..c7f96e151 100644 --- a/modules/worker/back/methods/worker/activeWithRole.js +++ b/modules/worker/back/methods/worker/activeWithRole.js @@ -1,7 +1,7 @@ module.exports = Self => { Self.remoteMethod('activeWithRole', { - description: 'Returns active workers with an inherited role', + description: 'Returns active workers with a role', accessType: 'READ', accepts: [{ arg: 'filter', From 5195c0100b0536c8b5b550eadf58af40718d3bba Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 8 Jun 2023 14:49:28 +0200 Subject: [PATCH 08/42] refs #5244 fix: sql --- db/changes/232601/00-aclWorker.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/changes/232601/00-aclWorker.sql b/db/changes/232601/00-aclWorker.sql index 7e5081530..e79d8f738 100644 --- a/db/changes/232601/00-aclWorker.sql +++ b/db/changes/232601/00-aclWorker.sql @@ -1,3 +1,3 @@ -INSERT INTO `salix`.`ACL` (id, model, property, accessType, permission, principalType, principalId) +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) VALUES ('Worker', 'search', 'READ', 'ALLOW', 'ROLE', 'employee'); From a699e2d8748ce295193620f324500481c4668a40 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 21 Jun 2023 14:07:36 +0200 Subject: [PATCH 09/42] =?UTF-8?q?refs=20#5244=20feat:=20a=C3=B1adido=20'de?= =?UTF-8?q?patments'=20como=20binding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/worker-autocomplete/index.js | 26 ++++++--- modules/ticket/front/tracking/edit/index.html | 2 +- modules/worker/back/methods/worker/search.js | 57 +++++++++++++------ 3 files changed, 59 insertions(+), 26 deletions(-) diff --git a/front/core/components/worker-autocomplete/index.js b/front/core/components/worker-autocomplete/index.js index efaa6a4a9..436959c5d 100755 --- a/front/core/components/worker-autocomplete/index.js +++ b/front/core/components/worker-autocomplete/index.js @@ -4,25 +4,35 @@ import Autocomplete from '../autocomplete'; export default class WorkerAutocomplete extends Autocomplete { constructor(...args) { super(...args); + } + + $onInit() { + let url = 'Workers/search'; + if (this.departments) { + const parameter = encodeURIComponent(JSON.stringify(this.departments)); + url = `Workers/search?departmentCodes=${parameter}`; + } Object.assign(this, { label: 'Worker', - url: 'Workers/search', - fields: ['id', 'name', 'nickname'], + url: url, searchFunction: function({$search}) { return {and: [ - {active: {neq: false}}, + {'u.active': {neq: false}}, {or: [ - {name: $search}, - {nickname: {like: '%' + $search + '%'}}, - {code: {like: $search + '%'}} + {'u.name': $search}, + {'u.nickname': {like: '%' + $search + '%'}}, + {'w.code': {like: $search + '%'}} ]} ]}; - } + }, }); } } ngModule.vnComponent('vnWorkerAutocomplete', { slotTemplate: require('./index.html'), - controller: WorkerAutocomplete + controller: WorkerAutocomplete, + bindings: { + departments: ' + departments="['VN']"> { - Self.remoteMethod('search', { + Self.remoteMethodCtx('search', { description: 'Returns an array of search from an specified worker', accepts: [{ arg: 'filter', - type: 'Object', + type: 'object', description: 'Filter defining where and paginated data', required: true + }, + { + arg: 'departmentCodes', + type: ['string'], + description: 'Department codes to search workers', }], returns: { type: ['object'], @@ -17,24 +25,39 @@ module.exports = Self => { } }); - Self.search = async filter => { - const $ = Self.app.models; + Self.search = async(ctx, filter, departmentCodes) => { + const models = Self.app.models; + const conn = Self.dataSource.connector; - let {where} = filter; - const users = where && await $.VnUser.find({ - fields: ['id'], - where - }); + let allDepartments = []; + if (departmentCodes) { + const departments = await models.Department.find({ + fields: ['id'], + where: {code: {inq: departmentCodes}} + }); + const departmentIds = departments.map(department => department.id); - const workers = await Self.find({ - fields: ['id'], - where: { - businessFk: {neq: null}, - id: users ? {inq: users.map(u => u.id)} : undefined + let departmentLeaves = []; + for (let id of departmentIds) { + const leaves = await models.Department.getLeaves(ctx, id, null); + console.log(leaves); + for (let leave of leaves) departmentLeaves.push(leave.id); } - }); - where = {id: {inq: workers.map(w => w.id)}}; - return await $.VnUser.find(Object.assign({}, filter, {where})); + allDepartments = departmentIds.concat(departmentLeaves); + console.log(allDepartments); + const where = {'d.id': {inq: allDepartments}}; + filter = mergeFilters(filter, {where}); + } + + const stmt = new ParameterizedSQL( + `SELECT DISTINCT w.code, u.name, u.nickname + FROM worker w + JOIN account.user u ON u.id = w.id + JOIN business b ON b.workerFk = w.id + JOIN department d ON d.id = b.departmentFk`); + + stmt.merge(conn.makeSuffix(filter)); + return conn.executeStmt(stmt); }; }; From e9ef81f8d7b7640f802d0fc8b4ec4a1ac5ee29ed Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 21 Jun 2023 15:00:46 +0200 Subject: [PATCH 10/42] refs #5244 feat: coge todos los hijos recursivamente --- db/changes/232601/00-department.sql | 3 ++ modules/worker/back/methods/worker/search.js | 30 +++++++++++--------- 2 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 db/changes/232601/00-department.sql diff --git a/db/changes/232601/00-department.sql b/db/changes/232601/00-department.sql new file mode 100644 index 000000000..777d26b9f --- /dev/null +++ b/db/changes/232601/00-department.sql @@ -0,0 +1,3 @@ +UPDATE `vn`.`department` + SET code='VN' +WHERE name='VERDNATURA'; diff --git a/modules/worker/back/methods/worker/search.js b/modules/worker/back/methods/worker/search.js index 388b94e6b..c02053b0c 100644 --- a/modules/worker/back/methods/worker/search.js +++ b/modules/worker/back/methods/worker/search.js @@ -29,24 +29,14 @@ module.exports = Self => { const models = Self.app.models; const conn = Self.dataSource.connector; - let allDepartments = []; if (departmentCodes) { const departments = await models.Department.find({ - fields: ['id'], + fields: ['id', 'sons'], where: {code: {inq: departmentCodes}} }); - const departmentIds = departments.map(department => department.id); - let departmentLeaves = []; - for (let id of departmentIds) { - const leaves = await models.Department.getLeaves(ctx, id, null); - console.log(leaves); - for (let leave of leaves) departmentLeaves.push(leave.id); - } - - allDepartments = departmentIds.concat(departmentLeaves); - console.log(allDepartments); - const where = {'d.id': {inq: allDepartments}}; + const allLeaves = await getAllLeaves(ctx, departments); + const where = {'d.id': {inq: allLeaves}}; filter = mergeFilters(filter, {where}); } @@ -60,4 +50,18 @@ module.exports = Self => { stmt.merge(conn.makeSuffix(filter)); return conn.executeStmt(stmt); }; + + async function getAllLeaves(ctx, departments) { + const models = Self.app.models; + const leaves = []; + for (const department of departments) { + if (department.sons > 0) { + const subLeaves = await models.Department.getLeaves(ctx, department.id, null); + const grandLeaves = await getAllLeaves(ctx, subLeaves); + leaves.push(...grandLeaves); + } + leaves.push(department.id); + } + return leaves; + } }; From 3cedef6f1616dfb9bae0263f5654f142e3ddfb99 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 29 Jun 2023 15:22:53 +0200 Subject: [PATCH 11/42] refs #5244 fix: add id --- modules/worker/back/methods/worker/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/methods/worker/search.js b/modules/worker/back/methods/worker/search.js index c02053b0c..14916cbb6 100644 --- a/modules/worker/back/methods/worker/search.js +++ b/modules/worker/back/methods/worker/search.js @@ -41,7 +41,7 @@ module.exports = Self => { } const stmt = new ParameterizedSQL( - `SELECT DISTINCT w.code, u.name, u.nickname + `SELECT DISTINCT w.id, w.code, u.name, u.nickname FROM worker w JOIN account.user u ON u.id = w.id JOIN business b ON b.workerFk = w.id From f3e771747ae2d231d46bf643fa63d90c8f05bf37 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 29 Jun 2023 15:56:07 +0200 Subject: [PATCH 12/42] refs #5244 fix: getItemTypeWorker permite filtrar por id --- .../back/methods/worker/getItemTypeWorker.js | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 modules/worker/back/methods/worker/getItemTypeWorker.js diff --git a/modules/worker/back/methods/worker/getItemTypeWorker.js b/modules/worker/back/methods/worker/getItemTypeWorker.js new file mode 100644 index 000000000..b1f49ae99 --- /dev/null +++ b/modules/worker/back/methods/worker/getItemTypeWorker.js @@ -0,0 +1,65 @@ +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; +const buildFilter = require('vn-loopback/util/filter').buildFilter; +const mergeFilters = require('vn-loopback/util/filter').mergeFilters; + +module.exports = Self => { + Self.remoteMethod('getItemTypeWorker', { + description: 'Returns the workers that appear in itemType', + accessType: 'READ', + accepts: [{ + arg: 'filter', + type: 'Object', + description: 'Filter defining where and paginated data', + required: true + }], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/getItemTypeWorker`, + verb: 'GET' + } + }); + + Self.getItemTypeWorker = async(filter, options) => { + const myOptions = {}; + const conn = Self.dataSource.connector; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const query = + `SELECT DISTINCT u.id, w.firstName, w.lastName, u.nickname, u.name + FROM itemType it + JOIN worker w ON w.id = it.workerFk + JOIN account.user u ON u.id = w.id`; + + let stmt = new ParameterizedSQL(query); + + let clientFilter = Object.assign({}, filter); + clientFilter.where = buildFilter(filter.where, (param, value) => { + switch (param) { + case 'role': + return {'r.name': value}; + case 'firstName': + return {or: [ + {'w.firstName': {like: `%${value}%`}}, + {'w.lastName': {like: `%${value}%`}}, + {'u.name': {like: `%${value}%`}}, + {'u.nickname': {like: `%${value}%`}} + ]}; + case 'id': + return {'w.id': value}; + } + }); + + let myFilter = { + where: {'u.active': true} + }; + + myFilter = mergeFilters(myFilter, clientFilter); + stmt.merge(conn.makeSuffix(myFilter)); + return conn.executeStmt(stmt); + }; +}; From 7b4e8570aaf20597864cb2c4048fb965231d6ace Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 30 Jun 2023 12:03:26 +0200 Subject: [PATCH 13/42] refs #5244 refactor: se sustituyen los activeWithRole con where="{role: {inq: ['logistic', 'buyer']}}" por getItemTypeWorker --- .../front/consumption-search-panel/index.html | 5 ++- .../front/latest-buys-search-panel/index.html | 3 +- .../front/fixed-price-search-panel/index.html | 3 +- modules/item/front/index/index.js | 3 +- .../front/request-search-panel/index.html | 17 +++++----- .../front/consumption-search-panel/index.html | 5 ++- .../ticket-request/getItemTypeWorker.js | 33 +++++++++++-------- 7 files changed, 34 insertions(+), 35 deletions(-) diff --git a/modules/client/front/consumption-search-panel/index.html b/modules/client/front/consumption-search-panel/index.html index 4d23eb53a..c113ee601 100644 --- a/modules/client/front/consumption-search-panel/index.html +++ b/modules/client/front/consumption-search-panel/index.html @@ -17,12 +17,11 @@ - {{nickname}} diff --git a/modules/entry/front/latest-buys-search-panel/index.html b/modules/entry/front/latest-buys-search-panel/index.html index 075d6a8f7..c73bf7365 100644 --- a/modules/entry/front/latest-buys-search-panel/index.html +++ b/modules/entry/front/latest-buys-search-panel/index.html @@ -54,11 +54,10 @@ vn-id="salesPerson" disabled="false" ng-model="$ctrl.filter.salesPersonFk" - url="Workers/activeWithRole" + url="TicketRequests/getItemTypeWorker" show-field="nickname" search-function="{firstName: $search}" value-field="id" - where="{role: {inq: ['logistic', 'buyer']}}" label="Buyer" on-change="$ctrl.addFilters()"> diff --git a/modules/item/front/fixed-price-search-panel/index.html b/modules/item/front/fixed-price-search-panel/index.html index ebe210277..347e65571 100644 --- a/modules/item/front/fixed-price-search-panel/index.html +++ b/modules/item/front/fixed-price-search-panel/index.html @@ -54,11 +54,10 @@ vn-id="buyer" disabled="false" ng-model="$ctrl.filter.buyerFk" - url="Workers/activeWithRole" + url="TicketRequests/getItemTypeWorker" show-field="nickname" search-function="{firstName: $search}" value-field="id" - where="{role: {inq: ['logistic', 'buyer']}}" label="Buyer" on-change="$ctrl.addFilters()">
diff --git a/modules/item/front/index/index.js b/modules/item/front/index/index.js index 10bd4bbb7..2bcc2302a 100644 --- a/modules/item/front/index/index.js +++ b/modules/item/front/index/index.js @@ -44,8 +44,7 @@ class Controller extends Section { { field: 'buyerFk', autocomplete: { - url: 'Workers/activeWithRole', - where: `{role: {inq: ['logistic', 'buyer']}}`, + url: 'TicketRequests/getItemTypeWorker', searchFunction: '{firstName: $search}', showField: 'nickname', valueField: 'id', diff --git a/modules/item/front/request-search-panel/index.html b/modules/item/front/request-search-panel/index.html index a76684776..806ab79b1 100644 --- a/modules/item/front/request-search-panel/index.html +++ b/modules/item/front/request-search-panel/index.html @@ -1,7 +1,7 @@
@@ -22,12 +22,11 @@ - {{nickname}} @@ -57,7 +56,7 @@ {{firstName}} {{lastName}} - +
- - {{nickname}} diff --git a/modules/ticket/back/methods/ticket-request/getItemTypeWorker.js b/modules/ticket/back/methods/ticket-request/getItemTypeWorker.js index 0655c7bba..f160cfaac 100644 --- a/modules/ticket/back/methods/ticket-request/getItemTypeWorker.js +++ b/modules/ticket/back/methods/ticket-request/getItemTypeWorker.js @@ -1,7 +1,9 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; +const buildFilter = require('vn-loopback/util/filter').buildFilter; +const mergeFilters = require('vn-loopback/util/filter').mergeFilters; module.exports = Self => { - Self.remoteMethodCtx('getItemTypeWorker', { + Self.remoteMethod('getItemTypeWorker', { description: 'Returns the workers that appear in itemType', accessType: 'READ', accepts: [{ @@ -20,10 +22,9 @@ module.exports = Self => { } }); - Self.getItemTypeWorker = async(ctx, filter, options) => { + Self.getItemTypeWorker = async(filter, options) => { const myOptions = {}; const conn = Self.dataSource.connector; - let tx; if (typeof options == 'object') Object.assign(myOptions, options); @@ -33,25 +34,29 @@ module.exports = Self => { FROM itemType it JOIN worker w ON w.id = it.workerFk JOIN account.user u ON u.id = w.id`; + const stmt = new ParameterizedSQL(query); - let stmt = new ParameterizedSQL(query); - - if (filter.where) { - const value = filter.where.firstName; - const myFilter = { - where: {or: [ + filter.where = buildFilter(filter.where, (param, value) => { + switch (param) { + case 'firstName': + return {or: [ {'w.firstName': {like: `%${value}%`}}, {'w.lastName': {like: `%${value}%`}}, {'u.name': {like: `%${value}%`}}, {'u.nickname': {like: `%${value}%`}} - ]} - }; + ]}; + case 'id': + return {'w.id': value}; + } + }); - stmt.merge(conn.makeSuffix(myFilter)); - } + let myFilter = { + where: {'u.active': true} + }; - if (tx) await tx.commit(); + myFilter = mergeFilters(myFilter, filter); + stmt.merge(conn.makeSuffix(myFilter)); return conn.executeStmt(stmt); }; }; From 954c2f5435518e7b8493d04de2eb312c1ee3f1ed Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 12 Jul 2023 13:12:51 +0200 Subject: [PATCH 14/42] refs #5244 feat: carga valor inicial --- .../core/components/worker-autocomplete/index.js | 10 ++++++---- modules/claim/front/basic-data/index.html | 3 +++ modules/worker/back/methods/worker/search.js | 15 +++++++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/front/core/components/worker-autocomplete/index.js b/front/core/components/worker-autocomplete/index.js index 436959c5d..24cc02797 100755 --- a/front/core/components/worker-autocomplete/index.js +++ b/front/core/components/worker-autocomplete/index.js @@ -7,6 +7,8 @@ export default class WorkerAutocomplete extends Autocomplete { } $onInit() { + super.$onInit(); + let url = 'Workers/search'; if (this.departments) { const parameter = encodeURIComponent(JSON.stringify(this.departments)); @@ -17,11 +19,11 @@ export default class WorkerAutocomplete extends Autocomplete { url: url, searchFunction: function({$search}) { return {and: [ - {'u.active': {neq: false}}, + {'active': {neq: false}}, {or: [ - {'u.name': $search}, - {'u.nickname': {like: '%' + $search + '%'}}, - {'w.code': {like: $search + '%'}} + {'name': $search}, + {'nickname': {like: '%' + $search + '%'}}, + {'code': {like: $search + '%'}} ]} ]}; }, diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html index 16e134c60..70be85a8f 100644 --- a/modules/claim/front/basic-data/index.html +++ b/modules/claim/front/basic-data/index.html @@ -34,6 +34,9 @@ where="{role: 'salesPerson'}" label="Attended by"> + + { filter = mergeFilters(filter, {where}); } - const stmt = new ParameterizedSQL( - `SELECT DISTINCT w.id, w.code, u.name, u.nickname - FROM worker w - JOIN account.user u ON u.id = w.id - JOIN business b ON b.workerFk = w.id - JOIN department d ON d.id = b.departmentFk`); + const stmt = new ParameterizedSQL(` + SELECT * + FROM( + SELECT DISTINCT w.id, w.code, u.name, u.nickname, u.active + FROM worker w + JOIN account.user u ON u.id = w.id + JOIN business b ON b.workerFk = w.id + JOIN department d ON d.id = b.departmentFk + ) w`); stmt.merge(conn.makeSuffix(filter)); return conn.executeStmt(stmt); From c876719a5c9fb66ed88735596388833389338d15 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 13 Jul 2023 12:59:02 +0200 Subject: [PATCH 15/42] refs #5244 fix: corregidos errores --- front/core/components/autocomplete/index.js | 9 +++- .../worker-autocomplete/index.spec.js | 54 ------------------- modules/worker/back/methods/worker/search.js | 5 +- 3 files changed, 10 insertions(+), 58 deletions(-) delete mode 100644 front/core/components/worker-autocomplete/index.spec.js diff --git a/front/core/components/autocomplete/index.js b/front/core/components/autocomplete/index.js index b8a0617b3..c78c29398 100755 --- a/front/core/components/autocomplete/index.js +++ b/front/core/components/autocomplete/index.js @@ -152,7 +152,14 @@ export default class Autocomplete extends Field { filter.include = this.include; let json = encodeURIComponent(JSON.stringify(filter)); - this.$http.get(`${this.url}?filter=${json}`).then( + + let url; + if (this.url.includes('?')) + url = `${this.url}&filter=${json}`; + else + url = `${this.url}?filter=${json}`; + + this.$http.get(url).then( json => this.onSelectionRequest(json.data), () => this.onSelectionRequest() ); diff --git a/front/core/components/worker-autocomplete/index.spec.js b/front/core/components/worker-autocomplete/index.spec.js deleted file mode 100644 index 847761179..000000000 --- a/front/core/components/worker-autocomplete/index.spec.js +++ /dev/null @@ -1,54 +0,0 @@ -describe('Component vnAutocomplete', () => { - let $element; - let controller; - let data = {id: 1, name: 'Bruce Wayne'}; - - beforeEach(ngModule('vnCore')); - - beforeEach(inject(($compile, $rootScope) => { - $element = $compile(``)($rootScope); - controller = $element.controller('vnAutocomplete'); - })); - - afterEach(() => { - $element.remove(); - }); - - describe('url() setter', () => { - it(`should set the url property`, () => { - controller.url = '/TestModels'; - - expect(controller.url).toEqual('/TestModels'); - }); - }); - - describe('field() setter/getter', () => { - it(`should set the field property`, () => { - controller.field = 'id'; - - expect(controller.field).toEqual('id'); - }); - }); - - describe('selection property', () => { - beforeEach(() => { - controller.field = data.id; - }); - - it(`should set selection finding an existing item in the initialData property`, () => { - controller.initialData = data; - - expect(controller.selection).toEqual(data); - }); - - it(`should set selection finding an existing item in the data property`, () => { - controller.data = [data]; - - expect(controller.selection).toEqual(data); - }); - - it(`should set selection to null when can't find an existing item in the data property`, () => { - expect(controller.selection).toEqual(null); - }); - }); -}); diff --git a/modules/worker/back/methods/worker/search.js b/modules/worker/back/methods/worker/search.js index 8be9ecc5e..50fe71235 100644 --- a/modules/worker/back/methods/worker/search.js +++ b/modules/worker/back/methods/worker/search.js @@ -36,18 +36,17 @@ module.exports = Self => { }); const allLeaves = await getAllLeaves(ctx, departments); - const where = {'d.id': {inq: allLeaves}}; + const where = {'departmentFk': {inq: allLeaves}}; filter = mergeFilters(filter, {where}); } const stmt = new ParameterizedSQL(` SELECT * FROM( - SELECT DISTINCT w.id, w.code, u.name, u.nickname, u.active + SELECT DISTINCT w.id, w.code, u.name, u.nickname, u.active, b.departmentFk FROM worker w JOIN account.user u ON u.id = w.id JOIN business b ON b.workerFk = w.id - JOIN department d ON d.id = b.departmentFk ) w`); stmt.merge(conn.makeSuffix(filter)); From 75a66571baa3be6244e36b9e7877eaebf8930b76 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 13 Jul 2023 12:59:39 +0200 Subject: [PATCH 16/42] refs #5244 refactor: modificados todos los url='activeWith...' --- modules/claim/front/basic-data/index.html | 15 +++++-------- modules/claim/front/development/index.html | 13 ++++-------- modules/claim/front/search-panel/index.html | 20 ++++++------------ modules/client/front/basic-data/index.html | 21 ++++++++----------- modules/client/front/create/index.html | 21 ++++++++----------- modules/client/front/search-panel/index.html | 11 +++------- .../front/request-search-panel/index.html | 13 ++++-------- .../front/index/search-panel/index.html | 14 +++++-------- modules/order/front/search-panel/index.html | 11 ++++------ modules/route/front/basic-data/index.html | 13 ++---------- modules/route/front/create/index.html | 12 ++++------- modules/route/front/search-panel/index.html | 15 +++++-------- modules/supplier/front/basic-data/index.html | 18 +++++++--------- modules/ticket/front/search-panel/index.html | 14 +++++-------- modules/ticket/front/tracking/edit/index.html | 9 +------- modules/worker/front/basic-data/index.html | 7 ++----- modules/worker/front/create/index.html | 7 ++----- .../front/department/basic-data/index.html | 14 ++++++------- 18 files changed, 83 insertions(+), 165 deletions(-) diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html index 70be85a8f..10aa7623a 100644 --- a/modules/claim/front/basic-data/index.html +++ b/modules/claim/front/basic-data/index.html @@ -25,17 +25,12 @@ - - + disabled="false" + show-field="nickname" + ng-model="$ctrl.claim.workerFk" + departments="['VT']" + label="Attended by"> - + @@ -66,16 +66,11 @@ show-field="description" rule> - - + --> - \ No newline at end of file + diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html index 151a06c8e..fbc527d60 100644 --- a/modules/claim/front/search-panel/index.html +++ b/modules/claim/front/search-panel/index.html @@ -22,26 +22,18 @@ - - {{firstName}} {{name}} - - + - {{firstName}} {{name}} - + - @@ -59,18 +59,15 @@ - - - + - - {{firstName}} {{lastName}} - + departments="['VT']" + show-field="nickname"> + - - {{code}} - {{town.name}} ({{town.province.name}}, + {{code}} - {{town.name}} ({{town.province.name}}, {{town.province.country.country}}) @@ -82,7 +79,7 @@ - {{name}}, {{province.name}} + {{name}}, {{province.name}} ({{province.country.country}}) @@ -150,4 +147,4 @@ - \ No newline at end of file + diff --git a/modules/client/front/search-panel/index.html b/modules/client/front/search-panel/index.html index a02f93882..2105d3a65 100644 --- a/modules/client/front/search-panel/index.html +++ b/modules/client/front/search-panel/index.html @@ -14,17 +14,12 @@ vn-one label="Name" ng-model="filter.name"> - - {{firstName}} {{name}} - + - - {{firstName}} {{lastName}} - + departments="['VT']" + label="Salesperson"> + -
@@ -43,16 +43,12 @@ label="Nickname" ng-model="filter.nickname"> - - {{firstName}} {{name}} - + - - + -
\ No newline at end of file +
diff --git a/modules/route/front/basic-data/index.html b/modules/route/front/basic-data/index.html index c63fee53b..a51a3dbdb 100644 --- a/modules/route/front/basic-data/index.html +++ b/modules/route/front/basic-data/index.html @@ -8,20 +8,11 @@
- - -
{{::nickname}}
-
{{::name}}
-
-
+ - - + show-field="nickname"> + diff --git a/modules/route/front/search-panel/index.html b/modules/route/front/search-panel/index.html index a78d88d1c..f3d392580 100644 --- a/modules/route/front/search-panel/index.html +++ b/modules/route/front/search-panel/index.html @@ -1,7 +1,7 @@
@@ -15,16 +15,11 @@ - - + show-field="nickname"> + - - + @@ -45,7 +41,7 @@ @@ -63,4 +59,4 @@ ng-click="watcher.loadOriginalData()"> - \ No newline at end of file + diff --git a/modules/ticket/front/search-panel/index.html b/modules/ticket/front/search-panel/index.html index 52bede97f..d80f21531 100644 --- a/modules/ticket/front/search-panel/index.html +++ b/modules/ticket/front/search-panel/index.html @@ -1,7 +1,7 @@
@@ -62,16 +62,12 @@ label="Nickname" ng-model="filter.nickname"> - - {{firstName}} {{name}} - + + ng-model="$ctrl.workerFk"> - - diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html index d89d88f2e..2d85d018d 100644 --- a/modules/worker/front/basic-data/index.html +++ b/modules/worker/front/basic-data/index.html @@ -37,14 +37,11 @@ - - + - - + - - + - + @@ -78,12 +76,12 @@ label="Fill in days without physical check-ins" ng-model="$ctrl.department.hasToRefill"> - - + + - + From a6b8f4ddf88a5960e9dda46a89b06129942bcba0 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Jul 2023 09:46:25 +0200 Subject: [PATCH 17/42] refs #5244 fix: tfront --- front/core/lib/component.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/front/core/lib/component.js b/front/core/lib/component.js index 6bb83e55a..5695d9449 100644 --- a/front/core/lib/component.js +++ b/front/core/lib/component.js @@ -12,9 +12,10 @@ export default class Component extends EventEmitter { * @param {HTMLElement} $element The main component element * @param {$rootScope.Scope} $scope The element scope * @param {Function} $transclude The transclusion function + * @param {Function} $location The location function */ - constructor($element, $scope, $transclude) { - super(); + constructor($element, $scope, $transclude, $location) { + super($element, $scope, $transclude, $location); this.$ = $scope; if (!$element) return; @@ -164,7 +165,7 @@ export default class Component extends EventEmitter { $transclude.$$boundTransclude.$$slots[slot]; } } -Component.$inject = ['$element', '$scope', '$transclude']; +Component.$inject = ['$element', '$scope', '$location', '$state']; /* * Automatically adds the most used services to the prototype, so they are From d6a27741b53c30de3999faa81212867c674ba427 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Jul 2023 09:50:56 +0200 Subject: [PATCH 18/42] a --- .../back/methods/worker/getItemTypeWorker.js | 65 ------------------- 1 file changed, 65 deletions(-) delete mode 100644 modules/worker/back/methods/worker/getItemTypeWorker.js diff --git a/modules/worker/back/methods/worker/getItemTypeWorker.js b/modules/worker/back/methods/worker/getItemTypeWorker.js deleted file mode 100644 index b1f49ae99..000000000 --- a/modules/worker/back/methods/worker/getItemTypeWorker.js +++ /dev/null @@ -1,65 +0,0 @@ -const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; -const buildFilter = require('vn-loopback/util/filter').buildFilter; -const mergeFilters = require('vn-loopback/util/filter').mergeFilters; - -module.exports = Self => { - Self.remoteMethod('getItemTypeWorker', { - description: 'Returns the workers that appear in itemType', - accessType: 'READ', - accepts: [{ - arg: 'filter', - type: 'Object', - description: 'Filter defining where and paginated data', - required: true - }], - returns: { - type: ['object'], - root: true - }, - http: { - path: `/getItemTypeWorker`, - verb: 'GET' - } - }); - - Self.getItemTypeWorker = async(filter, options) => { - const myOptions = {}; - const conn = Self.dataSource.connector; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - const query = - `SELECT DISTINCT u.id, w.firstName, w.lastName, u.nickname, u.name - FROM itemType it - JOIN worker w ON w.id = it.workerFk - JOIN account.user u ON u.id = w.id`; - - let stmt = new ParameterizedSQL(query); - - let clientFilter = Object.assign({}, filter); - clientFilter.where = buildFilter(filter.where, (param, value) => { - switch (param) { - case 'role': - return {'r.name': value}; - case 'firstName': - return {or: [ - {'w.firstName': {like: `%${value}%`}}, - {'w.lastName': {like: `%${value}%`}}, - {'u.name': {like: `%${value}%`}}, - {'u.nickname': {like: `%${value}%`}} - ]}; - case 'id': - return {'w.id': value}; - } - }); - - let myFilter = { - where: {'u.active': true} - }; - - myFilter = mergeFilters(myFilter, clientFilter); - stmt.merge(conn.makeSuffix(myFilter)); - return conn.executeStmt(stmt); - }; -}; From 7312ed9cc4dbea12b624be248b786e29e2aa2052 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Jul 2023 09:56:07 +0200 Subject: [PATCH 19/42] refs #5244 fix back test --- .../methods/ticket-request/specs/getItemTypeWorkers.spec.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/ticket/back/methods/ticket-request/specs/getItemTypeWorkers.spec.js b/modules/ticket/back/methods/ticket-request/specs/getItemTypeWorkers.spec.js index ae5c508b6..c57451c26 100644 --- a/modules/ticket/back/methods/ticket-request/specs/getItemTypeWorkers.spec.js +++ b/modules/ticket/back/methods/ticket-request/specs/getItemTypeWorkers.spec.js @@ -1,12 +1,10 @@ const models = require('vn-loopback/server/server').models; describe('ticket-request getItemTypeWorker()', () => { - const ctx = {req: {accessToken: {userId: 18}}}; - it('should return the buyer as result', async() => { const filter = {where: {firstName: 'buyer'}}; - const result = await models.TicketRequest.getItemTypeWorker(ctx, filter); + const result = await models.TicketRequest.getItemTypeWorker(filter); expect(result.length).toEqual(1); }); @@ -14,7 +12,7 @@ describe('ticket-request getItemTypeWorker()', () => { it('should return the workers at itemType as result', async() => { const filter = {}; - const result = await models.TicketRequest.getItemTypeWorker(ctx, filter); + const result = await models.TicketRequest.getItemTypeWorker(filter); expect(result.length).toBeGreaterThan(1); }); From 2f27f32c45c64034f538b0feb1dad99f301cb388 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Jul 2023 11:26:48 +0200 Subject: [PATCH 20/42] refs #5244 fix: e2e --- e2e/helpers/extensions.js | 2 ++ e2e/helpers/selectors.js | 14 +++++++------- e2e/paths/05-ticket/05_tracking_state.spec.js | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index fe3ef08bd..b6ea32a6c 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -632,6 +632,7 @@ let actions = { await this.write(selector, value.toString()); break; case 'vn-autocomplete': + case 'vn-worker-autocomplete': if (value) await this.autocompleteSearch(selector, value.toString()); else @@ -667,6 +668,7 @@ let actions = { switch (tagName) { case 'vn-textfield': case 'vn-autocomplete': + case 'vn-worker-autocomplete': case 'vn-input-time': case 'vn-datalist': el = await input.$('input'); diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 977c8a837..3302280e3 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -187,7 +187,7 @@ export default { country: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.countryFk"]', userName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.userName"]', email: 'vn-client-create vn-textfield[ng-model="$ctrl.client.email"]', - salesPerson: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]', + salesPerson: 'vn-client-create vn-worker-autocomplete[ng-model="$ctrl.client.salesPersonFk"]', saveNewProvicenButton: '#saveProvince', saveNewCityButton: '#saveCity', saveNewPoscode: '#savePostcode', @@ -199,7 +199,7 @@ export default { email: 'vn-client-basic-data vn-textfield[ng-model="$ctrl.client.email"]', phone: 'vn-client-basic-data vn-textfield[ng-model="$ctrl.client.phone"]', mobile: 'vn-client-basic-data vn-textfield[ng-model="$ctrl.client.mobile"]', - salesPerson: 'vn-client-basic-data vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]', + salesPerson: 'vn-client-basic-data vn-worker-autocomplete[ng-model="$ctrl.client.salesPersonFk"]', channel: 'vn-client-basic-data vn-autocomplete[ng-model="$ctrl.client.contactChannelFk"]', transferor: 'vn-client-basic-data vn-autocomplete[ng-model="$ctrl.client.transferorFk"]', businessType: 'vn-client-basic-data vn-autocomplete[ng-model="$ctrl.client.businessTypeFk"]', @@ -735,7 +735,7 @@ export default { }, createStateView: { state: 'vn-autocomplete[ng-model="$ctrl.stateFk"]', - worker: 'vn-autocomplete[ng-model="$ctrl.workerFk"]', + worker: 'vn-worker-autocomplete[ng-model="$ctrl.workerFk"]', saveStateButton: `button[type=submit]` }, claimsIndex: { @@ -781,12 +781,12 @@ export default { firstClaimReason: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimReasonFk"]', firstClaimResult: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimResultFk"]', firstClaimResponsible: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimResponsibleFk"]', - firstClaimWorker: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.workerFk"]', + firstClaimWorker: 'vn-claim-development vn-horizontal:nth-child(1) vn-worker-autocomplete[ng-model="claimDevelopment.workerFk"]', firstClaimRedelivery: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimRedeliveryFk"]', secondClaimReason: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimReasonFk"]', secondClaimResult: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimResultFk"]', secondClaimResponsible: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimResponsibleFk"]', - secondClaimWorker: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.workerFk"]', + secondClaimWorker: 'vn-claim-development vn-horizontal:nth-child(2) vn-worker-autocomplete[ng-model="claimDevelopment.workerFk"]', secondClaimRedelivery: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimRedeliveryFk"]', saveDevelopmentButton: 'button[type=submit]' }, @@ -854,7 +854,7 @@ export default { }, createRouteView: { - worker: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.workerFk"]', + worker: 'vn-route-create vn-worker-autocomplete[ng-model="$ctrl.route.workerFk"]', createdDatePicker: 'vn-route-create vn-date-picker[ng-model="$ctrl.route.created"]', vehicleAuto: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.vehicleFk"]', agency: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.agencyModeFk"]', @@ -976,7 +976,7 @@ export default { street: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.street"]', user: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.name"]', email: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.email"]', - boss: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.bossFk"]', + boss: 'vn-worker-create vn-worker-autocomplete[ng-model="$ctrl.worker.bossFk"]', role: 'vn-worker-create vn-autocomplete[ng-model="$ctrl.worker.roleFk"]', iban: 'vn-worker-create vn-textfield[ng-model="$ctrl.worker.iban"]', createButton: 'vn-worker-create vn-submit[label="Create"]', diff --git a/e2e/paths/05-ticket/05_tracking_state.spec.js b/e2e/paths/05-ticket/05_tracking_state.spec.js index 949c9a8e6..9ac373287 100644 --- a/e2e/paths/05-ticket/05_tracking_state.spec.js +++ b/e2e/paths/05-ticket/05_tracking_state.spec.js @@ -59,7 +59,7 @@ describe('Ticket Create new tracking state path', () => { const result = await page .waitToGetProperty(selectors.createStateView.worker, 'value'); - expect(result).toEqual('salesPersonNick'); + expect(result).toEqual('salesPerson'); }); it(`should succesfully create a valid state`, async() => { From ea4190f15cd9227aece6361a981be22f8f7f665d Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 24 Jul 2023 13:32:28 +0200 Subject: [PATCH 21/42] refs #5216 update expedition state added --- .../expedition-state/updateExpeditionState.js | 71 +++++++++++++++++++ .../ticket/back/models/expedition-state.js | 1 + 2 files changed, 72 insertions(+) create mode 100644 modules/ticket/back/methods/expedition-state/updateExpeditionState.js diff --git a/modules/ticket/back/methods/expedition-state/updateExpeditionState.js b/modules/ticket/back/methods/expedition-state/updateExpeditionState.js new file mode 100644 index 000000000..ce5144d30 --- /dev/null +++ b/modules/ticket/back/methods/expedition-state/updateExpeditionState.js @@ -0,0 +1,71 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethod('updateExpedtionState', { + description: 'Update an expedition state', + accepts: [ + { + arg: 'expeditions', + type: [ + { + expeditionFk: 'number', + stateCode: 'string' + } + ], + required: true, + description: 'Array of objects containing expeditionFk and stateCode' + } + ], + http: { + path: `/updateExpeditionState`, + verb: 'post' + } + }); + + Self.updateExpedtionState = async(expeditions, options) => { + const models = Self.app.models; + let tx; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + if (expeditions.length === 0) + return false; + + const promises = []; + try { + const conn = Self.dataSource.connector; + for (const expedition of expeditions) { + const stmt = new ParameterizedSQL( + `SELECT id FROM vn.expeditionStateType WHERE code = ?`, + [expedition.stateCode] + ); + const result = await conn.query(stmt); + if (result.length === 0) + throw new Error(`The state code '${exp.stateCode}' does not exist.`); + + const typeFk = result[0].id; + + const newExpeditionState = await models.Self.create({ + expeditionFk: expedition.expeditionFk, + typeFk, + }); + } + + await Promise.all(promises); + + if (tx) await tx.commit(); + + return true; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/models/expedition-state.js b/modules/ticket/back/models/expedition-state.js index af76af718..041c57be6 100644 --- a/modules/ticket/back/models/expedition-state.js +++ b/modules/ticket/back/models/expedition-state.js @@ -1,3 +1,4 @@ module.exports = function(Self) { require('../methods/expedition-state/filter')(Self); + require('../methods/expedition-state/updateExpeditionState')(Self); }; From fa9dfdf411ef9028f04853567a07abefe790635e Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 25 Jul 2023 16:32:38 +0200 Subject: [PATCH 22/42] refs #5216 try ACL updateExpeditionState --- db/changes/233201/00-addExpeditionState.sql | 2 ++ .../{updateExpeditionState.js => addExpeditionState.js} | 5 +++-- modules/ticket/back/models/expedition-state.js | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 db/changes/233201/00-addExpeditionState.sql rename modules/ticket/back/methods/expedition-state/{updateExpeditionState.js => addExpeditionState.js} (92%) diff --git a/db/changes/233201/00-addExpeditionState.sql b/db/changes/233201/00-addExpeditionState.sql new file mode 100644 index 000000000..fb236b0c3 --- /dev/null +++ b/db/changes/233201/00-addExpeditionState.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) + VALUES ('ExpeditionState','addExpeditionState','WRITE','ALLOW','ROLE','delivery'); \ No newline at end of file diff --git a/modules/ticket/back/methods/expedition-state/updateExpeditionState.js b/modules/ticket/back/methods/expedition-state/addExpeditionState.js similarity index 92% rename from modules/ticket/back/methods/expedition-state/updateExpeditionState.js rename to modules/ticket/back/methods/expedition-state/addExpeditionState.js index ce5144d30..d22d7c676 100644 --- a/modules/ticket/back/methods/expedition-state/updateExpeditionState.js +++ b/modules/ticket/back/methods/expedition-state/addExpeditionState.js @@ -17,7 +17,7 @@ module.exports = Self => { } ], http: { - path: `/updateExpeditionState`, + path: `/addExpeditionState`, verb: 'post' } }); @@ -52,10 +52,11 @@ module.exports = Self => { const typeFk = result[0].id; - const newExpeditionState = await models.Self.create({ + const newExpeditionState = models.Self.create({ expeditionFk: expedition.expeditionFk, typeFk, }); + promises.push(newExpeditionState); } await Promise.all(promises); diff --git a/modules/ticket/back/models/expedition-state.js b/modules/ticket/back/models/expedition-state.js index 041c57be6..496dd88d3 100644 --- a/modules/ticket/back/models/expedition-state.js +++ b/modules/ticket/back/models/expedition-state.js @@ -1,4 +1,4 @@ module.exports = function(Self) { require('../methods/expedition-state/filter')(Self); - require('../methods/expedition-state/updateExpeditionState')(Self); + require('../methods/expedition-state/addExpeditionState')(Self); }; From bbc26d8ba4f9bd5b02d8c3981366ad6041a6b4c6 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 26 Jul 2023 12:36:30 +0200 Subject: [PATCH 23/42] WIP refs #5216 addExpeditionState --- .../expedition-state/addExpeditionState.js | 33 ++++++++----------- modules/ticket/back/model-config.json | 3 ++ .../back/models/expedition-state-type.js | 3 ++ .../back/models/expedition-state-type.json | 22 +++++++++++++ 4 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 modules/ticket/back/models/expedition-state-type.js create mode 100644 modules/ticket/back/models/expedition-state-type.json diff --git a/modules/ticket/back/methods/expedition-state/addExpeditionState.js b/modules/ticket/back/methods/expedition-state/addExpeditionState.js index d22d7c676..33a5ae552 100644 --- a/modules/ticket/back/methods/expedition-state/addExpeditionState.js +++ b/modules/ticket/back/methods/expedition-state/addExpeditionState.js @@ -1,17 +1,11 @@ -const UserError = require('vn-loopback/util/user-error'); - module.exports = Self => { - Self.remoteMethod('updateExpedtionState', { + Self.remoteMethod('addExpeditionState', { description: 'Update an expedition state', + accessType: 'WRITE', accepts: [ { arg: 'expeditions', - type: [ - { - expeditionFk: 'number', - stateCode: 'string' - } - ], + type: ['object'], required: true, description: 'Array of objects containing expeditionFk and stateCode' } @@ -23,6 +17,7 @@ module.exports = Self => { }); Self.updateExpedtionState = async(expeditions, options) => { + console.log('Expeditions!!!!!!!!', expeditions); const models = Self.app.models; let tx; const myOptions = {}; @@ -35,22 +30,22 @@ module.exports = Self => { myOptions.transaction = tx; } - if (expeditions.length === 0) - return false; - const promises = []; try { const conn = Self.dataSource.connector; for (const expedition of expeditions) { - const stmt = new ParameterizedSQL( - `SELECT id FROM vn.expeditionStateType WHERE code = ?`, - [expedition.stateCode] + const expeditionStateType = await models.expeditionStateType.findOne( + { + fields: ['id'], + where: {code: expedition.stateCode} + } ); - const result = await conn.query(stmt); - if (result.length === 0) - throw new Error(`The state code '${exp.stateCode}' does not exist.`); - const typeFk = result[0].id; + const result = await conn.query(stmt); + if (!expeditionStateType.id) + throw new Error(`The state code '${expedition.stateCode}' does not exist.`); + + const typeFk = result.id; const newExpeditionState = models.Self.create({ expeditionFk: expedition.expeditionFk, diff --git a/modules/ticket/back/model-config.json b/modules/ticket/back/model-config.json index 3c7e12eea..83d7303b7 100644 --- a/modules/ticket/back/model-config.json +++ b/modules/ticket/back/model-config.json @@ -20,6 +20,9 @@ "ExpeditionState": { "dataSource": "vn" }, + "ExpeditionStateType": { + "dataSource": "vn" + }, "Packaging": { "dataSource": "vn" }, diff --git a/modules/ticket/back/models/expedition-state-type.js b/modules/ticket/back/models/expedition-state-type.js new file mode 100644 index 000000000..f21b44940 --- /dev/null +++ b/modules/ticket/back/models/expedition-state-type.js @@ -0,0 +1,3 @@ +module.exports = function(Self) { + +}; diff --git a/modules/ticket/back/models/expedition-state-type.json b/modules/ticket/back/models/expedition-state-type.json new file mode 100644 index 000000000..70207568b --- /dev/null +++ b/modules/ticket/back/models/expedition-state-type.json @@ -0,0 +1,22 @@ +{ + "name": "ExpeditionStateType", + "base": "VnModel", + "options": { + "mysql": { + "table": "expeditionStateType" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "description": { + "type": "string" + }, + "code": { + "type": "string" + } + } +} \ No newline at end of file From 10361ba78e584735dd2b239f97cdbde036a93a93 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 26 Jul 2023 13:33:56 +0200 Subject: [PATCH 24/42] refs #5216 addExpeditionState refactored --- .../expedition-state/addExpeditionState.js | 27 ++++++++++--------- .../back/models/expedition-state-type.js | 3 --- 2 files changed, 14 insertions(+), 16 deletions(-) delete mode 100644 modules/ticket/back/models/expedition-state-type.js diff --git a/modules/ticket/back/methods/expedition-state/addExpeditionState.js b/modules/ticket/back/methods/expedition-state/addExpeditionState.js index 33a5ae552..16b7a4c75 100644 --- a/modules/ticket/back/methods/expedition-state/addExpeditionState.js +++ b/modules/ticket/back/methods/expedition-state/addExpeditionState.js @@ -5,23 +5,28 @@ module.exports = Self => { accepts: [ { arg: 'expeditions', - type: ['object'], + type: [{ + expeditionFk: 'number', + stateCode: 'string', + }], required: true, description: 'Array of objects containing expeditionFk and stateCode' } ], + returns: { + type: 'boolean', + root: true + }, http: { - path: `/addExpeditionState`, + path: `/addState`, verb: 'post' } }); - Self.updateExpedtionState = async(expeditions, options) => { - console.log('Expeditions!!!!!!!!', expeditions); + Self.addExpeditionState = async(expeditions, options) => { const models = Self.app.models; let tx; const myOptions = {}; - if (typeof options == 'object') Object.assign(myOptions, options); @@ -32,22 +37,19 @@ module.exports = Self => { const promises = []; try { - const conn = Self.dataSource.connector; for (const expedition of expeditions) { - const expeditionStateType = await models.expeditionStateType.findOne( + const expeditionStateType = await models.ExpeditionStateType.findOne( { fields: ['id'], where: {code: expedition.stateCode} } ); - const result = await conn.query(stmt); if (!expeditionStateType.id) throw new Error(`The state code '${expedition.stateCode}' does not exist.`); - const typeFk = result.id; - - const newExpeditionState = models.Self.create({ + const typeFk = expeditionStateType.id; + const newExpeditionState = models.ExpeditionState.create({ expeditionFk: expedition.expeditionFk, typeFk, }); @@ -57,11 +59,10 @@ module.exports = Self => { await Promise.all(promises); if (tx) await tx.commit(); - return true; } catch (e) { if (tx) await tx.rollback(); - throw e; + return false; } }; }; diff --git a/modules/ticket/back/models/expedition-state-type.js b/modules/ticket/back/models/expedition-state-type.js deleted file mode 100644 index f21b44940..000000000 --- a/modules/ticket/back/models/expedition-state-type.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = function(Self) { - -}; From 8d0b3efa113a3309ec22f389c95131c9792aa4a2 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 14 Aug 2023 09:39:40 +0200 Subject: [PATCH 25/42] refs #4815 feat:DeviceLog Model --- db/changes/233401/01-deviceLog_acl.sql | 6 ++++ modules/worker/back/model-config.json | 3 ++ modules/worker/back/models/device-log.json | 40 ++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 db/changes/233401/01-deviceLog_acl.sql create mode 100644 modules/worker/back/models/device-log.json diff --git a/db/changes/233401/01-deviceLog_acl.sql b/db/changes/233401/01-deviceLog_acl.sql new file mode 100644 index 000000000..dd8bc936b --- /dev/null +++ b/db/changes/233401/01-deviceLog_acl.sql @@ -0,0 +1,6 @@ + +ALTER TABLE vn.deviceLog ADD serialNumber varchar(45) DEFAULT NULL NULL; + +INSERT INTO `salix`.`ACL` ( model, property, accessType, permission, principalType, principalId) +VALUES( 'DeviceLog', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'); + diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index 60ec273a5..b261f895e 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -23,6 +23,9 @@ "Device": { "dataSource": "vn" }, + "DeviceLog": { + "dataSource": "vn" + }, "DeviceProduction": { "dataSource": "vn" }, diff --git a/modules/worker/back/models/device-log.json b/modules/worker/back/models/device-log.json new file mode 100644 index 000000000..9278b9038 --- /dev/null +++ b/modules/worker/back/models/device-log.json @@ -0,0 +1,40 @@ +{ + "name": "DeviceLog", + "base": "VnModel", + "options": { + "mysql": { + "table": "deviceLog" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + }, + "android_id": { + "type": "string" + }, + "userFk": { + "type": "number" + }, + "created": { + "type": "date" + }, + "nameApp": { + "type": "string" + }, + "versionApp": { + "type": "string" + }, + "deviceProductionFk": { + "type": "number" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userFk" + } + } +} From dad792cb76269af581c0664b518a4af2bf9a08c4 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 24 Aug 2023 07:40:37 +0200 Subject: [PATCH 26/42] refs #5244 move changes sql --- db/changes/{232601 => 233601}/00-aclWorker.sql | 0 db/changes/{232601 => 233601}/00-department.sql | 0 front/core/components/worker-autocomplete/index.js | 2 +- front/core/lib/event-emitter.js | 1 + modules/worker/back/methods/worker/search.js | 4 ++-- 5 files changed, 4 insertions(+), 3 deletions(-) rename db/changes/{232601 => 233601}/00-aclWorker.sql (100%) rename db/changes/{232601 => 233601}/00-department.sql (100%) diff --git a/db/changes/232601/00-aclWorker.sql b/db/changes/233601/00-aclWorker.sql similarity index 100% rename from db/changes/232601/00-aclWorker.sql rename to db/changes/233601/00-aclWorker.sql diff --git a/db/changes/232601/00-department.sql b/db/changes/233601/00-department.sql similarity index 100% rename from db/changes/232601/00-department.sql rename to db/changes/233601/00-department.sql diff --git a/front/core/components/worker-autocomplete/index.js b/front/core/components/worker-autocomplete/index.js index 24cc02797..70ca69e6e 100755 --- a/front/core/components/worker-autocomplete/index.js +++ b/front/core/components/worker-autocomplete/index.js @@ -16,7 +16,7 @@ export default class WorkerAutocomplete extends Autocomplete { } Object.assign(this, { label: 'Worker', - url: url, + url, searchFunction: function({$search}) { return {and: [ {'active': {neq: false}}, diff --git a/front/core/lib/event-emitter.js b/front/core/lib/event-emitter.js index 0e0ce1872..83e361253 100644 --- a/front/core/lib/event-emitter.js +++ b/front/core/lib/event-emitter.js @@ -83,3 +83,4 @@ export default class EventEmitter { } } } +EventEmitter.$inject = ['$element', '$scope']; diff --git a/modules/worker/back/methods/worker/search.js b/modules/worker/back/methods/worker/search.js index 50fe71235..cd0a466ea 100644 --- a/modules/worker/back/methods/worker/search.js +++ b/modules/worker/back/methods/worker/search.js @@ -3,11 +3,11 @@ const mergeFilters = require('vn-loopback/util/filter').mergeFilters; module.exports = Self => { Self.remoteMethodCtx('search', { - description: 'Returns an array of search from an specified worker', + description: 'Returns an array of search results for a specified worker', accepts: [{ arg: 'filter', type: 'object', - description: 'Filter defining where and paginated data', + description: 'Filter to define conditions and paginate the data.', required: true }, { From bda39374178e10aac5f3c0413629b707e228709d Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 24 Aug 2023 10:01:07 +0200 Subject: [PATCH 27/42] refs #5216 path replaced and test created --- .../expedition-state/addExpeditionState.js | 23 +++--- .../specs/addExpeditionState.spec.js | 75 +++++++++++++++++++ 2 files changed, 88 insertions(+), 10 deletions(-) create mode 100644 modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js diff --git a/modules/ticket/back/methods/expedition-state/addExpeditionState.js b/modules/ticket/back/methods/expedition-state/addExpeditionState.js index 16b7a4c75..cc70cbb8d 100644 --- a/modules/ticket/back/methods/expedition-state/addExpeditionState.js +++ b/modules/ticket/back/methods/expedition-state/addExpeditionState.js @@ -5,10 +5,7 @@ module.exports = Self => { accepts: [ { arg: 'expeditions', - type: [{ - expeditionFk: 'number', - stateCode: 'string', - }], + type: ['object'], required: true, description: 'Array of objects containing expeditionFk and stateCode' } @@ -18,7 +15,7 @@ module.exports = Self => { root: true }, http: { - path: `/addState`, + path: `/addExpeditionState`, verb: 'post' } }); @@ -44,11 +41,18 @@ module.exports = Self => { where: {code: expedition.stateCode} } ); - - if (!expeditionStateType.id) - throw new Error(`The state code '${expedition.stateCode}' does not exist.`); + if (!expeditionStateType) + throw new Error(`The state code: ${expedition.stateCode} does not exist.`); const typeFk = expeditionStateType.id; + + const existsExpedition = await models.Expedition.findOne({ + fields: ['id'], + where: {id: expedition.expeditionFk} + }); + if (!existsExpedition) + throw new Error(`The expedition with id: ${expedition.expeditionFk} does not exist.`); + const newExpeditionState = models.ExpeditionState.create({ expeditionFk: expedition.expeditionFk, typeFk, @@ -59,10 +63,9 @@ module.exports = Self => { await Promise.all(promises); if (tx) await tx.commit(); - return true; } catch (e) { if (tx) await tx.rollback(); - return false; + throw e; } }; }; diff --git a/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js b/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js new file mode 100644 index 000000000..c9c40ccd9 --- /dev/null +++ b/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js @@ -0,0 +1,75 @@ +const models = require('vn-loopback/server/server').models; + +describe('expeditionState addExpeditionState()', () => { + it('should update the expedition states', async() => { + const tx = await models.ExpeditionState.beginTransaction({}); + + try { + const options = {transaction: tx}; + const payload = [ + { + expeditionFk: 5, + stateCode: 'ON DELIVERY' + }, + ]; + + await models.ExpeditionState.addExpeditionState(payload, options); + + const expeditionState = await models.ExpeditionState.findOne({ + where: {id: 5} + }); + + expect(expeditionState.typeFk).toEqual(1); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should throw an error an error when an stateCode does not exist', async() => { + const tx = await models.ExpeditionState.beginTransaction({}); + let error; + + try { + const options = {transaction: tx}; + const payload = [ + { + expeditionFk: 2, + stateCode: 'DUMMY' + } + ]; + await models.ExpeditionState.addExpeditionState(payload, options); + + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error.message).toContain('The state code: DUMMY does not exist.'); + }); + + it('should throw an error when expeditionFk does not exist', async() => { + const tx = await models.ExpeditionState.beginTransaction({}); + let error; + try { + const options = {transaction: tx}; + const payload = [ + { + expeditionFk: 50, + stateCode: 'LOST' + } + ]; + + await models.ExpeditionState.addExpeditionState(payload, options); + + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error.message).toContain('The expedition with id: 50 does not exist.'); + }); +}); From b5b7770f3f19cbea1d63d5806cd790bfeeb48ede Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 24 Aug 2023 10:41:28 +0200 Subject: [PATCH 28/42] refs #6146 fixes: muestra la agencia de la ruta --- .../back/methods/route/getSuggestedTickets.js | 19 +++++++++++++++++-- modules/route/front/ticket-popup/index.html | 12 ++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/modules/route/back/methods/route/getSuggestedTickets.js b/modules/route/back/methods/route/getSuggestedTickets.js index c1a9c7cae..e1b90d359 100644 --- a/modules/route/back/methods/route/getSuggestedTickets.js +++ b/modules/route/back/methods/route/getSuggestedTickets.js @@ -24,7 +24,14 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const route = await Self.app.models.Route.findById(id, null, myOptions); + const route = await Self.app.models.Route.findById(id, { + include: { + relation: 'agencyMode', + scope: { + fields: ['name'] + } + } + }, myOptions); const zoneAgencyModes = await Self.app.models.ZoneAgencyMode.find({ where: { @@ -35,11 +42,13 @@ module.exports = Self => { const zoneIds = []; for (let zoneAgencyMode of zoneAgencyModes) zoneIds.push(zoneAgencyMode.zoneFk); + const minDate = new Date(route.created); minDate.setHours(0, 0, 0, 0); const maxDate = new Date(route.created); maxDate.setHours(23, 59, 59, 59); + let tickets = await Self.app.models.Ticket.find({ where: { zoneFk: {inq: zoneIds}, @@ -80,6 +89,12 @@ module.exports = Self => { ] }, myOptions); - return tickets; + return tickets.map(ticket => { + const simpleTicket = ticket.toJSON(); + return { + ...simpleTicket, + agencyName: route.agencyMode().name + }; + }); }; }; diff --git a/modules/route/front/ticket-popup/index.html b/modules/route/front/ticket-popup/index.html index 99e3364b8..5046d5e43 100644 --- a/modules/route/front/ticket-popup/index.html +++ b/modules/route/front/ticket-popup/index.html @@ -19,17 +19,17 @@ - Ticket Client Province - + - Population - + Population + PC Address @@ -39,7 +39,7 @@ - @@ -62,7 +62,7 @@ From 4c1d9cd7679242392237b511efd5171ee892c346 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 24 Aug 2023 11:32:20 +0200 Subject: [PATCH 29/42] hotFix(priceDifference): import UserError --- modules/ticket/back/methods/ticket/priceDifference.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/ticket/back/methods/ticket/priceDifference.js b/modules/ticket/back/methods/ticket/priceDifference.js index 495e9e1aa..7dc85bd3d 100644 --- a/modules/ticket/back/methods/ticket/priceDifference.js +++ b/modules/ticket/back/methods/ticket/priceDifference.js @@ -1,3 +1,5 @@ +const UserError = require('vn-loopback/util/user-error'); + module.exports = Self => { Self.remoteMethodCtx('priceDifference', { description: 'Returns sales with price difference if the ticket is editable', From 386de69bceb91c9fc6adeea666cf2b842fd31c96 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 24 Aug 2023 12:47:10 +0200 Subject: [PATCH 30/42] refs #5216 fix error handling --- .../00-addExpeditionState.sql | 0 .../expedition-state/addExpeditionState.js | 25 ++++++++----------- .../specs/addExpeditionState.spec.js | 6 ++--- 3 files changed, 13 insertions(+), 18 deletions(-) rename db/changes/{233201 => 233601}/00-addExpeditionState.sql (100%) diff --git a/db/changes/233201/00-addExpeditionState.sql b/db/changes/233601/00-addExpeditionState.sql similarity index 100% rename from db/changes/233201/00-addExpeditionState.sql rename to db/changes/233601/00-addExpeditionState.sql diff --git a/modules/ticket/back/methods/expedition-state/addExpeditionState.js b/modules/ticket/back/methods/expedition-state/addExpeditionState.js index cc70cbb8d..e82d279b0 100644 --- a/modules/ticket/back/methods/expedition-state/addExpeditionState.js +++ b/modules/ticket/back/methods/expedition-state/addExpeditionState.js @@ -1,3 +1,5 @@ +const UserError = require('vn-loopback/util/user-error'); + module.exports = Self => { Self.remoteMethod('addExpeditionState', { description: 'Update an expedition state', @@ -31,8 +33,7 @@ module.exports = Self => { tx = await Self.beginTransaction({}); myOptions.transaction = tx; } - - const promises = []; + let expeditionId; try { for (const expedition of expeditions) { const expeditionStateType = await models.ExpeditionStateType.findOne( @@ -42,30 +43,24 @@ module.exports = Self => { } ); if (!expeditionStateType) - throw new Error(`The state code: ${expedition.stateCode} does not exist.`); + throw new UserError(`Invalid state code: ${expedition.stateCode}.`); const typeFk = expeditionStateType.id; + expeditionId = expedition.expeditionFk; - const existsExpedition = await models.Expedition.findOne({ - fields: ['id'], - where: {id: expedition.expeditionFk} - }); - if (!existsExpedition) - throw new Error(`The expedition with id: ${expedition.expeditionFk} does not exist.`); - - const newExpeditionState = models.ExpeditionState.create({ + await models.ExpeditionState.create({ expeditionFk: expedition.expeditionFk, typeFk, }); - promises.push(newExpeditionState); } - await Promise.all(promises); - if (tx) await tx.commit(); } catch (e) { if (tx) await tx.rollback(); - throw e; + if (e instanceof UserError) + throw e; + + throw new UserError(`Invalid expedition id: ${expeditionId}.`); } }; }; diff --git a/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js b/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js index c9c40ccd9..819a43a60 100644 --- a/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js +++ b/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js @@ -8,7 +8,7 @@ describe('expeditionState addExpeditionState()', () => { const options = {transaction: tx}; const payload = [ { - expeditionFk: 5, + expeditionFk: 8, stateCode: 'ON DELIVERY' }, ]; @@ -47,7 +47,7 @@ describe('expeditionState addExpeditionState()', () => { await tx.rollback(); } - expect(error.message).toContain('The state code: DUMMY does not exist.'); + expect(error.message).toContain('Invalid state code: DUMMY.'); }); it('should throw an error when expeditionFk does not exist', async() => { @@ -70,6 +70,6 @@ describe('expeditionState addExpeditionState()', () => { await tx.rollback(); } - expect(error.message).toContain('The expedition with id: 50 does not exist.'); + expect(error.message).toContain('Invalid expedition id: 50.'); }); }); From 7e0865e4b7feb0d1fe7f20b5e726c07c14cdeddd Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 25 Aug 2023 08:01:11 +0200 Subject: [PATCH 31/42] refs #5941 feat(sendToSupport): don't show the button if it doesn't have token --- front/core/components/snackbar/snackbar.js | 2 +- front/core/components/support-dialog/index.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/front/core/components/snackbar/snackbar.js b/front/core/components/snackbar/snackbar.js index 7f4583188..b380c47c3 100644 --- a/front/core/components/snackbar/snackbar.js +++ b/front/core/components/snackbar/snackbar.js @@ -27,7 +27,7 @@ export default class Controller extends Component { setTimeout(() => element.classList.add('shown'), 30); shape.element = element; - if (data.additionalData) { + if (data.additionalData && this.vnToken.token) { this.additionalData = data.additionalData; let supportButton = document.createElement('i'); supportButton.setAttribute('class', 'material-icons clickable'); diff --git a/front/core/components/support-dialog/index.js b/front/core/components/support-dialog/index.js index eaaab047f..d15c14b4a 100644 --- a/front/core/components/support-dialog/index.js +++ b/front/core/components/support-dialog/index.js @@ -7,12 +7,15 @@ export default class Controller extends Dialog { } responseHandler(response) { + if (response !== 'accept') + return super.responseHandler(response); + this.$http.post('Ostickets/send-to-support', { reason: this.reason, additionalData: this.additionalData }) - .then(() => super.responseHandler(response)) - .then(() => this.vnApp.showSuccess(this.$t('Email sended!'))); + .then(() => super.responseHandler(response)) + .then(() => this.vnApp.showSuccess(this.$t('Email sended!'))); } } From ca28d2d78f662ae7b8da8c87d2a848d20f8ef115 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 25 Aug 2023 14:37:32 +0200 Subject: [PATCH 32/42] ref #5216 myOptions added --- .../back/methods/expedition-state/addExpeditionState.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/expedition-state/addExpeditionState.js b/modules/ticket/back/methods/expedition-state/addExpeditionState.js index e82d279b0..f1199f188 100644 --- a/modules/ticket/back/methods/expedition-state/addExpeditionState.js +++ b/modules/ticket/back/methods/expedition-state/addExpeditionState.js @@ -40,7 +40,7 @@ module.exports = Self => { { fields: ['id'], where: {code: expedition.stateCode} - } + }, myOptions ); if (!expeditionStateType) throw new UserError(`Invalid state code: ${expedition.stateCode}.`); @@ -51,7 +51,7 @@ module.exports = Self => { await models.ExpeditionState.create({ expeditionFk: expedition.expeditionFk, typeFk, - }); + }, myOptions); } if (tx) await tx.commit(); From de8aba289a39895354938c0dab594f5085ca09a1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 28 Aug 2023 10:36:29 +0200 Subject: [PATCH 33/42] refs #5991 Deleted view currentWorkersStats --- db/export-structure.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/db/export-structure.sh b/db/export-structure.sh index a6888f2ac..0fb413a97 100755 --- a/db/export-structure.sh +++ b/db/export-structure.sh @@ -23,7 +23,6 @@ IGNORETABLES=( --ignore-table=bs.productionIndicators --ignore-table=bs.VentasPorCliente --ignore-table=bs.v_ventas - --ignore-table=postgresql.currentWorkersStats --ignore-table=vn.accounting__ --ignore-table=vn.agencyModeZone --ignore-table=vn.agencyProvince From 7848634bff0e605674d52927a44431474d071a58 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 28 Aug 2023 11:51:25 +0200 Subject: [PATCH 34/42] refs #5300 Deleted postgresql dependences --- db/export-data.sh | 7 ------- db/export-structure.sh | 1 - 2 files changed, 8 deletions(-) diff --git a/db/export-data.sh b/db/export-data.sh index 59edf6ebc..7d346b235 100755 --- a/db/export-data.sh +++ b/db/export-data.sh @@ -97,13 +97,6 @@ TABLES=( ) dump_tables ${TABLES[@]} -TABLES=( - postgresql - labour_agreement - media_type -) -dump_tables ${TABLES[@]} - TABLES=( sage TiposIva diff --git a/db/export-structure.sh b/db/export-structure.sh index 0fb413a97..4ecbfa7e8 100755 --- a/db/export-structure.sh +++ b/db/export-structure.sh @@ -7,7 +7,6 @@ SCHEMAS=( edi hedera pbx - postgresql sage salix stock From 4d802182f56528710d6e5044ad7331b846d3dbbd Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 28 Aug 2023 11:59:45 +0200 Subject: [PATCH 35/42] refs #5300 calendar_employee depend. (refs #5378) --- db/tests/vn/workerTimeControlCheck.spec.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/db/tests/vn/workerTimeControlCheck.spec.js b/db/tests/vn/workerTimeControlCheck.spec.js index 9140628e6..65f5db129 100644 --- a/db/tests/vn/workerTimeControlCheck.spec.js +++ b/db/tests/vn/workerTimeControlCheck.spec.js @@ -239,12 +239,6 @@ xdescribe('worker workerTimeControl_check()', () => { stmts.push('START TRANSACTION'); - stmt = new ParameterizedSQL(`INSERT INTO postgresql.calendar_employee(businessFk,calendar_state_id,date) - VALUES - (?,1,CURDATE())`, [ - workerId - ]); - stmts.push(stmt); stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) VALUES (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), From f38ff9ef9cffe2c6b352aab5b086a589a6d2fb90 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 28 Aug 2023 12:00:35 +0200 Subject: [PATCH 36/42] refs #5300 calendar_employee depend. (refs #5378) --- db/tests/vn/workerTimeControlCheck.spec.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/tests/vn/workerTimeControlCheck.spec.js b/db/tests/vn/workerTimeControlCheck.spec.js index 65f5db129..0ca1429d4 100644 --- a/db/tests/vn/workerTimeControlCheck.spec.js +++ b/db/tests/vn/workerTimeControlCheck.spec.js @@ -54,7 +54,6 @@ xdescribe('worker workerTimeControl_check()', () => { }); it('should throw an error if the worker with a special category has not finished the 9h break', async() => { - // dayBreak to 9h in postgresql.professional_category const workerId = 1110; const tabletId = 1; let stmts = []; @@ -91,7 +90,6 @@ xdescribe('worker workerTimeControl_check()', () => { }); it('should check f the worker with a special category has finished the 9h break', async() => { - // dayBreak to 9h in postgresql.professional_category const workerId = 1110; const tabletId = 1; let stmts = []; From b1978b07bd513b82058892bd84084168b0719539 Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 31 Aug 2023 11:06:47 +0200 Subject: [PATCH 37/42] changes path desactualizado --- db/changes/{233201 => 233601}/00-saleGroupDetail.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/changes/{233201 => 233601}/00-saleGroupDetail.sql (100%) diff --git a/db/changes/233201/00-saleGroupDetail.sql b/db/changes/233601/00-saleGroupDetail.sql similarity index 100% rename from db/changes/233201/00-saleGroupDetail.sql rename to db/changes/233601/00-saleGroupDetail.sql From 4eeae466831541f07ef1b8b0f2443383802753de Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 31 Aug 2023 11:28:37 +0200 Subject: [PATCH 38/42] post subida --- CHANGELOG.md | 8 ++++++++ db/changes/233801/.gitkeep | 0 package.json | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/changes/233801/.gitkeep diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b3c43005..0cb94fc66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2338.01] - 2023-09-21 + +### Added + +### Changed + +### Fixed + ## [2336.01] - 2023-09-07 ### Added diff --git a/db/changes/233801/.gitkeep b/db/changes/233801/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/package.json b/package.json index dd833a8ad..44a651af4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "23.36.01", + "version": "23.38.01", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From e7cd052199f1df73342d47631c8fd8ea5c4e2110 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 31 Aug 2023 13:49:00 +0200 Subject: [PATCH 39/42] refs #6132 add messageError --- loopback/locale/en.json | 3 ++- loopback/locale/es.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 46b48e2ea..5d2b7ab03 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -185,5 +185,6 @@ "You don't have enough privileges.": "You don't have enough privileges.", "This ticket is locked.": "This ticket is locked.", "This ticket is not editable.": "This ticket is not editable.", - "The ticket doesn't exist.": "The ticket doesn't exist." + "The ticket doesn't exist.": "The ticket doesn't exist.", + "Ticket without Route": "Ticket without route" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 195b683ad..ccd63e0ff 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -315,5 +315,6 @@ "This ticket is not editable.": "Este ticket no es editable.", "The ticket doesn't exist.": "No existe el ticket.", "Social name should be uppercase": "La razón social debe ir en mayúscula", - "Street should be uppercase": "La dirección fiscal debe ir en mayúscula" + "Street should be uppercase": "La dirección fiscal debe ir en mayúscula", + "Ticket without Route": "Ticket sin ruta" } From 7d8828e6043a8e97ef28108907c7485b2fdcb822 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 31 Aug 2023 13:50:31 +0200 Subject: [PATCH 40/42] refs #6132 fix: saveSign without route --- modules/ticket/back/methods/ticket/saveSign.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index 55d2e3281..9888328e7 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -93,6 +93,8 @@ module.exports = Self => { }, myOptions); const dmsType = await models.DmsType.findOne({where: {code: 'Ticket'}, fields: ['id']}, myOptions); const ctxUploadFile = Object.assign({}, ctx); + if (ticket.route() === null) + throw new UserError('Ticket without route'); ctxUploadFile.args = { warehouseId: ticket.warehouseFk, companyId: ticket.companyFk, From 281ae0eb0477e8c55a84f58024e4fa038b47bdc7 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 1 Sep 2023 07:21:15 +0200 Subject: [PATCH 41/42] refs #4815 feat:DeviceLogModel --- db/changes/233401/01-deviceLog_acl.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/changes/233401/01-deviceLog_acl.sql b/db/changes/233401/01-deviceLog_acl.sql index dd8bc936b..7b7becf58 100644 --- a/db/changes/233401/01-deviceLog_acl.sql +++ b/db/changes/233401/01-deviceLog_acl.sql @@ -1,6 +1,6 @@ -ALTER TABLE vn.deviceLog ADD serialNumber varchar(45) DEFAULT NULL NULL; +ALTER TABLE `vn`.`deviceLog`ADD serialNumber varchar(45) DEFAULT NULL NULL; INSERT INTO `salix`.`ACL` ( model, property, accessType, permission, principalType, principalId) -VALUES( 'DeviceLog', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'); +VALUES( 'DeviceLog', 'create', 'WRITE', 'ALLOW', 'ROLE', 'employee'); From 473e710d1b825f229ee940e36625794323dcfc22 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 1 Sep 2023 07:22:15 +0200 Subject: [PATCH 42/42] refs #4815 feat:DeviceLogModel --- db/changes/233401/01-deviceLog_acl.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/changes/233401/01-deviceLog_acl.sql b/db/changes/233401/01-deviceLog_acl.sql index 7b7becf58..ebe3f8ed5 100644 --- a/db/changes/233401/01-deviceLog_acl.sql +++ b/db/changes/233401/01-deviceLog_acl.sql @@ -1,5 +1,5 @@ -ALTER TABLE `vn`.`deviceLog`ADD serialNumber varchar(45) DEFAULT NULL NULL; +ALTER TABLE `vn`.`deviceLog` ADD serialNumber varchar(45) DEFAULT NULL NULL; INSERT INTO `salix`.`ACL` ( model, property, accessType, permission, principalType, principalId) VALUES( 'DeviceLog', 'create', 'WRITE', 'ALLOW', 'ROLE', 'employee');