Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //We almost never want award levels without their attending awards
- //It seems best to load award levels in this context
- private getAwardLevels(prog: Session): Observable<IncentiveTier[]> {
- return this.incentiveTierApi.find({
- where: {
- programId: prog.id,
- },
- include: [
- {
- relation: 'unit',
- },
- {
- relation: 'incentives',
- },
- {
- relation: 'incentiveTierIncentives',
- scope: {
- include: 'incentive',
- },
- },
- ],
- order: 'toAchieveInMi',
- }).do((aws: IncentiveTier[]) => console.log({AWS: aws}));
- }
- //assume $program returns a Session object whenever it's loaded or whenever the selected value changes. Right now on my local build it's hardcoded to use my test session.
- private _$awardLevels: BehaviorSubject<IncentiveTier[]>;
- get $awardLevels(): Observable<IncentiveTier[]> {
- if (!this._$awardLevels) {
- this._$awardLevels = new BehaviorSubject<IncentiveTier[]>([]);
- this.$program
- .filter((prog: Session) => !!prog)
- .flatMap((prog: Session) => this.getAwardLevels(prog))
- .do((awds: IncentiveTier[]) => console.log({AWDS: awds}))
- .subscribe(this._$awardLevels);
- }
- return this._$awardLevels.asObservable();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement