🤦♂️ - [React-json-form]: Git is hard, think I made it back
This commit is contained in:
parent
5a67f695b2
commit
7721546ff9
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "samples",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
|
@ -1,73 +1,94 @@
|
|||
# react-json-form
|
||||
# JSON Form builder
|
||||
|
||||
## Summary
|
||||
|
||||
Short summary on functionality and used technologies.
|
||||
Let's the user build a form and receive responses in the form
|
||||
|
||||
[picture of the solution in action, if possible]
|
||||
![Sample gif](./assets/Demo.gif)
|
||||
|
||||
## Used SharePoint Framework Version
|
||||
## Compatibility
|
||||
|
||||
![version](https://img.shields.io/badge/version-1.17.1-green.svg)
|
||||
| :warning: Important |
|
||||
|:---------------------------|
|
||||
| Every SPFx version is only compatible with specific version(s) of Node.js. In order to be able to build this sample, please ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.|
|
||||
|Refer to <https://aka.ms/spfx-matrix> for more information on SPFx compatibility. |
|
||||
|
||||
This sample is optimally compatible with the following environment configuration:
|
||||
|
||||
![SPFx 1.17.1](https://img.shields.io/badge/SPFx-1.17.1-green.svg)
|
||||
![Node.js v16](https://img.shields.io/badge/Node.js-v16-green.svg)
|
||||
![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg)
|
||||
![Does not work with SharePoint 2019](https://img.shields.io/badge/SharePoint%20Server%202019-Incompatible-red.svg "SharePoint Server 2019 requires SPFx 1.4.1 or lower")
|
||||
![Does not work with SharePoint 2016 (Feature Pack 2)](https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202)-Incompatible-red.svg "SharePoint Server 2016 Feature Pack 2 requires SPFx 1.1")
|
||||
![Local Workbench Unsupported](https://img.shields.io/badge/Local%20Workbench-Unsupported-red.svg "Local workbench is no longer available as of SPFx 1.13 and above")
|
||||
![Hosted Workbench Compatible](https://img.shields.io/badge/Hosted%20Workbench-Compatible-green.svg)
|
||||
![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Not%20Tested-yellow.svg)
|
||||
|
||||
For more information about SPFx compatibility, please refer to https://aka.ms/spfx-matrix
|
||||
|
||||
## Applies to
|
||||
|
||||
- [SharePoint Framework](https://aka.ms/spfx)
|
||||
- [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
||||
* [SharePoint Framework](https://learn.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
|
||||
* [Microsoft 365 tenant](https://learn.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment)
|
||||
|
||||
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)
|
||||
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/m365devprogram)
|
||||
|
||||
## Prerequisites
|
||||
## Contributors
|
||||
|
||||
> Any special pre-requisites?
|
||||
|
||||
## Solution
|
||||
|
||||
| Solution | Author(s) |
|
||||
| ----------- | ------------------------------------------------------- |
|
||||
| folder name | Author details (name, company, twitter alias with link) |
|
||||
*[Dan Toft](https://github.com/Tanddant)
|
||||
|
||||
## Version history
|
||||
|
||||
| Version | Date | Comments |
|
||||
| ------- | ---------------- | --------------- |
|
||||
| 1.1 | March 10, 2021 | Update comment |
|
||||
| 1.0 | January 29, 2021 | Initial release |
|
||||
| 1.0 | March 16, 2023 | Initial release |
|
||||
|
||||
## Disclaimer
|
||||
|
||||
**THIS CODE IS PROVIDED _AS IS_ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
||||
## Prerequisites
|
||||
|
||||
---
|
||||
You'll need a document library to store the responses
|
||||
|
||||
## Minimal Path to Awesome
|
||||
## Minimal path to awesome
|
||||
|
||||
- Clone this repository
|
||||
- Ensure that you are at the solution folder
|
||||
- in the command-line run:
|
||||
- **npm install**
|
||||
- **gulp serve**
|
||||
* Clone this repository (or [download this solution as a .ZIP file](https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-json-form) then unzip it)
|
||||
* From your command line, change your current directory to the directory containing this sample (`react-json-form`, located under `samples`)
|
||||
* in the command line run:
|
||||
* `npm install`
|
||||
* `gulp serve`
|
||||
|
||||
> Include any additional steps as needed.
|
||||
> This sample can also be opened with [VS Code Remote Development](https://code.visualstudio.com/docs/remote/remote-overview). Visit <https://aka.ms/spfx-devcontainer> for further instructions.
|
||||
|
||||
## Features
|
||||
|
||||
Description of the extension that expands upon high-level summary above.
|
||||
> PLEASE DON'T ACTUALLY USE THIS IN IT'S CURRENT STATE!
|
||||
>
|
||||
> The way this is setup to save it to save a .json file in a document library containing both the forms config and the values
|
||||
|
||||
This extension illustrates the following concepts:
|
||||
You have the option to edit the raw JSON in the property pane, from here you'll also set the document library where the JSON files are stored
|
||||
|
||||
- topic 1
|
||||
- topic 2
|
||||
- topic 3
|
||||
![property pane](assets/Raw%20JSON.png)
|
||||
|
||||
> Notice that better pictures and documentation will increase the sample usage and the value you are providing for others. Thanks for your submissions advance.
|
||||
There's support for conditional fields ()
|
||||
|
||||
> Share your web part with others through Microsoft 365 Patterns and Practices program to get visibility and exposure. More details on the community, open-source projects and other activities from http://aka.ms/m365pnp.
|
||||
|
||||
## References
|
||||
## Help
|
||||
|
||||
- [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
||||
- [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview)
|
||||
- [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
|
||||
- [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview)
|
||||
- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development
|
||||
We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.
|
||||
|
||||
If you're having issues building the solution, please run [spfx doctor](https://pnp.github.io/cli-microsoft365/cmd/spfx/spfx-doctor/) from within the solution folder to diagnose incompatibility issues with your environment.
|
||||
|
||||
You can try looking at [issues related to this sample](https://github.com/pnp/sp-dev-fx-webparts/issues?q=label%3A%22sample%3A%20react-json-form%22) to see if anybody else is having the same issues.
|
||||
|
||||
You can also try looking at [discussions related to this sample](https://github.com/pnp/sp-dev-fx-webparts/discussions?discussions_q=react-json-form) and see what the community is saying.
|
||||
|
||||
If you encounter any issues using this sample, [create a new issue](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected%2Csample%3A%20react-json-form&template=bug-report.yml&sample=react-json-form&authors=@Tanddant&title=react-json-form%20-%20).
|
||||
|
||||
For questions regarding this sample, [create a new question](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aquestion%2Csample%3A%20react-json-form&template=question.yml&sample=react-json-form&authors=@Tanddant&title=react-json-form%20-%20).
|
||||
|
||||
Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aenhancement%2Csample%3A%20react-json-form&template=suggestion.yml&sample=react-json-form&authors=@Tanddant&title=react-json-form%20-%20).
|
||||
|
||||
## Disclaimer
|
||||
|
||||
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
||||
|
||||
<img src="https://m365-visitor-stats.azurewebsites.net/sp-dev-fx-webparts/samples/react-json-form" />
|
Binary file not shown.
After Width: | Height: | Size: 869 KiB |
|
@ -4,6 +4,6 @@ export default function useObject<T>(InitialValue?: T) {
|
|||
const [value, setValue] = useState<T>(InitialValue ?? {} as T);
|
||||
const updateValue: (Updates: Partial<T>) => void = (Updates: Partial<T>) => setValue((prev) => ({ ...prev, ...Updates }))
|
||||
return {
|
||||
value, updateValue
|
||||
value, updateValue, overwriteData: setValue
|
||||
};
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import { FieldType, IConditionalField, IField, IGroupField } from "../webparts/jsonForm/model/FormField";
|
||||
import { FieldType, IConditionalField, IField, IGroupField } from "../Models/FormField";
|
||||
|
||||
export const generateGuid: () => string = () => {
|
||||
return Math.random().toString(36).substring(2, 15) +
|
||||
|
@ -8,7 +8,7 @@ export const generateGuid: () => string = () => {
|
|||
export const NewField: () => IField = () => ({ Id: generateGuid(), Type: FieldType.PlaceHolder } as IField)
|
||||
|
||||
|
||||
const UNSUPPORTED_FIELDTYPES: FieldType[] = [FieldType.PlaceHolder, FieldType.MultiChoice, FieldType.PlaceHolder, FieldType.Label];
|
||||
const UNSUPPORTED_LOOKUP_FIELDTYPES: FieldType[] = [FieldType.PlaceHolder, FieldType.MultiChoice, FieldType.PlaceHolder, FieldType.Label];
|
||||
|
||||
export const GetLookupFields: (Fields: IField[]) => IField[] = (Fields: IField[]) => {
|
||||
const arr: IField[] = [];
|
||||
|
@ -27,5 +27,5 @@ export const GetLookupFields: (Fields: IField[]) => IField[] = (Fields: IField[]
|
|||
}
|
||||
}
|
||||
|
||||
return arr.filter(x => x.DisplayName != null && !UNSUPPORTED_FIELDTYPES.some(bannedType => bannedType == x.Type));;
|
||||
return arr.filter(x => x.DisplayName != null && !UNSUPPORTED_LOOKUP_FIELDTYPES.some(bannedType => bannedType == x.Type));;
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
|
|||
import { PropertyFieldCodeEditor, PropertyFieldCodeEditorLanguages } from '@pnp/spfx-property-controls/lib/PropertyFieldCodeEditor';
|
||||
import { PropertyFieldListPicker, PropertyFieldListPickerOrderBy } from '@pnp/spfx-property-controls/lib/PropertyFieldListPicker';
|
||||
import { IJsonFormProps, JsonForm } from './components/JsonForm';
|
||||
import { IForm } from './model/FormField';
|
||||
import { SPFI, SPFx, spfi } from '@pnp/sp/presets/all'
|
||||
import { IForm } from '../../Models/Form';
|
||||
import { IDataProvider, SharePointProvider } from '../../Providers/SharePointProvider';
|
||||
|
||||
export interface IJsonFormWebPartProps {
|
||||
formJson: string;
|
||||
|
@ -19,12 +19,12 @@ export interface IJsonFormWebPartProps {
|
|||
|
||||
export interface AppContext {
|
||||
context: BaseComponentContext;
|
||||
SP: SPFI;
|
||||
ListId: string;
|
||||
ItemId?: number
|
||||
provider: IDataProvider;
|
||||
}
|
||||
|
||||
export const SPFxContext = React.createContext<AppContext>(null);
|
||||
const urlSearchParams = new URLSearchParams(window.location.search);
|
||||
export const FILLED_FORM_QUERY_KEY = "FormServerRelativeUrl";
|
||||
|
||||
export default class JsonFormWebPart extends BaseClientSideWebPart<IJsonFormWebPartProps> {
|
||||
|
||||
|
@ -34,9 +34,7 @@ export default class JsonFormWebPart extends BaseClientSideWebPart<IJsonFormWebP
|
|||
{
|
||||
value: {
|
||||
context: this.context,
|
||||
SP: spfi().using(SPFx(this.context)),
|
||||
ListId: urlSearchParams.get("ListId") ?? this.properties.listId,
|
||||
ItemId: urlSearchParams.has("ItemId") ? parseInt(urlSearchParams.get("ItemId")) : null
|
||||
provider: new SharePointProvider(this.context, this.properties.listId)
|
||||
} as AppContext
|
||||
},
|
||||
React.createElement<IJsonFormProps>(
|
||||
|
@ -44,7 +42,9 @@ export default class JsonFormWebPart extends BaseClientSideWebPart<IJsonFormWebP
|
|||
{
|
||||
Form: JSON.parse(this.properties.formJson),
|
||||
SaveForm: (updated: IForm) => this.properties.formJson = JSON.stringify({ ...JSON.parse(this.properties.formJson), ...updated }, null, 2),
|
||||
Mode: this.displayMode
|
||||
Mode: this.displayMode,
|
||||
ListId: this.properties.listId,
|
||||
ServerRelativeUrl: urlSearchParams.has(FILLED_FORM_QUERY_KEY) ? urlSearchParams.get(FILLED_FORM_QUERY_KEY) : null,
|
||||
}
|
||||
)
|
||||
);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as React from 'react';
|
||||
import { FieldType, GroupDirection, IChoiceField, IConditionalField, IField, IGroupField } from '../../model/FormField';
|
||||
import { FieldType, GroupDirection, IChoiceField, IConditionalField, IField, IGroupField } from '../../../../Models/FormField';
|
||||
import { Position, SpinButton, TextField, Checkbox, Dropdown, MessageBar, MessageBarType, Text } from '@fluentui/react';
|
||||
import { Label } from 'office-ui-fabric-react';
|
||||
|
||||
|
@ -8,49 +8,52 @@ export interface IFieldProps {
|
|||
onChange: (updates: object) => void;
|
||||
form: any;
|
||||
field: IField;
|
||||
readonly: boolean;
|
||||
}
|
||||
|
||||
export const Field: React.FunctionComponent<IFieldProps> = (props: React.PropsWithChildren<IFieldProps>) => {
|
||||
const { field, onChange, form } = props;
|
||||
const { field, onChange, form, readonly } = props;
|
||||
switch (field.Type) {
|
||||
case FieldType.Label: return <Label>{field.DisplayName}</Label>;
|
||||
|
||||
case FieldType.Header: return <Text variant='xLarge'>{field.DisplayName}</Text>;
|
||||
|
||||
case FieldType.Text: return <TextField
|
||||
value={form[field.Id]}
|
||||
value={form[field.Id] ?? ""}
|
||||
label={field.DisplayName}
|
||||
readOnly={readonly}
|
||||
onChange={(_, val) => onChange({ [field.Id]: val })}
|
||||
/>;
|
||||
|
||||
case FieldType.MultilineText: return <TextField
|
||||
value={form[field.Id]}
|
||||
value={form[field.Id] ?? ""}
|
||||
label={field.DisplayName}
|
||||
rows={5}
|
||||
multiline
|
||||
readOnly={readonly}
|
||||
onChange={(_, val) => onChange({ [field.Id]: val })}
|
||||
/>;
|
||||
|
||||
case FieldType.Number: return <SpinButton
|
||||
inputMode='numeric'
|
||||
labelPosition={Position.top}
|
||||
value={form[field.Id]}
|
||||
value={form[field.Id] ?? ""}
|
||||
label={field.DisplayName}
|
||||
onChange={(_, val) => onChange({ [field.Id]: Number(val) })}
|
||||
onChange={readonly ? null : (_, val) => onChange({ [field.Id]: Number(val) })}
|
||||
/>;
|
||||
|
||||
case FieldType.Boolean: return <Checkbox
|
||||
label={field.DisplayName}
|
||||
checked={form[field.Id]}
|
||||
onChange={(_, val) => onChange({ [field.Id]: val })}
|
||||
checked={form[field.Id] ?? false}
|
||||
onChange={readonly ? () => null : (_, val) => onChange({ [field.Id]: val })}
|
||||
styles={{ root: { alignItems: 'center', marginTop: "1.75em" } }}
|
||||
/>;
|
||||
|
||||
case FieldType.Choice: return <Dropdown
|
||||
options={(field as any as IChoiceField).Options.map(x => ({ key: x, text: x }))}
|
||||
selectedKey={form[field.Id]}
|
||||
selectedKey={form[field.Id] ?? ""}
|
||||
label={field.DisplayName}
|
||||
onChange={(_, option) => onChange({ [field.Id]: option.key })}
|
||||
onChange={readonly ? null : (_, option) => onChange({ [field.Id]: option.key })}
|
||||
/>
|
||||
|
||||
case FieldType.MultiChoice: return <Dropdown
|
||||
|
@ -58,7 +61,7 @@ export const Field: React.FunctionComponent<IFieldProps> = (props: React.PropsWi
|
|||
selectedKeys={form[field.Id] ?? []}
|
||||
label={field.DisplayName}
|
||||
multiSelect
|
||||
onChange={(_, val) => {
|
||||
onChange={readonly ? null : (_, val) => {
|
||||
let selected: string[] = form[field.Id] ?? [];
|
||||
selected = val.selected ? [...selected, val.key as string] : selected.filter(x => x != val.key);
|
||||
onChange({ [field.Id]: selected })
|
||||
|
@ -81,7 +84,7 @@ export const Field: React.FunctionComponent<IFieldProps> = (props: React.PropsWi
|
|||
const f = (field as IConditionalField);
|
||||
const visible = form[f.LookupFieldId] == f.MatchValue
|
||||
if (!visible) return <></>
|
||||
return <Field field={f.Field} form={form} onChange={onChange} />
|
||||
return <Field readonly={readonly} field={f.Field} form={form} onChange={onChange} />
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as React from 'react';
|
||||
import { FieldType, GroupDirection, IChoiceField, IConditionalField, IField, IGroupField } from '../../model/FormField';
|
||||
import { FieldType, GroupDirection, IChoiceField, IConditionalField, IField, IGroupField } from '../../../../Models/FormField';
|
||||
import { ActionButton, ChoiceGroup, DefaultButton, Dialog, DialogFooter, Dropdown, Label, Position, PrimaryButton, SpinButton, Stack, TextField } from '@fluentui/react';
|
||||
import useObject from '../../../../Hooks/UseObject';
|
||||
import { NewField } from '../../../../Util/Util';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as React from 'react';
|
||||
import { FieldType, GroupDirection, IChoiceField, IConditionalField, IField, IGroupField } from '../../model/FormField';
|
||||
import { FieldType, GroupDirection, IChoiceField, IConditionalField, IField, IGroupField } from '../../../../Models/FormField';
|
||||
import { ActionButton, Checkbox, Dropdown, Label, MessageBar, MessageBarType, Position, PrimaryButton, SpinButton, Text, TextField, getTheme } from '@fluentui/react';
|
||||
import { cloneDeep } from '@microsoft/sp-lodash-subset';
|
||||
import { FieldEditorDialog } from './FieldEditorDialog';
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import * as React from 'react';
|
||||
import { IForm } from '../model/FormField';
|
||||
import useObject from '../../../Hooks/UseObject';
|
||||
import { PrimaryButton, Stack, DialogFooter } from '@fluentui/react'
|
||||
import { Field } from './Fields/Field';
|
||||
|
@ -8,22 +7,42 @@ import { Placeholder, WebPartTitle } from '@pnp/spfx-controls-react';
|
|||
import { FormFieldCustomizer } from './Fields/FormFieldCustomizer';
|
||||
import { GetLookupFields, NewField } from '../../../Util/Util';
|
||||
import { cloneDeep } from '@microsoft/sp-lodash-subset';
|
||||
import { SPFxContext } from '../JsonFormWebPart';
|
||||
import { FILLED_FORM_QUERY_KEY, SPFxContext } from '../JsonFormWebPart';
|
||||
import { IForm } from '../../../Models/Form';
|
||||
|
||||
export interface IJsonFormProps {
|
||||
Form: IForm;
|
||||
SaveForm: (updated: IForm) => void;
|
||||
Mode: DisplayMode;
|
||||
ServerRelativeUrl?: string;
|
||||
ListId: string;
|
||||
}
|
||||
|
||||
export const JsonForm: React.FunctionComponent<IJsonFormProps> = (props: React.PropsWithChildren<IJsonFormProps>) => {
|
||||
const { Mode } = props;
|
||||
const { value: Form, updateValue: UpdateForm } = useObject<IForm>(props.Form);
|
||||
const { value: filledForm, updateValue } = useObject<any>();
|
||||
const { ListId } = React.useContext(SPFxContext);
|
||||
const { Mode, ServerRelativeUrl } = props;
|
||||
const { value: Form, updateValue: UpdateForm, overwriteData: __SETFORM } = useObject<IForm>(props.ServerRelativeUrl ? { Fields: [], Title: "" } : props.Form);
|
||||
const { value: filledForm, updateValue, overwriteData: __SETFILLEDFORM } = useObject<any>();
|
||||
const { provider } = React.useContext(SPFxContext);
|
||||
|
||||
console.log(ListId);
|
||||
if (ListId == null || ListId == "")
|
||||
React.useEffect(() => {
|
||||
if (ServerRelativeUrl != null) {
|
||||
const fetch = async () => {
|
||||
const result = await provider.GetSubmission(ServerRelativeUrl);
|
||||
__SETFILLEDFORM(result.response);
|
||||
__SETFORM(result.form);
|
||||
}
|
||||
fetch();
|
||||
}
|
||||
}, [])
|
||||
|
||||
const saveForm = async () => {
|
||||
const serverRelativeUrl = await provider.SaveSubmission({ form: Form, response: filledForm });
|
||||
var searchParams = new URLSearchParams(window.location.search);
|
||||
searchParams.set(FILLED_FORM_QUERY_KEY, serverRelativeUrl);
|
||||
window.location.search = searchParams.toString();
|
||||
}
|
||||
|
||||
if (props.ListId == null || props.ListId == "")
|
||||
return <Placeholder description={'Open the property pane and select a list to store responses'} iconName={'Edit'} iconText={'Please configure web part'} />
|
||||
|
||||
return (
|
||||
|
@ -34,12 +53,14 @@ export const JsonForm: React.FunctionComponent<IJsonFormProps> = (props: React.P
|
|||
<>
|
||||
<Stack tokens={{ childrenGap: 5 }}>
|
||||
{Form.Fields.map(field => {
|
||||
return <Field field={field} onChange={updateValue} form={filledForm} />
|
||||
return <Field readonly={props.ServerRelativeUrl != null} field={field} onChange={updateValue} form={filledForm} />
|
||||
})}
|
||||
</Stack>
|
||||
<DialogFooter>
|
||||
<PrimaryButton text='Submit' iconProps={{ iconName: "Accept" }} onClick={() => alert(JSON.stringify(filledForm, null, 2))} />
|
||||
</DialogFooter>
|
||||
{props.ServerRelativeUrl == null &&
|
||||
<DialogFooter>
|
||||
<PrimaryButton text='Submit' iconProps={{ iconName: "Accept" }} onClick={() => saveForm()} />
|
||||
</DialogFooter>
|
||||
}
|
||||
</>
|
||||
}
|
||||
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
export enum FieldType {
|
||||
Text = "Text",
|
||||
MultilineText = "MultilineText",
|
||||
Number = "Number",
|
||||
Boolean = "Boolean",
|
||||
Choice = "Choice",
|
||||
MultiChoice = "MultiChoice",
|
||||
FieldGroup = "FieldGroup",
|
||||
PlaceHolder = "PlaceHolder",
|
||||
Label = "Label",
|
||||
Conditional = "Conditional",
|
||||
Header = "Header"
|
||||
}
|
||||
|
||||
export interface IField {
|
||||
Id: string;
|
||||
DisplayName?: string;
|
||||
Type: FieldType;
|
||||
}
|
||||
|
||||
export interface IChoiceField extends IField {
|
||||
Options: string[]
|
||||
}
|
||||
|
||||
export interface IConditionalField extends IField {
|
||||
LookupFieldId: string;
|
||||
MatchValue: string | number | boolean;
|
||||
Field: IField;
|
||||
}
|
||||
|
||||
export enum GroupDirection {
|
||||
Vertical,
|
||||
Horizontal
|
||||
}
|
||||
|
||||
export interface IGroupField extends IField {
|
||||
Fields: (IField | IChoiceField | IGroupField | IConditionalField)[]
|
||||
Direction: GroupDirection;
|
||||
}
|
||||
|
||||
export interface IForm {
|
||||
Title: string;
|
||||
Fields: (IField | IChoiceField | IGroupField | IConditionalField)[];
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
"outDir": "lib",
|
||||
"inlineSources": false,
|
||||
"strictNullChecks": false,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitAny": false,
|
||||
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
|
|
Loading…
Reference in New Issue