'use strict' ; import BaseModel from '../bases/BaseModel' ; import { IStageData } from 'teambition' ; class StageModel extends BaseModel { public setStages ( tasklistId , stages ) { let result = [ ] ; angular . forEach ( stages , ( stage , index ) => { let cache = this . getDetail ( stage . _id ) ; if ( ! cache ) { result . push ( stage ) ; this . setDetail ( stage ) ; } else { result . push ( cache ) ; } } ) ; this . _set ( 'stages:tasklist' , tasklistId , stages ) ; } public getStages ( tasklistid ) { return this . _get < IStageData [ ] > ( 'stages:tasklist' , tasklistid ) ; } public getDetail ( stageId ) { return this . _get < IStageData > ( 'stage:detail' , stageId ) ; } public setDetail ( stage ) { this . _set ( 'stage:detail' , stage . _id , stage ) ; } } export default new StageModel ( ) ;