note detail view header refresh

This commit is contained in:
Yuri Kuznetsov
2025-06-30 14:48:14 +03:00
parent 6958a5a357
commit 052cdf20dd
+51 -20
View File
@@ -51,6 +51,8 @@ class NoteDetailView extends MainView {
this.isDeleted = true;
this.getHeaderView().reRender();
});
this.addActionHandler('fullRefresh', () => this.actionFullRefresh());
}
/**
@@ -84,38 +86,67 @@ class NoteDetailView extends MainView {
}
getHeader() {
const parentType = this.model.get('parentType');
const parentId = this.model.get('parentId');
const parentName = this.model.get('parentName');
const type = this.model.get('type');
const parentType = this.model.attributes.parentType;
const parentId = this.model.attributes.parentId;
const $type = $('<span>')
.text(this.getLanguage().translateOption(type, 'type', 'Note'));
const typeText = document.createElement('span');
typeText.textContent = this.getLanguage().translateOption(this.model.attributes.type, 'type', 'Note');
if (this.model.get('deleted') || this.isDeleted) {
$type.css('text-decoration', 'line-through');
if (this.model.attributes.deleted || this.isDeleted) {
typeText.style.textDecoration = 'line-through';
}
typeText.title = this.translate('clickToRefresh', 'messages');
typeText.dataset.action = 'fullRefresh';
typeText.style.cursor = 'pointer';
if (parentType && parentId) {
return this.buildHeaderHtml([
$('<a>')
.attr('href', `#${parentType}`)
.text(this.translate(parentType, 'scopeNamesPlural')),
$('<a>')
.attr('href', `#${parentType}/view/${parentId}`)
.text(parentName || parentId),
$('<span>')
.text(this.translate('Stream', 'scopeNames')),
$type,
(() => {
const a = document.createElement('a');
a.href = `#${parentType}`;
a.textContent = this.translate(parentType, 'scopeNamesPlural');
return a;
})(),
(() => {
const a = document.createElement('a');
a.href = `#${parentType}/view/${parentId}`;
a.textContent = this.model.attributes.parentName || parentId;
return a;
})(),
(() => {
const span = document.createElement('span');
span.textContent = this.translate('Stream', 'scopeNames');
return span;
})(),
typeText,
]);
}
return this.buildHeaderHtml([
$('<span>')
.text(this.translate('Stream', 'scopeNames')),
$type,
(() => {
const span = document.createElement('span');
span.textContent = this.translate('Stream', 'scopeNames');
return span;
})(),
typeText,
]);
}
/**
* @private
*/
async actionFullRefresh() {
Espo.Ui.notifyWait();
await this.model.fetch();
Espo.Ui.notify();
}
}
export default NoteDetailView;