More sync operations

This commit is contained in:
Magnus Åhall 2024-12-18 19:12:10 +01:00
parent 9df85d9580
commit d0150145ed
10 changed files with 362 additions and 131 deletions

View file

@ -41,6 +41,7 @@ export class NodeUI extends Component {
</div>
<div id="name">${node.Name}</div>
<${NodeContent} key=${node.UUID} node=${node} ref=${this.nodeContent} />
<div id="blank"></div>
`
@ -228,9 +229,11 @@ class NodeContent extends Component {
}
let element
/*
if (node.RenderMarkdown.value)
element = html`<${MarkdownContent} key='markdown-content' content=${content} />`
else
*/
element = html`
<div class="grow-wrap">
<textarea id="node-content" class="node-content" ref=${this.contentDiv} oninput=${evt => this.contentChanged(evt)} required rows=1>${content}</textarea>
@ -273,15 +276,14 @@ class NodeContent extends Component {
export class Node {
constructor(nodeData, level) {//{{{
this.Level = level
this._children_fetched = false
this.Children = []
this.data = nodeData
this.UUID = nodeData.UUID
this.ParentUUID = nodeData.ParentUUID
this.UserID = nodeData.UserID
this.CryptoKeyID = nodeData.CryptoKeyID
this.Name = nodeData.Name
this._children_fetched = false
this.Children = []
/*
this.RenderMarkdown = signal(nodeData.RenderMarkdown)
this.Markdown = false
this.ShowChecklist = signal(false)
@ -294,6 +296,14 @@ export class Node {
this.ScheduleEvents = signal([])
// it doesn't control it afterwards.
// Used to expand the crumbs upon site loading.
*/
}//}}}
get(prop) {//{{{
return this.data[prop]
}//}}}
updated() {//{{{
// '2024-12-17T17:33:48.85939Z
return new Date(Date.parse(this.data.Updated))
}//}}}
hasFetchedChildren() {//{{{
return this._children_fetched
@ -311,7 +321,7 @@ export class Node {
if (this.CryptoKeyID != 0 && !this._decrypted)
this.#decrypt()
*/
return this._content
return this.data.Content
}//}}}
setContent(new_content) {//{{{
this._content = new_content
@ -325,8 +335,8 @@ export class Node {
*/
}//}}}
static sort(a, b) {//{{{
if (a.Name < b.Name) return -1
if (a.Name > b.Name) return 0
if (a.data.Name < b.data.Name) return -1
if (a.data.Name > b.data.Name) return 0
return 0
}//}}}
}