import TabAwareWidget from "./tab_aware_widget.js";
const TPL = `
`;
export default class NoteActionsWidget extends TabAwareWidget {
doRender() {
this.$widget = $(TPL);
this.$showRevisionsButton = this.$widget.find('.show-note-revisions-button');
this.$showRevisionsButton.on('click', e => this.triggerEvent(e, 'showNoteRevisions'));
this.$showAttributesButton = this.$widget.find('.show-attributes-button');
this.$showAttributesButton.on('click', e => this.triggerEvent(e, 'showAttributes'));
this.$showLinkMapButton = this.$widget.find('.show-link-map-button');
this.$showLinkMapButton.on('click', e => this.triggerEvent(e, 'showLinkMap'));
this.$showSourceButton = this.$widget.find('.show-source-button');
this.$showSourceButton.on('click', e => this.triggerEvent(e, 'showNoteSource'));
this.$showNoteInfoButton = this.$widget.find('.show-note-info-button');
this.$showNoteInfoButton.on('click', e => this.triggerEvent(e, 'showNoteInfo'));
this.$exportNoteButton = this.$widget.find('.export-note-button');
return this.$widget;
}
refreshWithNote(note) {
this.$showSourceButton.prop('disabled', !['text', 'relation-map', 'search', 'code'].includes(note.type));
this.$exportNoteButton.prop('disabled', note.type !== 'text');
}
triggerEvent(e, eventName) {
const $item = $(e.target).closest('dropdown-item');
if ($item.is('[disabled]')) {
return;
}
this.trigger(eventName);
}
}