import { Store } from 'vuex' ; import Service from '@/services/Service' ; import Task from '@/models/soukai/Task' ; interface State { activeTask : Task | null ; editing : boolean ; } export default class Tasks extends Service { public get active ( ) : Task | null { return this . storage . activeTask ; } public get editing ( ) : boolean { return this . storage . editing ; } public setActive ( task , editing = false ) { this . app . $store . commit ( 'setActiveTask' , task ) ; this . setEditing ( editing ) ; } public setEditing ( editing ) { this . app . $store . commit ( 'setEditing' , editing ) ; } protected get storage ( ) : State { return this . app . $store . state . tasks ? this . app . $store . state . tasks : { } ; } protected registerStoreModule ( store ) { store . registerModule ( 'tasks' , { state : { activeTask : null , editing : false , } , mutations : { setActiveTask ( state , activeTask ) { state . activeTask = activeTask ; } , setEditing ( state , editing ) { state . editing = editing ; } , } , } ) ; } protected unregisterStoreModule ( store ) { store . unregisterModule ( 'tasks' ) ; } }