diff options
Diffstat (limited to 'plugins/vue/demo/components/name.js')
-rw-r--r-- | plugins/vue/demo/components/name.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/plugins/vue/demo/components/name.js b/plugins/vue/demo/components/name.js new file mode 100644 index 0000000..ec1de62 --- /dev/null +++ b/plugins/vue/demo/components/name.js @@ -0,0 +1,53 @@ +export const Name = { + + props: ["of", "objects"], + + computed: { + name() { + const nameObjects = this.objects + .filter(o=> + 'name' in o && + 'of' in o && + 'timestamp' in o && + typeof o.name == 'string' && + o.of == this.of && + o._by == this.of && + typeof o.timestamp == 'number') + .sortBy('-timestamp') + + return nameObjects.length? + nameObjects[0].name : 'anonymous' + } + }, + + template: '{{name}}' +} + +export const SetMyName = { + + props: ["tags"], + + data: ()=> ({ + name: '' + }), + + methods: { + setMyName() { + this.$graffitiUpdate({ + name: this.name, + timestamp: Date.now(), + of: this.$graffitiID.value, + _tags: this.tags + }) + this.name = '' + } + }, + + template: ` + <form @submit.prevent="setMyName"> + <label for="nameBox">Change your name:</label> + <input v-model="name" id="nameBox"/> + <br> + <input type="submit" value="Submit"/> + </form>` +} |