aboutsummaryrefslogtreecommitdiff
path: root/src/components/user_note
diff options
context:
space:
mode:
authorTusooa Zhu <tusooa@kazv.moe>2022-08-20 13:02:27 -0400
committertusooa <tusooa@kazv.moe>2022-12-21 23:16:00 -0500
commit1101305ffb72bacd68698bfbe6e961953a9043de (patch)
treee39252de0c24463b1cee18a4b4e77a9e7c7d953c /src/components/user_note
parentcb175d3f65ea79acc54949a3e33e926ce1357733 (diff)
Add ui for note editing
Diffstat (limited to 'src/components/user_note')
-rw-r--r--src/components/user_note/user_note.js31
-rw-r--r--src/components/user_note/user_note.vue88
2 files changed, 119 insertions, 0 deletions
diff --git a/src/components/user_note/user_note.js b/src/components/user_note/user_note.js
new file mode 100644
index 00000000..6a479800
--- /dev/null
+++ b/src/components/user_note/user_note.js
@@ -0,0 +1,31 @@
+const UserNote = {
+ props: {
+ user: Object,
+ relationship: Object
+ },
+ data () {
+ return {
+ localNote: '',
+ editing: false
+ }
+ },
+ computed: {
+ shouldShow () {
+ return this.relationship.note || this.editing
+ }
+ },
+ methods: {
+ startEditing () {
+ this.localNote = this.relationship.note
+ this.editing = true
+ },
+ cancelEditing () {
+ this.editing = false
+ },
+ finalizeEditing () {
+ this.editing = false
+ }
+ }
+}
+
+export default UserNote
diff --git a/src/components/user_note/user_note.vue b/src/components/user_note/user_note.vue
new file mode 100644
index 00000000..46db1ca7
--- /dev/null
+++ b/src/components/user_note/user_note.vue
@@ -0,0 +1,88 @@
+<template>
+ <div
+ class="user-note"
+ >
+ <div class="heading">
+ <span>{{ $t('user_card.note') }}</span>
+ <div class="buttons">
+ <button
+ v-show="!editing"
+ class="button-default btn"
+ @click="startEditing"
+ >
+ {{ $t('user_card.edit_note') }}
+ </button>
+ <button
+ v-show="editing"
+ class="button-default btn"
+ @click="finalizeEditing"
+ >
+ {{ $t('user_card.edit_note_apply') }}
+ </button>
+ <button
+ v-show="editing"
+ class="button-default btn"
+ @click="cancelEditing"
+ >
+ {{ $t('user_card.edit_note_cancel') }}
+ </button>
+ </div>
+ </div>
+ <input
+ v-show="editing"
+ class="note-text"
+ type="string"
+ :model="localNote"
+ >
+ <span
+ v-show="!editing"
+ class="note-text"
+ :class="{ '-blank': !relationship.note }"
+ >
+ {{ relationship.note || $t('user_card.note_blank') }}
+ </span>
+ </div>
+</template>
+
+<script src="./user_note.js"></script>
+
+<style lang="scss">
+@import '../../variables';
+
+.user-note {
+ display: flex;
+ flex-direction: column;
+
+ .heading {
+ display: flex;
+ flex-direction: row;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 0.75em;
+
+ .btn {
+ min-width: 95px;
+ }
+
+ .buttons {
+ display: flex;
+ flex-direction: row;
+ justify-content: right;
+
+ .btn {
+ margin-left: 0.5em;
+ }
+ }
+ }
+
+ .note-text {
+ line-height: 2;
+ align-self: stretch;
+ }
+
+ .note-text.-blank {
+ font-style: italic;
+ color: var(--faint, $fallback--faint);
+ }
+}
+</style>