* 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:
@@ -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])
|
||||
})
|
||||
|
@@ -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) )
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user