* 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

@@ -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) )
})