Skip to content

Build your personal knowledge base with Trilium Notes

attrs WIP

zadam22302e8200ce
diff --git a/db/migrations/0159__migrate_attr_definitions.sql b/db/migrations/0159__migrate_attr_definitions.sql
new file mode 100644
index 0000000000..8ed5419db2
--- /dev/null
+++ b/db/migrations/0159__migrate_attr_definitions.sql
@@ -0,0 +1,2 @@
+UPDATE attributes SET type = 'label', name = 'label:' || name WHERE type = 'label-definition';
+UPDATE attributes SET type = 'label', name = 'relation:' || name WHERE type = 'relation-definition';
diff --git a/src/public/app/widgets/note_attributes.js b/src/public/app/widgets/note_attributes.js
index 13733b4585..655d08b41e 100644
--- a/src/public/app/widgets/note_attributes.js
+++ b/src/public/app/widgets/note_attributes.js
@@ -94,8 +94,8 @@ const TPL = `
z-index: 1000;
padding: 10px;
position: absolute;
- max-width: 400px;
- max-height: 500px;
+ max-width: 600px;
+ max-height: 600px;
overflow: auto;
}
@@ -104,9 +104,61 @@ const TPL = `
margin-top: 10px;
margin-bottom: 10px;
}
+
+.attr-edit {
+ width: 100%;
+}
+
+.attr-edit th {
+ text-align: left;
+}
+
+.attr-edit td input {
+ width: 100%;
+}
</style>
<div class="attr-extras" style="display: none;">
+ <h5>Label detail</h5>
+
+ <table class="attr-edit">
+ <tr>
+ <th>Name:</th>
+ <td><input type="text" class="form-control form-control-sm" /></td>
+ </tr>
+ <tr>
+ <th>Value:</th>
+ <td><input type="text" class="form-control form-control-sm" /></td>
+ </tr>
+ <tr>
+ <th>Inheritable:</th>
+ <td><input type="checkbox" class="form-control form-control-sm" /></td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <div style="display: flex; justify-content: space-between">
+ <div>
+ <button type="submit" class="btn btn-sm btn-primary">Save</button>
+ <button type="submit" class="btn btn-sm btn-secondary">Cancel</button>
+ </div>
+
+ <div>
+ <button type="submit" class="btn btn-sm btn-danger">Delete</button>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </table>
+
+ <br/>
+
+ <h5>Other notes with this label</h5>
+
+ <div class="form-check">
+ <input type="checkbox" class="form-check-input" id="match-value-too">
+ <label class="form-check-label" for="match-value-too">match value too</label>
+ </div>
+
<div class="attr-extras-title"></div>
<ul class="attr-extras-list"></ul>
@@ -152,11 +204,11 @@ export default class NoteAttributesWidget extends TabAwareWidget {
this.$attrExtras.hide();
});
- this.$editor.on('blur', () => {
- this.save();
-
- this.$attrExtras.hide();
- });
+ // this.$editor.on('blur', () => {
+ // this.save();
+ //
+ // this.$attrExtras.hide();
+ // });
return this.$widget;
}
@@ -253,6 +305,8 @@ export default class NoteAttributesWidget extends TabAwareWidget {
);
}
+ this.$attrExtrasTitle.hide();
+
this.$attrExtrasList.empty();
const displayedResults = results.length <= DISPLAYED_NOTES ? results : results.slice(0, DISPLAYED_NOTES);
diff --git a/src/services/app_info.js b/src/services/app_info.js
index 0df3b0b747..af90d2b89f 100644
--- a/src/services/app_info.js
+++ b/src/services/app_info.js
@@ -4,7 +4,7 @@ const build = require('./build');
const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir');
-const APP_DB_VERSION = 158;
+const APP_DB_VERSION = 159;
const SYNC_VERSION = 14;
const CLIPPER_PROTOCOL_VERSION = "1.0";
@@ -16,4 +16,4 @@ module.exports = {
buildRevision: build.buildRevision,
dataDirectory: TRILIUM_DATA_DIR,
clipperProtocolVersion: CLIPPER_PROTOCOL_VERSION
-};
\ No newline at end of file
+};
diff --git a/src/services/backup.js b/src/services/backup.js
index 1b09137a29..1810ca0284 100644
--- a/src/services/backup.js
+++ b/src/services/backup.js
@@ -9,7 +9,6 @@ const sqlInit = require('./sql_init');
const syncMutexService = require('./sync_mutex');
const attributeService = require('./attributes');
const cls = require('./cls');
-const utils = require('./utils');
const Database = require('better-sqlite3');
function regularBackup() {
@@ -100,12 +99,15 @@ if (!fs.existsSync(dataDir.BACKUP_DIR)) {
fs.mkdirSync(dataDir.BACKUP_DIR, 0o700);
}
-sqlInit.dbReady.then(() => {
- setInterval(cls.wrap(regularBackup), 4 * 60 * 60 * 1000);
+// hack
+setTimeout(() => {
+ sqlInit.dbReady.then(() => {
+ setInterval(cls.wrap(regularBackup), 4 * 60 * 60 * 1000);
- // kickoff first backup soon after start up
- setTimeout(cls.wrap(regularBackup), 5 * 60 * 1000);
-});
+ // kickoff first backup soon after start up
+ setTimeout(cls.wrap(regularBackup), 5 * 60 * 1000);
+ });
+}, 5000);
module.exports = {
backupNow,
diff --git a/src/services/cls.js b/src/services/cls.js
index 32af8ff6c2..c1f8ff6094 100644
--- a/src/services/cls.js
+++ b/src/services/cls.js
@@ -42,7 +42,7 @@ function getAndClearSyncRows() {
}
function addSyncRow(syncRow) {
- const syncRows = getSyncRows();
+ const syncRows = namespace.get('syncRows') || [];
syncRows.push(syncRow);