Merge pull request #6040 from tsiegleauq/search-cannot-find-uml
Find umlauts using search
This commit is contained in:
commit
88e870c9df
@ -45,7 +45,16 @@ declare global {
|
|||||||
interface Number {
|
interface Number {
|
||||||
modulo(n: number): number;
|
modulo(n: number): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface String {
|
||||||
|
decode(): string;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* May only be created once since this thing is fat
|
||||||
|
*/
|
||||||
|
const domParser = new DOMParser();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Angular's global App Component
|
* Angular's global App Component
|
||||||
@ -103,6 +112,7 @@ export class AppComponent {
|
|||||||
this.overloadSetFunctions();
|
this.overloadSetFunctions();
|
||||||
this.overloadModulo();
|
this.overloadModulo();
|
||||||
this.loadCustomIcons();
|
this.loadCustomIcons();
|
||||||
|
this.overloadDecodeString();
|
||||||
|
|
||||||
// Wait until the App reaches a stable state.
|
// Wait until the App reaches a stable state.
|
||||||
// Required for the Service Worker.
|
// Required for the Service Worker.
|
||||||
@ -198,6 +208,23 @@ export class AppComponent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is not the fastest solution but the most reliable one.
|
||||||
|
* Certain languages and TinyMCE do not follow the any predictable
|
||||||
|
* behaviour when it comes to encoding UTF8.
|
||||||
|
* decodeURI and decodeURIComponent were not able to successfully
|
||||||
|
* replace any ;&*uml with something meaningfull.
|
||||||
|
*/
|
||||||
|
private overloadDecodeString(): void {
|
||||||
|
Object.defineProperty(String.prototype, 'decode', {
|
||||||
|
enumerable: false,
|
||||||
|
value(): string {
|
||||||
|
const doc = domParser.parseFromString(this, 'text/html');
|
||||||
|
return doc.body.textContent || '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enhances the number object with a real modulo operation (not remainder).
|
* Enhances the number object with a real modulo operation (not remainder).
|
||||||
* TODO: Remove this, if the remainder operation is changed to modulo.
|
* TODO: Remove this, if the remainder operation is changed to modulo.
|
||||||
|
@ -231,19 +231,25 @@ export class ViewMotion
|
|||||||
const properties: SearchProperty[] = [];
|
const properties: SearchProperty[] = [];
|
||||||
properties.push({ key: 'Title', value: this.getTitle() });
|
properties.push({ key: 'Title', value: this.getTitle() });
|
||||||
properties.push({ key: 'Submitters', value: this.submittersAsUsers.map(user => user.full_name).join(', ') });
|
properties.push({ key: 'Submitters', value: this.submittersAsUsers.map(user => user.full_name).join(', ') });
|
||||||
properties.push({ key: 'Text', value: this.text, trusted: true });
|
properties.push({ key: 'Text', value: this.text.decode(), trusted: true });
|
||||||
properties.push({ key: 'Reason', value: this.reason, trusted: true });
|
properties.push({ key: 'Reason', value: this.reason.decode(), trusted: true });
|
||||||
if (this.amendment_paragraphs) {
|
if (this.amendment_paragraphs) {
|
||||||
properties.push({
|
properties.push({
|
||||||
key: 'Amendments',
|
key: 'Amendments',
|
||||||
value: this.amendment_paragraphs.filter(x => !!x).join('\n'),
|
value: this.amendment_paragraphs
|
||||||
|
.filter(x => !!x)
|
||||||
|
.join('\n')
|
||||||
|
.decode(),
|
||||||
trusted: true
|
trusted: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
properties.push({ key: 'Tags', value: this.tags.map(tag => tag.getTitle()).join(', ') });
|
properties.push({ key: 'Tags', value: this.tags.map(tag => tag.getTitle()).join(', ') });
|
||||||
properties.push({
|
properties.push({
|
||||||
key: 'Comments',
|
key: 'Comments',
|
||||||
value: this.motion.comments.map(comment => comment.comment).join('\n'),
|
value: this.motion.comments
|
||||||
|
.map(comment => comment.comment)
|
||||||
|
.join('\n')
|
||||||
|
.decode(),
|
||||||
trusted: true
|
trusted: true
|
||||||
});
|
});
|
||||||
properties.push({ key: 'Supporters', value: this.supporters.map(user => user.full_name).join(', ') });
|
properties.push({ key: 'Supporters', value: this.supporters.map(user => user.full_name).join(', ') });
|
||||||
|
@ -27,12 +27,14 @@ export class ViewTopic extends BaseViewModelWithAgendaItemAndListOfSpeakers<Topi
|
|||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
public formatForSearch(): SearchRepresentation {
|
public formatForSearch(): SearchRepresentation {
|
||||||
return {
|
const properties = [
|
||||||
properties: [
|
|
||||||
{ key: 'Title', value: this.getTitle() },
|
{ key: 'Title', value: this.getTitle() },
|
||||||
{ key: 'Text', value: this.text, trusted: true }
|
{ key: 'Text', value: this.text.decode(), trusted: true }
|
||||||
],
|
];
|
||||||
searchValue: [this.getTitle(), this.text]
|
|
||||||
|
return {
|
||||||
|
properties,
|
||||||
|
searchValue: properties.map(property => property.value)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user