Skip to content

Commit

Permalink
typeahead: remove HTML tags from suggestion
Browse files Browse the repository at this point in the history
* Fixes the typeahead suggestion as the ngx-bootstrap library doesn't
  allow HTML tags into typeahead suggestion anymore.
* Closes rero/rero-ils#1708.

Co-Authored-by: Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
zannkukai committed Feb 23, 2021
1 parent 97a5b95 commit 5c11c8b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ export class DocumentsTypeahead implements ITypeahead {
truncate = true;
text = this._mainTitlePipe.transform(metadata.title).substr(0, this.maxLengthSuggestion);
}
text = text.replace(new RegExp(escapeRegExp(query), 'gi'), `<b>${query}</b>`);
if (truncate) {
text = text + ' ...';
text = text + '';
}
return {
label: text,
Expand Down
6 changes: 1 addition & 5 deletions projects/admin/src/app/class/typeahead/patrons-typeahead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,8 @@ export class PatronsTypeahead implements ITypeahead {
* @return Metadata - the label, $ref.
*/
private _getPatronsRef(metadata: any, query: string): SuggestionMetadata {
let label = this._patronService.getFormattedName(metadata);
if (metadata.hasOwnProperty('birth_date')) {
label += `<small class="ml-2 font-weight-bold">[${metadata.birth_date}]</small>`;
}
return {
label,
label: this._patronService.getFormattedName(metadata),
value: this._apiService.getRefEndpoint('patrons', metadata.pid)
};
}
Expand Down

0 comments on commit 5c11c8b

Please sign in to comment.