allow #newNotesOnTop=false to negate previous setting, closes #3796

This commit is contained in:
zadam 2023-04-03 21:08:32 +02:00
parent a0e9ac73c9
commit d100b0dc07
4 changed files with 31 additions and 3 deletions

4
package-lock.json generated
View file

@ -1,11 +1,11 @@
{
"name": "trilium",
"version": "0.59.2",
"version": "0.59.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "0.59.2",
"version": "0.59.3",
"hasInstallScript": true,
"license": "AGPL-3.0-only",
"dependencies": {

View file

@ -532,6 +532,20 @@ class BNote extends AbstractBeccaEntity {
*/
hasLabel(name, value) { return this.hasAttribute(LABEL, name, value); }
/**
* @param {string} name - label name
* @returns {boolean} true if label exists (including inherited) and does not have "false" value.
*/
isLabelTruthy(name) {
const label = this.getLabel(name);
if (!label) {
return false;
}
return label && label.value !== 'false';
}
/**
* @param {string} name - label name
* @param {string} [value] - label value

View file

@ -595,6 +595,20 @@ class FNote {
*/
hasLabel(name) { return this.hasAttribute(LABEL, name); }
/**
* @param {string} name - label name
* @returns {boolean} true if label exists (including inherited) and does not have "false" value.
*/
isLabelTruthy(name) {
const label = this.getLabel(name);
if (!label) {
return false;
}
return label && label.value !== 'false';
}
/**
* @param {string} name - relation name
* @returns {boolean} true if relation exists (excluding inherited)

View file

@ -23,7 +23,7 @@ const ValidationError = require("../errors/validation_error");
const noteTypesService = require("./note_types");
function getNewNotePosition(parentNote) {
if (parentNote.hasLabel('newNotesOnTop')) {
if (parentNote.isLabelTruthy('newNotesOnTop')) {
const minNotePos = parentNote.getChildBranches()
.reduce((min, note) => Math.min(min, note.notePosition), 0);