Cleaned up some display issues that probably still need work
Added some colors to the notes and basic support for displaying the colors on the main list Added a toggle to disable the fancy text editor and just use a basic textarea Added some mobile styles with much better support for smaller screens Added tag suggestions based on user input, excluding tags from current note, only using tags user has put into system Cleaned and refactored a bunch of stuff
This commit is contained in:
@@ -16,13 +16,13 @@ Notes.create = (userId, noteText) => {
|
||||
})
|
||||
}
|
||||
|
||||
Notes.update = (userId, noteId, noteText) => {
|
||||
Notes.update = (userId, noteId, noteText, fancyInput, color) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
const now = Math.round((+new Date)/1000)
|
||||
|
||||
db.promise()
|
||||
.query('UPDATE notes SET text = ?, updated = ? WHERE id = ? AND user = ? LIMIT 1', [noteText, now, noteId, userId])
|
||||
.query('UPDATE notes SET text = ?, raw_input = ?, updated = ?, color = ? WHERE id = ? AND user = ? LIMIT 1', [noteText, fancyInput, now, color, noteId, userId])
|
||||
.then((rows, fields) => {
|
||||
resolve(rows[0])
|
||||
})
|
||||
@@ -39,7 +39,7 @@ Notes.delete = (userId, noteId) => {
|
||||
Notes.get = (userId, noteId) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
db.promise()
|
||||
.query('SELECT text, updated FROM notes WHERE user = ? AND id = ? LIMIT 1', [userId,noteId])
|
||||
.query('SELECT text, updated, raw_input FROM notes WHERE user = ? AND id = ? LIMIT 1', [userId,noteId])
|
||||
.then((rows, fields) => {
|
||||
resolve(rows[0][0])
|
||||
})
|
||||
@@ -64,7 +64,7 @@ Notes.search = (userId, searchQuery, searchTags) => {
|
||||
|
||||
//Default note lookup gets all notes
|
||||
let noteSearchQuery = `
|
||||
SELECT notes.id, SUBSTRING(text, 1, 200) as text, updated
|
||||
SELECT notes.id, SUBSTRING(text, 1, 200) as text, updated, color
|
||||
FROM notes
|
||||
LEFT JOIN notes_tags ON (notes.id = notes_tags.note_id)
|
||||
WHERE user = ?`
|
||||
|
@@ -105,4 +105,27 @@ Tags.lookup = (tagText) => {
|
||||
})
|
||||
.catch(console.log)
|
||||
})
|
||||
}
|
||||
|
||||
//Suggest note tags - don't suggest tags already on note
|
||||
Tags.suggest = (userId, noteId, tagText) => {
|
||||
|
||||
tagText += '%'
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
db.promise()
|
||||
.query(`SELECT text FROM notes_tags
|
||||
JOIN tags ON notes_tags.tag_id = tags.id
|
||||
WHERE notes_tags.user_id = ?
|
||||
AND tags.text LIKE ?
|
||||
AND notes_tags.tag_id NOT IN (
|
||||
SELECT notes_tags.tag_id FROM notes_tags WHERE notes_tags.note_id = ?
|
||||
)
|
||||
GROUP BY text
|
||||
LIMIT 6;`, [userId, tagText, noteId])
|
||||
.then((rows, fields) => {
|
||||
resolve(rows[0]) //Return new ID
|
||||
})
|
||||
.catch(console.log)
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user