From adc288b88a05def71b481c378a184c660414c18e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Cutzach?= Date: Thu, 22 Aug 2024 17:05:17 +0200 Subject: [PATCH] wip: working implementation todo: tests, notification of success --- app/client/ui/AdminPanelCss.ts | 1 + app/client/ui/DocumentSettings.ts | 188 +++++++++++++++++++++++------- app/client/ui2018/checkbox.ts | 1 - 3 files changed, 147 insertions(+), 43 deletions(-) diff --git a/app/client/ui/AdminPanelCss.ts b/app/client/ui/AdminPanelCss.ts index 2853a3fa..d0d48e8b 100644 --- a/app/client/ui/AdminPanelCss.ts +++ b/app/client/ui/AdminPanelCss.ts @@ -159,6 +159,7 @@ const cssItemName = styled('div', ` `); const cssItemDescription = styled('div', ` + max-width: 320px; margin-right: auto; margin-bottom: -1px; /* aligns with the value */ `); diff --git a/app/client/ui/DocumentSettings.ts b/app/client/ui/DocumentSettings.ts index 33b41a36..3a2e8f06 100644 --- a/app/client/ui/DocumentSettings.ts +++ b/app/client/ui/DocumentSettings.ts @@ -42,7 +42,6 @@ export class DocSettingsPage extends Disposable { private _timezone = this._docInfo.timezone; private _locale: KoSaveableObservable = this._docInfo.documentSettingsJson.prop('locale'); private _currency: KoSaveableObservable = this._docInfo.documentSettingsJson.prop('currency'); - // private _type: KoSaveableObservable = this._docInfo.documentSettingsJson.prop('type'); private _engine: Computed = Computed.create(this, ( use => use(this._docInfo.documentSettingsJson.prop('engine')) )) @@ -87,6 +86,18 @@ export class DocSettingsPage extends Disposable { {defaultCurrencyLabel: t("Local currency ({{currency}})", {currency: getCurrency(l)})}) ) }), + dom.create(AdminSectionItem, { + id: 'templateMode', + name: t('Template mode'), + description: t('Special document mode'), + value: cssDocTypeContainer( + dom.create(displayCurrentType, docPageModel.type, /*docPageModel.currentDocId.get()*/), + cssSmallButton(t('Edit'), + dom.on('click', this._doSetDocumentType.bind(this, true)) + ) + ), + disabled: isDocEditor ? false : t('Only available to document editors'), + }), ]), dom.create(cssAdminSection, t('Data Engine'), [ @@ -193,15 +204,6 @@ export class DocSettingsPage extends Disposable { value: cssSmallLinkButton(t('Manage webhooks'), urlState().setLinkUrl({docPage: 'webhook'})), }), ]), - - dom.create(cssAdminSection, t('Document conversion'), [ - dom.create(AdminSectionItem, { - id: 'document-type', - name: t('Document type'), - description: t('Convert the document'), - value: dom.create(buildTypeSelect, docPageModel.type, docPageModel.currentDocId.get()), - }), - ]), ); } @@ -232,11 +234,11 @@ export class DocSettingsPage extends Disposable { const docPageModel = this._gristDoc.docPageModel; modal((ctl, owner) => { this.onDispose(() => ctl.close()); - const selected = Observable.create