(core) updates from grist-core

This commit is contained in:
Paul Fitzpatrick
2023-04-17 09:58:04 -04:00
7 changed files with 30 additions and 19 deletions

View File

@@ -11,6 +11,7 @@ import {TableData} from 'app/client/models/TableData';
import {FieldBuilder} from 'app/client/widgets/FieldBuilder';
import {UserAction} from 'app/common/DocActions';
import {Disposable, Observable} from 'grainjs';
import isPlainObject from 'lodash/isPlainObject';
import * as ko from 'knockout';
import noop = require('lodash/noop');
@@ -163,7 +164,10 @@ export class ColumnTransform extends Disposable {
protected async addTransformColumn(colType: string): Promise<number> {
// Retrieve widget options on prepare (useful for type transforms)
const newColInfo = await this._tableData.sendTableAction(['AddColumn', "gristHelper_Transform", {
type: colType, isFormula: true, formula: this.getIdentityFormula(),
type: colType,
isFormula: true,
formula: this.getIdentityFormula(),
...(this.origWidgetOptions ? {widgetOptions: JSON.stringify(this.origWidgetOptions)} : {}),
}]);
return newColInfo.colRef;
}
@@ -219,6 +223,9 @@ export class ColumnTransform extends Disposable {
* The user actions to send when actually executing the transform.
*/
protected executeActions(): UserAction[] {
const newWidgetOptions = isPlainObject(this.origWidgetOptions) ?
{...this.origWidgetOptions as object, ...this._fieldBuilder.options.peek()} :
this._fieldBuilder.options.peek();
return [
[
'CopyFromColumn',
@@ -229,7 +236,7 @@ export class ColumnTransform extends Disposable {
// Those options are supposed to be set by prepTransformColInfo(TypeTransform) and
// adjusted by client.
// TODO: is this really needed? Aren't those options already in the data-engine?
JSON.stringify(this._fieldBuilder.options.peek()),
JSON.stringify(newWidgetOptions),
],
];
}

View File

@@ -11,7 +11,7 @@ import {primaryButton} from 'app/client/ui2018/buttons';
import {mediaXSmall, testId, theme} from 'app/client/ui2018/cssVars';
import {icon} from 'app/client/ui2018/icons';
import {menu, menuAnnotate, menuDivider, menuIcon, menuItem, menuItemLink, menuText} from 'app/client/ui2018/menus';
import {buildUrlId, parseUrlId} from 'app/common/gristUrls';
import {buildUrlId, parseUrlId, shouldHideUiElement} from 'app/common/gristUrls';
import * as roles from 'app/common/roles';
import {Document} from 'app/common/UserAPI';
import {dom, DomContents, styled} from 'grainjs';
@@ -244,8 +244,8 @@ function menuExports(doc: Document, pageModel: DocPageModel) {
href: pageModel.appModel.api.getDocAPI(doc.id).getDownloadXlsxUrl(),
target: '_blank', download: ''
}, menuIcon('Download'), t("Export XLSX"), testId('tb-share-option')),
menuItem(() => sendToDrive(doc, pageModel),
menuIcon('Download'), t("Send to Google Drive"), testId('tb-share-option')),
(shouldHideUiElement("sendToDrive") ? null : menuItem(() => sendToDrive(doc, pageModel),
menuIcon('Download'), t("Send to Google Drive"), testId('tb-share-option'))),
];
}

View File

@@ -615,7 +615,8 @@ export interface GristLoadConfig {
userLocale?: string;
}
export const HideableUiElements = StringUnion("helpCenter", "billing", "templates", "multiSite", "multiAccounts");
export const HideableUiElements = StringUnion("helpCenter", "billing", "templates", "multiSite", "multiAccounts",
"sendToDrive");
export type IHideableUiElement = typeof HideableUiElements.type;
export function shouldHideUiElement(elem: IHideableUiElement): boolean {