Refactor itemtype loading
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good

This commit is contained in:
Willem Dantuma
2020-02-11 18:55:43 +01:00
parent 52170590e3
commit b83aca7969
5 changed files with 83 additions and 47 deletions

View File

@@ -6,12 +6,13 @@ import { IItem } from '../models/item';
import { IItemTask } from '../models/itemTask';
import { HttpClient, HttpParams } from "@angular/common/http";
import { AppConfig } from "../shared/app.config";
import {ItemTypeService} from './itemtype.service';
@Injectable({
providedIn: 'root',
})
export class ItemService {
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
constructor(public httpClient: HttpClient, public appConfig: AppConfig,private itemTypeService:ItemTypeService) {
}
ApiEndpoint() {
@@ -37,7 +38,13 @@ export class ItemService {
if (searchTags) params = params.append("t", searchTags);
if (startDate) params = params.append("sd", startDate.toISOString());
if (endDate) params = params.append("ed", endDate.toISOString());
if (itemType) params = params.append("it", itemType);
if (itemType) {
params = params.append("it", itemType);
let extraAttributes = this.itemTypeService.getExtraAttributes(itemType);
if(extraAttributes) {
params = params.append("da", extraAttributes);
}
}
if (parentCode) params = params.append("pc", parentCode);
if (dataFilter) params = params.append("df", dataFilter);
if (level) params = params.append("lvl", dataFilter);