Skip to content

Commit 4ae5db4

Browse files
committed
Merge branch 'dev' of https://github.com/spdavid/sp-dev-fx-controls-react into spdavid-dev
2 parents a239fb0 + a84f5f7 commit 4ae5db4

File tree

11 files changed

+93
-4
lines changed

11 files changed

+93
-4
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 more 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+
> **Disclaimer**: 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.
6+
7+
**Empty term picker**
8+
9+
![Empty term picker](../assets/termpicker-empty.png)
10+
11+
**Selecting terms**
12+
13+
![Selecting terms](../assets/termpicker-selection.png)
14+
15+
**Selected terms in picker**
16+
17+
![Selected terms in the input](../assets/termpicker-selected-terms.png)
18+
19+
**Term picker: Auto Complete**
20+
21+
![Selected terms in the input](../assets/termpicker-autocomplete.png)
22+
23+
24+
## How to use this control in your solutions
25+
26+
- 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.
27+
- Import the following modules to your component:
28+
29+
```TypeScript
30+
import { TaxonomyPicker, IPickerTerms } from "@pnp/spfx-controls-react/lib/TaxonomyPicker";
31+
```
32+
33+
- Use the `TaxonomyPicker` control in your code as follows:
34+
35+
```TypeScript
36+
<TaxonomyPicker
37+
allowMultipleSelections={true}
38+
termsetNameOrID="Countries"
39+
panelTitle="Select Term"
40+
label="Taxonomy Picker"
41+
context={this.props.context}
42+
onChange={this._onTaxPickerChange}
43+
isTermSetSelectable={false}
44+
/>
45+
```
46+
47+
- With the `onChange` property you can capture the event of when the terms in the picker has changed:
48+
49+
```typescript
50+
private _onTaxPickerChange(terms : IPickerTerms)
51+
{
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 term set 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 term set of the term |
81+
| termSetName | string | no | The Name of the parent term set 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ 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

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)