Skip to content

Commit

Permalink
changed logic for bindingParametrs
Browse files Browse the repository at this point in the history
  • Loading branch information
dimakuba committed Sep 30, 2016
1 parent e66405a commit 8f18863
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class CrudLinkset {
addLink(gridOptions) {
let className = this.crudService.getLinkedClass();
let previousCrudLevel: CrudLevel = this.crudService.previousCrudLevel();
this.crudService.model[previousCrudLevel.linksetProperty.name] = [];
let params: any = previousCrudLevel.linksetProperty.data;

return this.getLinkset(gridOptions, previousCrudLevel.linksetProperty.type, className)
Expand Down
1 change: 1 addition & 0 deletions modules/admin/src/app/crud/crudView/crud.view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class CrudView {
this.resolveData = this.route.snapshot.data['view'];
this.crudService.gridOptions.columnDefs = this.resolveData.grid;
this.crudService.gridOptions.rowData = [];
this.crudService.resetCrudLevels();
}

navigateToCreate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class MultipleSelect {

clearAll(): void {
this.resetParams();

this.crudService.model[this.property.property] = [];
this.crudService.multipleSelectValid = true;
}

Expand All @@ -123,7 +123,6 @@ export class MultipleSelect {

resetParams(): void {
this.crudService.titleColumns[this.property.property] = [];
this.crudService.model[this.property.property] = [];
this.crudService.titleColumns = [];
this.ridItems = [];
}
Expand Down
29 changes: 9 additions & 20 deletions modules/admin/src/app/services/grid.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,16 @@ export class GridService {
this.database.load(rid)
.then(res => {
let result: MetaDataPropertyBindingParameterModel = res.json();
let linksetPromises = [];

if (currentCrudLevel.linksetProperty.data.hasOwnProperty('@rid')) {
if (currentCrudLevel.linksetProperty.data['@rid']
=== result.toProperty) {
linksetPromises.push(
this.database.load(
currentCrudLevel.linksetProperty.data['@rid'])
.then(response => {
let customer = response.json();

customer[currentCrudLevel.linksetProperty.name]
.forEach(link => {
expression
.or('@rid = ?', link);
});
})
);
}
let links: Array<string> = currentCrudLevel.linksetProperty.data[
currentCrudLevel.linksetProperty.name];

if (Array.isArray(links)) {
links.forEach((item, i) => {
expression
.or(result.toProperty + ' ' +
result.operator + ' ?', links['_' + i]);
});
}
return Promise.all(linksetPromises);
})
);
}
Expand Down

0 comments on commit 8f18863

Please sign in to comment.