* Search bar only appears in header menu on mobile

* Added tooltip to logout button
* Tags follow archived, inbox, main note fast filters
This commit is contained in:
Max G 2020-02-12 05:29:56 +00:00
parent 771b739c37
commit a51d81b013
4 changed files with 45 additions and 22 deletions

View File

@ -111,7 +111,7 @@
</div>
<div class="six wide center aligned column">
<img v-if="!loggedIn" src="/api/static/assets/favicon.ico" alt="logo" />
<search-input v-if="loggedIn"></search-input>
<search-input v-if="loggedIn && mobile"></search-input>
</div>
<div class="three wide right aligned column">
@ -196,7 +196,7 @@
</div>
</div>
<div class="menu-section" v-if="loggedIn">
<div class="menu-section" v-if="loggedIn" data-tooltip="Click to log out" data-inverted="" data-position="right center">
<div v-if="loggedIn" v-on:click="destroyLoginToken" class="menu-item menu-button">
<i class="user outline icon"></i>{{ucWords($store.getters.getUsername)}}
</div>

View File

@ -3,16 +3,16 @@
<div class="ui grid" :class="{ 'mush-it-up':showOneColumn() }" ref="content">
<div v-if="!$store.getters.getIsUserOnMobile" class="sixteen wide column">
<div class="sixteen wide column">
<!-- :class="{ 'sixteen wide column':showOneColumn(), 'sixteen wide column':!showOneColumn() }" -->
<div class="ui grid">
<div class="eight wide column">
<div class="six wide column" v-if="!$store.getters.getIsUserOnMobile">
<search-input></search-input>
</div>
<div class="eight wide column">
<div class="ten wide column" :class="{ 'sixteen wide column':$store.getters.getIsUserOnMobile }">
<div class="ui basic button" v-on:click="updateFastFilters(3)" v-if="$store.getters.totals && $store.getters.totals['sharedToNotes'] > 0" style="position: relative;">
<i class="green mail icon"></i>Inbox
@ -41,14 +41,6 @@
</div>
<div v-if="$store.getters.getIsUserOnMobile && showClear" class="row">
<div class="sixteen wide column">
<span class="ui fluid green button" @click="reset">
<i class="arrow circle left icon"></i>Back to All Notes
</span>
</div>
</div>
<div v-if="commonTags.length > 0" class="sixteen wide column">
<h4><i class="green tags icon"></i>Tags</h4>
<span v-for="tag in commonTags" @click="toggleTagFilter(tag.id)">
@ -654,7 +646,14 @@
},
fetchUserTags(){
return new Promise((resolve, reject) => {
axios.post('/api/tag/usertags')
let postData = {
searchQuery: this.searchTerm,
searchTags: this.searchTags,
fastFilters: this.fastFilters,
}
axios.post('/api/tag/usertags', postData)
.then( ({data}) => {
this.commonTags = data
resolve(data)

View File

@ -2,16 +2,40 @@ let db = require('@config/database')
let Tag = module.exports = {}
Tag.userTags = (userId) => {
Tag.userTags = (userId, searchQuery, searchTags, fastFilters) => {
return new Promise((resolve, reject) => {
db.promise()
.query(`
SELECT tag.id, text, COUNT(note_tag.note_id) as usages FROM tag
let query = `
SELECT
tag.id,
text,
COUNT(note_tag.note_id) as usages
FROM tag
JOIN note_tag ON tag.id = note_tag.tag_id
JOIN note On note.id = note_tag.note_id
WHERE note_tag.user_id = ?
GROUP BY tag.id
ORDER BY id DESC
`, [userId])
`
//Show shared notes
if(fastFilters.onlyShowSharedNotes == 1){
query += ' AND note.share_user_id IS NOT NULL' //Show Archived
} else {
query += ' AND note.share_user_id IS NULL'
}
//Show archived notes, only if fast filter is set, default to not archived
if(fastFilters.onlyArchived == 1){
query += ' AND note.archived = 1' //Show Archived
} else {
query += ' AND note.archived = 0' //Exclude archived
}
query += ` GROUP BY tag.id
ORDER BY id DESC`
db.promise()
.query(query, [userId])
.then( (rows, fields) => {
resolve(rows[0])
})

View File

@ -44,7 +44,7 @@ router.post('/get', function (req, res) {
//Get all the tags for this user in order of usage
router.post('/usertags', function (req, res) {
Tags.userTags(userId)
Tags.userTags(userId, req.body.searchQuery, req.body.searchTags, req.body.fastFilters)
.then( data => res.send(data) )
})