mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	attrs WIP
This commit is contained in:
		
							
								
								
									
										2
									
								
								db/migrations/0159__migrate_attr_definitions.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								db/migrations/0159__migrate_attr_definitions.sql
									
									
									
									
									
										Normal file
									
								
							@@ -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';
 | 
				
			||||||
@@ -94,8 +94,8 @@ const TPL = `
 | 
				
			|||||||
    z-index: 1000;
 | 
					    z-index: 1000;
 | 
				
			||||||
    padding: 10px;
 | 
					    padding: 10px;
 | 
				
			||||||
    position: absolute;
 | 
					    position: absolute;
 | 
				
			||||||
    max-width: 400px;
 | 
					    max-width: 600px;
 | 
				
			||||||
    max-height: 500px;
 | 
					    max-height: 600px;
 | 
				
			||||||
    overflow: auto;
 | 
					    overflow: auto;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -104,9 +104,61 @@ const TPL = `
 | 
				
			|||||||
    margin-top: 10px;
 | 
					    margin-top: 10px;
 | 
				
			||||||
    margin-bottom: 10px;
 | 
					    margin-bottom: 10px;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.attr-edit {
 | 
				
			||||||
 | 
					    width: 100%;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.attr-edit th {
 | 
				
			||||||
 | 
					    text-align: left;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.attr-edit td input {
 | 
				
			||||||
 | 
					    width: 100%;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
</style>
 | 
					</style>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div class="attr-extras" style="display: none;">
 | 
					<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>
 | 
					    <div class="attr-extras-title"></div>
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    <ul class="attr-extras-list"></ul>
 | 
					    <ul class="attr-extras-list"></ul>
 | 
				
			||||||
@@ -152,11 +204,11 @@ export default class NoteAttributesWidget extends TabAwareWidget {
 | 
				
			|||||||
            this.$attrExtras.hide();
 | 
					            this.$attrExtras.hide();
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.$editor.on('blur', () => {
 | 
					        // this.$editor.on('blur', () => {
 | 
				
			||||||
            this.save();
 | 
					        //     this.save();
 | 
				
			||||||
 | 
					        //
 | 
				
			||||||
            this.$attrExtras.hide();
 | 
					        //     this.$attrExtras.hide();
 | 
				
			||||||
        });
 | 
					        // });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return this.$widget;
 | 
					        return this.$widget;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -253,6 +305,8 @@ export default class NoteAttributesWidget extends TabAwareWidget {
 | 
				
			|||||||
                    );
 | 
					                    );
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                this.$attrExtrasTitle.hide();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                this.$attrExtrasList.empty();
 | 
					                this.$attrExtrasList.empty();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                const displayedResults = results.length <= DISPLAYED_NOTES ? results : results.slice(0, DISPLAYED_NOTES);
 | 
					                const displayedResults = results.length <= DISPLAYED_NOTES ? results : results.slice(0, DISPLAYED_NOTES);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,7 @@ const build = require('./build');
 | 
				
			|||||||
const packageJson = require('../../package');
 | 
					const packageJson = require('../../package');
 | 
				
			||||||
const {TRILIUM_DATA_DIR} = require('./data_dir');
 | 
					const {TRILIUM_DATA_DIR} = require('./data_dir');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const APP_DB_VERSION = 158;
 | 
					const APP_DB_VERSION = 159;
 | 
				
			||||||
const SYNC_VERSION = 14;
 | 
					const SYNC_VERSION = 14;
 | 
				
			||||||
const CLIPPER_PROTOCOL_VERSION = "1.0";
 | 
					const CLIPPER_PROTOCOL_VERSION = "1.0";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -16,4 +16,4 @@ module.exports = {
 | 
				
			|||||||
    buildRevision: build.buildRevision,
 | 
					    buildRevision: build.buildRevision,
 | 
				
			||||||
    dataDirectory: TRILIUM_DATA_DIR,
 | 
					    dataDirectory: TRILIUM_DATA_DIR,
 | 
				
			||||||
    clipperProtocolVersion: CLIPPER_PROTOCOL_VERSION
 | 
					    clipperProtocolVersion: CLIPPER_PROTOCOL_VERSION
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,6 @@ const sqlInit = require('./sql_init');
 | 
				
			|||||||
const syncMutexService = require('./sync_mutex');
 | 
					const syncMutexService = require('./sync_mutex');
 | 
				
			||||||
const attributeService = require('./attributes');
 | 
					const attributeService = require('./attributes');
 | 
				
			||||||
const cls = require('./cls');
 | 
					const cls = require('./cls');
 | 
				
			||||||
const utils = require('./utils');
 | 
					 | 
				
			||||||
const Database = require('better-sqlite3');
 | 
					const Database = require('better-sqlite3');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function regularBackup() {
 | 
					function regularBackup() {
 | 
				
			||||||
@@ -100,12 +99,15 @@ if (!fs.existsSync(dataDir.BACKUP_DIR)) {
 | 
				
			|||||||
    fs.mkdirSync(dataDir.BACKUP_DIR, 0o700);
 | 
					    fs.mkdirSync(dataDir.BACKUP_DIR, 0o700);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
sqlInit.dbReady.then(() => {
 | 
					// hack
 | 
				
			||||||
    setInterval(cls.wrap(regularBackup), 4 * 60 * 60 * 1000);
 | 
					setTimeout(() => {
 | 
				
			||||||
 | 
					    sqlInit.dbReady.then(() => {
 | 
				
			||||||
 | 
					        setInterval(cls.wrap(regularBackup), 4 * 60 * 60 * 1000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // kickoff first backup soon after start up
 | 
					        // kickoff first backup soon after start up
 | 
				
			||||||
    setTimeout(cls.wrap(regularBackup), 5 * 60 * 1000);
 | 
					        setTimeout(cls.wrap(regularBackup), 5 * 60 * 1000);
 | 
				
			||||||
});
 | 
					    });
 | 
				
			||||||
 | 
					}, 5000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = {
 | 
					module.exports = {
 | 
				
			||||||
    backupNow,
 | 
					    backupNow,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,7 +42,7 @@ function getAndClearSyncRows() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function addSyncRow(syncRow) {
 | 
					function addSyncRow(syncRow) {
 | 
				
			||||||
    const syncRows = getSyncRows();
 | 
					    const syncRows = namespace.get('syncRows') || [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    syncRows.push(syncRow);
 | 
					    syncRows.push(syncRow);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user