Skip to content

Commit 08ac2e8

Browse files
author
Tom German
committed
Fixes and cleanup following merge with 'dev'
1 parent 801bb06 commit 08ac2e8

File tree

3 files changed

+37
-24
lines changed

3 files changed

+37
-24
lines changed

src/common/SPEntities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export interface ISPField {
6060
ValidationMessage?: string;
6161
MinimumValue?: number;
6262
MaximumValue?: number;
63+
CurrencyLocaleId?: number;
6364
}
6465

6566
/**

src/controls/dynamicForm/DynamicForm.tsx

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,47 @@
11
/* 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";
43
import * as strings from "ControlStrings";
4+
import styles from "./DynamicForm.module.scss";
5+
6+
// Controls
57
import {
68
DefaultButton,
79
PrimaryButton,
810
} 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";
1016
import { IDropdownOption } from "office-ui-fabric-react/lib/components/Dropdown";
17+
import { MessageBar, MessageBarType } from "office-ui-fabric-react/lib/MessageBar";
1118
import { ProgressIndicator } from "office-ui-fabric-react/lib/ProgressIndicator";
1219
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";
1820
import { DynamicField } from "./dynamicField";
1921
import {
2022
DateFormat,
2123
FieldChangeAdditionalData,
2224
IDynamicFieldProps,
2325
} from "./dynamicField/IDynamicFieldProps";
24-
import styles from "./DynamicForm.module.scss";
26+
import { IFilePickerResult } from "../filePicker";
2527
import { IDynamicFormProps } from "./IDynamicFormProps";
2628
import { IDynamicFormState } from "./IDynamicFormState";
27-
import {
28-
Dialog,
29-
DialogFooter,
30-
DialogType,
31-
} from "office-ui-fabric-react/lib/Dialog";
3229

30+
// pnp/sp, helpers / utils
31+
import { sp } from "@pnp/sp";
3332
import "@pnp/sp/lists";
3433
import "@pnp/sp/content-types";
3534
import "@pnp/sp/folders";
3635
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";
3937
import { cloneDeep, isEqual } from "lodash";
38+
import { ICustomFormatting, ICustomFormattingBodySection, ICustomFormattingNode } from "../../common/utilities/ICustomFormatting";
39+
import SPservice from "../../services/SPService";
4040
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";
4243
import { Context } from "../../common/utilities/FormulaEvaluation.types";
44+
import CustomFormattingHelper from "../../common/utilities/CustomFormatting";
4345

4446
const stackTokens: IStackTokens = { childrenGap: 20 };
4547

@@ -898,14 +900,15 @@ export class DynamicForm extends React.Component<
898900

899901
this.setState({
900902
clientValidationFormulas,
901-
fieldCollection: tempFields,
902-
validationFormulas,
903-
etag,
904903
customFormatting: {
905904
header: headerJSON,
906905
body: bodySections,
907906
footer: footerJSON
908-
}
907+
},
908+
etag,
909+
fieldCollection: tempFields,
910+
installedLanguages,
911+
validationFormulas
909912
}, () => this.performValidation(true));
910913

911914
} catch (error) {
@@ -952,6 +955,7 @@ export class DynamicForm extends React.Component<
952955
let richText = false;
953956
let dateFormat: DateFormat | undefined;
954957
let principalType = "";
958+
let cultureName: string;
955959
let minValue: number | undefined;
956960
let maxValue: number | undefined;
957961
let showAsPercentage: boolean | undefined;
@@ -989,6 +993,9 @@ export class DynamicForm extends React.Component<
989993
maxValue = numberField.MaximumValue;
990994
}
991995
showAsPercentage = field.ShowAsPercentage;
996+
if (field.FieldType === "Currency") {
997+
cultureName = this.cultureNameLookup(numberField.CurrencyLocaleId);
998+
}
992999
}
9931000

9941001
// Setup Lookup fields
@@ -1150,6 +1157,7 @@ export class DynamicForm extends React.Component<
11501157
newValue: undefined,
11511158
stringValue,
11521159
subPropertyValues,
1160+
cultureName,
11531161
fieldTermSetId: termSetId,
11541162
fieldAnchorId: anchorId,
11551163
options: choices,
@@ -1188,6 +1196,12 @@ export class DynamicForm extends React.Component<
11881196
return tempFields;
11891197
}
11901198

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+
11911205
private uploadImage = async (
11921206
file: IFilePickerResult
11931207
): Promise<IUploadImageResult> => {

src/controls/dynamicForm/dynamicField/DynamicField.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ import { IPickerTerms, TaxonomyPicker } from '../../taxonomyPicker';
2222
import styles from '../DynamicForm.module.scss';
2323
import { IDynamicFieldProps } from './IDynamicFieldProps';
2424
import { IDynamicFieldState } from './IDynamicFieldState';
25-
import { isArray } from 'lodash';
2625
import CurrencyMap from "../CurrencyMap";
2726

28-
2927
export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFieldState> {
3028

3129
constructor(props: IDynamicFieldProps) {
@@ -308,7 +306,7 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
308306
onChange={(e, newText) => { this.onChange(newText); }}
309307
disabled={disabled}
310308
onBlur={this.onBlur}
311-
errorMessage={customNumberErrorMessage}
309+
errorMessage={errorText || customNumberErrorMessage}
312310
min={minimumValue}
313311
max={maximumValue} />
314312
{descriptionEl}

0 commit comments

Comments
 (0)