Skip to content

Commit 24f988e

Browse files
authored
Merge pull request #87 from haystack/develop
Show hidden threads on margin and show msg if there are no threads in sidebar
2 parents 834313b + 6ca724e commit 24f988e

File tree

9 files changed

+198
-56
lines changed

9 files changed

+198
-56
lines changed

public/style/plugin.css

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@
916916
}
917917
#nb-app .nb-sidebar .thread-view .thread-row .footer > span .icon {
918918
height: 14px;
919-
vertical-align: top;
919+
vertical-align: bottom;
920920
}
921921

922922
#nb-app-wrapper .thread-overflow-wrapper .tooltip-arrow {
@@ -1731,7 +1731,49 @@ nb-innotation-controller {
17311731
background-color: #555;
17321732
}
17331733

1734+
.empty-and-filterd {
1735+
display: flex;
1736+
flex-direction: column;
1737+
justify-content: center;
1738+
align-items: center;
1739+
height: 100%;
1740+
padding: 0 20px;
1741+
text-align: center;
1742+
}
1743+
1744+
.empty-and-filterd .filter-icon svg {
1745+
font-size: 3em !important;
1746+
transform: initial;
1747+
}
1748+
1749+
.empty-and-filterd .text {
1750+
font-size: 1.5em;
1751+
color: #666;
1752+
font-weight: bold;
1753+
margin: 10px;
1754+
}
1755+
1756+
.empty-and-filterd button {
1757+
color: #fff;
1758+
background: #4f2874;
1759+
height: 30px;
1760+
width: 100px;
1761+
font-size: 1.2em;
1762+
border-radius: 0;
1763+
border: initial;
1764+
}
1765+
1766+
.empty-and-filterd button:hover {
1767+
background: #431f64;
1768+
color: #fff;
1769+
border: initial;
1770+
1771+
}
17341772

1773+
div.trigger span {
1774+
display: flex;
1775+
height: 100%;
1776+
}
17351777

