Add more detail to search results
Adds getSummary to the MediaTypeModel.ts abstract class, which allows individual models to give more detail to better allow people to pick the right result
This commit is contained in:
parent
e4788750f7
commit
39017bfa82
7 changed files with 23 additions and 1 deletions
|
|
@ -29,7 +29,7 @@ export class MediaDbSearchResultModal extends SelectModal<MediaTypeModel> {
|
|||
// Renders each suggestion item.
|
||||
renderElement(item: MediaTypeModel, el: HTMLElement) {
|
||||
el.createEl('div', {text: this.plugin.mediaTypeManager.getFileName(item)});
|
||||
el.createEl('small', {text: `${item.englishTitle}\n`});
|
||||
el.createEl('small', {text: `${item.getSummary()}\n`});
|
||||
el.createEl('small', {text: `${item.type.toUpperCase() + (item.subType ? ` (${item.subType})` : '')} from ${item.dataSource}`});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,4 +42,8 @@ export class GameModel extends MediaTypeModel {
|
|||
return MediaType.Game;
|
||||
}
|
||||
|
||||
getSummary(): string {
|
||||
return this.englishTitle + ' (' + this.year + ')';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ export abstract class MediaTypeModel {
|
|||
|
||||
abstract getMediaType(): MediaType;
|
||||
|
||||
//a string that contains enough info to disambiguate from similar media
|
||||
abstract getSummary(): string;
|
||||
|
||||
abstract getTags(): string[];
|
||||
|
||||
toMetaDataObject(): object {
|
||||
|
|
|
|||
|
|
@ -44,4 +44,7 @@ export class MovieModel extends MediaTypeModel {
|
|||
return MediaType.Movie;
|
||||
}
|
||||
|
||||
getSummary(): string {
|
||||
return this.englishTitle + ' (' + this.year + ')';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,4 +37,10 @@ export class MusicReleaseModel extends MediaTypeModel {
|
|||
return MediaType.MusicRelease;
|
||||
}
|
||||
|
||||
getSummary(): string {
|
||||
var summary = this.title + ' (' + this.year + ')';
|
||||
if(this.artists.length > 0)
|
||||
summary += ' - ' + this.artists.join(', ')
|
||||
return summary;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,4 +47,7 @@ export class SeriesModel extends MediaTypeModel {
|
|||
return MediaType.Series;
|
||||
}
|
||||
|
||||
getSummary(): string {
|
||||
return this.title + ' (' + this.year + ')';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,4 +43,7 @@ export class WikiModel extends MediaTypeModel {
|
|||
return copy;
|
||||
}
|
||||
|
||||
getSummary(): string {
|
||||
return this.title;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue