Skip to content

Commit f9380ec

Browse files
authored
Merge pull request #1747 from GuidoZam/DynamicForm-Lookup-Sorting
Added orderBy to DynamicField props for lookup fields
2 parents dd5e8fc + 7697fc3 commit f9380ec

2 files changed

Lines changed: 30 additions & 22 deletions

File tree

src/controls/dynamicForm/dynamicField/DynamicField.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
7979
principalType,
8080
description,
8181
maximumValue,
82-
minimumValue
82+
minimumValue,
83+
orderBy
8384
} = this.props;
8485

8586
const {
@@ -237,6 +238,7 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
237238
itemLimit={1}
238239
onSelectedItem={(newValue) => { this.onChange(newValue, true); }}
239240
context={context}
241+
orderBy={orderBy}
240242
/>
241243
{descriptionEl}
242244
{errorTextEl}
@@ -283,8 +285,8 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
283285
onChange={(e, newText) => { this.onChange(newText); }}
284286
disabled={disabled}
285287
onBlur={this.onBlur}
286-
errorMessage={errorText || customNumberErrorMessage}
287-
min={minimumValue}
288+
errorMessage={errorText || customNumberErrorMessage}
289+
min={minimumValue}
288290
max={maximumValue} />
289291
{descriptionEl}
290292
</div>;
@@ -306,8 +308,8 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
306308
onChange={(e, newText) => { this.onChange(newText); }}
307309
disabled={disabled}
308310
onBlur={this.onBlur}
309-
errorMessage={errorText || customNumberErrorMessage}
310-
min={minimumValue}
311+
errorMessage={errorText || customNumberErrorMessage}
312+
min={minimumValue}
311313
max={maximumValue} />
312314
{descriptionEl}
313315
</div>;
@@ -687,7 +689,7 @@ export class DynamicField extends React.Component<IDynamicFieldProps, IDynamicFi
687689
}
688690
else {
689691
// selectedItemArr = this.props.value;
690-
selectedItemArr = !changedValue ? [] :
692+
selectedItemArr = !changedValue ? [] :
691693
( Array.isArray(changedValue) ? [ ...changedValue ] : [ changedValue] );
692694
}
693695

src/controls/dynamicForm/dynamicField/IDynamicFieldProps.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,46 @@ export type FieldChangeAdditionalData = IFilePickerResult;
77

88
export interface IDynamicFieldProps {
99
context: BaseComponentContext;
10-
10+
1111
/** Internal column name */
1212
columnInternalName: string;
1313
cultureName?: string;
14-
14+
1515
/** SharePoint Field Type */
1616
fieldType: string;
17-
17+
1818
/** Text label for field */
1919
label?: string;
20-
20+
2121
/** Placeholder text for field */
2222
placeholder?: string;
23-
23+
2424
/** Specifies if a field should be filled in order to pass validation */
2525
required: boolean;
26-
26+
2727
/** Specifies if a field should be disabled */
2828
disabled?: boolean;
29-
29+
3030
/** List Item Id, passed to various utility/helper functions to determine things like selected User UPN, Lookup text, Term labels etc. */
3131
listItemId?: number;
32-
32+
3333
/** The default value of the field. */
3434
defaultValue: any; // eslint-disable-line @typescript-eslint/no-explicit-any
3535

3636
/** Holds a field value. Set on all fields in the form. */
3737
value?: any; // eslint-disable-line @typescript-eslint/no-explicit-any
38-
38+
3939
/** Fired by DynamicField when a field value is changed */
40-
onChanged?: (columnInternalName: string, newValue: any, validate: boolean, additionalData?: FieldChangeAdditionalData) => void; // eslint-disable-line @typescript-eslint/no-explicit-any
40+
onChanged?: (
41+
columnInternalName: string,
42+
newValue: any,
43+
validate: boolean,
44+
additionalData?: FieldChangeAdditionalData
45+
) => void; // eslint-disable-line @typescript-eslint/no-explicit-any
4146

4247
/** Represents the value of the field as updated by the user. Only updated by fields when changed. */
4348
newValue?: any; // eslint-disable-line @typescript-eslint/no-explicit-any
44-
49+
4550
/** Represents a stringified value of the field. Used in custom formatting and validation. */
4651
stringValue: any; // eslint-disable-line @typescript-eslint/no-explicit-any
4752

@@ -50,7 +55,7 @@ export interface IDynamicFieldProps {
5055

5156
/** If validation raises an error message, it can be stored against the field here for display by DynamicField */
5257
validationErrorMessage?: string;
53-
58+
5459
/** Field Term Set ID, used in Taxonomy / Metadata fields */
5560
fieldTermSetId?: string;
5661

@@ -64,16 +69,16 @@ export interface IDynamicFieldProps {
6469
lookupField?: string;
6570

6671
// changedValue: any; // eslint-disable-line @typescript-eslint/no-explicit-any
67-
72+
6873
/** Equivalent to HiddenListInternalName, used for Taxonomy Metadata fields */
6974
hiddenFieldName?: string;
70-
75+
7176
/** Order of the field in the form */
7277
Order: number;
73-
78+
7479
/** Used for files / image uploads */
7580
additionalData?: FieldChangeAdditionalData;
76-
81+
7782
// Related to various field types
7883
options?: IDropdownOption[];
7984
isRichText?: boolean;
@@ -84,4 +89,5 @@ export interface IDynamicFieldProps {
8489
maximumValue?: number;
8590
minimumValue?: number;
8691
showAsPercentage?: boolean;
92+
orderBy?: string;
8793
}

0 commit comments

Comments
 (0)