AW-432 add itemtype service
FarmMaps.Develop/FarmMapsLib/develop This commit looks good Details

pull/1/head
Willem Dantuma 2019-08-08 13:59:07 +02:00
parent 7f6c403091
commit ec9bd4b974
2 changed files with 39 additions and 1 deletions

View File

@ -18,6 +18,7 @@ import { AppCommonRoutingModule } from './common-routing.module';
import { MODULE_NAME } from './module-name';
//components
import { ItemTypeService } from './services/itemtype.service';
import { FolderService } from './services/folder.service';
import { TimespanService} from './services/timespan.service';
import { ItemService} from './services/item.service';
@ -55,6 +56,7 @@ import {NgbDateNativeAdapter} from './services/date-adapter.service'
import { from } from 'rxjs';
export {FolderService,
ItemTypeService,
TimespanService,
ItemService,
EventService,
@ -144,7 +146,8 @@ export class AppCommonModule {
AuthGuard,
NavBarGuard,
FullScreenGuard,
TimespanService
TimespanService,
ItemTypeService
]
};
}

View File

@ -0,0 +1,35 @@
import { Component, Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import * as appCommonReducer from '../reducers/app-common.reducer'
import {IItemTypes} from '../models/item.types'
import {IItem} from '../models/item'
@Injectable()
export class ItemTypeService {
private _itemTypes: IItemTypes;
constructor(private store: Store<appCommonReducer.State> ) {
this.store.select(appCommonReducer.selectGetItemTypes).subscribe((itemTypes) => {
this._itemTypes = itemTypes;
});
}
getIcon(itemType: string) {
var icon = "fa-file-o";
if (this._itemTypes[itemType]) icon = this._itemTypes[itemType].icon;
return icon;
}
getColor(itemType: string) {
var color = "#000000";
if (this._itemTypes[itemType]) color = this._itemTypes[itemType].iconColor;
return color;
}
hasViewer(item: IItem) {
let itemType: string = item.itemType;
if (this._itemTypes[itemType]) return this._itemTypes[itemType].viewer !== undefined;
return false;
}
}