AW-432 add itemtype service
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
This commit is contained in:
parent
7f6c403091
commit
ec9bd4b974
@ -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
|
||||
]
|
||||
};
|
||||
}
|
||||
|
35
projects/common/src/lib/services/itemtype.service.ts
Normal file
35
projects/common/src/lib/services/itemtype.service.ts
Normal 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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user