Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
This commit is contained in:
commit
b84d94e3a4
|
@ -189,7 +189,7 @@
|
|||
"url": "/index",
|
||||
"state": "client.card.risk.index",
|
||||
"component": "vn-client-risk-index",
|
||||
"description": "Risk",
|
||||
"description": "Balance",
|
||||
"params": {
|
||||
"client": "$ctrl.client"
|
||||
}
|
||||
|
|
|
@ -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">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
url="/client/api/ObservationTypes"
|
||||
fields="['id', 'description']"
|
||||
data="types">
|
||||
data="types"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<form name="form" ng-submit="$ctrl.submit()" compact>
|
||||
<vn-card pad-large>
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
url="/client/api/Addresses"
|
||||
filter="::$ctrl.filter"
|
||||
link="{clientFk: $ctrl.$stateParams.id}"
|
||||
data="addresses">
|
||||
data="addresses"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
|
||||
<vn-vertical>
|
||||
|
|
|
@ -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">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
url="/client/api/clientObservations"
|
||||
filter="{order: 'created DESC'}"
|
||||
link="{clientFk: $ctrl.$stateParams.id}"
|
||||
data="notes">
|
||||
data="notes"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
|
||||
<vn-vertical compact>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<vn-card pad-large>
|
||||
<vn-horizontal>
|
||||
<vn-one>
|
||||
<vn-title>Risk</vn-title>
|
||||
<vn-title>Balance</vn-title>
|
||||
</vn-one>
|
||||
<vn-one>
|
||||
<vn-autocomplete vn-one
|
||||
|
|
|
@ -61,7 +61,6 @@ export default class Autocomplete extends Input {
|
|||
|
||||
set url(value) {
|
||||
this.dropDownAssign({url: value});
|
||||
this.refreshSelection();
|
||||
}
|
||||
|
||||
dropDownAssign(props) {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,8 @@
|
|||
url="/item/api/ItemBarcodes"
|
||||
fields="['id', 'itemFk', 'code']"
|
||||
link="{itemFk: $ctrl.$stateParams.id}"
|
||||
data="barcodes">
|
||||
data="barcodes"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
url="/item/api/ItemNiches"
|
||||
fields="['id', 'itemFk', 'warehouseFk', 'code']"
|
||||
link="{itemFk: $ctrl.$stateParams.id}"
|
||||
data="niches">
|
||||
data="niches"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<vn-card class="summary" compact>
|
||||
<vn-card class="summary">
|
||||
<vn-vertical pad-medium>
|
||||
<vn-horizontal>
|
||||
<vn-auto margin-medium>
|
||||
<vn-auto margin-medium>
|
||||
<vn-vertical>
|
||||
<vn-one>
|
||||
<h5 text-center pad-small-v class="title">{{$ctrl.item.id}}</h5>
|
||||
|
|
|
@ -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">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="itemTags"
|
||||
data="$ctrl.itemTags"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<vn-crud-model
|
||||
url="/item/api/Tags"
|
||||
fields="['id','name','isFree', 'sourceTable']"
|
||||
data="tags">
|
||||
data="tags"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
|
||||
<vn-card pad-large>
|
||||
<vn-title>Tags</vn-title>
|
||||
<vn-horizontal ng-repeat="itemTag in itemTags">
|
||||
<vn-horizontal ng-repeat="itemTag in $ctrl.itemTags">
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
vn-id="tag"
|
||||
|
@ -44,12 +47,12 @@
|
|||
<vn-autocomplete
|
||||
ng-show="tag.selection.isFree === false"
|
||||
vn-three
|
||||
url="{{$ctrl.getSourceTable(tag.selection)}}"
|
||||
url="{{$ctrl.sourceTables[itemTag.id].url}}"
|
||||
search-function="{name: {regexp: $search}}"
|
||||
label="Value"
|
||||
field="itemTag.value"
|
||||
show-field="name"
|
||||
value-field="name"
|
||||
show-field="{{$ctrl.sourceTables[itemTag.id].field}}"
|
||||
value-field="{{$ctrl.sourceTables[itemTag.id].field}}"
|
||||
vn-acl="buyer">
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
|
|
|
@ -10,6 +10,40 @@ class Controller {
|
|||
fields: ['id', 'name', 'isFree', 'sourceTable']
|
||||
}
|
||||
};
|
||||
this.sourceTables = {};
|
||||
}
|
||||
|
||||
set itemTags(value) {
|
||||
if (value) {
|
||||
value.forEach(tag => {
|
||||
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(() => {
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<vn-crud-model
|
||||
url="/item/api/TaxClasses"
|
||||
fields="['id', 'description', 'code']"
|
||||
data="classes">
|
||||
data="classes"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<form name="form" ng-submit="$ctrl.submit()" compact>
|
||||
<vn-card pad-large>
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
url="/ticket/api/Sales"
|
||||
link="{ticketFk: $ctrl.$stateParams.id}"
|
||||
filter="::$ctrl.filter"
|
||||
data="components">
|
||||
data="components"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-vertical>
|
||||
<vn-card pad-large>
|
||||
|
|
|
@ -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">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
url="/ticket/api/ObservationTypes"
|
||||
data="observationTypes">
|
||||
data="observationTypes"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
url="/ticket/api/TicketPackagings"
|
||||
fields="['id', 'ticketFk', 'packagingFk', 'quantity', 'created']"
|
||||
link="{ticketFk: $ctrl.$stateParams.id}"
|
||||
data="packages" on-data-change="$ctrl.onDataChange()">
|
||||
data="packages" on-data-change="$ctrl.onDataChange()"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
link="{ticketFk: $ctrl.$stateParams.id}"
|
||||
filter="::$ctrl.filter"
|
||||
limit="20"
|
||||
data="sales">
|
||||
data="sales"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
|
||||
<vn-vertical>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import ngModule from '../../module';
|
||||
import './style.scss';
|
||||
|
||||
class Controller {
|
||||
constructor($stateParams, $scope) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue