mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) updates from grist-core
This commit is contained in:
@@ -9,6 +9,9 @@ import { cssIconBackground, icon } from 'app/client/ui2018/icons';
|
||||
import { gristLink } from 'app/client/ui2018/links';
|
||||
import { NewAbstractWidget, Options } from 'app/client/widgets/NewAbstractWidget';
|
||||
import { Computed, dom, DomArg, DomContents, fromKo, Observable, styled } from 'grainjs';
|
||||
import {makeT} from 'app/client/lib/localization';
|
||||
|
||||
const t = makeT('NTextBox');
|
||||
|
||||
/**
|
||||
* TextBox - The most basic widget for displaying text information.
|
||||
@@ -62,7 +65,7 @@ export class NTextBox extends NewAbstractWidget {
|
||||
return dom('div.field_clip',
|
||||
dom.style('text-align', this.alignment),
|
||||
dom.cls('text_wrapping', this.wrapping),
|
||||
dom.domComputed((use) => use(row._isAddRow) ? null : makeLinks(use(this.valueFormatter).formatAny(use(value))))
|
||||
dom.domComputed((use) => use(row._isAddRow) ? null : makeLinks(use(this.valueFormatter).formatAny(use(value), t)))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,19 +79,28 @@ export class BaseFormatter {
|
||||
* Formats using this.format() if a value is of the right type for this formatter, or using
|
||||
* AnyFormatter otherwise. This method the recommended API. There is no need to override it.
|
||||
*/
|
||||
public formatAny(value: any): string {
|
||||
return this.isRightType(value) ? this.format(value) : formatUnknown(value);
|
||||
public formatAny(value: any, translate?: (val: string) => string): string {
|
||||
return this.isRightType(value) ? this.format(value, translate) : formatUnknown(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a value that matches the type of this formatter. This should be overridden by derived
|
||||
* classes to handle values in formatter-specific ways.
|
||||
*/
|
||||
protected format(value: any): string {
|
||||
protected format(value: any, _translate?: (val: string) => string): string {
|
||||
return String(value);
|
||||
}
|
||||
}
|
||||
|
||||
export class BoolFormatter extends BaseFormatter {
|
||||
public format(value: boolean | 0 | 1, translate?: (val: string) => string): string {
|
||||
if (typeof value === 'boolean' && translate) {
|
||||
return translate(String(value));
|
||||
}
|
||||
return super.format(value, translate);
|
||||
}
|
||||
}
|
||||
|
||||
class AnyFormatter extends BaseFormatter {
|
||||
public format(value: any): string {
|
||||
return formatUnknown(value);
|
||||
@@ -265,7 +274,7 @@ class ReferenceListFormatter extends ReferenceFormatter {
|
||||
const formatters: { [name: string]: typeof BaseFormatter } = {
|
||||
Numeric: NumericFormatter,
|
||||
Int: IntFormatter,
|
||||
Bool: BaseFormatter,
|
||||
Bool: BoolFormatter,
|
||||
Date: DateFormatter,
|
||||
DateTime: DateTimeFormatter,
|
||||
Ref: ReferenceFormatter,
|
||||
|
||||
@@ -60,7 +60,7 @@ export const MIN_URLID_PREFIX_LENGTH = 12;
|
||||
*/
|
||||
|
||||
export const commonUrls = {
|
||||
help: "https://support.getgrist.com",
|
||||
help: getHelpCenterUrl(),
|
||||
helpAccessRules: "https://support.getgrist.com/access-rules",
|
||||
helpConditionalFormatting: "https://support.getgrist.com/conditional-formatting",
|
||||
helpLinkingWidgets: "https://support.getgrist.com/linking-widgets",
|
||||
@@ -493,6 +493,9 @@ export interface GristLoadConfig {
|
||||
|
||||
// In single-org mode, this is the single well-known org. Suppress any org selection UI.
|
||||
singleOrg?: string;
|
||||
|
||||
// Url for support for the browser client to use.
|
||||
helpCenterUrl?: string;
|
||||
|
||||
// When set, this directs the client to encode org information in path, not in domain.
|
||||
pathOnly?: boolean;
|
||||
@@ -641,6 +644,15 @@ export function getKnownOrg(): string|null {
|
||||
}
|
||||
}
|
||||
|
||||
export function getHelpCenterUrl(): string|null {
|
||||
if(isClient()) {
|
||||
const gristConfig: GristLoadConfig = (window as any).gristConfig;
|
||||
return gristConfig && gristConfig.helpCenterUrl || null;
|
||||
} else {
|
||||
return process.env.GRIST_HELP_CENTER || null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Like getKnownOrg, but respects singleOrg/GRIST_SINGLE_ORG strictly.
|
||||
* The main difference in behavior would be for orgs with custom domains
|
||||
|
||||
@@ -41,6 +41,7 @@ export function makeGristConfig(homeUrl: string|null, extra: Partial<GristLoadCo
|
||||
org: process.env.GRIST_SINGLE_ORG || (mreq && mreq.org),
|
||||
baseDomain,
|
||||
singleOrg: process.env.GRIST_SINGLE_ORG,
|
||||
helpCenterUrl: process.env.GRIST_HELP_CENTER || "https://support.getgrist.com",
|
||||
pathOnly,
|
||||
supportAnon: shouldSupportAnon(),
|
||||
supportEngines: getSupportedEngineChoices(),
|
||||
|
||||
Reference in New Issue
Block a user