refs #5244 fix: corregidos errores
This commit is contained in:
parent
1d7f0e2135
commit
c876719a5c
|
@ -152,7 +152,14 @@ export default class Autocomplete extends Field {
|
||||||
filter.include = this.include;
|
filter.include = this.include;
|
||||||
|
|
||||||
let json = encodeURIComponent(JSON.stringify(filter));
|
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),
|
json => this.onSelectionRequest(json.data),
|
||||||
() => this.onSelectionRequest()
|
() => this.onSelectionRequest()
|
||||||
);
|
);
|
||||||
|
|
|
@ -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(`<vn-autocomplete></vn-autocomplete>`)($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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -36,18 +36,17 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const allLeaves = await getAllLeaves(ctx, departments);
|
const allLeaves = await getAllLeaves(ctx, departments);
|
||||||
const where = {'d.id': {inq: allLeaves}};
|
const where = {'departmentFk': {inq: allLeaves}};
|
||||||
filter = mergeFilters(filter, {where});
|
filter = mergeFilters(filter, {where});
|
||||||
}
|
}
|
||||||
|
|
||||||
const stmt = new ParameterizedSQL(`
|
const stmt = new ParameterizedSQL(`
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM(
|
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
|
FROM worker w
|
||||||
JOIN account.user u ON u.id = w.id
|
JOIN account.user u ON u.id = w.id
|
||||||
JOIN business b ON b.workerFk = w.id
|
JOIN business b ON b.workerFk = w.id
|
||||||
JOIN department d ON d.id = b.departmentFk
|
|
||||||
) w`);
|
) w`);
|
||||||
|
|
||||||
stmt.merge(conn.makeSuffix(filter));
|
stmt.merge(conn.makeSuffix(filter));
|
||||||
|
|
Loading…
Reference in New Issue