@ -9,8 +9,8 @@ export default class LoadResults {
}
}
this . noteIdTo Source Id = { } ;
this . source IdToNoteIds = { } ;
this . noteIdTo Component Id = { } ;
this . component IdToNoteIds = { } ;
this . branches = [ ] ;
@ -20,7 +20,7 @@ export default class LoadResults {
this . noteRevisions = [ ] ;
this . contentNoteIdTo Source Id = [ ] ;
this . contentNoteIdTo Component Id = [ ] ;
this . options = [ ] ;
}
@ -29,22 +29,22 @@ export default class LoadResults {
return this . entities [ entityName ] ? . [ entityId ] ;
}
addNote ( noteId , source Id) {
this . noteIdTo SourceId[ noteId ] = this . noteIdToSource Id[ noteId ] || [ ] ;
addNote ( noteId , component Id) {
this . noteIdTo ComponentId[ noteId ] = this . noteIdToComponent Id[ noteId ] || [ ] ;
if ( ! this . noteIdTo SourceId[ noteId ] . includes ( source Id) ) {
this . noteIdTo SourceId[ noteId ] . push ( source Id) ;
if ( ! this . noteIdTo ComponentId[ noteId ] . includes ( component Id) ) {
this . noteIdTo ComponentId[ noteId ] . push ( component Id) ;
}
this . sourceIdToNoteIds[ sourceId ] = this . sourceIdToNoteIds [ source Id] || [ ] ;
this . componentIdToNoteIds[ componentId ] = this . componentIdToNoteIds [ component Id] || [ ] ;
if ( ! this . sourceIdToNoteIds[ source Id] ) {
this . sourceIdToNoteIds[ source Id] . push ( noteId ) ;
if ( ! this . componentIdToNoteIds[ component Id] ) {
this . componentIdToNoteIds[ component Id] . push ( noteId ) ;
}
}
addBranch ( branchId , source Id) {
this . branches . push ( { branchId , source Id} ) ;
addBranch ( branchId , component Id) {
this . branches . push ( { branchId , component Id} ) ;
}
getBranches ( ) {
@ -53,7 +53,7 @@ export default class LoadResults {
. filter ( branch => ! ! branch ) ;
}
addNoteReordering ( parentNoteId , source Id) {
addNoteReordering ( parentNoteId , component Id) {
this . noteReorderings . push ( parentNoteId ) ;
}
@ -61,20 +61,20 @@ export default class LoadResults {
return this . noteReorderings ;
}
addAttribute ( attributeId , source Id) {
this . attributes . push ( { attributeId , source Id} ) ;
addAttribute ( attributeId , component Id) {
this . attributes . push ( { attributeId , component Id} ) ;
}
/** @returns {Attribute[]} */
getAttributes ( source Id = 'none' ) {
getAttributes ( component Id = 'none' ) {
return this . attributes
. filter ( row => row . sourceId !== source Id)
. filter ( row => row . componentId !== component Id)
. map ( row => this . getEntity ( "attributes" , row . attributeId ) )
. filter ( attr => ! ! attr ) ;
}
addNoteRevision ( noteRevisionId , noteId , source Id) {
this . noteRevisions . push ( { noteRevisionId , noteId , source Id} ) ;
addNoteRevision ( noteRevisionId , noteId , component Id) {
this . noteRevisions . push ( { noteRevisionId , noteId , component Id} ) ;
}
hasNoteRevisionForNote ( noteId ) {
@ -82,28 +82,28 @@ export default class LoadResults {
}
getNoteIds ( ) {
return Object . keys ( this . noteIdTo Source Id) ;
return Object . keys ( this . noteIdTo Component Id) ;
}
isNoteReloaded ( noteId , source Id = null ) {
isNoteReloaded ( noteId , component Id = null ) {
if ( ! noteId ) {
return false ;
}
const sourceIds = this . noteIdToSource Id[ noteId ] ;
return sourceIds && ! ! sourceIds . find ( sId => sId !== source Id) ;
const componentIds = this . noteIdToComponent Id[ noteId ] ;
return componentIds && ! ! componentIds . find ( sId => sId !== component Id) ;
}
addNoteContent ( noteId , source Id) {
this . contentNoteIdTo SourceId. push ( { noteId , source Id} ) ;
addNoteContent ( noteId , component Id) {
this . contentNoteIdTo ComponentId. push ( { noteId , component Id} ) ;
}
isNoteContentReloaded ( noteId , source Id) {
isNoteContentReloaded ( noteId , component Id) {
if ( ! noteId ) {
return false ;
}
return this . contentNoteIdTo Source Id. find ( l => l . noteId === noteId && l . sourceId !== source Id) ;
return this . contentNoteIdTo Component Id. find ( l => l . noteId === noteId && l . componentId !== component Id) ;
}
addOption ( name ) {
@ -124,17 +124,17 @@ export default class LoadResults {
}
isEmpty ( ) {
return Object . keys ( this . noteIdTo Source Id) . length === 0
return Object . keys ( this . noteIdTo Component Id) . length === 0
&& this . branches . length === 0
&& this . attributes . length === 0
&& this . noteReorderings . length === 0
&& this . noteRevisions . length === 0
&& this . contentNoteIdTo Source Id. length === 0
&& this . contentNoteIdTo Component Id. length === 0
&& this . options . length === 0 ;
}
isEmptyForTree ( ) {
return Object . keys ( this . noteIdTo Source Id) . length === 0
return Object . keys ( this . noteIdTo Component Id) . length === 0
&& this . branches . length === 0
&& this . attributes . length === 0
&& this . noteReorderings . length === 0 ;