mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
adding a button to the detail to explicitly save changes.
This commit is contained in:
parent
2c9565b4b3
commit
aa4a645670
@ -203,7 +203,7 @@ function parser(tokens, str, allowEmptyRelations = false) {
|
|||||||
attr.endIndex = tokens[i].endIndex;
|
attr.endIndex = tokens[i].endIndex;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error(`Unrecognized attribute "${text}" in ${context(i)}`);
|
throw new Error(`Invalid attribute "${text}" in ${context(i)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +121,8 @@ const TPL = `
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<button class="btn btn-primary btn-sm attr-save-changes-and-close-button" style="width: 100%; margin-top: 15px;">Save & close</button>
|
||||||
|
|
||||||
<div class="related-notes-container">
|
<div class="related-notes-container">
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
@ -199,6 +201,13 @@ export default class AttributeDetailWidget extends BasicWidget {
|
|||||||
this.$closeAttrDetailButton = this.$widget.find('.close-attr-detail-button');
|
this.$closeAttrDetailButton = this.$widget.find('.close-attr-detail-button');
|
||||||
this.$attrIsOwnedBy = this.$widget.find('.attr-is-owned-by');
|
this.$attrIsOwnedBy = this.$widget.find('.attr-is-owned-by');
|
||||||
|
|
||||||
|
this.$saveAndCloseButton = this.$widget.find('.attr-save-changes-and-close-button');
|
||||||
|
this.$saveAndCloseButton.on('click', async () => {
|
||||||
|
await this.triggerCommand('saveAttributes');
|
||||||
|
|
||||||
|
this.hide();
|
||||||
|
});
|
||||||
|
|
||||||
this.$closeAttrDetailButton.on('click', () => this.hide());
|
this.$closeAttrDetailButton.on('click', () => this.hide());
|
||||||
|
|
||||||
$(window).on('mouseup', e => {
|
$(window).on('mouseup', e => {
|
||||||
@ -388,6 +397,10 @@ export default class AttributeDetailWidget extends BasicWidget {
|
|||||||
|
|
||||||
if (this.attrType === 'label-definition') {
|
if (this.attrType === 'label-definition') {
|
||||||
props.push(this.$attrInputLabelType.val());
|
props.push(this.$attrInputLabelType.val());
|
||||||
|
|
||||||
|
if (this.$attrInputLabelType.val() === 'number' && this.$attrInputNumberPrecision.val() !== '') {
|
||||||
|
props.push('precision=' + this.$attrInputNumberPrecision.val());
|
||||||
|
}
|
||||||
} else if (this.attrType === 'relation-definition' && this.$attrInputInverseRelation.val().trim().length > 0) {
|
} else if (this.attrType === 'relation-definition' && this.$attrInputInverseRelation.val().trim().length > 0) {
|
||||||
props.push("inverse=" + this.$attrInputInverseRelation.val());
|
props.push("inverse=" + this.$attrInputInverseRelation.val());
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ const TPL = `
|
|||||||
padding: 0 0 0 5px !important;
|
padding: 0 0 0 5px !important;
|
||||||
margin: 0 !important;
|
margin: 0 !important;
|
||||||
color: var(--muted-text-color);
|
color: var(--muted-text-color);
|
||||||
max-height: 200px;
|
max-height: 100px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,12 +282,12 @@ export default class AttributeEditorWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async save() {
|
async save() {
|
||||||
this.$saveAttributesButton.fadeOut();
|
|
||||||
|
|
||||||
const attributes = this.parseAttributes();
|
const attributes = this.parseAttributes();
|
||||||
|
|
||||||
if (attributes) {
|
if (attributes) {
|
||||||
await server.put(`notes/${this.noteId}/attributes`, attributes, this.componentId);
|
await server.put(`notes/${this.noteId}/attributes`, attributes, this.componentId);
|
||||||
|
|
||||||
|
this.$saveAttributesButton.fadeOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,6 +184,10 @@ export default class AttributeListWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async saveAttributesCommand() {
|
||||||
|
await this.attributeEditorWidget.save();
|
||||||
|
}
|
||||||
|
|
||||||
updateAttributeListCommand({attributes}) {
|
updateAttributeListCommand({attributes}) {
|
||||||
this.attributeEditorWidget.updateAttributeList(attributes);
|
this.attributeEditorWidget.updateAttributeList(attributes);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user