mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Refactor disabled summary button logic
Summary: A project test began failing because of an incompatibility with pointer-events being disabled. This gets us back to green. Test Plan: Existing tests. Reviewers: jordigh Reviewed By: jordigh Subscribers: jordigh Differential Revision: https://phab.getgrist.com/D4325
This commit is contained in:
parent
df5080ef38
commit
5c486e686e
@ -328,6 +328,8 @@ export class PageWidgetSelect extends Disposable {
|
|||||||
private _isNewTableDisabled = Computed.create(this, this._value.type, (use, type) => !isValidSelection(
|
private _isNewTableDisabled = Computed.create(this, this._value.type, (use, type) => !isValidSelection(
|
||||||
'New Table', type, {isNewPage: this._options.isNewPage, summarize: use(this._value.summarize)}));
|
'New Table', type, {isNewPage: this._options.isNewPage, summarize: use(this._value.summarize)}));
|
||||||
|
|
||||||
|
private _isSummaryDisabled = Computed.create(this, this._value.type, (_use, type) => !isSummaryCompatible(type));
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _value: IWidgetValueObs,
|
private _value: IWidgetValueObs,
|
||||||
private _tables: Observable<TableRec[]>,
|
private _tables: Observable<TableRec[]>,
|
||||||
@ -389,8 +391,9 @@ export class PageWidgetSelect extends Disposable {
|
|||||||
cssEntry.cls('-selected', (use) => use(this._value.summarize) &&
|
cssEntry.cls('-selected', (use) => use(this._value.summarize) &&
|
||||||
use(this._value.table) === table.id()
|
use(this._value.table) === table.id()
|
||||||
),
|
),
|
||||||
cssEntry.cls('-disabled', (use) => !isSummaryCompatible(use(this._value.type))),
|
cssEntry.cls('-disabled', this._isSummaryDisabled),
|
||||||
dom.on('click', (ev, el) => this._selectPivot(table.id(), el as HTMLElement)),
|
dom.on('click', (_ev, el) =>
|
||||||
|
!this._isSummaryDisabled.get() && this._selectPivot(table.id(), el as HTMLElement)),
|
||||||
testId('pivot'),
|
testId('pivot'),
|
||||||
),
|
),
|
||||||
testId('table'),
|
testId('table'),
|
||||||
@ -572,7 +575,6 @@ const cssEntry = styled('div', `
|
|||||||
&-disabled {
|
&-disabled {
|
||||||
color: ${theme.widgetPickerItemDisabledBg};
|
color: ${theme.widgetPickerItemDisabledBg};
|
||||||
cursor: default;
|
cursor: default;
|
||||||
pointer-events: none;
|
|
||||||
}
|
}
|
||||||
&-disabled&-selected {
|
&-disabled&-selected {
|
||||||
background-color: inherit;
|
background-color: inherit;
|
||||||
|
Loading…
Reference in New Issue
Block a user