From fde76cdd28e851bf3acc4544c09a7582006b576c Mon Sep 17 00:00:00 2001 From: Gerard Date: Wed, 19 Dec 2018 11:20:17 +0100 Subject: [PATCH 1/9] #918 item.tag rellenar el color secundario gris no lo guarda --- client/item/src/tags/index.html | 13 ++-- client/item/src/tags/index.js | 44 ++++++++++--- client/item/src/tags/index.spec.js | 65 ++++++++++++------- .../common/methods/item-tag/filterItemTags.js | 21 +++++- .../item-tag/specs/filterItemTags.spec.js | 6 +- 5 files changed, 103 insertions(+), 46 deletions(-) diff --git a/client/item/src/tags/index.html b/client/item/src/tags/index.html index fac558db6..3f90b7428 100644 --- a/client/item/src/tags/index.html +++ b/client/item/src/tags/index.html @@ -5,11 +5,12 @@ link="{itemFk: $ctrl.$stateParams.id}" include="$ctrl.include" order="priority ASC" - data="itemTags"> + on-row-change="$ctrl.getSourceTable(obj)" + data="$ctrl.itemTags"> Tags - + { + this.getSourceTable(tag); + }); + + this._itemTags = value; + } + } + + get itemTags() { + return this._itemTags; + } + + getSourceTable(obj) { + let sourceTable; + this.sourceTables[obj.id] = {}; + let tag = obj.tag; + + if (!tag || !tag.sourceTable && (tag.isFree === true || tag.isFree === undefined)) + sourceTable = null; + else if (tag.sourceTable) { + sourceTable = '/api/' + tag.sourceTable.charAt(0).toUpperCase() + + tag.sourceTable.substring(1) + 's'; + this.sourceTables[obj.id].field = 'name'; + } else { + sourceTable = `/api/ItemTags/filterItemTags/${tag.id}`; + this.sourceTables[obj.id].field = 'value'; + } + + this.sourceTables[obj.id].url = sourceTable; } add() { @@ -28,16 +62,6 @@ class Controller { return max + 1; } - getSourceTable(selection) { - if (!selection || selection.isFree === true) - return null; - if (selection.sourceTable) { - return '/api/' + selection.sourceTable.charAt(0).toUpperCase() + - selection.sourceTable.substring(1) + 's'; - } else if (selection.sourceTable == null) - return `/api/ItemTags/filterItemTags/${selection.id}`; - } - onSubmit() { this.$scope.watcher.check(); this.$scope.model.save().then(() => { diff --git a/client/item/src/tags/index.spec.js b/client/item/src/tags/index.spec.js index 21b6879c0..647ee2dba 100644 --- a/client/item/src/tags/index.spec.js +++ b/client/item/src/tags/index.spec.js @@ -1,7 +1,7 @@ import './index.js'; import {crudModel} from '../../../helpers/crudModelHelper'; -describe('Item', () => { +fdescribe('Item', () => { describe('Component vnItemTags', () => { let $componentController; let $scope; @@ -19,6 +19,46 @@ describe('Item', () => { controller = $componentController('vnItemTags', {$scope}); })); + describe('itemTags setter', () => { + it('should call getSourceTable one time for each element in the value array', () => { + spyOn(controller, 'getSourceTable'); + let itemTags = [ + {id: 1}, + {id: 2}, + {id: 3}, + {id: 4} + ]; + + controller.itemTags = itemTags; + + expect(controller.getSourceTable.calls.count()).toEqual(4); + expect(controller.itemTags).toEqual(itemTags); + }); + }); + + describe('getSourceTable', () => { + it('should return null when the property isFree equals true', () => { + let tag = {id: 1}; + controller.getSourceTable(tag); + + expect(controller.sourceTables[1].url).toBe(null); + }); + + it('should return the route of the model in loopback with the first char of the string uppercase and adding a s', () => { + let tag = {id: 1, tag: {sourceTable: 'ink'}}; + controller.getSourceTable(tag); + + expect(controller.sourceTables[1].url).toBe('/api/Inks'); + }); + + it('should return the route filteritemtags with the id of the selection', () => { + let tag = {id: 1, tag: {id: 3, sourceTable: null, isFree: false}}; + controller.getSourceTable(tag); + + expect(controller.sourceTables[1].url).toBe('/api/ItemTags/filterItemTags/3'); + }); + }); + describe('getHighestPriority', () => { it('should return the highest priority value + 1 from the array', () => { let result = controller.getHighestPriority(); @@ -33,28 +73,5 @@ describe('Item', () => { expect(result).toEqual(1); }); }); - - describe('getSourceTable', () => { - it('should return null when the property isFree equals true', () => { - let selection = {isFree: true}; - let result = controller.getSourceTable(selection); - - expect(result).toBe(null); - }); - - it('should return the route of the model in loopback with the first char of the string uppercase and adding a s', () => { - let selection = {sourceTable: "ink"}; - let result = controller.getSourceTable(selection); - - expect(result).toBe("/api/Inks"); - }); - - it('should return the route filteritemtags with the id of the selection', () => { - let selection = {id: 3, sourceTable: null, isFree: false}; - let result = controller.getSourceTable(selection); - - expect(result).toBe("/api/ItemTags/filterItemTags/3"); - }); - }); }); }); diff --git a/services/loopback/common/methods/item-tag/filterItemTags.js b/services/loopback/common/methods/item-tag/filterItemTags.js index 8e6b3665f..8aac14374 100644 --- a/services/loopback/common/methods/item-tag/filterItemTags.js +++ b/services/loopback/common/methods/item-tag/filterItemTags.js @@ -1,3 +1,6 @@ +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; +const mergeFilters = require('../../filter.js').mergeFilters; + module.exports = Self => { Self.remoteMethod('filterItemTags', { description: 'Returns the distinct values of a tag property', @@ -8,6 +11,10 @@ module.exports = Self => { required: true, description: 'The foreign key from tag table', http: {source: 'path'} + }, { + arg: 'filter', + type: 'Object', + description: `Filter defining where, order, offset, and limit - must be a JSON-encoded string` }], returns: { root: true, @@ -19,8 +26,16 @@ module.exports = Self => { } }); - Self.filterItemTags = async tagFk => { - let query = `SELECT DISTINCT(value) AS name FROM vn.itemTag WHERE tagFk = ?`; - return await Self.rawSql(query, [tagFk]); + Self.filterItemTags = async (tagFk, filter) => { + let conn = Self.dataSource.connector; + let where = {tagFk: tagFk}; + myFilter = mergeFilters(filter, {where}); + + stmt = new ParameterizedSQL( + `SELECT DISTINCT(value) + FROM itemTag`); + stmt.merge(conn.makeSuffix(myFilter)); + + return await conn.executeStmt(stmt); }; }; diff --git a/services/loopback/common/methods/item-tag/specs/filterItemTags.spec.js b/services/loopback/common/methods/item-tag/specs/filterItemTags.spec.js index a45e7e51b..4ae12c6db 100644 --- a/services/loopback/common/methods/item-tag/specs/filterItemTags.spec.js +++ b/services/loopback/common/methods/item-tag/specs/filterItemTags.spec.js @@ -1,9 +1,9 @@ const app = require(`${servicesDir}/item/server/server`); describe('item filterItemTags()', () => { - it('should call the filterItemTags method', async() => { - let [result] = await app.models.ItemTag.filterItemTags(1); + it('should filter ItemTags table', async () => { + let [result] = await app.models.ItemTag.filterItemTags(1, {}); - expect(result.name).toEqual('Blue'); + expect(result.value).toEqual('Blue'); }); }); From 062fd39e92b141c8e8f6acf8f33ceb8239f551b4 Mon Sep 17 00:00:00 2001 From: Gerard Date: Wed, 19 Dec 2018 11:22:16 +0100 Subject: [PATCH 2/9] =?UTF-8?q?#922=20Cambiar=20el=20nombre=20de=20la=20se?= =?UTF-8?q?cci=C3=B3n=20client.risk=20de=20Riesgo=20a=20Balance?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client/routes.json | 2 +- client/client/src/risk/index/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/client/routes.json b/client/client/routes.json index ca5f629e5..808e5af41 100644 --- a/client/client/routes.json +++ b/client/client/routes.json @@ -189,7 +189,7 @@ "url": "/index", "state": "client.card.risk.index", "component": "vn-client-risk-index", - "description": "Risk", + "description": "Balance", "params": { "client": "$ctrl.client" } diff --git a/client/client/src/risk/index/index.html b/client/client/src/risk/index/index.html index 239f22ca4..936dab9de 100644 --- a/client/client/src/risk/index/index.html +++ b/client/client/src/risk/index/index.html @@ -15,7 +15,7 @@ - Risk + Balance Date: Wed, 19 Dec 2018 11:37:30 +0100 Subject: [PATCH 3/9] fixed styles --- client/item/src/summary/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/item/src/summary/index.html b/client/item/src/summary/index.html index 62f363694..f7f6f0d8d 100644 --- a/client/item/src/summary/index.html +++ b/client/item/src/summary/index.html @@ -1,7 +1,7 @@ - + - +
{{$ctrl.item.id}}
From 6c6d5cd8c1532585cc1217102f7fa48eb111b677 Mon Sep 17 00:00:00 2001 From: Gerard Date: Wed, 19 Dec 2018 15:59:35 +0100 Subject: [PATCH 4/9] #877 Establecer propiedad autoLoad del crud-model por defecto a false --- client/client/src/address/edit/index.html | 6 ++++-- client/client/src/address/index/index.html | 3 ++- client/client/src/contact/index.html | 3 ++- client/client/src/note/index/index.html | 3 ++- client/core/src/components/crud-model/crud-model.js | 2 +- client/item/src/barcode/index.html | 3 ++- client/item/src/create/index.html | 2 +- client/item/src/niche/index.html | 3 ++- client/item/src/tags/index.html | 6 ++++-- client/item/src/tax/index.html | 3 ++- client/ticket/src/component/index.html | 3 ++- client/ticket/src/note/index.html | 6 ++++-- client/ticket/src/package/index.html | 3 ++- client/ticket/src/picture/index.html | 3 ++- client/ticket/src/services/index.html | 3 ++- 15 files changed, 34 insertions(+), 18 deletions(-) diff --git a/client/client/src/address/edit/index.html b/client/client/src/address/edit/index.html index ef7966e08..c20c4146e 100644 --- a/client/client/src/address/edit/index.html +++ b/client/client/src/address/edit/index.html @@ -16,12 +16,14 @@ url="/client/api/AddressObservations" fields="['id', 'addressFk', 'observationTypeFk', 'description']" link="{addressFk: $ctrl.$stateParams.addressId}" - data="observations"> + data="observations" + auto-load="true">
+ data="types" + auto-load="true">
diff --git a/client/client/src/address/index/index.html b/client/client/src/address/index/index.html index 4b859445c..b9e60c2e2 100644 --- a/client/client/src/address/index/index.html +++ b/client/client/src/address/index/index.html @@ -3,7 +3,8 @@ url="/client/api/Addresses" filter="::$ctrl.filter" link="{clientFk: $ctrl.$stateParams.id}" - data="addresses"> + data="addresses" + auto-load="true"> diff --git a/client/client/src/contact/index.html b/client/client/src/contact/index.html index 7678beaab..8838c2d17 100644 --- a/client/client/src/contact/index.html +++ b/client/client/src/contact/index.html @@ -3,7 +3,8 @@ url="/client/api/ClientContacts" fields="['id', 'name', 'phone', 'clientFk']" link="{clientFk: $ctrl.$stateParams.id}" - data="contacts"> + data="contacts" + auto-load="true"> + data="notes" + auto-load="true"> diff --git a/client/core/src/components/crud-model/crud-model.js b/client/core/src/components/crud-model/crud-model.js index 62115f55a..5a0f8d5d2 100644 --- a/client/core/src/components/crud-model/crud-model.js +++ b/client/core/src/components/crud-model/crud-model.js @@ -13,7 +13,7 @@ export default class CrudModel extends ModelProxy { this.$http = $http; this.$q = $q; this.primaryKey = 'id'; - this.autoLoad = true; + this.autoLoad = false; } $onInit() { diff --git a/client/item/src/barcode/index.html b/client/item/src/barcode/index.html index 406e81eff..416d04b5b 100644 --- a/client/item/src/barcode/index.html +++ b/client/item/src/barcode/index.html @@ -3,7 +3,8 @@ url="/item/api/ItemBarcodes" fields="['id', 'itemFk', 'code']" link="{itemFk: $ctrl.$stateParams.id}" - data="barcodes"> + data="barcodes" + auto-load="true"> + + data="niches" + auto-load="true"> + data="$ctrl.itemTags" + auto-load="true"> + data="tags" + auto-load="true"> diff --git a/client/item/src/tax/index.html b/client/item/src/tax/index.html index 69f7e0f4a..75963852a 100644 --- a/client/item/src/tax/index.html +++ b/client/item/src/tax/index.html @@ -1,7 +1,8 @@ + data="classes" + auto-load="true"> diff --git a/client/ticket/src/component/index.html b/client/ticket/src/component/index.html index 4664f9093..a6d0dcd22 100644 --- a/client/ticket/src/component/index.html +++ b/client/ticket/src/component/index.html @@ -3,7 +3,8 @@ url="/ticket/api/Sales" link="{ticketFk: $ctrl.$stateParams.id}" filter="::$ctrl.filter" - data="components"> + data="components" + auto-load="true"> diff --git a/client/ticket/src/note/index.html b/client/ticket/src/note/index.html index 67a84623e..8e79d53af 100644 --- a/client/ticket/src/note/index.html +++ b/client/ticket/src/note/index.html @@ -3,11 +3,13 @@ url="/ticket/api/TicketObservations" fields="['id', 'ticketFk', 'observationTypeFk', 'description']" link="{ticketFk: $ctrl.$stateParams.id}" - data="observations"> + data="observations" + auto-load="true"> + data="observationTypes" + auto-load="true"> + data="packages" on-data-change="$ctrl.onDataChange()" + auto-load="true"> + data="sales" + auto-load="true"> diff --git a/client/ticket/src/services/index.html b/client/ticket/src/services/index.html index b8e37668a..d8820aab8 100644 --- a/client/ticket/src/services/index.html +++ b/client/ticket/src/services/index.html @@ -2,7 +2,8 @@ vn-id="model" url="/ticket/api/TicketServices" link="{ticketFk: $ctrl.$stateParams.id}" - data="services" on-data-change="$ctrl.onDataChange()"> + data="services" + auto-load="true"> Date: Wed, 19 Dec 2018 16:00:30 +0100 Subject: [PATCH 5/9] Bug #850 El autocomplete hace dos peticiones en lugar de una --- client/core/src/components/autocomplete/autocomplete.js | 1 - 1 file changed, 1 deletion(-) diff --git a/client/core/src/components/autocomplete/autocomplete.js b/client/core/src/components/autocomplete/autocomplete.js index c31b4881e..e91b9ff6a 100755 --- a/client/core/src/components/autocomplete/autocomplete.js +++ b/client/core/src/components/autocomplete/autocomplete.js @@ -36,7 +36,6 @@ export default class Autocomplete extends Input { this.assignDropdownProps(); this.showField = this.$.dropDown.showField; this.valueField = this.$.dropDown.valueField; - this.refreshSelection(); } get model() { From 964d69738e392d27e1e4dbd2ace1bfb3baa0c86b Mon Sep 17 00:00:00 2001 From: Gerard Date: Wed, 19 Dec 2018 16:02:02 +0100 Subject: [PATCH 6/9] fdescribe deleted --- client/item/src/tags/index.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/item/src/tags/index.spec.js b/client/item/src/tags/index.spec.js index 647ee2dba..87dd05172 100644 --- a/client/item/src/tags/index.spec.js +++ b/client/item/src/tags/index.spec.js @@ -1,7 +1,7 @@ import './index.js'; import {crudModel} from '../../../helpers/crudModelHelper'; -fdescribe('Item', () => { +describe('Item', () => { describe('Component vnItemTags', () => { let $componentController; let $scope; From 68eb61bd7ee617605756b64657df4f519f29f950 Mon Sep 17 00:00:00 2001 From: Gerard Date: Wed, 19 Dec 2018 16:41:32 +0100 Subject: [PATCH 7/9] rollback --- client/item/src/create/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/item/src/create/index.html b/client/item/src/create/index.html index 5bb0ee3a2..ee5a37d01 100644 --- a/client/item/src/create/index.html +++ b/client/item/src/create/index.html @@ -1,4 +1,4 @@ - + Date: Thu, 20 Dec 2018 09:22:07 +0100 Subject: [PATCH 8/9] #923 Modificar estilos de vn-table --- client/core/src/components/table/style.scss | 18 ++++++++++++++++ client/ticket/src/request/index/index.js | 1 - client/ticket/src/request/index/style.scss | 23 --------------------- client/ticket/src/sale/style.scss | 16 -------------- client/ticket/src/weekly/style.scss | 11 ---------- 5 files changed, 18 insertions(+), 51 deletions(-) delete mode 100644 client/ticket/src/request/index/style.scss diff --git a/client/core/src/components/table/style.scss b/client/core/src/components/table/style.scss index 3ada4feec..c8facf5ea 100644 --- a/client/core/src/components/table/style.scss +++ b/client/core/src/components/table/style.scss @@ -122,4 +122,22 @@ vn-table { } } } + + vn-autocomplete { + div.mdl-textfield { + padding: 0px !important; + } + label.mdl-textfield__label:after { + bottom: 0; + } + div.icons { + display: none !important; + } + } + + vn-textfield { + max-width: 100px; + float: right; + margin: 0!important; + } } \ No newline at end of file diff --git a/client/ticket/src/request/index/index.js b/client/ticket/src/request/index/index.js index 2cee00bc0..44e91f739 100644 --- a/client/ticket/src/request/index/index.js +++ b/client/ticket/src/request/index/index.js @@ -1,5 +1,4 @@ import ngModule from '../../module'; -import './style.scss'; class Controller { constructor($stateParams, $scope) { diff --git a/client/ticket/src/request/index/style.scss b/client/ticket/src/request/index/style.scss deleted file mode 100644 index 9e7f3812a..000000000 --- a/client/ticket/src/request/index/style.scss +++ /dev/null @@ -1,23 +0,0 @@ -vn-ticket-request-index { - vn-textfield { - margin: 0!important; - max-width: 150px; - } - vn-autocomplete { - div.mdl-textfield { - padding: 0px !important; - } - label.mdl-textfield__label:after { - bottom: 0; - } - div.icons { - display: none !important; - } - vn-drop-down { - vn-textfield { - max-width: initial !important - } - } - } -} - diff --git a/client/ticket/src/sale/style.scss b/client/ticket/src/sale/style.scss index f4e420775..67a082c79 100644 --- a/client/ticket/src/sale/style.scss +++ b/client/ticket/src/sale/style.scss @@ -80,14 +80,6 @@ vn-ticket-sale { } vn-table { - vn-textfield { - max-width: 100px; - float: right; - margin: 0!important; - input { - text-align: right; - } - } img { border-radius: 50%; max-width: 50px; @@ -102,12 +94,4 @@ vn-ticket-sale { margin-top: 1em; } } - - vn-textfield { - span.filter { - padding-top: 3px; - padding-right: 3px; - color: $main-font-color - } - } } \ No newline at end of file diff --git a/client/ticket/src/weekly/style.scss b/client/ticket/src/weekly/style.scss index b7d1a2b80..1d67b9cd0 100644 --- a/client/ticket/src/weekly/style.scss +++ b/client/ticket/src/weekly/style.scss @@ -3,15 +3,4 @@ vn-ticket-weekly { margin: auto; max-width: 880px; } - vn-autocomplete { - div.mdl-textfield { - padding: 0px !important; - } - label.mdl-textfield__label:after { - bottom: 0; - } - div.icons { - display: none !important; - } - } } \ No newline at end of file From 110fb9e3eb49a47385db6dc5bc3bf75a5029aaea Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 20 Dec 2018 10:52:08 +0100 Subject: [PATCH 9/9] #850 El autocomplete hace dos peticiones en lugar de una --- client/core/src/components/autocomplete/autocomplete.js | 2 +- .../core/src/components/autocomplete/autocomplete.spec.js | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/client/core/src/components/autocomplete/autocomplete.js b/client/core/src/components/autocomplete/autocomplete.js index e91b9ff6a..5cd812510 100755 --- a/client/core/src/components/autocomplete/autocomplete.js +++ b/client/core/src/components/autocomplete/autocomplete.js @@ -36,6 +36,7 @@ export default class Autocomplete extends Input { this.assignDropdownProps(); this.showField = this.$.dropDown.showField; this.valueField = this.$.dropDown.valueField; + this.refreshSelection(); } get model() { @@ -60,7 +61,6 @@ export default class Autocomplete extends Input { set url(value) { this.dropDownAssign({url: value}); - this.refreshSelection(); } dropDownAssign(props) { diff --git a/client/core/src/components/autocomplete/autocomplete.spec.js b/client/core/src/components/autocomplete/autocomplete.spec.js index aaa948b70..847761179 100644 --- a/client/core/src/components/autocomplete/autocomplete.spec.js +++ b/client/core/src/components/autocomplete/autocomplete.spec.js @@ -47,14 +47,6 @@ describe('Component vnAutocomplete', () => { expect(controller.selection).toEqual(data); }); - it(`should perform a query if the item id isn't present in the data property`, inject($httpBackend => { - $httpBackend.whenGET(/testUrl.*/).respond([data]); - controller.url = 'testUrl'; - $httpBackend.flush(); - - 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); });