Skip to content

Commit ea41fef

Browse files
committed
Merge branch 'spdavid-dev' into dev
2 parents a239fb0 + 0ad67ca commit ea41fef

File tree

11 files changed

+95
-5
lines changed

11 files changed

+95
-5
lines changed
16.1 KB
Loading
35.5 KB
Loading
1.09 KB
Loading
20.5 KB
Loading
3.84 KB
Loading
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Taxonomy Picker
2+
3+
This control Allows you to select one or more Terms from a TermSet via its name or TermSet ID. You can also configure the control to select the child terms from a specific term in the TermSet by setting the AnchorId.
4+
5+
!!! note "Disclaimer"
6+
This control makes use of the `ProcessQuery` API end-points to retrieve the managed metadata information. This will get changed once the APIs for managing managed metadata will become available.
7+
8+
**Empty term picker**
9+
10+
![Empty term picker](../assets/termpicker-empty.png)
11+
12+
**Selecting terms**
13+
14+
![Selecting terms](../assets/termpicker-selection.png)
15+
16+
**Selected terms in picker**
17+
18+
![Selected terms in the input](../assets/termpicker-selected-terms.png)
19+
20+
**Term picker: Auto Complete**
21+
22+
![Selected terms in the input](../assets/termpicker-autocomplete.png)
23+
24+
25+
## How to use this control in your solutions
26+
27+
- Check that you installed the `@pnp/spfx-controls-react` dependency. Check out the [getting started](../#getting-started) page for more information about installing the dependency.
28+
- Import the following modules to your component:
29+
30+
```TypeScript
31+
import { TaxonomyPicker, IPickerTerms } from "@pnp/spfx-controls-react/lib/TaxonomyPicker";
32+
```
33+
34+
- Use the `TaxonomyPicker` control in your code as follows:
35+
36+
```TypeScript
37+
<TaxonomyPicker
38+
allowMultipleSelections={true}
39+
TermSetNameOrID="Countries"
40+
panelTitle="Select Term"
41+
label="Taxonomy Picker"
42+
context={this.props.context}
43+
onChange={this.onTaxPickerChange}
44+
isTermSetSelectable={false}
45+
/>
46+
```
47+
48+
- With the `onChange` property you can capture the event of when the terms in the picker has changed:
49+
50+
```typescript
51+
private onTaxPickerChange(terms : IPickerTerms) {
52+
console.log("Terms", terms);
53+
}
54+
```
55+
56+
## Implementation
57+
58+
The TaxonomyPicker control can be configured with the following properties:
59+
60+
| Property | Type | Required | Description |
61+
| ---- | ---- | ---- | ---- |
62+
| panelTitle | string | yes | TermSet Picker Panel title. |
63+
| label | string | yes | Text displayed above the Taxonomy Picker. |
64+
| disabled | string | no | Specify if the control needs to be disabled. |
65+
| context | WebPartContext | yes | Context of the current web part. |
66+
| initialValues | IPickerTerms | no | Defines the selected by default term sets. |
67+
| allowMultipleSelections | boolean | no | Defines if the user can select only one or many term sets. Default value is false. |
68+
| TermSetNameOrID | string | yes | The name or Id of your TermSet that you would like the Taxonomy Picker to chose terms from. |
69+
| onChange | function | no | captures the event of when the terms in the picker has changed. |
70+
| isTermSetSelectable | boolean | no | Specify if the TermSet itself is selectable in the tree view. |
71+
| anchorId | string | no | Set the anchorid to a child term in the TermSet to be able to select terms from that level and below. |
72+
73+
Interface `IPickerTerm`
74+
75+
| Property | Type | Required | Description |
76+
| ---- | ---- | ---- | ---- |
77+
| key | string | yes | The ID of the term |
78+
| name | string | yes | The name of the term |
79+
| path | string | yes | The path of the term |
80+
| termSet | string | yes | The Id of the parent TermSet of the term |
81+
| termSetName | string | no | The Name of the parent TermSet of the term |
82+
83+
Interface `IPickerTerms`
84+
85+
An Array of IPickerTerm
86+
87+
![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/Placeholder)

docs/documentation/docs/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ The following controls are currently available:
3333
- [ListView](./controls/ListView) (List view control)
3434
- [Placeholder](./controls/Placeholder) (Control that can be used to show an initial placeholder if the web part has to be configured)
3535
- [SiteBreadcrumb](./controls/SiteBreadcrumb) (Breadcrumb control)
36+
- [SiteBreadcrumb](./controls/TaxonomyPicker) (Taxonomy Picker)
3637
- [WebPartTitle](./controls/WebPartTitle) (Customizable web part title control)
3738
- [IFrameDialog](./controls/IFrameDialog) (renders a Dialog with an iframe as a content)
3839

3940
Field customizer controls:
4041

41-
> **Note**: If you want to use these controls in your solution, first check out the start guide for these controls: [using the field controls](./controls/fields/main).
42+
!!! note
43+
If you want to use these controls in your solution, first check out the start guide for these controls: [using the field controls](./controls/fields/main).
4244

4345
- [FieldAttachmentsRenderer](./controls/fields/FieldAttachmentsRenderer) (renders Clip icon based on the provided `count` property is defined and greater than 0)
4446
- [FieldDateRenderer](./controls/fields/FieldDateRenderer) (renders date string as a simple text)

docs/documentation/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pages:
88
- Placeholder: 'controls/Placeholder.md'
99
- SiteBreadcrumb: 'controls/SiteBreadcrumb.md'
1010
- WebPartTitle: 'controls/WebPartTitle.md'
11+
- TaxonomyPicker: 'controls/TaxonomyPicker.md'
1112
- IFrameDialog: 'controls/IFrameDialog.md'
1213
- 'Field Controls':
1314
- 'Getting started': 'controls/fields/main.md'

src/controls/taxonomyPicker/ITaxonomyPicker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export interface ITaxonomyPickerProps {
3434
/**
3535
* Id of a child term in the termset where to be able to selected and search the terms from
3636
*/
37-
ancoreId?: string;
37+
anchorId?: string;
3838
/**
3939
* Specify if the term set itself is selectable in the tree view
4040
*/

src/controls/taxonomyPicker/TaxonomyPicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export class TaxonomyPicker extends React.Component<ITaxonomyPickerProps, ITaxon
280280
this.state.loaded === true && this.state.termSetAndTerms && (
281281
<div key={this.state.termSetAndTerms.Id} >
282282
<h3>{this.state.termSetAndTerms.Name}</h3>
283-
<TermParent anchorId={this.props.ancoreId}
283+
<TermParent anchorId={this.props.anchorId}
284284
autoExpand={null}
285285
termset={this.state.termSetAndTerms}
286286
isTermSetSelectable={this.props.isTermSetSelectable}

0 commit comments

Comments
 (0)