diff options
Diffstat (limited to 'demo/components')
-rw-r--r-- | demo/components/moderation.js | 4 | ||||
-rw-r--r-- | demo/components/private-messaging.js | 66 |
2 files changed, 70 insertions, 0 deletions
diff --git a/demo/components/moderation.js b/demo/components/moderation.js index 1a2b0fd..4cf8071 100644 --- a/demo/components/moderation.js +++ b/demo/components/moderation.js @@ -22,6 +22,8 @@ export default { <graffiti-objects :tags="[channel]" v-slot="{objects}"> + <h3>Example 1</h3> + <p> Only show me objects with more than <input v-model.number="likeThreshold"/> likes. </p> @@ -35,6 +37,8 @@ export default { </graffiti-objects> </ul> + <h3>Example 2</h3> + <p> Only show me objects that <select v-model="admin"> diff --git a/demo/components/private-messaging.js b/demo/components/private-messaging.js new file mode 100644 index 0000000..61f783b --- /dev/null +++ b/demo/components/private-messaging.js @@ -0,0 +1,66 @@ +import Chat from './chat.js' +import {Name} from './name.js' + +export default { + + data: ()=> ({ + recipient: null, + message: '' + }), + + methods: { + messageObjects: Chat.methods.messageObjects, + chatObjects(objects) { + return this.messageObjects(objects).filter(o=> + '_to' in o && o._to.length == 1) + }, + + sendMessage() { + if (!this.message) return + this.$graffitiUpdate({ + message: this.message, + timestamp: Date.now(), + _to: [this.recipient], + _tags: [this.$graffitiMyID, this.recipient] + }) + this.message = '' + } + }, + + template: ` + Send private message to: + <graffiti-objects :tags="['demo']" v-slot="{objects}"> + <select v-model="recipient"> + <option v-for="id in objects.notMine.authors" :value="id"> + <Name :of="id"> + </option> + </select> + </graffiti-objects> + + <form @submit.prevent="sendMessage"> + <input v-model="message"> + <input type="submit" value="Submit"/> + </form> + + <graffiti-objects :tags="[$graffitiMyID]" v-slot="{objects}"> + + <h3>My Outbox</h3> + + <ul v-for="object in chatObjects(objects).mine"> + <li> + To <em><Name :of="object._to[0]"/></em>: + {{ object.message }} + </li> + </ul> + + <h3>My Inbox</h3> + + <ul v-for="object in chatObjects(objects).notMine"> + <li> + From <em><Name :of="object._by"/></em>: + {{ object.message }} + </li> + </ul> + + </graffiti-objects>` +} |