import { AutoAction } from './auto-actions.model' ; import { Column } from './column.model' ; import { Category } from './category.model' ; import { IssueTracker } from './issue-tracker.model' ; import { User } from './user.model' ; export class Board { public columns : Column [ ] ; public categories : Category [ ] ; public auto_actions : AutoAction [ ] ; public issue_trackers : IssueTracker [ ] ; public users : User [ ] ; constructor ( public id = 0 , public name = '' , public is_active = true , columnArray = [ ] , categoryArray = [ ] , actionsArray = [ ] , trackerArray = [ ] , userArray = [ ] ) { this . columns = [ ] ; this . categories = [ ] ; this . auto_actions = [ ] ; this . issue_trackers = [ ] ; this . users = [ ] ; columnArray . forEach ( ( column ) => { this . columns . push ( this . convertColumn ( column ) ) ; } ) ; this . columns . sort ( ( a , b ) => a . position - b . position ) ; categoryArray . forEach ( ( category ) => { this . categories . push ( this . convertCategory ( category ) ) ; } ) ; actionsArray . forEach ( ( action ) => { this . auto_actions . push ( new AutoAction ( + action . id , + action . trigger , + action . source_id , + action . type , action . change_to , + action . board_id ) ) ; } ) ; trackerArray . forEach ( ( tracker ) => { this . issue_trackers . push ( new IssueTracker ( + tracker . id , tracker . url , tracker . regex ) ) ; } ) ; userArray . forEach ( ( user ) => { this . users . push ( new User ( + user . default_board_id , user . email , + user . id , user . last_login , + user . security_level , + user . user_option_id , user . username , user . board_access , user . collapsed ) ) ; } ) ; } addColumn ( name ) { const column = new Column ( 0 , name , this . columns . length ) ; this . columns . push ( column ) ; } addCategory ( name , color ) { this . categories . push ( new Category ( 0 , name , color ) ) ; } addIssueTracker ( url , regex ) { this . issue_trackers . push ( new IssueTracker ( 0 , url , regex ) ) ; } private convertColumn ( column ) { const col = new Column ( + column . id , column . name , + column . position , + column . board_id , + column . task_limit , column . ownTask ) ; return col ; } private convertCategory ( category ) { const cat = new Category ( + category . id , category . name , category . default_task_color , + category . board_id ) ; return cat ; } }