Skip to content
Snippets Groups Projects
Verified Commit 46a55ebd authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FIX #8956 assigned basket save filter

parent 1e470b3f
No related branches found
No related tags found
No related merge requests found
...@@ -147,7 +147,7 @@ export class BasketListComponent implements OnInit { ...@@ -147,7 +147,7 @@ export class BasketListComponent implements OnInit {
window['MainHeaderComponent'].setSnav(this.sidenavLeft); window['MainHeaderComponent'].setSnav(this.sidenavLeft);
window['MainHeaderComponent'].setSnavRight(this.sidenavRight); window['MainHeaderComponent'].setSnavRight(this.sidenavRight);
this.listProperties = this.filtersListService.initListsProperties('bbain', params['groupSerialId'], params['basketId']); this.listProperties = this.filtersListService.initListsProperties(this.currentBasketInfo.ownerId, this.currentBasketInfo.groupId, this.currentBasketInfo.basketId);
this.refreshDao(); this.refreshDao();
......
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
interface listProperties { interface listProperties {
'id' : string, 'id': number,
'groupId' : number, 'groupId': number,
'basketId' : number, 'basketId': number,
'page' : string, 'page': string,
'order' : string, 'order': string,
'orderDir' : string, 'orderDir': string,
'search' : string, 'search': string,
'delayed': boolean, 'delayed': boolean,
'categories' : string[], 'categories': string[],
'priorities' : string[], 'priorities': string[],
'entities' : string[], 'entities': string[],
'statuses' : string[] 'statuses': string[]
} }
@Injectable() @Injectable()
...@@ -26,11 +26,11 @@ export class FiltersListService { ...@@ -26,11 +26,11 @@ export class FiltersListService {
this.listsProperties = JSON.parse(sessionStorage.getItem('propertyList')); this.listsProperties = JSON.parse(sessionStorage.getItem('propertyList'));
} }
initListsProperties(userId: string, groupId: number, basketId: number) { initListsProperties(userId: number, groupId: number, basketId: number) {
this.listsPropertiesIndex = 0; this.listsPropertiesIndex = 0;
let listProperties: listProperties; let listProperties: listProperties;
if (this.listsProperties != null) { if (this.listsProperties != null) {
this.listsProperties.forEach((element, index) => { this.listsProperties.forEach((element, index) => {
if (element.id == userId && element.groupId == groupId && element.basketId == basketId) { if (element.id == userId && element.groupId == groupId && element.basketId == basketId) {
...@@ -39,38 +39,39 @@ export class FiltersListService { ...@@ -39,38 +39,39 @@ export class FiltersListService {
} }
}); });
} else { } else {
this.listsProperties = []; this.listsProperties = [];
} }
if (!listProperties) { if (!listProperties) {
listProperties = { listProperties = {
'id' : userId, 'id': userId,
'groupId' : groupId, 'groupId': groupId,
'basketId' : basketId, 'basketId': basketId,
'page' : '0', 'page': '0',
'order' : '', 'order': '',
'orderDir' : 'DESC', 'orderDir': 'DESC',
'search' : '', 'search': '',
'delayed': false, 'delayed': false,
'categories' : [], 'categories': [],
'priorities' : [], 'priorities': [],
'entities' : [], 'entities': [],
'statuses' : [], 'statuses': [],
}; };
this.listsProperties.push(listProperties); this.listsProperties.push(listProperties);
this.saveListsProperties(); this.saveListsProperties();
} }
return listProperties; return listProperties;
} }
updateListsPropertiesPage(page : number) { updateListsPropertiesPage(page: number) {
if (this.listsProperties) { if (this.listsProperties) {
this.listsProperties[this.listsPropertiesIndex].page = page; this.listsProperties[this.listsPropertiesIndex].page = page;
this.saveListsProperties(); this.saveListsProperties();
} }
} }
updateListsProperties(listProperties : any) { updateListsProperties(listProperties: any) {
if (this.listsProperties) { if (this.listsProperties) {
this.listsProperties[this.listsPropertiesIndex] = listProperties; this.listsProperties[this.listsPropertiesIndex] = listProperties;
this.saveListsProperties(); this.saveListsProperties();
...@@ -81,53 +82,53 @@ export class FiltersListService { ...@@ -81,53 +82,53 @@ export class FiltersListService {
sessionStorage.setItem('propertyList', JSON.stringify(this.listsProperties)); sessionStorage.setItem('propertyList', JSON.stringify(this.listsProperties));
} }
getUrlFilters () { getUrlFilters() {
let filters = ''; let filters = '';
if (this.listsProperties) { if (this.listsProperties) {
if (this.listsProperties[this.listsPropertiesIndex].delayed) { if (this.listsProperties[this.listsPropertiesIndex].delayed) {
filters += '&delayed=true'; filters += '&delayed=true';
} }
if (this.listsProperties[this.listsPropertiesIndex].order.length > 0) { if (this.listsProperties[this.listsPropertiesIndex].order.length > 0) {
filters += '&order='+this.listsProperties[this.listsPropertiesIndex].order + ' ' + this.listsProperties[this.listsPropertiesIndex].orderDir; filters += '&order=' + this.listsProperties[this.listsPropertiesIndex].order + ' ' + this.listsProperties[this.listsPropertiesIndex].orderDir;
} }
if (this.listsProperties[this.listsPropertiesIndex].search.length > 0) { if (this.listsProperties[this.listsPropertiesIndex].search.length > 0) {
filters += '&search='+this.listsProperties[this.listsPropertiesIndex].search; filters += '&search=' + this.listsProperties[this.listsPropertiesIndex].search;
} }
if (this.listsProperties[this.listsPropertiesIndex].categories.length > 0) { if (this.listsProperties[this.listsPropertiesIndex].categories.length > 0) {
let cat: any[] = []; let cat: any[] = [];
this.listsProperties[this.listsPropertiesIndex].categories.forEach((element: any) => { this.listsProperties[this.listsPropertiesIndex].categories.forEach((element: any) => {
cat.push(element.id); cat.push(element.id);
}); });
filters += '&categories='+cat.join(','); filters += '&categories=' + cat.join(',');
} }
if (this.listsProperties[this.listsPropertiesIndex].priorities.length > 0) { if (this.listsProperties[this.listsPropertiesIndex].priorities.length > 0) {
let prio: any[] = []; let prio: any[] = [];
this.listsProperties[this.listsPropertiesIndex].priorities.forEach((element: any) => { this.listsProperties[this.listsPropertiesIndex].priorities.forEach((element: any) => {
prio.push(element.id); prio.push(element.id);
}); });
filters += '&priorities='+prio.join(','); filters += '&priorities=' + prio.join(',');
} }
if (this.listsProperties[this.listsPropertiesIndex].statuses.length > 0) { if (this.listsProperties[this.listsPropertiesIndex].statuses.length > 0) {
let status: any[] = []; let status: any[] = [];
this.listsProperties[this.listsPropertiesIndex].statuses.forEach((element: any) => { this.listsProperties[this.listsPropertiesIndex].statuses.forEach((element: any) => {
status.push(element.id); status.push(element.id);
}); });
filters += '&statuses='+status.join(','); filters += '&statuses=' + status.join(',');
} }
if (this.listsProperties[this.listsPropertiesIndex].entities.length > 0) { if (this.listsProperties[this.listsPropertiesIndex].entities.length > 0) {
let ent: any[] = []; let ent: any[] = [];
this.listsProperties[this.listsPropertiesIndex].entities.forEach((element: any) => { this.listsProperties[this.listsPropertiesIndex].entities.forEach((element: any) => {
ent.push(element.id); ent.push(element.id);
}); });
filters += '&entities='+ent.join(','); filters += '&entities=' + ent.join(',');
} }
} }
return filters; return filters;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment