(core) Form Publishing

Summary:
Adds initial implementation of form publishing, built upon WYSIWYS shares.

A simple UI for publishing and unpublishing forms is included.

Test Plan: Browser tests.

Reviewers: jarek

Reviewed By: jarek

Subscribers: paulfitz, jarek

Differential Revision: https://phab.getgrist.com/D4154
This commit is contained in:
George Gevoian
2024-01-12 09:35:24 -08:00
parent 8ddcff4310
commit e12471347b
17 changed files with 634 additions and 85 deletions

View File

@@ -1,4 +1,5 @@
import {DocModel, IRowModel, refRecord, ViewRec} from 'app/client/models/DocModel';
import {ShareRec} from 'app/client/models/entities/ShareRec';
import * as ko from 'knockout';
// Represents a page entry in the tree of pages.
@@ -7,6 +8,7 @@ export interface PageRec extends IRowModel<"_grist_Pages"> {
isHidden: ko.Computed<boolean>;
isCensored: ko.Computed<boolean>;
isSpecial: ko.Computed<boolean>;
share: ko.Computed<ShareRec>;
}
export function createPageRec(this: PageRec, docModel: DocModel): void {
@@ -36,4 +38,5 @@ export function createPageRec(this: PageRec, docModel: DocModel): void {
this.isHidden = ko.pureComputed(() => {
return this.isCensored() || this.isSpecial();
});
this.share = refRecord(docModel.shares, this.shareRef);
}

View File

@@ -0,0 +1,10 @@
import {IRowModel} from 'app/client/models/DocModel';
import * as modelUtil from 'app/client/models/modelUtil';
export interface ShareRec extends IRowModel<"_grist_Shares"> {
optionsObj: modelUtil.SaveableObjObservable<any>;
}
export function createShareRec(this: ShareRec): void {
this.optionsObj = modelUtil.jsonObservable(this.options);
}

View File

@@ -1,7 +1,7 @@
import {BoxSpec} from 'app/client/components/Layout';
import {KoArray} from 'app/client/lib/koArray';
import * as koUtil from 'app/client/lib/koUtil';
import {DocModel, IRowModel, recordSet, refRecord} from 'app/client/models/DocModel';
import {DocModel, IRowModel, PageRec, recordSet, refRecord} from 'app/client/models/DocModel';
import {TabBarRec, ViewSectionRec} from 'app/client/models/DocModel';
import * as modelUtil from 'app/client/models/modelUtil';
import * as ko from 'knockout';
@@ -30,6 +30,8 @@ export interface ViewRec extends IRowModel<"_grist_Views"> {
// If the active section is removed, set the next active section to be the default.
_isActiveSectionGone: ko.Computed<boolean>;
page: ko.Computed<PageRec|null>;
}
export function createViewRec(this: ViewRec, docModel: DocModel): void {
@@ -76,6 +78,11 @@ export function createViewRec(this: ViewRec, docModel: DocModel): void {
this.activeSectionId(0);
}
}));
this.page = this.autoDispose(ko.pureComputed(() => {
const viewRef = this.id();
return docModel.allPages().find(p => p.viewRef() === viewRef) ?? null;
}));
}
function getFirstLeaf(layoutSpec: BoxSpec|undefined): BoxSpec['leaf'] {

View File

@@ -71,6 +71,7 @@ export interface ViewSectionRec extends IRowModel<"_grist_Views_section">, RuleO
columns: ko.Computed<ColumnRec[]>;
optionsObj: modelUtil.SaveableObjObservable<any>;
shareOptionsObj: modelUtil.SaveableObjObservable<any>;
customDef: CustomViewSectionDef;
@@ -380,6 +381,7 @@ export function createViewSectionRec(this: ViewSectionRec, docModel: DocModel):
};
this.optionsObj = modelUtil.jsonObservable(this.options,
(obj: any) => defaults(obj || {}, defaultOptions));
this.shareOptionsObj = modelUtil.jsonObservable(this.shareOptions);
const customViewDefaults = {
mode: 'url',