import { Injectable } from '@angular/core' ; import { ContentEntry , ContentEntryType , ContentFile , ContentMenuItem , ContentPage , ContentSection , ContentVersion , } from '../../../main/src/app/content/meta' ; import { uuid } from './util/uuid' ; export const contentFileVersion = '2' ; /**
 * Editor ONLY service.
 */ @ Injectable ( { providedIn : 'root' , } ) export class DataService { data : ContentFile = { __v : contentFileVersion , versions : [ ] , } ; readonly sourceLang = 'en' ; constructor ( ) { this . logData ( ) ; } createVersion ( ) { return { id : uuid ( ) , sections : [ ] , } ; } cloneVersion ( version ) { const cloned = JSON . parse ( JSON . stringify ( version ) ) ; cloned . id = uuid ( ) ; return cloned ; } createSection ( ) { return { id : uuid ( ) , menu : { items : [ ] , } , pages : [ ] , } ; } createPage ( ) { return { id : uuid ( ) , entries : [ ] , } ; } createEntry < T extends ContentEntry > ( type = 'text' ) { return { id : uuid ( ) , type , } as any ; } createMenuItem ( ) { return { id : uuid ( ) , } ; } logData ( ) { } delete ( array , index ) { array . splice ( index , 1 ) ; } move ( array , from , to ) { if ( to >= 0 && to < array . length ) { array . splice ( to , 0 , array . splice ( from , 1 ) [ 0 ] ) ; } } migrate ( ) { } }