|
1 | 1 | /* eslint-disable @microsoft/spfx/no-async-await */
|
2 |
| -import { SPHttpClient } from "@microsoft/sp-http"; |
3 |
| -import { IInstalledLanguageInfo, sp } from "@pnp/sp/presets/all"; |
| 2 | +import * as React from "react"; |
4 | 3 | import * as strings from "ControlStrings";
|
| 4 | +import styles from "./DynamicForm.module.scss"; |
| 5 | + |
| 6 | +// Controls |
5 | 7 | import {
|
6 | 8 | DefaultButton,
|
7 | 9 | PrimaryButton,
|
8 | 10 | } from "office-ui-fabric-react/lib/Button";
|
9 |
| -import { MessageBar, MessageBarType } from "office-ui-fabric-react/lib/MessageBar"; |
| 11 | +import { |
| 12 | + Dialog, |
| 13 | + DialogFooter, |
| 14 | + DialogType, |
| 15 | +} from "office-ui-fabric-react/lib/Dialog"; |
10 | 16 | import { IDropdownOption } from "office-ui-fabric-react/lib/components/Dropdown";
|
| 17 | +import { MessageBar, MessageBarType } from "office-ui-fabric-react/lib/MessageBar"; |
11 | 18 | import { ProgressIndicator } from "office-ui-fabric-react/lib/ProgressIndicator";
|
12 | 19 | import { IStackTokens, Stack } from "office-ui-fabric-react/lib/Stack";
|
13 |
| -import * as React from "react"; |
14 |
| -import { ISPField, IUploadImageResult } from "../../common/SPEntities"; |
15 |
| -import { FormulaEvaluation } from "../../common/utilities/FormulaEvaluation"; |
16 |
| -import SPservice from "../../services/SPService"; |
17 |
| -import { IFilePickerResult } from "../filePicker"; |
18 | 20 | import { DynamicField } from "./dynamicField";
|
19 | 21 | import {
|
20 | 22 | DateFormat,
|
21 | 23 | FieldChangeAdditionalData,
|
22 | 24 | IDynamicFieldProps,
|
23 | 25 | } from "./dynamicField/IDynamicFieldProps";
|
24 |
| -import styles from "./DynamicForm.module.scss"; |
| 26 | +import { IFilePickerResult } from "../filePicker"; |
25 | 27 | import { IDynamicFormProps } from "./IDynamicFormProps";
|
26 | 28 | import { IDynamicFormState } from "./IDynamicFormState";
|
27 |
| -import { |
28 |
| - Dialog, |
29 |
| - DialogFooter, |
30 |
| - DialogType, |
31 |
| -} from "office-ui-fabric-react/lib/Dialog"; |
32 | 29 |
|
| 30 | +// pnp/sp, helpers / utils |
| 31 | +import { sp } from "@pnp/sp"; |
33 | 32 | import "@pnp/sp/lists";
|
34 | 33 | import "@pnp/sp/content-types";
|
35 | 34 | import "@pnp/sp/folders";
|
36 | 35 | import "@pnp/sp/items";
|
37 |
| -import { sp } from "@pnp/sp"; |
38 |
| -import { ICustomFormatting, ICustomFormattingBodySection, ICustomFormattingNode } from "../../common/utilities/ICustomFormatting"; |
| 36 | +import { IInstalledLanguageInfo } from "@pnp/sp/presets/all"; |
39 | 37 | import { cloneDeep, isEqual } from "lodash";
|
| 38 | +import { ICustomFormatting, ICustomFormattingBodySection, ICustomFormattingNode } from "../../common/utilities/ICustomFormatting"; |
| 39 | +import SPservice from "../../services/SPService"; |
40 | 40 | import { IRenderListDataAsStreamClientFormResult } from "../../services/ISPService";
|
41 |
| -import CustomFormattingHelper from "../../common/utilities/CustomFormatting"; |
| 41 | +import { ISPField, IUploadImageResult } from "../../common/SPEntities"; |
| 42 | +import { FormulaEvaluation } from "../../common/utilities/FormulaEvaluation"; |
42 | 43 | import { Context } from "../../common/utilities/FormulaEvaluation.types";
|
| 44 | +import CustomFormattingHelper from "../../common/utilities/CustomFormatting"; |
43 | 45 |
|
44 | 46 | const stackTokens: IStackTokens = { childrenGap: 20 };
|
45 | 47 |
|
@@ -898,14 +900,15 @@ export class DynamicForm extends React.Component<
|
898 | 900 |
|
899 | 901 | this.setState({
|
900 | 902 | clientValidationFormulas,
|
901 |
| - fieldCollection: tempFields, |
902 |
| - validationFormulas, |
903 |
| - etag, |
904 | 903 | customFormatting: {
|
905 | 904 | header: headerJSON,
|
906 | 905 | body: bodySections,
|
907 | 906 | footer: footerJSON
|
908 |
| - } |
| 907 | + }, |
| 908 | + etag, |
| 909 | + fieldCollection: tempFields, |
| 910 | + installedLanguages, |
| 911 | + validationFormulas |
909 | 912 | }, () => this.performValidation(true));
|
910 | 913 |
|
911 | 914 | } catch (error) {
|
@@ -952,6 +955,7 @@ export class DynamicForm extends React.Component<
|
952 | 955 | let richText = false;
|
953 | 956 | let dateFormat: DateFormat | undefined;
|
954 | 957 | let principalType = "";
|
| 958 | + let cultureName: string; |
955 | 959 | let minValue: number | undefined;
|
956 | 960 | let maxValue: number | undefined;
|
957 | 961 | let showAsPercentage: boolean | undefined;
|
@@ -989,6 +993,9 @@ export class DynamicForm extends React.Component<
|
989 | 993 | maxValue = numberField.MaximumValue;
|
990 | 994 | }
|
991 | 995 | showAsPercentage = field.ShowAsPercentage;
|
| 996 | + if (field.FieldType === "Currency") { |
| 997 | + cultureName = this.cultureNameLookup(numberField.CurrencyLocaleId); |
| 998 | + } |
992 | 999 | }
|
993 | 1000 |
|
994 | 1001 | // Setup Lookup fields
|
@@ -1150,6 +1157,7 @@ export class DynamicForm extends React.Component<
|
1150 | 1157 | newValue: undefined,
|
1151 | 1158 | stringValue,
|
1152 | 1159 | subPropertyValues,
|
| 1160 | + cultureName, |
1153 | 1161 | fieldTermSetId: termSetId,
|
1154 | 1162 | fieldAnchorId: anchorId,
|
1155 | 1163 | options: choices,
|
@@ -1188,6 +1196,12 @@ export class DynamicForm extends React.Component<
|
1188 | 1196 | return tempFields;
|
1189 | 1197 | }
|
1190 | 1198 |
|
| 1199 | + private cultureNameLookup(lcid: number): string { |
| 1200 | + const pageCulture = this.props.context.pageContext.cultureInfo.currentCultureName; |
| 1201 | + if (!lcid) return pageCulture; |
| 1202 | + return this.state.installedLanguages?.find(lang => lang.Lcid === lcid).DisplayName ?? pageCulture; |
| 1203 | + } |
| 1204 | + |
1191 | 1205 | private uploadImage = async (
|
1192 | 1206 | file: IFilePickerResult
|
1193 | 1207 | ): Promise<IUploadImageResult> => {
|
|
0 commit comments