import { Doc } from './Doc' ; import { File } from './File' ; import { IStorage } from './storage/IStorage.model' ; const DEFAULT_TITLE = 'Untitled Folder' ; export class Folder extends File { public icon : string ; public isRemote : boolean ; static deserialize ( storage , id , serialized ) { const folder = new Folder ( storage , serialized . title , serialized . parentFolderId ) ; folder . icon = serialized . icon ; folder . isRemote = serialized . isRemote ; folder . deserialize ( id , serialized ) ; return folder ; } static create ( storage , title , icon , isRemote , parentFolderId ? ) { const folder = new Folder ( storage , title , parentFolderId ) ; folder . _title = title ; folder . created = new Date ( ) ; folder . isRemote = isRemote ; folder . icon = icon ; return folder ; } constructor ( storage , title , parentFolderId ) { super ( storage , title , parentFolderId ) ; } get isDoc ( ) { return false ; } get title ( ) { return this . _title ; } set title ( newTitle ) { this . _title = newTitle || DEFAULT_TITLE ; } set description ( newDescription ) { this . _description = newDescription ; } get description ( ) { return this . _description ; } async saveMetadata ( ) { await this . storage . save ( this ) ; } async fetchDocs ( ) { return this . storage . fetchDocs ( this ) ; } serialize ( ) { return Object . assign ( super . serialize ( ) , { type : 'folder' , icon : this . icon , isRemote : this . isRemote , } ) ; } }