Skip to content

Commit cf6eded

Browse files
committed
Panel works only with termset
1 parent d8dc76a commit cf6eded

16 files changed

+1657
-1
lines changed

src/TaxonomyPicker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './controls/TaxonomyPicker/index';
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as React from 'react';
2+
import styles from './TaxonomyPicker.module.scss';
3+
import { Icon } from 'office-ui-fabric-react/lib/Icon';
4+
5+
export interface IFieldErrorMessageProps {
6+
errorMessage: string;
7+
}
8+
9+
/**
10+
* Component that shows an error message when something went wront with the property control
11+
*/
12+
export default class FieldErrorMessage extends React.Component<IFieldErrorMessageProps> {
13+
public render(): JSX.Element {
14+
if (this.props.errorMessage !== 'undefined' && this.props.errorMessage !== null && this.props.errorMessage !== '') {
15+
return (
16+
<div aria-live="assertive">
17+
<p className={`ms-TextField-errorMessage ${styles.errorMessage}`}>
18+
<Icon iconName='Error' className={styles.errorIcon} />
19+
<span data-automation-id="error-message">{this.props.errorMessage}</span>
20+
</p>
21+
</div>
22+
);
23+
} else {
24+
return null;
25+
}
26+
}
27+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import { IPickerTerms } from './ITermPicker';
2+
import { ITermStore, IGroup, ITermSet, ITerm } from '../../services/ISPTermStorePickerService';
3+
import SPTermStorePickerService from '../../services/SPTermStorePickerService';
4+
import { IWebPartContext } from '@microsoft/sp-webpart-base';
5+
6+
/**
7+
* PropertyFieldTermPickerHost properties interface
8+
// */
9+
export interface ITaxonomyPickerProps {
10+
/**
11+
* Property field label displayed on top
12+
*/
13+
label: string;
14+
/**
15+
* TermSet Picker Panel title
16+
*/
17+
panelTitle: string;
18+
/**
19+
* Defines if the user can select only one or many term sets. Default value is false.
20+
*/
21+
allowMultipleSelections?: boolean;
22+
/**
23+
* Defines the selected by default term sets.
24+
*/
25+
initialValues?: IPickerTerms;
26+
/**
27+
* WebPart's context
28+
*/
29+
context: IWebPartContext;
30+
/**
31+
* Limit the terms that can be picked by the Term Set name or ID
32+
*/
33+
termsetNameOrID: string;
34+
/**
35+
* Id of a child term in the termset where to be able to selected and search the terms from
36+
*/
37+
ancoreId?: string;
38+
/**
39+
* Whether the property pane field is enabled or not.
40+
*/
41+
disabled?: boolean;
42+
/**
43+
* The method is used to get the validation error message and determine whether the input value is valid or not.
44+
*
45+
* When it returns string:
46+
* - If valid, it returns empty string.
47+
* - If invalid, it returns the error message string and the text field will
48+
* show a red border and show an error message below the text field.
49+
*
50+
* When it returns Promise<string>:
51+
* - The resolved value is display as error message.
52+
* - The rejected, the value is thrown away.
53+
*
54+
*/
55+
onGetErrorMessage?: (value: IPickerTerms) => string | Promise<string>;
56+
/**
57+
* Custom Field will start to validate after users stop typing for `deferredValidationTime` milliseconds.
58+
* Default value is 200.
59+
*/
60+
deferredValidationTime?: number;
61+
62+
onChange?: (newValue?: IPickerTerms) => void;
63+
}
64+
65+
/**
66+
* PropertyFieldTermPickerHost state interface
67+
*/
68+
export interface ITaxonomyPickerState {
69+
70+
termSetAndTerms? : ITermSet;
71+
errorMessage?: string;
72+
openPanel?: boolean;
73+
loaded?: boolean;
74+
activeNodes?: IPickerTerms;
75+
}
76+
77+
export interface ITermChanges {
78+
changedCallback: (term: ITerm, checked: boolean) => void;
79+
activeNodes?: IPickerTerms;
80+
}
81+
82+
export interface ITermGroupProps extends ITermChanges {
83+
group: IGroup;
84+
termstore: string;
85+
termsService: SPTermStorePickerService;
86+
multiSelection: boolean;
87+
}
88+
89+
export interface ITermGroupState {
90+
expanded: boolean;
91+
}
92+
93+
export interface ITermSetProps extends ITermChanges {
94+
termset: ITermSet;
95+
autoExpand: () => void;
96+
multiSelection: boolean;
97+
}
98+
99+
export interface ITermSetState {
100+
101+
loaded?: boolean;
102+
expanded?: boolean;
103+
}
104+
105+
export interface ITermProps extends ITermChanges {
106+
termset: string;
107+
term: ITerm;
108+
multiSelection: boolean;
109+
}
110+
111+
export interface ITermState {
112+
selected?: boolean;
113+
}
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
import { IWebPartContext } from '@microsoft/sp-webpart-base';
2+
3+
4+
5+
/**
6+
* Selected terms
7+
*/
8+
export interface IPickerTerm {
9+
name: string;
10+
key: string;
11+
path: string;
12+
termSet: string;
13+
termSetName? : string;
14+
}
15+
16+
export interface IPickerTerms extends Array<IPickerTerm> { }
17+
18+
/**
19+
* Generic Term Object (abstract interface)
20+
*/
21+
export interface ISPTermObject {
22+
Name: string;
23+
Guid: string;
24+
Identity: string;
25+
leaf: boolean;
26+
children?: ISPTermObject[];
27+
collapsed?: boolean;
28+
type: string;
29+
}
30+
31+
/**
32+
* Defines a SharePoint Term Store
33+
*/
34+
export interface ISPTermStore extends ISPTermObject {
35+
IsOnline: boolean;
36+
WorkingLanguage: string;
37+
DefaultLanguage: string;
38+
Languages: string[];
39+
}
40+
41+
/**
42+
* Defines an array of Term Stores
43+
*/
44+
export interface ISPTermStores extends Array<ISPTermStore> {
45+
}
46+
47+
/**
48+
* Defines a Term Store Group of term sets
49+
*/
50+
export interface ISPTermGroup extends ISPTermObject {
51+
IsSiteCollectionGroup: boolean;
52+
IsSystemGroup: boolean;
53+
CreatedDate: string;
54+
LastModifiedDate: string;
55+
}
56+
57+
/**
58+
* Array of Term Groups
59+
*/
60+
export interface ISPTermGroups extends Array<ISPTermGroup> {
61+
}
62+
63+
64+
/**
65+
* Public properties of the PropertyFieldTermPicker custom field
66+
*/
67+
export interface IPropertyFieldTermPickerProps {
68+
/**
69+
* Property field label displayed on top
70+
*/
71+
label: string;
72+
/**
73+
* TermSet Picker Panel title
74+
*/
75+
panelTitle: string;
76+
/**
77+
* Defines if the user can select only one or many term sets. Default value is false.
78+
*/
79+
allowMultipleSelections?: boolean;
80+
/**
81+
* Defines the selected by default term sets.
82+
*/
83+
initialValues?: IPickerTerms;
84+
/**
85+
* Indicator to define if the system Groups are exclude. Default is false.
86+
*/
87+
excludeSystemGroup?: boolean;
88+
/**
89+
* WebPart's context
90+
*/
91+
context: IWebPartContext;
92+
/**
93+
* Limit the term sets that can be used by the group name or ID
94+
*/
95+
limitByGroupNameOrID?: string;
96+
/**
97+
* Limit the terms that can be picked by the Term Set name or ID
98+
*/
99+
limitByTermsetNameOrID?: string;
100+
/**
101+
* Defines a onPropertyChange function to raise when the selected value changed.
102+
* Normally this function must be always defined with the 'this.onPropertyChange'
103+
* method of the web part object.
104+
*/
105+
onPropertyChange(propertyPath: string, oldValue: any, newValue: any): void;
106+
/**
107+
* Parent Web Part properties
108+
*/
109+
properties: any;
110+
/**
111+
* An UNIQUE key indicates the identity of this control
112+
*/
113+
key: string;
114+
/**
115+
* Whether the property pane field is enabled or not.
116+
*/
117+
disabled?: boolean;
118+
/**
119+
* The method is used to get the validation error message and determine whether the input value is valid or not.
120+
*
121+
* When it returns string:
122+
* - If valid, it returns empty string.
123+
* - If invalid, it returns the error message string and the text field will
124+
* show a red border and show an error message below the text field.
125+
*
126+
* When it returns Promise<string>:
127+
* - The resolved value is display as error message.
128+
* - The rejected, the value is thrown away.
129+
*
130+
*/
131+
onGetErrorMessage?: (value: IPickerTerms) => string | Promise<string>;
132+
/**
133+
* Custom Field will start to validate after users stop typing for `deferredValidationTime` milliseconds.
134+
* Default value is 200.
135+
*/
136+
deferredValidationTime?: number;
137+
/**
138+
* Specifies if you want to show or hide the term store name from the panel
139+
*/
140+
hideTermStoreName?: boolean;
141+
}
142+
143+
/**
144+
* Private properties of the PropertyFieldTermPicker custom field.
145+
* We separate public & private properties to include onRender & onDispose method waited
146+
* by the PropertyFieldCustom, witout asking to the developer to add it when he's using
147+
* the PropertyFieldTermPicker.
148+
*/
149+
// export interface IPropertyFieldTermPickerPropsInternal extends IPropertyFieldTermPickerProps {
150+
// // // onRender(elem: HTMLElement): void;
151+
// // // onDispose(elem: HTMLElement): void;
152+
// }

0 commit comments

Comments
 (0)