Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TaxonomyPicker: Include check for separator while filtering path of terms when anchorId is configured #625

Merged
merged 1 commit into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/controls/taxonomyPicker/TermParent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export default class TermParent extends React.Component<ITermParentProps, ITermP
{
const anchorTerm = this._terms.filter(t => t.Id.toLowerCase() === this.props.anchorId.toLowerCase()).shift();
if (anchorTerm) {
const anchorDepth = anchorTerm.PathDepth;
const anchorTermPath = anchorTerm.PathOfTerm + /* Append (;) separator, as a suffix to anchor term path. */ ';';
this._anchorName = anchorTerm.Name;
var anchorTerms : ITerm[] = this._terms.filter(t => t.PathOfTerm.substring(0, anchorTerm.PathOfTerm.length) === anchorTerm.PathOfTerm && t.Id !== anchorTerm.Id);
let anchorTerms : ITerm[] = this._terms.filter(t => t.PathOfTerm.substring(0, anchorTermPath.length) === anchorTermPath && t.Id !== anchorTerm.Id);

anchorTerms = anchorTerms.map(term => {
term.PathDepth = term.PathDepth - anchorTerm.PathDepth;
Expand Down
5 changes: 2 additions & 3 deletions src/services/SPTermStorePickerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ export default class SPTermStorePickerService {
return null;
}


private searchTermsBySearchText(terms, searchText) {
if (terms) {
return terms.filter((t) => { return t.name.toLowerCase().indexOf(searchText.toLowerCase()) > -1; });
Expand All @@ -296,7 +295,6 @@ export default class SPTermStorePickerService {
return [];
}


public async searchTermsByTermId(searchText: string, termId: string): Promise<IPickerTerm[]> {
if (Environment.type === EnvironmentType.Local) {
// If the running environment is local, load the data from the mock
Expand Down Expand Up @@ -352,7 +350,8 @@ export default class SPTermStorePickerService {
if (anchorId) {
const anchorTerm = terms.filter(t => t.Id.toLowerCase() === anchorId.toLowerCase()).shift();
if (anchorTerm) {
const anchorTerms: ITerm[] = terms.filter(t => t.PathOfTerm.substring(0, anchorTerm.PathOfTerm.length) === anchorTerm.PathOfTerm && t.Id !== anchorTerm.Id);
const anchorTermPath = anchorTerm.PathOfTerm + /* Append (;) separator, as a suffix to anchor term path. */ ';';
const anchorTerms : ITerm[] = terms.filter(t => t.PathOfTerm.substring(0, anchorTermPath.length) === anchorTermPath && t.Id !== anchorTerm.Id);

anchorTerms.forEach(term => {
returnTerms.push(this.convertTermToPickerTerm(term));
Expand Down