17361778
/* UC Davis LibreTexts */
17371779
@media (min-width: 83em) {

src/app.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ function embedNbApp() {
154154
<nb-highlights
155155
:key="redrawHighlightsKey"
156156
:threads="filteredThreads"
157+
:threads-hidden="hiddenThreads"
157158
:thread-selected="threadSelected"
158159
:threads-hovered="threadsHovered"
159160
:draft-range="draftRange"
@@ -408,6 +409,10 @@ function embedNbApp() {
408409
totalSpotlights: function () {
409410
return this.threads.filter(t => (t.spotlight && t.spotlight.type && t.spotlight.type !== 'NONE') ||(t.systemSpotlight && t.systemSpotlight.type && t.systemSpotlight.type !== 'NONE')).length
410411
},
412+
hiddenThreads: function () {
413+
let ht = this.threads.filter(t => !this.filteredThreads.includes(t))
414+
return ht
415+
},
411416
filteredThreads: function () {
412417
let items = this.threads
413418
let searchText = this.filter.searchText
@@ -482,7 +487,9 @@ function embedNbApp() {
482487
let filterUpvotes = this.filter.upvotes
483488
if (filterUpvotes.length > 0) {
484489
items = items.filter(item => {
485-
if ( (filterUpvotes.includes('anyone') && item.hasUpvotes()) || (this.currentConfigs.isExpClass && item.hasUserPost(this.user.id))) {
490+
if ( (filterUpvotes.includes('anyone') && item.hasUpvotes())
491+
|| (this.currentConfigs.isExpClass && item.hasUserPost(this.user.id))
492+
|| (this.currentConfigs.isExpClass && item.hasReplyRequests())) {
486493
return true
487494
}
488495
if (filterUpvotes.includes('me') && item.hasMyUpvotes()) {

src/components/NbSidebar.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
:users="sortedUsers"
4747
:hashtags="sortedHashtags"
4848
:sync-config="syncConfig"
49+
:filter-visible="filterVisible"
4950
:current-configs="currentConfigs"
5051
:filter="filter"
5152
@search-option="onSearchOption"
@@ -63,7 +64,9 @@
6364
@max-threads="onMaxThreads"
6465
@min-replies="onMinReplies"
6566
@min-reply-reqs="onMinReplyReqs"
66-
@min-upvotes="onMinUpvotes">
67+
@min-upvotes="onMinUpvotes"
68+
@toggle-filters="onToggleFilters"
69+
@filter-hide="onFilterHide">
6770
</filter-view>
6871
<list-view
6972
:threads="threads"
@@ -86,7 +89,8 @@
8689
@toggle-spotlights="onToggleSpotlights"
8790
@select-thread="onSelectThread"
8891
@hover-thread="onHoverThread"
89-
@unhover-thread="onUnhoverThread">
92+
@unhover-thread="onUnhoverThread"
93+
@filter-show="onFilterShow">
9094
</list-view>
9195
<thread-view
9296
v-if="threadSelected"
@@ -253,6 +257,7 @@ export default {
253257
},
254258
data () {
255259
return {
260+
filterVisible: false,
256261
replyToComment: null,
257262
edittingComment: null,
258263
editor: {
@@ -330,6 +335,15 @@ export default {
330335
this.$emit('dragging', true)
331336
}
332337
},
338+
onToggleFilters: function (event) {
339+
this.filterVisible = !this.filterVisible
340+
},
341+
onFilterHide: function () {
342+
this.filterVisible = false
343+
},
344+
onFilterShow: function () {
345+
this.filterVisible = true
346+
},
333347
onHandleRedrawHighlights: function () {
334348
this.$emit('handle-redraw-highlights')
335349
},

src/components/editor/EditorView.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
<div class="checkbox-buttons">
4747
<input type="checkbox" id="draft-request-reply" v-if="currentConfigs.isExpClass" v-model="upvotedByMe">
4848
<input type="checkbox" id="draft-request-reply" v-else v-model="replyRequested">
49-
<label for="draft-request-reply">{{ currentConfigs.isExpClass ? "Discuss with class" : "Request replies" }}</label>
49+
<label for="draft-request-reply">{{ currentConfigs.isExpClass ? "Looking for Classmates' Perspectives" : "Request replies" }}</label>
50+
</div>
51+
<div class="checkbox-buttons">
5052
<div class="buttons">
5153
<button class="cancel" @click="cancel" :disabled='isSubmitting'>Cancel</button>
5254
<button class="submit" @click="submit" :disabled='isSubmitting || !canSubmit'>

src/components/filters/FilterView.vue

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,9 @@
4343
<span
4444
class="tooltip-target"
4545
v-tooltip="filterVisible ? 'hide' : 'show all filters'"
46-
@click="toggleFilters">
47-
<font-awesome-icon v-if="filterVisible"
48-
icon="times-circle" class="icon">
49-
</font-awesome-icon>
50-
<font-awesome-icon v-else icon="search-plus" class="icon">
51-
</font-awesome-icon>
46+
@click="onToggleFilters">
47+
<font-awesome-icon v-if="filterVisible" icon="times-circle" class="icon"></font-awesome-icon>
48+
<font-awesome-icon v-else icon="filter" class="icon"></font-awesome-icon>
5249
</span>
5350
<template slot="popover">
5451
<div class="filter-options">
@@ -70,16 +67,41 @@
7067
</div>
7168
</div>
7269
<div class="title">Max. # of threads</div>
73-
<div>
70+
<div>
71+
<input
72+
type="number"
73+
id="max-threads"
74+
placeholder="n/a"
75+
min="0"
76+
v-model="maxThreads"
77+
@keypress="event => validateNumber(event)"
78+
@change="onFilterChange('max-threads')">
79+
</div>
80+
<div class="title">{{currentConfigs.isExpClass ? `Looking for Classmates' Perspectives` : 'Upvotes'}}</div>
81+
<div class="upvotes">
82+
<div>
7483
<input
75-
type="number"
76-
id="max-threads"
77-
placeholder="n/a"
78-
min="0"
79-
v-model="maxThreads"
80-
@keypress="event => validateNumber(event)"
81-
@change="onFilterChange('max-threads')">
84+
type="checkbox"
85+
id="anyone-upvotes"
86+
value="anyone"
87+
v-model="filterUpvotes"
88+
@change="onFilterChange('upvotes')">
89+
<label for="anyone-upvotes">
90+
anyone
91+
</label>
92+
</div>
93+
<div>
94+
<input
95+
type="checkbox"
96+
id="my-upvotes"
97+
value="me"
98+
v-model="filterUpvotes"
99+
@change="onFilterChange('upvotes')">
100+
<label for="my-upvotes">
101+
me
102+
</label>
82103
</div>
104+
</div>
83105
<div class="title">Users tagged</div>
84106
<div class="user-tags">
85107
<div>
@@ -166,31 +188,7 @@
166188
</label>
167189
</div>
168190
</div>
169-
<div class="title">{{currentConfigs.isExpClass ? 'Discussion comments' : 'Upvotes'}}</div>
170-
<div class="upvotes">
171-
<div>
172-
<input
173-
type="checkbox"
174-
id="anyone-upvotes"
175-
value="anyone"
176-
v-model="filterUpvotes"
177-
@change="onFilterChange('upvotes')">
178-
<label for="anyone-upvotes">
179-
anyone
180-
</label>
181-
</div>
182-
<div>
183-
<input
184-
type="checkbox"
185-
id="my-upvotes"
186-
value="me"
187-
v-model="filterUpvotes"
188-
@change="onFilterChange('upvotes')">
189-
<label for="my-upvotes">
190-
me
191-
</label>
192-
</div>
193-
</div>
191+
194192
<div class="title">
195193
Others
196194
</div>
@@ -424,12 +422,15 @@ export default {
424422
users: Array,
425423
hashtags: Array,
426424
syncConfig: Boolean,
425+
filterVisible: {
426+
type: Boolean,
427+
default: false
428+
},
427429
filter: Object,
428430
currentConfigs: Object,
429431
},
430432
data () {
431433
return {
432-
filterVisible: false,
433434
filterBookmarks: false,
434435
filterHashtags: [],
435436
filterUserTags: [],
@@ -459,7 +460,7 @@ export default {
459460
if (this.filter.maxThreads !== this.maxThreads) {
460461
this.maxThreads = this.filter.maxThreads
461462
}
462-
}
463+
},
463464
},
464465
computed: {
465466
currentMaxThread: function() {
@@ -503,11 +504,11 @@ export default {
503504
this.filterBookmarks = !this.filterBookmarks
504505
this.onFilterChange('bookmarks')
505506
},
506-
toggleFilters: function (event) {
507-
this.filterVisible = !this.filterVisible
508-
},
509507
onFilterHide: function () {
510-
this.filterVisible = false
508+
this.$emit('filter-hide')
509+
},
510+
onToggleFilters: function () {
511+
this.$emit('toggle-filters')
511512
},
512513
onFilterChange: function (type) {
513514
switch (type) {

src/components/highlights/NbHighlight.vue

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,23 @@
3434
</rect>
3535

3636
</g>
37+
<g
38+
class="nb-highlight"
39+
v-else-if="isHidden"
40+
:style="style"
41+
v-tooltip.right="{content: getHiddenTooltipContent()}"
42+
@click="$emit('select-thread',thread)"
43+
@mouseenter="onHover(true)"
44+
@mouseleave="onHover(false)">
45+
<rect
46+
v-for="(box, index) in bounds.boxes"
47+
:key="index"
48+
:x="bounds.offsetX"
49+
:y="box.top + bounds.offsetY"
50+
:height="box.height"
51+
width="20">
52+
</rect>
53+
</g>
3754
<g
3855
class="nb-highlight"
3956
v-else
@@ -47,7 +64,7 @@
4764
:x="bounds.offsetX"
4865
:y="box.top + bounds.offsetY"
4966
:height="box.height"
50-
width="10">
67+
width="20">
5168
</rect>
5269
</g>
5370
</template>
@@ -112,6 +129,10 @@ export default {
112129
type: Boolean,
113130
default: false
114131
},
132+
isHidden: {
133+
type: Boolean,
134+
default: false
135+
},
115136
currentConfigs: {
116137
type: Object,
117138
default: () => {}
@@ -168,6 +189,9 @@ export default {
168189
return this.thread.systemSpotlight ? this.thread.systemSpotlight : this.thread.spotlight
169190
},
170191
style: function () {
192+
if (this.isHidden) {
193+
return "fill: none; stroke: rgb(255 204 1 / 95%); stroke-dasharray: 3;"
194+
}
171195
if (!this.thread) {
172196
return 'fill: rgb(231, 76, 60); fill-opacity: 0.3; cursor: pointer;'
173197
}
@@ -242,7 +266,7 @@ export default {
242266
return bounds
243267
},
244268
visible: function () {
245-
return this.showHighlights || (this.thread === this.threadSelected) || (this.showSpotlights && this.spotlight && this.spotlight.type === 'EM')
269+
return !this.isHidden && (this.showHighlights || (this.thread === this.threadSelected) || (this.showSpotlights && this.spotlight && this.spotlight.type === 'EM'))
246270
}
247271
},
248272
methods: {
@@ -316,6 +340,17 @@ export default {
316340
317341
}
318342
},
343+
getHiddenTooltipContent: function () {
344+
let content = "<span>Filtered comment:</span>"
345+
content += "<br>"
346+
let text = this.thread.text
347+
content += text.substring(0, 30)
348+
if (text.length > 30) {
349+
content += "..."
350+
}
351+
return content
352+
353+
},
319354
getTooltipContent: function () {
320355
if (!this.thread || !this.showSyncFeatures) {
321356
return ""

0 commit comments

Comments
 (0)