diff options
| author | Tusooa Zhu <tusooa@kazv.moe> | 2021-08-07 00:33:06 -0400 |
|---|---|---|
| committer | Tusooa Zhu <tusooa@kazv.moe> | 2022-03-07 19:19:29 -0500 |
| commit | 0f2fd8a3523e9e2cd1ca6fe287eb7304895f2cba (patch) | |
| tree | 1d5f2d3acd75161b61aabf6497f05052698373b2 /src/components/thread_tree | |
| parent | 0582f19e7c2c6f916b427d5ecfbbb571178ce841 (diff) | |
Implement thread folding/expanding
Diffstat (limited to 'src/components/thread_tree')
| -rw-r--r-- | src/components/thread_tree/thread_tree.js | 12 | ||||
| -rw-r--r-- | src/components/thread_tree/thread_tree.vue | 35 |
2 files changed, 43 insertions, 4 deletions
diff --git a/src/components/thread_tree/thread_tree.js b/src/components/thread_tree/thread_tree.js index 4f95122a..88b60109 100644 --- a/src/components/thread_tree/thread_tree.js +++ b/src/components/thread_tree/thread_tree.js @@ -21,7 +21,14 @@ const ThreadTree = { getHighlight: Function, getReplies: Function, setHighlight: Function, - toggleExpanded: Function + toggleExpanded: Function, + + // to control display of the whole thread forest + toggleThreadDisplay: Function, + threadDisplayStatus: Object, + showThreadRecursively: Function, + totalReplyCount: Object, + totalReplyDepth: Object }, computed: { reverseLookupTable () { @@ -35,6 +42,9 @@ const ThreadTree = { debug('getReplies:', this.getReplies(this.status.id)) return this.getReplies(this.status.id).map(({ id }) => this.statusById(id)) }, + threadShowing () { + return this.threadDisplayStatus[this.status.id] === 'showing' + } }, methods: { statusById (id) { diff --git a/src/components/thread_tree/thread_tree.vue b/src/components/thread_tree/thread_tree.vue index 8256eee6..9f591585 100644 --- a/src/components/thread_tree/thread_tree.vue +++ b/src/components/thread_tree/thread_tree.vue @@ -13,18 +13,23 @@ :replies="getReplies(status.id)" :in-profile="inProfile" :profile-user-id="profileUserId" - class="conversation-status status-fadein panel-body" + class="conversation-status conversation-status-treeview status-fadein panel-body" + + :controlled-thread-display-status="threadDisplayStatus[status.id]" + :controlled-toggle-thread-display="() => toggleThreadDisplay(status.id)" + @goto="setHighlight" @toggleExpanded="toggleExpanded" /> <div - v-if="currentReplies.length" + v-if="currentReplies.length && threadShowing" class="thread-tree-replies" > <thread-tree v-for="replyStatus in currentReplies" :key="replyStatus.id" ref="childComponent" + :depth="depth + 1" :status="replyStatus" :in-profile="inProfile" @@ -40,16 +45,40 @@ :set-highlight="setHighlight" :toggle-expanded="toggleExpanded" - class="conversation-status status-fadein panel-body" + :toggle-thread-display="toggleThreadDisplay" + :thread-display-status="threadDisplayStatus" + :show-thread-recursively="showThreadRecursively" + :total-reply-count="totalReplyCount" + :total-reply-depth="totalReplyDepth" /> </div> + <div + v-if="currentReplies.length && !threadShowing" + class="thread-tree-replies thread-tree-replies-hidden" + > + <button + class="button-unstyled -link thread-tree-show-replies-button" + @click="showThreadRecursively(status.id)" + > + {{ $t('status.thread_show_full', { numStatus: totalReplyCount[status.id], depth: totalReplyDepth[status.id] }) }} + </button> + </div> </div> </template> <script src="./thread_tree.js"></script> <style lang="scss"> +@import '../../_variables.scss'; .thread-tree-replies { margin-left: 1em; } +.thread-tree-replies-hidden { + padding: 1em; + border-bottom: 1px solid var(--border, #222); +} +.conversation-status.conversation-status-treeview:last-child, +.Conversation.-expanded .conversation-status.conversation-status-treeview:last-child { + border-bottom: 1px solid var(--border, #222); +} </style> |
