mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix backend implementation of bulk actions
This commit is contained in:
parent
433003cf38
commit
f272238dde
@ -78,21 +78,33 @@ const ACTION_HANDLERS = {
|
|||||||
},
|
},
|
||||||
renameLabel: (action, note) => {
|
renameLabel: (action, note) => {
|
||||||
for (const label of note.getOwnedLabels(action.oldLabelName)) {
|
for (const label of note.getOwnedLabels(action.oldLabelName)) {
|
||||||
label.name = action.newLabelName;
|
// attribute name is immutable, renaming means delete old + create new
|
||||||
label.save();
|
const newLabel = label.createClone('label', action.newLabelName, label.value);
|
||||||
|
|
||||||
|
newLabel.save();
|
||||||
|
label.markAsDeleted();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
renameRelation: (action, note) => {
|
renameRelation: (action, note) => {
|
||||||
for (const relation of note.getOwnedRelations(action.oldRelationName)) {
|
for (const relation of note.getOwnedRelations(action.oldRelationName)) {
|
||||||
relation.name = action.newRelationName;
|
// attribute name is immutable, renaming means delete old + create new
|
||||||
relation.save();
|
const newRelation = relation.createClone('relation', action.newRelationName, relation.value);
|
||||||
|
|
||||||
|
newRelation.save();
|
||||||
|
relation.markAsDeleted();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setLabelValue: (action, note) => {
|
updateLabelValue: (action, note) => {
|
||||||
note.setLabel(action.labelName, action.labelValue);
|
for (const label of note.getOwnedLabels(action.labelName)) {
|
||||||
|
label.value = action.labelValue;
|
||||||
|
label.save();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setRelationTarget: (action, note) => {
|
updateRelationTarget: (action, note) => {
|
||||||
note.setRelation(action.relationName, action.targetNoteId);
|
for (const relation of note.getOwnedLabels(action.relationName)) {
|
||||||
|
relation.value = action.targetNoteId;
|
||||||
|
relation.save();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
moveNote: (action, note) => {
|
moveNote: (action, note) => {
|
||||||
const targetParentNote = becca.getNote(action.targetParentNoteId);
|
const targetParentNote = becca.getNote(action.targetParentNoteId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user