Fumbling with wiki some more.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4604 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-11-04 16:32:21 +00:00
parent d06f490cc2
commit 00eb5222f8
4 changed files with 18 additions and 12 deletions

View File

@ -1,5 +1,5 @@
{
"type": "tildefriends-app",
"emoji": "📝",
"previous": "&KrBCh2/8NVdDwJrOK0JB/Tszo/lAtjRI4XVdjZ2XNK8=.sha256"
"previous": "&OpEjJ6ZLsIabI1SOzLymRGKlwy2Q6YUI+I3JW5cR7nA=.sha256"
}

View File

@ -56,11 +56,13 @@ function new_message() {
}
ssb.addEventListener('message', function(id) {
let resolve = g_new_message_resolve();
let resolve = g_new_message_resolve;
g_new_message_promise = new Promise(function(resolve, reject) {
g_new_message_resolve = resolve;
});
if (resolve) {
resolve();
}
});
core.register('message', async function message_handler(message) {

View File

@ -65,17 +65,19 @@ class TfCollectionElement extends LitElement {
let self = this;
return html`
<span style="display: inline-flex; flex-direction: row">
<select @change=${this.on_selected} id="select">
<option value="">(select)</option>
${Object.values(this.collection ?? {}).map(x => html`<option value=${x.id} ?selected=${this.selected_id == x.id}>${x.name}</option>`)}
<select @change=${this.on_selected} id="select" value=${this.selected_id}>
<option value="" ?selected=${this.selected_id === ''} disabled hidden>(select)</option>
${Object.values(this.collection ?? {}).map(x => html`<option value=${x.id} ?selected=${this.selected_id === x.id}>${x.name}</option>`)}
</select>
<span ?hidden=${!this.is_renaming}>
<label for="rename_name">Rename to:</label>
<span style="display: inline-flex; flex-direction: row; margin-left: 8px; margin-right: 8px">
<label for="rename_name">🏷Rename to:</label>
<input type="text" id="rename_name"></input>
<button @click=${this.on_rename}>Rename ${this.type}</button>
<button @click=${() => self.is_renaming = false}>x</button>
</span>
<button @click=${() => self.is_renaming = true} ?disabled=${this.is_renaming || !this.selected_id}></button>
</span>
<button @click=${() => self.is_renaming = true} ?disabled=${this.is_renaming || !this.selected_id}>🏷</button>
<button @click=${self.on_tombstone} ?disabled=${!this.selected_id}>🪦</button>
<span ?hidden=${!this.is_creating}>
<label for="create_name">New ${this.type} name:</label>

View File

@ -91,9 +91,11 @@ class TfCollectionsAppElement extends LitElement {
update_wiki_doc() {
let want_wiki_doc = this.hash_wiki_doc();
console.log('looking for', want_wiki_doc);
for (let wiki_doc of Object.values(this.wiki_docs ?? {})) {
if (wiki_doc.name === want_wiki_doc) {
this.wiki_doc = wiki_doc;
console.log('setting', wiki_doc.name);
}
}
}
@ -157,7 +159,7 @@ class TfCollectionsAppElement extends LitElement {
@change=${this.on_wiki_changed}></tf-collection>
<tf-collection
.collection=${this.wiki_docs}
selected_id=${this.wiki_doc?.id}
selected_id=${(this.wiki_doc && this.wiki_doc?.parent == this.wiki?.id) ? this.wiki_doc?.id : ''}
@change=${this.on_wiki_doc_changed}></tf-collection>
</div>
${this.wiki_doc && this.wiki_doc.parent === this.wiki?.id ? html`