mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 18:05:55 +01:00 
			
		
		
		
	allow duplicated attribute per note (in effect attributes can be multi-valued). Closes #33
This commit is contained in:
		| @@ -0,0 +1 @@ | ||||
| DROP INDEX IDX_attributes_noteId_name; | ||||
| @@ -118,4 +118,3 @@ CREATE INDEX IDX_note_images_noteId ON note_images (noteId); | ||||
| CREATE INDEX IDX_note_images_imageId ON note_images (imageId); | ||||
| CREATE INDEX IDX_note_images_noteId_imageId ON note_images (noteId, imageId); | ||||
| CREATE INDEX IDX_attributes_noteId ON attributes (noteId); | ||||
| CREATE UNIQUE INDEX IDX_attributes_noteId_name ON attributes (noteId, name); | ||||
|   | ||||
| @@ -28,7 +28,7 @@ const attributesDialog = (function() { | ||||
|  | ||||
|         function isValid() { | ||||
|             for (let attrs = self.attributes(), i = 0; i < attrs.length; i++) { | ||||
|                 if (self.isEmptyName(i) || self.isNotUnique(i)) { | ||||
|                 if (self.isEmptyName(i)) { | ||||
|                     return false; | ||||
|                 } | ||||
|             } | ||||
|   | ||||
| @@ -62,6 +62,8 @@ router.get('/', auth.checkApiAuth, wrap(async (req, res, next) => { | ||||
|  | ||||
|     const {query, params} = getSearchQuery(attrFilters, searchText); | ||||
|  | ||||
|     console.log(query, params); | ||||
|  | ||||
|     const noteIds = await sql.getColumn(query, params); | ||||
|  | ||||
|     res.send(noteIds); | ||||
| @@ -152,7 +154,7 @@ function getSearchQuery(attrFilters, searchText) { | ||||
|         searchParams.push(searchText); // two occurences in searchCondition | ||||
|     } | ||||
|  | ||||
|     const query = `SELECT notes.noteId FROM notes | ||||
|     const query = `SELECT DISTINCT notes.noteId FROM notes | ||||
|             ${joins.join('\r\n')} | ||||
|               WHERE  | ||||
|                 notes.isDeleted = 0 | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
| const build = require('./build'); | ||||
| const packageJson = require('../../package'); | ||||
|  | ||||
| const APP_DB_VERSION = 71; | ||||
| const APP_DB_VERSION = 72; | ||||
|  | ||||
| module.exports = { | ||||
|     app_version: packageJson.version, | ||||
|   | ||||
| @@ -394,8 +394,7 @@ | ||||
|               <td> | ||||
|                 <!-- Change to valueUpdate: blur is necessary because jQuery UI autocomplete hijacks change event --> | ||||
|                 <input type="text" class="attribute-name" data-bind="value: name, valueUpdate: 'blur',  event: { blur: $parent.attributeChanged }"/> | ||||
|  | ||||
|                 <div style="color: red" data-bind="if: $parent.isNotUnique($index())">Attribute name must be unique per note.</div> | ||||
|                 <div style="color: yellowgreen" data-bind="if: $parent.isNotUnique($index())"><span class="glyphicon glyphicon-info-sign"></span> Duplicate attribute.</div> | ||||
|                 <div style="color: red" data-bind="if: $parent.isEmptyName($index())">Attribute name can't be empty.</div> | ||||
|               </td> | ||||
|               <td> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user