hide complex modified field if not modified

This commit is contained in:
Yuri Kuznetsov
2024-03-30 09:23:56 +02:00
parent d232838676
commit 3c83e1dcd3
2 changed files with 26 additions and 4 deletions

View File

@@ -98,9 +98,10 @@ class DefaultSidePanelView extends SidePanelView {
baseName: 'modified',
},
});
}
if (!this.model.get('modifiedById') && !this.model.get('modifiedAt')) {
this.recordViewObject.hideField('complexModified');
if (!this.isModifiedVisible()) {
this.recordViewObject.hideField('complexModified');
}
}
} else {
this.recordViewObject.hideField('complexModified');
@@ -126,7 +127,7 @@ class DefaultSidePanelView extends SidePanelView {
return;
}
if (!this.model.get('modifiedById') && !this.model.get('modifiedAt')) {
if (!this.isModifiedVisible()) {
return;
}
@@ -152,6 +153,26 @@ class DefaultSidePanelView extends SidePanelView {
}
}
/**
* @private
* @return {boolean}
*/
isModifiedVisible() {
if (!this.hasComplexModified) {
return false;
}
if (!this.model.get('modifiedById') && !this.model.get('modifiedAt')) {
return false;
}
if (!this.model.get('modifiedById') && this.model.get('modifiedAt') === this.model.get('createdAt')) {
return false;
}
return true;
}
controlFollowersField() {
if (this.model.get('followersIds') && this.model.get('followersIds').length) {
this.recordViewObject.showField('followers');

View File

@@ -151,6 +151,7 @@ class SidePanelView extends View {
this.readOnly = this.readOnly || this.options.readOnly;
this.inlineEditDisabled = this.inlineEditDisabled || this.options.inlineEditDisabled;
/** @type {import('views/record/base').default} */
this.recordViewObject = this.options.recordViewObject;
}