Support removing editors, I think, and include wikis from the app owner and from the authenticated user.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4629 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
5b2ace80d4
commit
d467c4dd8a
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "📝",
|
"emoji": "📝",
|
||||||
"previous": "&Unu5AZjyD0RF/QzPh2/u7DuU8IPuSFSjYFkmiWAWcqk=.sha256"
|
"previous": "&G+R9QBUONLBiFGEecnE0w/qJPLOlj3WqtVUVemBdpbo=.sha256"
|
||||||
}
|
}
|
@ -7,9 +7,9 @@
|
|||||||
<tf-collections-app></tf-collections-app>
|
<tf-collections-app></tf-collections-app>
|
||||||
<script src="commonmark.min.js"></script>
|
<script src="commonmark.min.js"></script>
|
||||||
<script>window.litDisableBundleWarning = true;</script>
|
<script>window.litDisableBundleWarning = true;</script>
|
||||||
<script src="tf-collections-app.js" type="module"></script>
|
|
||||||
<script src="tf-collection.js" type="module"></script>
|
<script src="tf-collection.js" type="module"></script>
|
||||||
<script src="tf-id-picker.js" type="module"></script>
|
<script src="tf-id-picker.js" type="module"></script>
|
||||||
<script src="tf-wiki-doc.js" type="module"></script>
|
<script src="tf-wiki-doc.js" type="module"></script>
|
||||||
|
<script src="tf-wiki-app.js" type="module"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -17,6 +17,7 @@ class TfCollectionsAppElement extends LitElement {
|
|||||||
hash: {type: String},
|
hash: {type: String},
|
||||||
|
|
||||||
adding_editor: {type: Boolean},
|
adding_editor: {type: Boolean},
|
||||||
|
expand_editors: {type: Boolean},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +38,8 @@ class TfCollectionsAppElement extends LitElement {
|
|||||||
this.ids = await tfrpc.rpc.getIdentities();
|
this.ids = await tfrpc.rpc.getIdentities();
|
||||||
this.owner_ids = await tfrpc.rpc.getOwnerIdentities();
|
this.owner_ids = await tfrpc.rpc.getOwnerIdentities();
|
||||||
this.whoami = await tfrpc.rpc.localStorageGet('collections_whoami');
|
this.whoami = await tfrpc.rpc.localStorageGet('collections_whoami');
|
||||||
this.following = Object.keys(await tfrpc.rpc.following([this.whoami], 2)).sort();
|
let ids = [...new Set([...this.owner_ids, this.whoami])].sort();
|
||||||
|
this.following = Object.keys(await tfrpc.rpc.following(ids, 2)).sort();
|
||||||
|
|
||||||
await this.read_wikis();
|
await this.read_wikis();
|
||||||
await this.read_Wiki_docs();
|
await this.read_Wiki_docs();
|
||||||
@ -168,6 +170,20 @@ class TfCollectionsAppElement extends LitElement {
|
|||||||
this.adding_editor = false;
|
this.adding_editor = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async on_remove_editor(id) {
|
||||||
|
if (confirm(`Are you sure you want to remove ${id} as an editor?`)) {
|
||||||
|
let editors = [...this.wiki.editors];
|
||||||
|
if (editors.indexOf(id) != -1) {
|
||||||
|
editors = editors.filter(x => x !== id);
|
||||||
|
}
|
||||||
|
await tfrpc.rpc.appendMessage(this.whoami, {
|
||||||
|
type: 'wiki',
|
||||||
|
key: this.wiki.id,
|
||||||
|
editors: editors,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async on_wiki_tombstone(event) {
|
async on_wiki_tombstone(event) {
|
||||||
await tfrpc.rpc.appendMessage(this.whoami, {
|
await tfrpc.rpc.appendMessage(this.whoami, {
|
||||||
type: 'wiki',
|
type: 'wiki',
|
||||||
@ -244,14 +260,21 @@ class TfCollectionsAppElement extends LitElement {
|
|||||||
@rename=${this.on_wiki_doc_rename}
|
@rename=${this.on_wiki_doc_rename}
|
||||||
@tombstone=${this.on_wiki_doc_tombstone}
|
@tombstone=${this.on_wiki_doc_tombstone}
|
||||||
@change=${this.on_wiki_doc_changed}></tf-collection>`)}
|
@change=${this.on_wiki_doc_changed}></tf-collection>`)}
|
||||||
<div ?hidden=${!this.wiki?.editors}>
|
<button @click=${() => self.expand_editors = !self.expand_editors}>${this.wiki?.editors?.length} editor${this.wiki?.editors?.length > 1 ? 's' : ''}</button>
|
||||||
Editors: ${this.wiki?.editors}
|
<div ?hidden=${!this.wiki?.editors || !this.expand_editors}>
|
||||||
<button @click=${() => self.adding_editor = true} ?hidden=${this.wiki?.editors?.indexOf(this.whoami) == -1 || this.adding_editor}>+</button>
|
<div>
|
||||||
<div ?hidden=${!this.adding_editor}>
|
<ul>
|
||||||
<label for="add_editor">Add Editor:</label>
|
${this.wiki?.editors.map(id => html`<li><button ?hidden=${id == this.whoami} @click=${() => self.on_remove_editor(id)}>x</button> ${id}</li>`)}
|
||||||
<input type="text" id="add_editor"></input>
|
<li>
|
||||||
<button @click=${this.on_add_editor}>Add Editor</button>
|
<button @click=${() => self.adding_editor = true} ?hidden=${this.wiki?.editors?.indexOf(this.whoami) == -1 || this.adding_editor}>+</button>
|
||||||
<button @click=${() => self.adding_editor = false}>x</button>
|
<div ?hidden=${!this.adding_editor}>
|
||||||
|
<label for="add_editor">Add Editor:</label>
|
||||||
|
<input type="text" id="add_editor"></input>
|
||||||
|
<button @click=${this.on_add_editor}>Add Editor</button>
|
||||||
|
<button @click=${() => self.adding_editor = false}>x</button>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
Loading…
Reference in New Issue
Block a user