Skip to content

Commit fcf0345

Browse files
committed
Cleaned up Unused objects and interfaces
1 parent 26f237e commit fcf0345

File tree

9 files changed

+51
-219
lines changed

9 files changed

+51
-219
lines changed

src/controls/taxonomyPicker/ITaxonomyPicker.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ export interface ITaxonomyPickerProps {
5353
*
5454
*/
5555
onGetErrorMessage?: (value: IPickerTerms) => string | Promise<string>;
56+
5657
/**
57-
* Custom Field will start to validate after users stop typing for `deferredValidationTime` milliseconds.
58-
* Default value is 200.
58+
* onChange Event
5959
*/
60-
deferredValidationTime?: number;
61-
6260
onChange?: (newValue?: IPickerTerms) => void;
6361
}
6462

src/controls/taxonomyPicker/ITermPicker.ts

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -15,52 +15,6 @@ export interface IPickerTerm {
1515

1616
export interface IPickerTerms extends Array<IPickerTerm> { }
1717

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-
6418
/**
6519
* Public properties of the PropertyFieldTermPicker custom field
6620
*/
@@ -134,19 +88,6 @@ export interface IPropertyFieldTermPickerProps {
13488
* Default value is 200.
13589
*/
13690
deferredValidationTime?: number;
137-
/**
138-
* Specifies if you want to show or hide the term store name from the panel
139-
*/
140-
hideTermStoreName?: boolean;
91+
14192
}
14293

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-
// }

src/controls/taxonomyPicker/TaxonomyPicker.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import { ITaxonomyPickerProps, ITaxonomyPickerState, ITermGroupProps, ITermGroup
1515
import SPTermStorePickerService from './../../services/SPTermStorePickerService';
1616
import { ITermSet, IGroup, ITerm } from './../../services/ISPTermStorePickerService';
1717
import styles from './TaxonomyPicker.module.scss';
18-
import { sortBy, uniqBy } from '@microsoft/sp-lodash-subset';
19-
import TermSet from './TermSet';
18+
import { sortBy, uniqBy, cloneDeep } from '@microsoft/sp-lodash-subset';
19+
import TermParent from './TermParent';
2020
import FieldErrorMessage from './ErrorMessage';
2121
import * as appInsights from '../../common/appInsights';
2222

@@ -71,10 +71,8 @@ export class TaxonomyPicker extends React.Component<ITaxonomyPickerProps, ITaxon
7171
private loadTermStores(): void {
7272
this.termsService = new SPTermStorePickerService(this.props, this.props.context);
7373
this.termsService.getAllTerms(this.props.termsetNameOrID).then((response: ITermSet) => {
74-
console.log(response);
7574
// Check if a response was retrieved
7675
if (response !== null) {
77-
console.log(response);
7876
this.setState({
7977
termSetAndTerms: response,
8078
loaded: true
@@ -97,7 +95,7 @@ export class TaxonomyPicker extends React.Component<ITaxonomyPickerProps, ITaxon
9795
}
9896

9997
// Store the current code value
100-
this.previousValues = this.state.activeNodes;
98+
this.previousValues = cloneDeep(this.state.activeNodes);
10199
this.cancel = true;
102100

103101
this.loadTermStores();
@@ -264,18 +262,12 @@ export class TaxonomyPicker extends React.Component<ITaxonomyPickerProps, ITaxon
264262
/* Show spinner in the panel while retrieving terms */
265263
this.state.loaded === false ? <Spinner type={SpinnerType.normal} /> : ''
266264
}
267-
268-
269-
270265
{this.state.loaded === true &&
271266

272-
273-
274267
<div key={this.state.termSetAndTerms.Id} >
275268

276269
<h3>{this.state.termSetAndTerms.Name}</h3>
277-
{/* <TermSet termset={this.state.termSetAndTerms} activeNodes={this.state.activeNodes} changedCallback={this.termsChanged} multiSelection={this.props.allowMultipleSelections} /> */}
278-
<TermSet anchorId={this.props.ancoreId} autoExpand={null} termset={this.state.termSetAndTerms} activeNodes={this.state.activeNodes} changedCallback={this.termsChanged} multiSelection={this.props.allowMultipleSelections} />
270+
<TermParent anchorId={this.props.ancoreId} autoExpand={null} termset={this.state.termSetAndTerms} activeNodes={this.state.activeNodes} changedCallback={this.termsChanged} multiSelection={this.props.allowMultipleSelections} />
279271
</div>
280272

281273

src/controls/taxonomyPicker/Term.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export default class Term extends React.Component<ITermProps, ITermState> {
2727
* Handle the checkbox change trigger
2828
*/
2929
private _handleChange(ev: React.FormEvent<HTMLElement>, isChecked: boolean) {
30-
console.log("handling change");
3130
this.setState({
3231
selected: isChecked
3332
});

src/controls/taxonomyPicker/TermGroup.tsx

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/controls/taxonomyPicker/TermSet.tsx renamed to src/controls/taxonomyPicker/TermParent.tsx

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import Term from './Term';
88
import styles from './TaxonomyPicker.module.scss';
99

1010
/**
11-
* Term set component
11+
* Term Parent component, represents termset or term if anchorId
1212
*/
13-
export default class TermSet extends React.Component<ITermSetProps, ITermSetState> {
13+
export default class TermParent extends React.Component<ITermSetProps, ITermSetState> {
1414

1515
private _terms : ITerm[];
1616
private _anchorName : string;
@@ -22,24 +22,10 @@ export default class TermSet extends React.Component<ITermSetProps, ITermSetStat
2222
loaded: true,
2323
expanded: true
2424
};
25-
26-
// Check if the termset has to be automatically opened
27-
const selectedTermsInSet = this.props.activeNodes.filter(node => node.termSet === this.props.termset.Id);
28-
if (selectedTermsInSet.length > 0) {
29-
this._autoLoadTerms();
30-
}
31-
3225
this._handleClick = this._handleClick.bind(this);
33-
this._loadTerms = this._loadTerms.bind(this);
3426
}
3527

36-
/**
37-
* Autoload the terms of the term set
38-
*/
39-
private _autoLoadTerms() {
40-
// this.props.autoExpand();
41-
this._loadTerms(true);
42-
}
28+
4329

4430
/**
4531
* Handle the click event: collapse or expand
@@ -48,62 +34,31 @@ export default class TermSet extends React.Component<ITermSetProps, ITermSetStat
4834
this.setState({
4935
expanded: !this.state.expanded
5036
});
51-
52-
if (!this.state.expanded) {
53-
this._loadTerms();
54-
}
5537
}
5638

57-
58-
/**
59-
* Load the terms for the current term set
39+
40+
/**
41+
* componentWillMount
6042
*/
61-
private async _loadTerms(autoExpand?: boolean) {
62-
// Check if there are already terms loaded
63-
if (!this.state.loaded) {
64-
// Receive all the terms for the current term set
65-
// const termSet: ITermSet = await this.props.termsService.getAllTerms(this.props.termset._ObjectIdentity_);
66-
// if (termSet.Terms !== null) {
67-
// this.setState({
68-
// terms: termSet.Terms,
69-
// loaded: true,
70-
// expanded: typeof autoExpand !== 'undefined' ? autoExpand : this.state.expanded
71-
// });
72-
// } else {
73-
// this.setState({
74-
// terms: [],
75-
// loaded: true
76-
// });
77-
// }
78-
}
79-
}
80-
8143
public componentWillMount()
8244
{
83-
84-
8545
// fix term depth if anchroid for rendering
8646
if (this.props.anchorId)
8747
{
8848
const anchorTerm = this._terms.filter(t => t.Id.toLowerCase() === this.props.anchorId.toLowerCase()).shift();
89-
console.log(anchorTerm)
9049
if (anchorTerm)
9150
{
9251
const anchorDepth = anchorTerm.PathDepth;
9352
this._anchorName = anchorTerm.Name;
9453
var anchorTerms : ITerm[] = this._terms.filter(t => t.PathOfTerm.substring(0, anchorTerm.PathOfTerm.length) === anchorTerm.PathOfTerm && t.Id !== anchorTerm.Id);
9554

9655
anchorTerms = anchorTerms.map(term => {
97-
console.log(term.PathDepth);
9856
term.PathDepth = term.PathDepth - anchorTerm.PathDepth;
99-
console.log(term.PathDepth);
10057

10158
return term;
10259
});
10360

104-
console.log(anchorTerms);
10561
this._terms = anchorTerms;
106-
console.log(this._terms);
10762
}
10863
}
10964
}

0 commit comments

Comments
 (0)