2020-10-02 15:10:00 +00:00
|
|
|
/**
|
|
|
|
* Builds the structure of the right-side panel containing configuration and assorted tools.
|
|
|
|
* It includes the regular tabs, to configure the Page (including several sub-tabs), and Field;
|
|
|
|
* and allows other tools, such as Activity Feed, to be rendered temporarily in its place.
|
|
|
|
*
|
|
|
|
* A single RightPanel object is created in AppUI for a document page, and attached to PagePanels.
|
|
|
|
* GristDoc registers callbacks with it to create various standard tabs. These are created as
|
|
|
|
* needed, and destroyed when hidden.
|
|
|
|
*
|
|
|
|
* In addition, tools such as "Activity Feed" may use openTool() to replace the panel header and
|
|
|
|
* content. The user may dismiss this panel.
|
|
|
|
*
|
|
|
|
* All methods above return an object which may be disposed to close and dispose that specific
|
|
|
|
* tab from the outside (e.g. when GristDoc is disposed).
|
|
|
|
*/
|
|
|
|
|
|
|
|
import * as commands from 'app/client/components/commands';
|
2023-12-12 09:58:20 +00:00
|
|
|
import {HiddenQuestionConfig} from 'app/client/components/Forms/HiddenQuestionConfig';
|
2020-10-02 15:10:00 +00:00
|
|
|
import {GristDoc, IExtraTool, TabContent} from 'app/client/components/GristDoc';
|
2023-09-08 18:21:32 +00:00
|
|
|
import {EmptyFilterState} from "app/client/components/LinkingState";
|
2022-07-07 10:44:27 +00:00
|
|
|
import {RefSelect} from 'app/client/components/RefSelect';
|
2022-07-04 14:14:55 +00:00
|
|
|
import ViewConfigTab from 'app/client/components/ViewConfigTab';
|
2021-03-17 03:45:44 +00:00
|
|
|
import {domAsync} from 'app/client/lib/domAsync';
|
2020-10-02 15:10:00 +00:00
|
|
|
import * as imports from 'app/client/lib/imports';
|
2022-10-28 16:11:08 +00:00
|
|
|
import {makeT} from 'app/client/lib/localization';
|
2023-09-08 18:21:32 +00:00
|
|
|
import {createSessionObs, isBoolean, SessionObs} from 'app/client/lib/sessionObs';
|
2020-10-02 15:10:00 +00:00
|
|
|
import {reportError} from 'app/client/models/AppModel';
|
2023-09-08 18:21:32 +00:00
|
|
|
import {ColumnRec, ViewSectionRec} from 'app/client/models/DocModel';
|
2022-02-08 15:23:14 +00:00
|
|
|
import {CustomSectionConfig} from 'app/client/ui/CustomSectionConfig';
|
2023-12-12 09:58:20 +00:00
|
|
|
import {buildDescriptionConfig, buildTextInput} from 'app/client/ui/DescriptionConfig';
|
2023-07-13 14:00:56 +00:00
|
|
|
import {BuildEditorOptions} from 'app/client/ui/FieldConfig';
|
2023-08-29 14:50:42 +00:00
|
|
|
import {GridOptions} from 'app/client/ui/GridOptions';
|
|
|
|
import {attachPageWidgetPicker, IPageWidget, toPageWidget} from 'app/client/ui/PageWidgetPicker';
|
|
|
|
import {PredefinedCustomSectionConfig} from "app/client/ui/PredefinedCustomSectionConfig";
|
2022-11-17 20:17:51 +00:00
|
|
|
import {cssLabel} from 'app/client/ui/RightPanelStyles';
|
2023-08-29 14:50:42 +00:00
|
|
|
import {linkId, selectBy} from 'app/client/ui/selectBy';
|
2020-10-02 15:10:00 +00:00
|
|
|
import {VisibleFieldsConfig} from 'app/client/ui/VisibleFieldsConfig';
|
2023-08-29 14:50:42 +00:00
|
|
|
import {widgetTypesMap} from "app/client/ui/widgetTypesMap";
|
2020-10-02 15:10:00 +00:00
|
|
|
import {basicButton, primaryButton} from 'app/client/ui2018/buttons';
|
2022-09-06 01:51:57 +00:00
|
|
|
import {testId, theme, vars} from 'app/client/ui2018/cssVars';
|
2020-10-02 15:10:00 +00:00
|
|
|
import {textInput} from 'app/client/ui2018/editableLabel';
|
|
|
|
import {IconName} from 'app/client/ui2018/IconList';
|
|
|
|
import {icon} from 'app/client/ui2018/icons';
|
|
|
|
import {select} from 'app/client/ui2018/menus';
|
2021-03-17 03:45:44 +00:00
|
|
|
import {FieldBuilder} from 'app/client/widgets/FieldBuilder';
|
2023-09-08 18:21:32 +00:00
|
|
|
import {isFullReferencingType} from "app/common/gristTypes";
|
|
|
|
import {not} from 'app/common/gutil';
|
2020-10-02 15:10:00 +00:00
|
|
|
import {StringUnion} from 'app/common/StringUnion';
|
2023-08-29 14:50:42 +00:00
|
|
|
import {IWidgetType} from 'app/common/widgetTypes';
|
|
|
|
import {
|
|
|
|
bundleChanges,
|
|
|
|
Computed,
|
|
|
|
Disposable,
|
|
|
|
dom,
|
|
|
|
domComputed,
|
|
|
|
DomContents,
|
|
|
|
DomElementArg,
|
|
|
|
DomElementMethod,
|
|
|
|
IDomComponent,
|
|
|
|
MultiHolder,
|
|
|
|
Observable,
|
|
|
|
styled,
|
|
|
|
subscribe
|
|
|
|
} from 'grainjs';
|
2020-10-02 15:10:00 +00:00
|
|
|
import * as ko from 'knockout';
|
|
|
|
|
2023-09-08 18:21:32 +00:00
|
|
|
// some unicode characters
|
|
|
|
const BLACK_CIRCLE = '\u2022';
|
|
|
|
const ELEMENTOF = '\u2208'; //220A for small elementof
|
|
|
|
|
2022-10-28 16:11:08 +00:00
|
|
|
const t = makeT('RightPanel');
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
// Represents a top tab of the right side-pane.
|
|
|
|
const TopTab = StringUnion("pageWidget", "field");
|
|
|
|
|
|
|
|
// Represents a subtab of pageWidget in the right side-pane.
|
|
|
|
const PageSubTab = StringUnion("widget", "sortAndFilter", "data");
|
|
|
|
|
|
|
|
// Returns the icon and label of a type, default to those associate to 'record' type.
|
|
|
|
export function getFieldType(widgetType: IWidgetType|null) {
|
2022-10-28 16:11:08 +00:00
|
|
|
// A map of widget type to the icon and label to use for a field of that widget.
|
|
|
|
const fieldTypes = new Map<IWidgetType, {label: string, icon: IconName, pluralLabel: string}>([
|
2022-12-06 16:43:35 +00:00
|
|
|
['record', {label: t('Columns', { count: 1 }), icon: 'TypeCell', pluralLabel: t('Columns', { count: 2 })}],
|
|
|
|
['detail', {label: t('Fields', { count: 1 }), icon: 'TypeCell', pluralLabel: t('Fields', { count: 2 })}],
|
|
|
|
['single', {label: t('Fields', { count: 1 }), icon: 'TypeCell', pluralLabel: t('Fields', { count: 2 })}],
|
2022-10-28 16:11:08 +00:00
|
|
|
['chart', {label: t('Series', { count: 1 }), icon: 'ChartLine', pluralLabel: t('Series', { count: 2 })}],
|
2022-12-06 16:43:35 +00:00
|
|
|
['custom', {label: t('Columns', { count: 1 }), icon: 'TypeCell', pluralLabel: t('Columns', { count: 2 })}],
|
2022-10-28 16:11:08 +00:00
|
|
|
]);
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
return fieldTypes.get(widgetType || 'record') || fieldTypes.get('record')!;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class RightPanel extends Disposable {
|
|
|
|
public readonly header: DomContents;
|
|
|
|
public readonly content: DomContents;
|
|
|
|
|
|
|
|
// If the panel is showing a tool, such as Action Log, instead of the usual section/field
|
|
|
|
// configuration, this will be set to the tool's header and content.
|
|
|
|
private _extraTool: Observable<IExtraTool|null>;
|
|
|
|
|
|
|
|
// Which of the two standard top tabs (page widget or field) is selected, or was last selected.
|
|
|
|
private _topTab = createSessionObs(this, "rightTopTab", "pageWidget", TopTab.guard);
|
|
|
|
|
|
|
|
// Which subtab is open for configuring page widget.
|
|
|
|
private _subTab = createSessionObs(this, "rightPageSubTab", "widget", PageSubTab.guard);
|
|
|
|
|
|
|
|
// Which type of page widget is active, e.g. "record" or "chart". This affects the names and
|
|
|
|
// icons in the top tab.
|
|
|
|
private _pageWidgetType = Computed.create<IWidgetType|null>(this, (use) => {
|
|
|
|
const section: ViewSectionRec = use(this._gristDoc.viewModel.activeSection);
|
|
|
|
return (use(section.parentKey) || null) as IWidgetType;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Returns the active section if it's valid, null otherwise.
|
|
|
|
private _validSection = Computed.create(this, (use) => {
|
|
|
|
const sec = use(this._gristDoc.viewModel.activeSection);
|
|
|
|
return sec.getRowId() ? sec : null;
|
|
|
|
});
|
|
|
|
|
2023-09-08 18:21:32 +00:00
|
|
|
// Which subtab is open for configuring page widget.
|
|
|
|
private _advLinkInfoCollapsed = createSessionObs(this, "rightPageAdvancedLinkInfoCollapsed",
|
|
|
|
true, isBoolean);
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
constructor(private _gristDoc: GristDoc, private _isOpen: Observable<boolean>) {
|
|
|
|
super();
|
|
|
|
this._extraTool = _gristDoc.rightPanelTool;
|
|
|
|
this.autoDispose(subscribe(this._extraTool, (_use, tool) => tool && _isOpen.set(true)));
|
|
|
|
this.header = this._buildHeaderDom();
|
|
|
|
this.content = this._buildContentDom();
|
|
|
|
|
|
|
|
this.autoDispose(commands.createGroup({
|
|
|
|
fieldTabOpen: () => this._openFieldTab(),
|
|
|
|
viewTabOpen: () => this._openViewTab(),
|
2023-04-14 10:09:50 +00:00
|
|
|
viewTabFocus: () => this._viewTabFocus(),
|
2020-10-02 15:10:00 +00:00
|
|
|
sortFilterTabOpen: () => this._openSortFilter(),
|
|
|
|
dataSelectionTabOpen: () => this._openDataSelection()
|
|
|
|
}, this, true));
|
|
|
|
}
|
|
|
|
|
|
|
|
private _openFieldTab() {
|
|
|
|
this._open('field');
|
|
|
|
}
|
|
|
|
|
|
|
|
private _openViewTab() {
|
|
|
|
this._open('pageWidget', 'widget');
|
|
|
|
}
|
|
|
|
|
2023-04-14 10:09:50 +00:00
|
|
|
private _viewTabFocus() {
|
|
|
|
// If the view tab is already open, focus on the first input.
|
|
|
|
this._focus('pageWidget');
|
|
|
|
}
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
private _openSortFilter() {
|
|
|
|
this._open('pageWidget', 'sortAndFilter');
|
|
|
|
}
|
|
|
|
|
|
|
|
private _openDataSelection() {
|
|
|
|
this._open('pageWidget', 'data');
|
|
|
|
}
|
|
|
|
|
|
|
|
private _open(topTab: typeof TopTab.type, subTab?: typeof PageSubTab.type) {
|
|
|
|
bundleChanges(() => {
|
|
|
|
this._isOpen.set(true);
|
|
|
|
this._topTab.set(topTab);
|
|
|
|
if (subTab) {
|
|
|
|
this._subTab.set(subTab);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-14 10:09:50 +00:00
|
|
|
private _focus(topTab: typeof TopTab.type) {
|
|
|
|
bundleChanges(() => {
|
|
|
|
if (!this._isOpen.get()) { return; }
|
|
|
|
this._isOpen.set(true);
|
|
|
|
this._topTab.set(topTab);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
private _buildHeaderDom() {
|
|
|
|
return dom.domComputed((use) => {
|
|
|
|
if (!use(this._isOpen)) { return null; }
|
|
|
|
const tool = use(this._extraTool);
|
|
|
|
return tool ? this._buildToolHeader(tool) : this._buildStandardHeader();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private _buildToolHeader(tool: IExtraTool) {
|
|
|
|
return cssTopBarItem(cssTopBarIcon(tool.icon), tool.label,
|
|
|
|
cssHoverCircle(cssHoverIcon("CrossBig"),
|
|
|
|
dom.on('click', () => this._gristDoc.showTool('none')),
|
|
|
|
testId('right-tool-close'),
|
|
|
|
),
|
|
|
|
cssTopBarItem.cls('-selected', true)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private _buildStandardHeader() {
|
|
|
|
return dom.maybe(this._pageWidgetType, (type) => {
|
2023-08-29 14:50:42 +00:00
|
|
|
const widgetInfo = widgetTypesMap.get(type) || {label: 'Table', icon: 'TypeTable'};
|
2020-10-02 15:10:00 +00:00
|
|
|
const fieldInfo = getFieldType(type);
|
|
|
|
return [
|
|
|
|
cssTopBarItem(cssTopBarIcon(widgetInfo.icon), widgetInfo.label,
|
|
|
|
cssTopBarItem.cls('-selected', (use) => use(this._topTab) === 'pageWidget'),
|
|
|
|
dom.on('click', () => this._topTab.set("pageWidget")),
|
|
|
|
testId('right-tab-pagewidget')),
|
|
|
|
cssTopBarItem(cssTopBarIcon(fieldInfo.icon), fieldInfo.label,
|
|
|
|
cssTopBarItem.cls('-selected', (use) => use(this._topTab) === 'field'),
|
|
|
|
dom.on('click', () => this._topTab.set("field")),
|
|
|
|
testId('right-tab-field')),
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private _buildContentDom() {
|
|
|
|
return dom.domComputed((use) => {
|
|
|
|
if (!use(this._isOpen)) { return null; }
|
|
|
|
const tool = use(this._extraTool);
|
|
|
|
if (tool) { return tabContentToDom(tool.content); }
|
|
|
|
|
|
|
|
const topTab = use(this._topTab);
|
|
|
|
if (topTab === 'field') {
|
|
|
|
return dom.create(this._buildFieldContent.bind(this));
|
|
|
|
}
|
|
|
|
if (topTab === 'pageWidget' && use(this._pageWidgetType)) {
|
|
|
|
return dom.create(this._buildPageWidgetContent.bind(this));
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private _buildFieldContent(owner: MultiHolder) {
|
2021-03-17 03:45:44 +00:00
|
|
|
const fieldBuilder = owner.autoDispose(ko.computed(() => {
|
2021-07-30 15:16:33 +00:00
|
|
|
const vsi = this._gristDoc.viewModel.activeSection?.().viewInstance();
|
2020-10-02 15:10:00 +00:00
|
|
|
return vsi && vsi.activeFieldBuilder();
|
|
|
|
}));
|
2021-03-17 03:45:44 +00:00
|
|
|
|
2022-10-14 10:07:19 +00:00
|
|
|
const selectedColumns = owner.autoDispose(ko.computed(() => {
|
|
|
|
const vsi = this._gristDoc.viewModel.activeSection?.().viewInstance();
|
2022-11-14 11:30:50 +00:00
|
|
|
if (vsi && vsi.selectedColumns) {
|
|
|
|
return vsi.selectedColumns();
|
|
|
|
}
|
|
|
|
const field = fieldBuilder()?.field;
|
|
|
|
return field ? [field] : [];
|
2022-10-14 10:07:19 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
const isMultiSelect = owner.autoDispose(ko.pureComputed(() => {
|
|
|
|
const list = selectedColumns();
|
|
|
|
return Boolean(list && list.length > 1);
|
|
|
|
}));
|
|
|
|
|
|
|
|
owner.autoDispose(selectedColumns.subscribe(cols => {
|
2022-10-24 10:06:24 +00:00
|
|
|
if (owner.isDisposed() || this._gristDoc.isDisposed() || this._gristDoc.viewModel.isDisposed()) { return; }
|
|
|
|
const section = this._gristDoc.viewModel.activeSection();
|
|
|
|
if (!section || section.isDisposed()) { return; }
|
|
|
|
section.selectedFields(cols || []);
|
2022-10-14 10:07:19 +00:00
|
|
|
}));
|
|
|
|
this._gristDoc.viewModel.activeSection()?.selectedFields(selectedColumns.peek() || []);
|
|
|
|
|
2021-03-17 03:45:44 +00:00
|
|
|
const docModel = this._gristDoc.docModel;
|
|
|
|
const origColRef = owner.autoDispose(ko.computed(() => fieldBuilder()?.origColumn.origColRef() || 0));
|
|
|
|
const origColumn = owner.autoDispose(docModel.columns.createFloatingRowModel(origColRef));
|
|
|
|
const isColumnValid = owner.autoDispose(ko.computed(() => Boolean(origColRef())));
|
|
|
|
|
|
|
|
// Builder for the reference display column multiselect.
|
2022-07-07 10:44:27 +00:00
|
|
|
const refSelect = RefSelect.create(owner, {docModel, origColumn, fieldBuilder});
|
2021-03-17 03:45:44 +00:00
|
|
|
|
2023-12-12 09:58:20 +00:00
|
|
|
// The original selected field model.
|
|
|
|
const fieldRef = owner.autoDispose(ko.pureComputed(() => {
|
|
|
|
return ((fieldBuilder()?.field)?.id()) ?? 0;
|
|
|
|
}));
|
|
|
|
const selectedField = owner.autoDispose(docModel.viewFields.createFloatingRowModel(fieldRef));
|
|
|
|
|
|
|
|
// For forms we will show some extra options.
|
|
|
|
const isForm = owner.autoDispose(ko.computed(() => {
|
|
|
|
const vs = this._gristDoc.viewModel.activeSection();
|
|
|
|
return vs.parentKey() === 'form';
|
|
|
|
}));
|
|
|
|
|
2021-06-08 07:07:20 +00:00
|
|
|
// build cursor position observable
|
|
|
|
const cursor = owner.autoDispose(ko.computed(() => {
|
2021-07-30 15:16:33 +00:00
|
|
|
const vsi = this._gristDoc.viewModel.activeSection?.().viewInstance();
|
2021-06-08 07:07:20 +00:00
|
|
|
return vsi?.cursor.currentPosition() ?? {};
|
|
|
|
}));
|
|
|
|
|
2021-03-17 03:45:44 +00:00
|
|
|
return domAsync(imports.loadViewPane().then(ViewPane => {
|
|
|
|
const {buildNameConfig, buildFormulaConfig} = ViewPane.FieldConfig;
|
|
|
|
return dom.maybe(isColumnValid, () =>
|
|
|
|
buildConfigContainer(
|
2022-10-14 10:07:19 +00:00
|
|
|
cssSection(
|
|
|
|
dom.create(buildNameConfig, origColumn, cursor, isMultiSelect),
|
|
|
|
),
|
2023-12-12 09:58:20 +00:00
|
|
|
dom.maybe(isForm, () => [
|
|
|
|
cssSection(
|
|
|
|
dom.create(buildTextInput, {
|
|
|
|
cursor, label: 'Question', value: selectedField.question,
|
|
|
|
placeholder: selectedField.origLabel
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
]),
|
2023-01-17 10:39:23 +00:00
|
|
|
cssSection(
|
2023-05-12 13:08:28 +00:00
|
|
|
dom.create(buildDescriptionConfig, origColumn.description, { cursor, "testPrefix": "column" }),
|
2023-01-17 10:39:23 +00:00
|
|
|
),
|
2021-03-17 03:45:44 +00:00
|
|
|
cssSeparator(),
|
2022-10-14 10:07:19 +00:00
|
|
|
cssSection(
|
|
|
|
dom.create(buildFormulaConfig,
|
|
|
|
origColumn, this._gristDoc, this._activateFormulaEditor.bind(this)),
|
|
|
|
),
|
2021-03-17 03:45:44 +00:00
|
|
|
cssSeparator(),
|
|
|
|
dom.maybe<FieldBuilder|null>(fieldBuilder, builder => [
|
2022-12-06 13:57:29 +00:00
|
|
|
cssLabel(t("COLUMN TYPE")),
|
2022-10-14 10:07:19 +00:00
|
|
|
cssSection(
|
|
|
|
builder.buildSelectTypeDom(),
|
|
|
|
),
|
|
|
|
cssSection(
|
|
|
|
builder.buildSelectWidgetDom(),
|
|
|
|
),
|
|
|
|
cssSection(
|
|
|
|
builder.buildConfigDom(),
|
|
|
|
),
|
|
|
|
builder.buildColorConfigDom(),
|
|
|
|
cssSection(
|
|
|
|
builder.buildSettingOptions(),
|
|
|
|
dom.maybe(isMultiSelect, () => disabledSection())
|
|
|
|
),
|
2021-03-17 03:45:44 +00:00
|
|
|
]),
|
|
|
|
cssSeparator(),
|
2022-10-14 10:07:19 +00:00
|
|
|
cssSection(
|
|
|
|
dom.maybe(refSelect.isForeignRefCol, () => [
|
2023-04-26 13:33:12 +00:00
|
|
|
cssLabel(t('Add referenced columns')),
|
2022-10-14 10:07:19 +00:00
|
|
|
cssRow(refSelect.buildDom()),
|
|
|
|
cssSeparator()
|
|
|
|
]),
|
2022-12-06 13:57:29 +00:00
|
|
|
cssLabel(t("TRANSFORM")),
|
2022-10-14 10:07:19 +00:00
|
|
|
dom.maybe<FieldBuilder|null>(fieldBuilder, builder => builder.buildTransformDom()),
|
|
|
|
testId('panel-transform'),
|
|
|
|
),
|
2021-03-17 03:45:44 +00:00
|
|
|
this._disableIfReadonly(),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Helper to activate the side-pane formula editor over the given HTML element.
|
2023-07-13 14:00:56 +00:00
|
|
|
private _activateFormulaEditor(options: BuildEditorOptions) {
|
2021-03-17 03:45:44 +00:00
|
|
|
const vsi = this._gristDoc.viewModel.activeSection().viewInstance();
|
|
|
|
if (!vsi) { return; }
|
2023-07-13 14:00:56 +00:00
|
|
|
|
|
|
|
const {refElem, editValue, canDetach, onSave, onCancel} = options;
|
|
|
|
const editRow = vsi.moveEditRowToCursor();
|
|
|
|
return vsi.activeFieldBuilder.peek().openSideFormulaEditor({
|
|
|
|
editRow,
|
|
|
|
refElem,
|
|
|
|
canDetach,
|
|
|
|
editValue,
|
|
|
|
onSave,
|
|
|
|
onCancel,
|
|
|
|
});
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private _buildPageWidgetContent(_owner: MultiHolder) {
|
|
|
|
return [
|
|
|
|
cssSubTabContainer(
|
2022-12-06 13:57:29 +00:00
|
|
|
cssSubTab(t("Widget"),
|
2020-10-02 15:10:00 +00:00
|
|
|
cssSubTab.cls('-selected', (use) => use(this._subTab) === 'widget'),
|
|
|
|
dom.on('click', () => this._subTab.set("widget")),
|
|
|
|
testId('config-widget')),
|
2022-12-06 13:57:29 +00:00
|
|
|
cssSubTab(t("Sort & Filter"),
|
2020-10-02 15:10:00 +00:00
|
|
|
cssSubTab.cls('-selected', (use) => use(this._subTab) === 'sortAndFilter'),
|
|
|
|
dom.on('click', () => this._subTab.set("sortAndFilter")),
|
|
|
|
testId('config-sortAndFilter')),
|
2022-12-06 13:57:29 +00:00
|
|
|
cssSubTab(t("Data"),
|
2020-10-02 15:10:00 +00:00
|
|
|
cssSubTab.cls('-selected', (use) => use(this._subTab) === 'data'),
|
|
|
|
dom.on('click', () => this._subTab.set("data")),
|
|
|
|
testId('config-data')),
|
|
|
|
),
|
|
|
|
dom.domComputed(this._subTab, (subTab) => (
|
|
|
|
dom.maybe(this._validSection, (activeSection) => (
|
|
|
|
buildConfigContainer(
|
|
|
|
subTab === 'widget' ? dom.create(this._buildPageWidgetConfig.bind(this), activeSection) :
|
2023-11-20 00:46:32 +00:00
|
|
|
subTab === 'sortAndFilter' ? [
|
|
|
|
dom.create(this._buildPageSortFilterConfig.bind(this)),
|
|
|
|
cssConfigContainer.cls('-disabled', activeSection.isRecordCard),
|
|
|
|
] :
|
2020-10-02 15:10:00 +00:00
|
|
|
subTab === 'data' ? dom.create(this._buildPageDataConfig.bind(this), activeSection) :
|
|
|
|
null
|
|
|
|
)
|
|
|
|
))
|
|
|
|
))
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
private _createViewConfigTab(owner: MultiHolder): Observable<null|ViewConfigTab> {
|
|
|
|
const viewConfigTab = Observable.create<null|ViewConfigTab>(owner, null);
|
|
|
|
const gristDoc = this._gristDoc;
|
|
|
|
imports.loadViewPane()
|
|
|
|
.then(ViewPane => {
|
|
|
|
if (owner.isDisposed()) { return; }
|
|
|
|
viewConfigTab.set(owner.autoDispose(
|
2022-02-03 17:23:53 +00:00
|
|
|
ViewPane.ViewConfigTab.create({gristDoc, viewModel: gristDoc.viewModel})));
|
2020-10-02 15:10:00 +00:00
|
|
|
})
|
|
|
|
.catch(reportError);
|
|
|
|
return viewConfigTab;
|
|
|
|
}
|
|
|
|
|
|
|
|
private _buildPageWidgetConfig(owner: MultiHolder, activeSection: ViewSectionRec) {
|
|
|
|
// TODO: This uses private methods from ViewConfigTab. These methods are likely to get
|
|
|
|
// refactored, but if not, should be made public.
|
|
|
|
const viewConfigTab = this._createViewConfigTab(owner);
|
2022-02-08 15:23:14 +00:00
|
|
|
const hasCustomMapping = Computed.create(owner, use => {
|
2023-08-29 14:50:42 +00:00
|
|
|
const widgetType = use(this._pageWidgetType);
|
|
|
|
const isCustom = widgetType === 'custom' || widgetType?.startsWith('custom.');
|
2022-02-08 15:23:14 +00:00
|
|
|
const hasColumnMapping = use(activeSection.columnsToMap);
|
|
|
|
return Boolean(isCustom && hasColumnMapping);
|
|
|
|
});
|
2023-05-12 13:08:28 +00:00
|
|
|
|
|
|
|
// build cursor position observable
|
|
|
|
const cursor = owner.autoDispose(ko.computed(() => {
|
|
|
|
const vsi = this._gristDoc.viewModel.activeSection?.().viewInstance();
|
|
|
|
return vsi?.cursor.currentPosition() ?? {};
|
|
|
|
}));
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
return dom.maybe(viewConfigTab, (vct) => [
|
|
|
|
this._disableIfReadonly(),
|
2023-11-20 00:46:32 +00:00
|
|
|
dom.maybe(use => !use(activeSection.isRecordCard), () => [
|
|
|
|
cssLabel(dom.text(use => use(activeSection.isRaw) ? t("DATA TABLE NAME") : t("WIDGET TITLE")),
|
|
|
|
dom.style('margin-bottom', '14px'),
|
|
|
|
),
|
|
|
|
cssRow(cssTextInput(
|
|
|
|
Computed.create(owner, (use) => use(activeSection.titleDef)),
|
|
|
|
val => activeSection.titleDef.saveOnly(val),
|
|
|
|
dom.boolAttr('disabled', use => {
|
|
|
|
const isRawTable = use(activeSection.isRaw);
|
|
|
|
const isSummaryTable = use(use(activeSection.table).summarySourceTable) !== 0;
|
|
|
|
return isRawTable && isSummaryTable;
|
|
|
|
}),
|
|
|
|
testId('right-widget-title')
|
|
|
|
)),
|
|
|
|
|
|
|
|
cssSection(
|
|
|
|
dom.create(buildDescriptionConfig, activeSection.description, { cursor, "testPrefix": "right-widget" }),
|
|
|
|
),
|
|
|
|
]),
|
2023-05-12 13:08:28 +00:00
|
|
|
|
2022-02-07 14:02:26 +00:00
|
|
|
dom.maybe(
|
2023-11-20 00:46:32 +00:00
|
|
|
(use) => !use(activeSection.isRaw) && !use(activeSection.isRecordCard),
|
2022-02-07 14:02:26 +00:00
|
|
|
() => cssRow(
|
2022-12-06 13:57:29 +00:00
|
|
|
primaryButton(t("Change Widget"), this._createPageWidgetPicker()),
|
2022-02-07 14:02:26 +00:00
|
|
|
cssRow.cls('-top-space')
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2023-11-20 00:46:32 +00:00
|
|
|
cssSeparator(dom.hide(activeSection.isRecordCard)),
|
2020-10-02 15:10:00 +00:00
|
|
|
|
2023-12-12 09:58:20 +00:00
|
|
|
dom.domComputed(use => {
|
|
|
|
const vs = use(activeSection.viewInstance);
|
|
|
|
if (!vs || use(activeSection.parentKey) !== 'form') { return null; }
|
|
|
|
return [
|
|
|
|
cssRow(
|
|
|
|
primaryButton(t("Reset form"), dom.on('click', () => {
|
|
|
|
activeSection.layoutSpecObj.setAndSave(null).catch(reportError);
|
|
|
|
})),
|
|
|
|
cssRow.cls('-top-space')
|
|
|
|
),
|
|
|
|
];
|
|
|
|
}),
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
dom.maybe((use) => ['detail', 'single'].includes(use(this._pageWidgetType)!), () => [
|
2022-12-06 13:57:29 +00:00
|
|
|
cssLabel(t("Theme")),
|
2020-10-02 15:10:00 +00:00
|
|
|
dom('div',
|
|
|
|
vct._buildThemeDom(),
|
|
|
|
vct._buildLayoutDom())
|
|
|
|
]),
|
|
|
|
|
|
|
|
domComputed((use) => {
|
|
|
|
if (use(this._pageWidgetType) !== 'record') { return null; }
|
|
|
|
return dom.create(GridOptions, activeSection);
|
|
|
|
}),
|
|
|
|
|
2022-08-08 13:32:50 +00:00
|
|
|
domComputed((use) => {
|
|
|
|
if (use(this._pageWidgetType) !== 'record') { return null; }
|
|
|
|
return [
|
|
|
|
cssSeparator(),
|
2022-12-06 13:57:29 +00:00
|
|
|
cssLabel(t("ROW STYLE")),
|
2022-08-08 13:32:50 +00:00
|
|
|
domAsync(imports.loadViewPane().then(ViewPane =>
|
2022-12-06 13:57:29 +00:00
|
|
|
dom.create(ViewPane.ConditionalStyle, t("Row Style"), activeSection, this._gristDoc)
|
2022-08-08 13:32:50 +00:00
|
|
|
))
|
|
|
|
];
|
|
|
|
}),
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
dom.maybe((use) => use(this._pageWidgetType) === 'chart', () => [
|
2022-12-06 13:57:29 +00:00
|
|
|
cssLabel(t("CHART TYPE")),
|
2020-10-02 15:10:00 +00:00
|
|
|
vct._buildChartConfigDom(),
|
|
|
|
]),
|
|
|
|
|
2021-12-05 05:14:38 +00:00
|
|
|
dom.maybe((use) => use(this._pageWidgetType) === 'custom', () => {
|
|
|
|
const parts = vct._buildCustomTypeItems() as any[];
|
|
|
|
return [
|
2022-12-06 13:57:29 +00:00
|
|
|
cssLabel(t("CUSTOM")),
|
2021-12-05 05:14:38 +00:00
|
|
|
// If 'customViewPlugin' feature is on, show the toggle that allows switching to
|
|
|
|
// plugin mode. Note that the default mode for a new 'custom' view is 'url', so that's
|
|
|
|
// the only one that will be shown without the feature flag.
|
|
|
|
dom.maybe((use) => use(this._gristDoc.app.features).customViewPlugin,
|
|
|
|
() => dom('div', parts[0].buildDom())),
|
|
|
|
dom.maybe(use => use(activeSection.customDef.mode) === 'plugin',
|
|
|
|
() => dom('div', parts[2].buildDom())),
|
|
|
|
// In the default url mode, allow picking a url and granting/forbidding
|
|
|
|
// access to data.
|
2023-08-29 14:50:42 +00:00
|
|
|
dom.maybe(use => use(activeSection.customDef.mode) === 'url' && use(this._pageWidgetType) === 'custom',
|
2022-01-12 13:30:51 +00:00
|
|
|
() => dom.create(CustomSectionConfig, activeSection, this._gristDoc)),
|
2021-12-05 05:14:38 +00:00
|
|
|
];
|
|
|
|
}),
|
2023-08-29 14:50:42 +00:00
|
|
|
dom.maybe((use) => use(this._pageWidgetType)?.startsWith('custom.'), () => {
|
|
|
|
return [
|
|
|
|
dom.create(PredefinedCustomSectionConfig, activeSection, this._gristDoc),
|
|
|
|
];
|
|
|
|
}),
|
2020-10-02 15:10:00 +00:00
|
|
|
|
2022-02-07 14:02:26 +00:00
|
|
|
dom.maybe(
|
|
|
|
(use) => !(
|
|
|
|
use(hasCustomMapping) ||
|
|
|
|
use(this._pageWidgetType) === 'chart' ||
|
|
|
|
use(activeSection.isRaw)
|
2023-12-12 09:58:20 +00:00
|
|
|
) && use(activeSection.parentKey) !== 'form',
|
2022-02-07 14:02:26 +00:00
|
|
|
() => [
|
|
|
|
cssSeparator(),
|
|
|
|
dom.create(VisibleFieldsConfig, this._gristDoc, activeSection),
|
|
|
|
]),
|
2023-12-12 09:58:20 +00:00
|
|
|
|
|
|
|
dom.maybe(use => use(activeSection.parentKey) === 'form', () => [
|
|
|
|
cssSeparator(),
|
|
|
|
dom.create(HiddenQuestionConfig, activeSection),
|
|
|
|
]),
|
2020-10-02 15:10:00 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
private _buildPageSortFilterConfig(owner: MultiHolder) {
|
|
|
|
const viewConfigTab = this._createViewConfigTab(owner);
|
2022-11-17 20:17:51 +00:00
|
|
|
return dom.maybe(viewConfigTab, (vct) => vct.buildSortFilterDom());
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
|
2023-09-08 18:21:32 +00:00
|
|
|
private _buildLinkInfo(activeSection: ViewSectionRec, ...domArgs: DomElementArg[]) {
|
|
|
|
//NOTE!: linkingState.filterState might transiently be EmptyFilterState while things load
|
|
|
|
//Each case (filters-table, id cols, etc) needs to be able to handle having lfilter.filterLabels = {}
|
|
|
|
const tgtSec = activeSection;
|
|
|
|
return dom.domComputed((use) => {
|
|
|
|
|
|
|
|
const srcSec = use(tgtSec.linkSrcSection); //might be the empty section
|
|
|
|
const srcCol = use(tgtSec.linkSrcCol);
|
|
|
|
const srcColId = use(use(tgtSec.linkSrcCol).colId); // if srcCol is the empty col, colId will be undefined
|
2023-09-15 18:05:26 +00:00
|
|
|
|
|
|
|
if (srcSec.isDisposed()) { // can happen when deleting srcSection with rightpanel open
|
|
|
|
return cssLinkInfoPanel("");
|
|
|
|
}
|
|
|
|
|
2023-09-08 18:21:32 +00:00
|
|
|
//const tgtColId = use(use(tgtSec.linkTargetCol).colId);
|
|
|
|
const srcTable = use(srcSec.table);
|
|
|
|
const tgtTable = use(tgtSec.table);
|
|
|
|
|
|
|
|
const lstate = use(tgtSec.linkingState);
|
|
|
|
if(lstate == null) { return null; }
|
|
|
|
|
|
|
|
// if not filter-linking, this will be incorrect, but we don't use it then
|
|
|
|
const lfilter = lstate.filterState ? use(lstate.filterState): EmptyFilterState;
|
|
|
|
|
|
|
|
//If it's null then no cursor-link is set, but in that case we won't show the string anyway.
|
|
|
|
const cursorPos = lstate.cursorPos ? use(lstate.cursorPos) : 0;
|
|
|
|
const linkedCursorStr = cursorPos ? `${use(tgtTable.tableId)}[${cursorPos}]` : '';
|
|
|
|
|
|
|
|
// Make descriptor for the link's source like: "TableName . ColName" or "${SIGMA} TableName", etc
|
|
|
|
const fromTableDom = [
|
|
|
|
dom.maybe((use2) => use2(srcTable.summarySourceTable), () => cssLinkInfoIcon("Pivot")),
|
|
|
|
use(srcSec.titleDef) + (srcColId ? ` ${BLACK_CIRCLE} ${use(srcCol.label)}` : ''),
|
|
|
|
dom.style("white-space", "normal"), //Allow table name to wrap, reduces how often scrollbar needed
|
|
|
|
];
|
|
|
|
|
|
|
|
//Count filters for proper pluralization
|
|
|
|
const hasId = lfilter.filterLabels?.hasOwnProperty("id");
|
|
|
|
const numFilters = Object.keys(lfilter.filterLabels).length - (hasId ? 1 : 0);
|
|
|
|
|
|
|
|
// ================== Link-info Helpers
|
|
|
|
|
|
|
|
//For each col-filter in lfilters, makes a row showing "${icon} colName = [filterVals]"
|
|
|
|
//FilterVals is in a box to look like a grid cell
|
|
|
|
const makeFiltersTable = (): DomContents => {
|
|
|
|
return cssLinkInfoBody(
|
|
|
|
dom.style("width", "100%"), //width 100 keeps table from growing outside bounds of flex parent if overfull
|
|
|
|
dom("table",
|
|
|
|
dom.style("margin-left", "8px"),
|
|
|
|
Object.keys(lfilter.filterLabels).map( (colId) => {
|
|
|
|
const vals = lfilter.filterLabels[colId];
|
|
|
|
let operationSymbol = "=";
|
|
|
|
//if [filter (reflist) <- ref], op="intersects", need to convey "list has value". symbol =":"
|
|
|
|
//if [filter (ref) <- reflist], op="in", vals.length>1, need to convey "ref in list"
|
|
|
|
//Sometimes operation will be 'empty', but in that case "=" still works fine, i.e. "list = []"
|
|
|
|
if (lfilter.operations[colId] == "intersects") { operationSymbol = ":"; }
|
|
|
|
else if (vals.length > 1) { operationSymbol = ELEMENTOF; }
|
|
|
|
|
|
|
|
if (colId == "id") {
|
|
|
|
return dom("div", `ERROR: ID FILTER: ${colId}[${vals}]`);
|
|
|
|
} else {
|
|
|
|
return dom("tr",
|
|
|
|
dom("td", cssLinkInfoIcon("Filter"),
|
|
|
|
`${colId}`),
|
|
|
|
dom("td", operationSymbol, dom.style('padding', '0 2px 0 2px')),
|
|
|
|
dom("td", cssLinkInfoValuesBox(
|
|
|
|
isFullReferencingType(lfilter.colTypes[colId]) ?
|
|
|
|
cssLinkInfoIcon("FieldReference"): null,
|
|
|
|
`${vals.join(', ')}`)),
|
|
|
|
);
|
|
|
|
} }), //end of keys(filterLabels).map
|
|
|
|
));
|
|
|
|
};
|
|
|
|
|
|
|
|
//Given a list of filterLabels, show them all in a box, as if a grid cell
|
|
|
|
//Shows a "Reference" icon in the left side, since this should only be used for reflinks and cursor links
|
|
|
|
const makeValuesBox = (valueLabels: string[]): DomContents => {
|
|
|
|
return cssLinkInfoBody((
|
|
|
|
cssLinkInfoValuesBox(
|
|
|
|
cssLinkInfoIcon("FieldReference"),
|
|
|
|
valueLabels.join(', '), ) //TODO: join labels like "Entries[1], Entries[2]" to "Entries[[1,2]]"
|
|
|
|
));
|
|
|
|
};
|
|
|
|
|
|
|
|
const linkType = lstate.linkTypeDescription();
|
|
|
|
|
|
|
|
return cssLinkInfoPanel(() => { switch (linkType) {
|
|
|
|
case "Filter:Summary-Group":
|
|
|
|
case "Filter:Col->Col":
|
|
|
|
case "Filter:Row->Col":
|
|
|
|
case "Summary":
|
|
|
|
return [
|
|
|
|
dom("div", `Link applies filter${numFilters > 1 ? "s" : ""}:`),
|
|
|
|
makeFiltersTable(),
|
|
|
|
dom("div", `Linked from `, fromTableDom),
|
|
|
|
];
|
|
|
|
case "Show-Referenced-Records": {
|
|
|
|
//filterLabels might be {} if EmptyFilterState, so filterLabels["id"] might be undefined
|
|
|
|
const displayValues = lfilter.filterLabels["id"] ?? [];
|
|
|
|
return [
|
|
|
|
dom("div", `Link shows record${displayValues.length > 1 ? "s" : ""}:`),
|
|
|
|
makeValuesBox(displayValues),
|
|
|
|
dom("div", `from `, fromTableDom),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
case "Cursor:Same-Table":
|
|
|
|
case "Cursor:Reference":
|
|
|
|
return [
|
|
|
|
dom("div", `Link sets cursor to:`),
|
|
|
|
makeValuesBox([linkedCursorStr]),
|
|
|
|
dom("div", `from `, fromTableDom),
|
|
|
|
];
|
|
|
|
case "Error:Invalid":
|
|
|
|
default:
|
|
|
|
return dom("div", `Error: Couldn't identify link state`);
|
|
|
|
} },
|
|
|
|
...domArgs
|
|
|
|
); // End of cssLinkInfoPanel
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private _buildLinkInfoAdvanced(activeSection: ViewSectionRec) {
|
|
|
|
return dom.domComputed((use): DomContents => {
|
|
|
|
//TODO: if this just outputs a string, this could really be in LinkingState as a toDebugStr function
|
|
|
|
// but the fact that it's all observables makes that trickier to do correctly, so let's leave it here
|
|
|
|
const srcSec = use(activeSection.linkSrcSection); //might be the empty section
|
|
|
|
const tgtSec = activeSection;
|
2023-09-15 18:05:26 +00:00
|
|
|
|
|
|
|
if (srcSec.isDisposed()) { // can happen when deleting srcSection with rightpanel open
|
|
|
|
return cssRow("");
|
|
|
|
}
|
|
|
|
|
2023-09-08 18:21:32 +00:00
|
|
|
const srcCol = use(activeSection.linkSrcCol); // might be the empty column
|
|
|
|
const tgtCol = use(activeSection.linkTargetCol);
|
|
|
|
// columns might be the empty column
|
|
|
|
// to check nullness, use `.getRowId() == 0` or `use(srcCol.colId) == undefined`
|
|
|
|
|
|
|
|
const secToStr = (sec: ViewSectionRec) => (!sec || !sec.getRowId()) ?
|
|
|
|
'null' :
|
|
|
|
`#${use(sec.id)} "${use(sec.titleDef)}", (table "${use(use(sec.table).tableId)}")`;
|
|
|
|
const colToStr = (col: ColumnRec) => (!col || !col.getRowId()) ?
|
|
|
|
'null' :
|
|
|
|
`#${use(col.id)} "${use(col.colId)}", type "${use(col.type)}")`;
|
|
|
|
|
|
|
|
// linkingState can be null if the constructor throws, so for debugging we want to show link info
|
|
|
|
// if either the viewSection or the linkingState claim there's a link
|
|
|
|
const hasLink = use(srcSec.id) != undefined || use(tgtSec.linkingState) != null;
|
|
|
|
const lstate = use(tgtSec.linkingState);
|
|
|
|
const lfilter = lstate?.filterState ? use(lstate.filterState) : undefined;
|
|
|
|
|
2023-09-25 22:48:18 +00:00
|
|
|
// Debug info for cursor linking
|
|
|
|
const inPos = lstate?.incomingCursorPos ? use(lstate.incomingCursorPos) : null;
|
|
|
|
const cursorPosStr = (lstate?.cursorPos ? `${use(tgtSec.tableId)}[${use(lstate.cursorPos)}]` : "N/A") +
|
|
|
|
// TODO: the lastEdited and incomingCursorPos is kinda technical, to do with how bidirectional linking determines
|
|
|
|
// priority for cyclical cursor links. Might be too technical even for the "advanced info" box
|
|
|
|
`\n srclastEdited: T+${use(srcSec.lastCursorEdit)} \n tgtLastEdited: T+${use(tgtSec.lastCursorEdit)}` +
|
|
|
|
`\n incomingCursorPos: ${inPos ? `${inPos[0]}@T+${inPos[1]}` : "N/A"}`;
|
2023-09-08 18:21:32 +00:00
|
|
|
|
|
|
|
//Main link info as a big string, will be in a <pre></pre> block
|
|
|
|
let preString = "No Incoming Link";
|
|
|
|
if (hasLink) {
|
|
|
|
preString = [
|
|
|
|
`From Sec: ${secToStr(srcSec)}`,
|
|
|
|
`To Sec: ${secToStr(tgtSec)}`,
|
|
|
|
'',
|
|
|
|
`From Col: ${colToStr(srcCol)}`,
|
|
|
|
`To Col: ${colToStr(tgtCol)}`,
|
|
|
|
'===========================',
|
|
|
|
// Show linkstate
|
|
|
|
lstate == null ? "LinkState: null" : [
|
|
|
|
`Link Type: ${use(lstate.linkTypeDescription)}`,
|
|
|
|
``,
|
|
|
|
|
|
|
|
"Cursor Pos: " + cursorPosStr,
|
|
|
|
!lfilter ? "Filter State: null" :
|
|
|
|
["Filter State:", ...(Object.keys(lfilter).map(key =>
|
|
|
|
`- ${key}: ${JSON.stringify((lfilter as any)[key])}`))].join('\n'),
|
|
|
|
].join('\n')
|
|
|
|
].join('\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
const collapsed: SessionObs<Boolean> = this._advLinkInfoCollapsed;
|
|
|
|
return hasLink ? [
|
|
|
|
cssRow(
|
|
|
|
icon('Dropdown', dom.style('transform', (use2) => use2(collapsed) ? 'rotate(-90deg)' : '')),
|
|
|
|
"Advanced Link info",
|
|
|
|
dom.style('font-size', `${vars.smallFontSize}`),
|
|
|
|
dom.style('text-transform', 'uppercase'),
|
|
|
|
dom.style('cursor', 'pointer'),
|
|
|
|
dom.on('click', () => collapsed.set(!collapsed.get())),
|
|
|
|
),
|
|
|
|
dom.maybe(not(collapsed), () => cssRow(cssLinkInfoPre(preString)))
|
|
|
|
] : null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
private _buildPageDataConfig(owner: MultiHolder, activeSection: ViewSectionRec) {
|
|
|
|
const viewConfigTab = this._createViewConfigTab(owner);
|
|
|
|
const viewModel = this._gristDoc.viewModel;
|
|
|
|
const table = activeSection.table;
|
|
|
|
const groupedBy = Computed.create(owner, (use) => use(use(table).groupByColumns));
|
|
|
|
const link = Computed.create(owner, (use) => {
|
|
|
|
return linkId({
|
|
|
|
srcSectionRef: use(activeSection.linkSrcSectionRef),
|
|
|
|
srcColRef: use(activeSection.linkSrcColRef),
|
|
|
|
targetColRef: use(activeSection.linkTargetColRef)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-07-21 14:46:26 +00:00
|
|
|
// This computed is not enough to make sure that the linkOptions are up to date. Indeed
|
2020-10-02 15:10:00 +00:00
|
|
|
// the selectBy function depends on a much greater number of observables. Creating that many
|
2022-07-21 14:46:26 +00:00
|
|
|
// dependencies does not seem a better approach. Instead, we refresh the list of
|
|
|
|
// linkOptions only when the user clicks on the dropdown. Such behavior is not supported by the
|
|
|
|
// weasel select function as of writing and would require a custom implementation, so we will simulate
|
|
|
|
// this behavior by using temporary observable that will be changed when the user clicks on the dropdown.
|
|
|
|
const refreshTrigger = Observable.create(owner, false);
|
|
|
|
const linkOptions = Computed.create(owner, (use) => {
|
|
|
|
void use(refreshTrigger);
|
|
|
|
return selectBy(
|
2020-10-02 15:10:00 +00:00
|
|
|
this._gristDoc.docModel,
|
2022-07-21 14:46:26 +00:00
|
|
|
viewModel.viewSections().all(),
|
2020-10-02 15:10:00 +00:00
|
|
|
activeSection,
|
2022-07-21 14:46:26 +00:00
|
|
|
);
|
|
|
|
});
|
2020-10-02 15:10:00 +00:00
|
|
|
|
2022-07-18 11:39:58 +00:00
|
|
|
link.onWrite((val) => this._gristDoc.saveLink(val));
|
2020-10-02 15:10:00 +00:00
|
|
|
return [
|
|
|
|
this._disableIfReadonly(),
|
2022-12-06 13:57:29 +00:00
|
|
|
cssLabel(t("DATA TABLE")),
|
2020-10-02 15:10:00 +00:00
|
|
|
cssRow(
|
2022-12-06 13:57:29 +00:00
|
|
|
cssIcon('TypeTable'), cssDataLabel(t("SOURCE DATA")),
|
2020-10-02 15:10:00 +00:00
|
|
|
cssContent(dom.text((use) => use(use(table).primaryTableId)),
|
|
|
|
testId('pwc-table'))
|
|
|
|
),
|
|
|
|
dom(
|
|
|
|
'div',
|
2022-12-06 13:57:29 +00:00
|
|
|
cssRow(cssIcon('Pivot'), cssDataLabel(t("GROUPED BY"))),
|
2020-10-02 15:10:00 +00:00
|
|
|
cssRow(domComputed(groupedBy, (cols) => cssList(cols.map((c) => (
|
|
|
|
cssListItem(dom.text(c.label),
|
|
|
|
testId('pwc-groupedBy-col'))
|
|
|
|
))))),
|
|
|
|
|
|
|
|
testId('pwc-groupedBy'),
|
|
|
|
// hide if not a summary table
|
|
|
|
dom.hide((use) => !use(use(table).summarySourceTable)),
|
|
|
|
),
|
|
|
|
|
2023-11-20 00:46:32 +00:00
|
|
|
dom.maybe((use) => !use(activeSection.isRaw) && !use(activeSection.isRecordCard), () =>
|
2022-12-06 13:57:29 +00:00
|
|
|
cssButtonRow(primaryButton(t("Edit Data Selection"), this._createPageWidgetPicker(),
|
2022-02-07 14:02:26 +00:00
|
|
|
testId('pwc-editDataSelection')),
|
|
|
|
dom.maybe(
|
|
|
|
use => Boolean(use(use(activeSection.table).summarySourceTable)),
|
|
|
|
() => basicButton(
|
2022-12-06 13:57:29 +00:00
|
|
|
t("Detach"),
|
2022-02-07 14:02:26 +00:00
|
|
|
dom.on('click', () => this._gristDoc.docData.sendAction(
|
|
|
|
["DetachSummaryViewSection", activeSection.getRowId()])),
|
|
|
|
testId('detach-button'),
|
|
|
|
)),
|
|
|
|
cssRow.cls('-top-space'),
|
|
|
|
)),
|
2020-10-02 15:10:00 +00:00
|
|
|
|
|
|
|
// TODO: "Advanced settings" is for "on-demand" marking of tables. This should only be shown
|
|
|
|
// for raw data tables (once that's supported), should have updated UI, and should possibly
|
|
|
|
// be hidden for free plans.
|
|
|
|
dom.maybe(viewConfigTab, (vct) => cssRow(
|
|
|
|
dom('div', vct._buildAdvancedSettingsDom()),
|
|
|
|
)),
|
|
|
|
|
2023-11-20 00:46:32 +00:00
|
|
|
dom.maybe((use) => !use(activeSection.isRaw) && !use(activeSection.isRecordCard), () => [
|
|
|
|
cssSeparator(),
|
2022-12-06 13:57:29 +00:00
|
|
|
cssLabel(t("SELECT BY")),
|
2022-02-07 14:02:26 +00:00
|
|
|
cssRow(
|
2022-07-21 14:46:26 +00:00
|
|
|
dom.update(
|
2022-12-06 13:57:29 +00:00
|
|
|
select(link, linkOptions, {defaultLabel: t("Select Widget")}),
|
2022-07-21 14:46:26 +00:00
|
|
|
dom.on('click', () => {
|
|
|
|
refreshTrigger.set(!refreshTrigger.get());
|
|
|
|
})
|
|
|
|
),
|
2022-02-07 14:02:26 +00:00
|
|
|
testId('right-select-by')
|
|
|
|
),
|
|
|
|
]),
|
2020-10-02 15:10:00 +00:00
|
|
|
|
2023-09-08 18:21:32 +00:00
|
|
|
dom.maybe(activeSection.linkingState, () => cssRow(this._buildLinkInfo(activeSection))),
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
domComputed((use) => {
|
2023-06-21 14:43:22 +00:00
|
|
|
const selectorFor = use(use(activeSection.linkedSections).getObservable());
|
2020-10-02 15:10:00 +00:00
|
|
|
// TODO: sections should be listed following the order of appearance in the view layout (ie:
|
|
|
|
// left/right - top/bottom);
|
|
|
|
return selectorFor.length ? [
|
2022-12-06 13:57:29 +00:00
|
|
|
cssLabel(t("SELECTOR FOR"), testId('selector-for')),
|
2023-09-08 18:21:32 +00:00
|
|
|
cssRow(cssList(selectorFor.map((sec) => [
|
|
|
|
this._buildSectionItem(sec)
|
|
|
|
]))),
|
2020-10-02 15:10:00 +00:00
|
|
|
] : null;
|
|
|
|
}),
|
2023-09-08 18:21:32 +00:00
|
|
|
|
|
|
|
//Advanced link info is a little too JSON-ish for general use. But it's very useful for debugging
|
|
|
|
this._buildLinkInfoAdvanced(activeSection),
|
2020-10-02 15:10:00 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
private _createPageWidgetPicker(): DomElementMethod {
|
|
|
|
const gristDoc = this._gristDoc;
|
|
|
|
const section = gristDoc.viewModel.activeSection;
|
|
|
|
const onSave = (val: IPageWidget) => gristDoc.saveViewSection(section.peek(), val);
|
2022-12-20 02:06:39 +00:00
|
|
|
return (elem) => { attachPageWidgetPicker(elem, gristDoc, onSave, {
|
2022-12-06 13:57:29 +00:00
|
|
|
buttonLabel: t("Save"),
|
2020-10-02 15:10:00 +00:00
|
|
|
value: () => toPageWidget(section.peek()),
|
|
|
|
selectBy: (val) => gristDoc.selectBy(val),
|
|
|
|
}); };
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns dom for a section item.
|
|
|
|
private _buildSectionItem(sec: ViewSectionRec) {
|
|
|
|
return cssListItem(
|
|
|
|
dom.text(sec.titleDef),
|
2023-09-08 18:21:32 +00:00
|
|
|
this._buildLinkInfo(sec, dom.style("border", "none")),
|
2020-10-02 15:10:00 +00:00
|
|
|
testId('selector-for-entry')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns a DomArg that disables the content of the panel by adding a transparent overlay on top
|
|
|
|
// of it.
|
|
|
|
private _disableIfReadonly() {
|
|
|
|
if (this._gristDoc.docPageModel) {
|
|
|
|
return dom.maybe(this._gristDoc.docPageModel.isReadonly, () => (
|
|
|
|
cssOverlay(
|
|
|
|
testId('disable-overlay'),
|
2022-12-06 13:57:29 +00:00
|
|
|
cssBottomText(t("You do not have edit access to this document")),
|
2020-10-02 15:10:00 +00:00
|
|
|
)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-14 10:07:19 +00:00
|
|
|
function disabledSection() {
|
|
|
|
return cssOverlay(
|
|
|
|
testId('panel-disabled-section'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-03-17 03:45:44 +00:00
|
|
|
export function buildConfigContainer(...args: DomElementArg[]): HTMLElement {
|
2020-10-02 15:10:00 +00:00
|
|
|
return cssConfigContainer(
|
|
|
|
// The `position: relative;` style is needed for the overlay for the readonly mode. Note that
|
|
|
|
// we cannot set it on the cssConfigContainer directly because it conflicts with how overflow
|
|
|
|
// works. `padding-top: 1px;` prevents collapsing the top margins for the container and the
|
|
|
|
// first child.
|
|
|
|
dom('div', {style: 'position: relative; padding-top: 1px;'}, ...args),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This logic is copied from SidePane.js for building DOM from TabContent.
|
|
|
|
// TODO It may not be needed after new-ui refactoring of the side-pane content.
|
|
|
|
function tabContentToDom(content: Observable<TabContent[]>|TabContent[]|IDomComponent) {
|
|
|
|
function buildItemDom(item: any) {
|
|
|
|
return dom('div.config_item',
|
|
|
|
dom.show(item.showObs || true),
|
|
|
|
item.buildDom()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ("buildDom" in content) {
|
|
|
|
return content.buildDom();
|
|
|
|
}
|
|
|
|
|
|
|
|
return cssTabContents(
|
|
|
|
dom.forEach(content, itemOrHeader => {
|
|
|
|
if (itemOrHeader.header) {
|
|
|
|
return dom('div.config_group',
|
|
|
|
dom.show(itemOrHeader.showObs || true),
|
|
|
|
itemOrHeader.label ? dom('div.config_header', itemOrHeader.label) : null,
|
|
|
|
dom.forEach(itemOrHeader.items, item => buildItemDom(item)),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return buildItemDom(itemOrHeader);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const cssOverlay = styled('div', `
|
2022-09-06 01:51:57 +00:00
|
|
|
background-color: ${theme.rightPanelDisabledOverlay};
|
2020-10-02 15:10:00 +00:00
|
|
|
opacity: 0.8;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
z-index: 100;
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssBottomText = styled('span', `
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.text};
|
2020-10-02 15:10:00 +00:00
|
|
|
position: absolute;
|
|
|
|
bottom: -40px;
|
|
|
|
padding: 4px 16px;
|
|
|
|
`);
|
|
|
|
|
2022-08-08 13:32:50 +00:00
|
|
|
const cssRow = styled('div', `
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.text};
|
2020-10-02 15:10:00 +00:00
|
|
|
display: flex;
|
|
|
|
margin: 8px 16px;
|
|
|
|
align-items: center;
|
|
|
|
&-top-space {
|
|
|
|
margin-top: 24px;
|
|
|
|
}
|
2021-11-22 08:45:48 +00:00
|
|
|
&-disabled {
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.disabledText};
|
2021-11-22 08:45:48 +00:00
|
|
|
}
|
2020-10-02 15:10:00 +00:00
|
|
|
`);
|
|
|
|
|
2022-01-25 09:38:21 +00:00
|
|
|
|
2022-08-08 13:32:50 +00:00
|
|
|
const cssButtonRow = styled(cssRow, `
|
2020-10-02 15:10:00 +00:00
|
|
|
margin-left: 0;
|
|
|
|
margin-right: 0;
|
|
|
|
& > button {
|
|
|
|
margin-left: 16px;
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
2022-08-08 13:32:50 +00:00
|
|
|
const cssIcon = styled(icon, `
|
2020-10-02 15:10:00 +00:00
|
|
|
flex: 0 0 auto;
|
2022-09-06 01:51:57 +00:00
|
|
|
--icon-color: ${theme.lightText};
|
2020-10-02 15:10:00 +00:00
|
|
|
`);
|
|
|
|
|
|
|
|
const cssTopBarItem = styled('div', `
|
|
|
|
flex: 1 1 0px;
|
|
|
|
height: 100%;
|
2022-09-06 01:51:57 +00:00
|
|
|
background-color: ${theme.rightPanelTabBg};
|
2020-10-02 15:10:00 +00:00
|
|
|
font-weight: ${vars.headerControlTextWeight};
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.rightPanelTabFg};
|
|
|
|
--icon-color: ${theme.rightPanelTabIcon};
|
2020-10-02 15:10:00 +00:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
cursor: default;
|
|
|
|
|
|
|
|
&-selected {
|
2022-09-06 01:51:57 +00:00
|
|
|
background-color: ${theme.rightPanelTabSelectedBg};
|
2020-10-02 15:10:00 +00:00
|
|
|
font-weight: initial;
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.rightPanelTabSelectedFg};
|
|
|
|
--icon-color: ${theme.rightPanelTabSelectedFg};
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
&:not(&-selected):hover {
|
2022-09-06 01:51:57 +00:00
|
|
|
background-color: ${theme.rightPanelTabHoverBg};
|
|
|
|
--icon-color: ${theme.rightPanelTabIconHover};
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssTopBarIcon = styled(icon, `
|
|
|
|
flex: none;
|
|
|
|
margin: 16px;
|
|
|
|
height: 16px;
|
|
|
|
width: 16px;
|
2022-10-25 03:10:15 +00:00
|
|
|
background-color: var(--icon-color);
|
2020-10-02 15:10:00 +00:00
|
|
|
`);
|
|
|
|
|
|
|
|
const cssHoverCircle = styled('div', `
|
|
|
|
margin-left: auto;
|
|
|
|
margin-right: 8px;
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
|
|
|
background: none;
|
|
|
|
border-radius: 16px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
|
|
|
|
&:hover {
|
2022-10-25 03:10:15 +00:00
|
|
|
background-color: ${theme.rightPanelTabButtonHoverBg};
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssHoverIcon = styled(icon, `
|
|
|
|
height: 16px;
|
|
|
|
width: 16px;
|
2022-10-25 03:10:15 +00:00
|
|
|
background-color: var(--icon-color);
|
2020-10-02 15:10:00 +00:00
|
|
|
`);
|
|
|
|
|
2022-08-08 13:32:50 +00:00
|
|
|
const cssSubTabContainer = styled('div', `
|
2020-10-02 15:10:00 +00:00
|
|
|
height: 48px;
|
|
|
|
flex: none;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
`);
|
|
|
|
|
2022-08-08 13:32:50 +00:00
|
|
|
const cssSubTab = styled('div', `
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.rightPanelSubtabFg};
|
2020-10-02 15:10:00 +00:00
|
|
|
flex: auto;
|
|
|
|
height: 100%;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: flex-end;
|
|
|
|
text-align: center;
|
|
|
|
padding-bottom: 8px;
|
2022-09-06 01:51:57 +00:00
|
|
|
border-bottom: 1px solid ${theme.pagePanelsBorder};
|
2020-10-02 15:10:00 +00:00
|
|
|
cursor: default;
|
|
|
|
|
|
|
|
&-selected {
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.rightPanelSubtabSelectedFg};
|
|
|
|
border-bottom: 1px solid ${theme.rightPanelSubtabSelectedUnderline};
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
&:not(&-selected):hover {
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.rightPanelSubtabHoverFg};
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
&:hover {
|
2022-09-06 01:51:57 +00:00
|
|
|
border-bottom: 1px solid ${theme.rightPanelSubtabHoverUnderline};
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
.${cssSubTabContainer.className}:hover > &-selected:not(:hover) {
|
2022-09-06 01:51:57 +00:00
|
|
|
border-bottom: 1px solid ${theme.pagePanelsBorder};
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssTabContents = styled('div', `
|
|
|
|
padding: 16px 8px;
|
|
|
|
overflow: auto;
|
|
|
|
`);
|
|
|
|
|
2022-08-08 13:32:50 +00:00
|
|
|
const cssSeparator = styled('div', `
|
2022-09-06 01:51:57 +00:00
|
|
|
border-bottom: 1px solid ${theme.pagePanelsBorder};
|
2021-03-17 03:45:44 +00:00
|
|
|
margin-top: 16px;
|
2020-10-02 15:10:00 +00:00
|
|
|
`);
|
|
|
|
|
2023-03-28 16:11:40 +00:00
|
|
|
const cssConfigContainer = styled('div.test-config-container', `
|
2020-10-02 15:10:00 +00:00
|
|
|
overflow: auto;
|
|
|
|
--color-list-item: none;
|
|
|
|
--color-list-item-hover: none;
|
|
|
|
|
|
|
|
&:after {
|
|
|
|
content: "";
|
|
|
|
display: block;
|
|
|
|
height: 40px;
|
|
|
|
}
|
|
|
|
& .fieldbuilder_settings {
|
|
|
|
margin: 16px 0 0 0;
|
|
|
|
}
|
2023-11-20 00:46:32 +00:00
|
|
|
&-disabled {
|
|
|
|
opacity: 0.4;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
2020-10-02 15:10:00 +00:00
|
|
|
`);
|
|
|
|
|
|
|
|
const cssDataLabel = styled('div', `
|
|
|
|
flex: 0 0 81px;
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.lightText};
|
2020-10-02 15:10:00 +00:00
|
|
|
font-size: ${vars.xsmallFontSize};
|
|
|
|
margin-left: 4px;
|
|
|
|
margin-top: 2px;
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssContent = styled('div', `
|
|
|
|
flex: 0 1 auto;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
min-width: 1em;
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssList = styled('div', `
|
|
|
|
list-style: none;
|
|
|
|
width: 100%;
|
|
|
|
`);
|
|
|
|
|
|
|
|
|
|
|
|
const cssListItem = styled('li', `
|
2022-09-06 01:51:57 +00:00
|
|
|
background-color: ${theme.hover};
|
2020-10-02 15:10:00 +00:00
|
|
|
border-radius: 2px;
|
|
|
|
margin-bottom: 4px;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
width: 100%;
|
|
|
|
padding: 4px 8px;
|
|
|
|
`);
|
|
|
|
|
2022-08-08 13:32:50 +00:00
|
|
|
const cssTextInput = styled(textInput, `
|
2020-10-02 15:10:00 +00:00
|
|
|
flex: 1 0 auto;
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.inputFg};
|
|
|
|
background-color: ${theme.inputBg};
|
2022-07-06 07:41:09 +00:00
|
|
|
|
|
|
|
&:disabled {
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.inputDisabledFg};
|
|
|
|
background-color: ${theme.inputDisabledBg};
|
2022-07-06 07:41:09 +00:00
|
|
|
pointer-events: none;
|
|
|
|
}
|
2020-10-02 15:10:00 +00:00
|
|
|
`);
|
2022-10-14 10:07:19 +00:00
|
|
|
|
|
|
|
const cssSection = styled('div', `
|
|
|
|
position: relative;
|
|
|
|
`);
|
2023-09-08 18:21:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
//============ LinkInfo CSS ============
|
|
|
|
|
|
|
|
//LinkInfoPanel is a flex-column
|
|
|
|
//`LinkInfoPanel > table` is the table where we show linked filters, if there are any
|
|
|
|
const cssLinkInfoPanel = styled('div', `
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
flex-flow: column;
|
|
|
|
align-items: start;
|
|
|
|
text-align: left;
|
|
|
|
|
|
|
|
font-family: ${vars.fontFamily};
|
|
|
|
|
|
|
|
border: 1px solid ${theme.pagePanelsBorder};
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
|
|
padding: 6px;
|
|
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow-x: auto;
|
|
|
|
|
|
|
|
& table {
|
|
|
|
border-spacing: 2px;
|
|
|
|
border-collapse: separate;
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
// Center table / values box inside LinkInfoPanel
|
|
|
|
const cssLinkInfoBody= styled('div', `
|
|
|
|
margin: 2px 0 2px 0;
|
|
|
|
align-self: center;
|
|
|
|
`);
|
|
|
|
|
|
|
|
// Intended to imitate style of a grid cell
|
|
|
|
// white-space: normal allows multiple values to wrap
|
|
|
|
// min-height: 22px matches real field size, +2 for the borders
|
|
|
|
const cssLinkInfoValuesBox = styled('div', `
|
|
|
|
border: 1px solid ${'#CCC'};
|
|
|
|
padding: 3px 3px 0px 3px;
|
|
|
|
min-width: 60px;
|
|
|
|
min-height: 24px;
|
|
|
|
|
|
|
|
white-space: normal;
|
|
|
|
`);
|
|
|
|
|
|
|
|
//If inline with text, icons look better shifted up slightly
|
|
|
|
//since icons are position:relative, bottom:1 should shift it without affecting layout
|
|
|
|
const cssLinkInfoIcon = styled(icon, `
|
|
|
|
bottom: 1px;
|
|
|
|
margin-right: 3px;
|
|
|
|
background-color: ${theme.controlSecondaryFg};
|
|
|
|
`);
|
|
|
|
|
|
|
|
// ============== styles for _buildLinkInfoAdvanced
|
|
|
|
const cssLinkInfoPre = styled("pre", `
|
|
|
|
padding: 6px;
|
|
|
|
font-size: ${vars.smallFontSize};
|
|
|
|
line-height: 1.2;
|
|
|
|
`);
|