diff --git a/client/client/routes.json b/client/client/routes.json index ca5f629e59..808e5af41d 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/address/edit/index.html b/client/client/src/address/edit/index.html index ef7966e08a..c20c4146ed 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 4b859445c6..b9e60c2e2f 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 7678beaab6..8838c2d170 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/client/src/risk/index/index.html b/client/client/src/risk/index/index.html index 239f22ca47..936dab9de4 100644 --- a/client/client/src/risk/index/index.html +++ b/client/client/src/risk/index/index.html @@ -15,7 +15,7 @@ - Risk + Balance { 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); }); diff --git a/client/core/src/components/crud-model/crud-model.js b/client/core/src/components/crud-model/crud-model.js index 62115f55a7..5a0f8d5d2c 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/core/src/components/table/style.scss b/client/core/src/components/table/style.scss index 3ada4feec9..c8facf5ea2 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/item/src/barcode/index.html b/client/item/src/barcode/index.html index 406e81effe..416d04b5b7 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"> + - +
{{$ctrl.item.id}}
diff --git a/client/item/src/tags/index.html b/client/item/src/tags/index.html index fac558db60..e8a6d62140 100644 --- a/client/item/src/tags/index.html +++ b/client/item/src/tags/index.html @@ -5,22 +5,25 @@ link="{itemFk: $ctrl.$stateParams.id}" include="$ctrl.include" order="priority ASC" - data="itemTags"> + on-row-change="$ctrl.getSourceTable(obj)" + data="$ctrl.itemTags" + auto-load="true"> + data="tags" + auto-load="true"> 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 21b6879c06..87dd051721 100644 --- a/client/item/src/tags/index.spec.js +++ b/client/item/src/tags/index.spec.js @@ -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/client/item/src/tax/index.html b/client/item/src/tax/index.html index 69f7e0f4a5..75963852a0 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 4664f90933..a6d0dcd229 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 67a84623e3..8e79d53af2 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/request/index/index.js b/client/ticket/src/request/index/index.js index 2cee00bc06..44e91f739d 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 9e7f3812ad..0000000000 --- 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 f4e4207751..67a082c794 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/services/index.html b/client/ticket/src/services/index.html index b8e37668ae..d8820aab86 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"> { 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 a45e7e51b1..4ae12c6dbc 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'); }); });