mirror of https://github.com/TriliumNext/Notes
added dialog and read only view of attributes
parent
b250ad593c
commit
8fe6a9353a
@ -0,0 +1,45 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const attributesDialog = (function() {
|
||||||
|
const dialogEl = $("#attributes-dialog");
|
||||||
|
|
||||||
|
function AttributesModel(attributes) {
|
||||||
|
const model = this;
|
||||||
|
|
||||||
|
this.attributes = ko.observableArray(attributes);
|
||||||
|
|
||||||
|
this.addNewRow = function() {
|
||||||
|
model.attributes.push({
|
||||||
|
attribute_id: '',
|
||||||
|
name: '',
|
||||||
|
value: ''
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function showDialog() {
|
||||||
|
glob.activeDialog = dialogEl;
|
||||||
|
|
||||||
|
dialogEl.dialog({
|
||||||
|
modal: true,
|
||||||
|
width: 800,
|
||||||
|
height: 700
|
||||||
|
});
|
||||||
|
|
||||||
|
const noteId = noteEditor.getCurrentNoteId();
|
||||||
|
|
||||||
|
const attributes = await server.get('notes/' + noteId + '/attributes');
|
||||||
|
|
||||||
|
ko.applyBindings(new AttributesModel(attributes));
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).bind('keydown', 'alt+a', e => {
|
||||||
|
showDialog();
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
showDialog
|
||||||
|
};
|
||||||
|
})();
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
const sql = require('../../services/sql');
|
||||||
|
const auth = require('../../services/auth');
|
||||||
|
const wrap = require('express-promise-wrap').wrap;
|
||||||
|
|
||||||
|
router.get('/:noteId/attributes', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||||
|
const noteId = req.params.noteId;
|
||||||
|
|
||||||
|
res.send(await sql.getAll("SELECT * FROM attributes WHERE note_id = ? ORDER BY date_created", [noteId]));
|
||||||
|
}));
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
Loading…
Reference in New Issue