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", "type": "tildefriends-app",
"emoji": "📝", "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) { 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_promise = new Promise(function(resolve, reject) {
g_new_message_resolve = resolve; g_new_message_resolve = resolve;
}); });
if (resolve) {
resolve(); resolve();
}
}); });
core.register('message', async function message_handler(message) { core.register('message', async function message_handler(message) {

View File

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

View File

@ -91,9 +91,11 @@ class TfCollectionsAppElement extends LitElement {
update_wiki_doc() { update_wiki_doc() {
let want_wiki_doc = this.hash_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 ?? {})) { for (let wiki_doc of Object.values(this.wiki_docs ?? {})) {
if (wiki_doc.name === want_wiki_doc) { if (wiki_doc.name === want_wiki_doc) {
this.wiki_doc = 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> @change=${this.on_wiki_changed}></tf-collection>
<tf-collection <tf-collection
.collection=${this.wiki_docs} .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> @change=${this.on_wiki_doc_changed}></tf-collection>
</div> </div>
${this.wiki_doc && this.wiki_doc.parent === this.wiki?.id ? html` ${this.wiki_doc && this.wiki_doc.parent === this.wiki?.id ? html`