From 2e0353618d2803a5968b641a4fbfd7fcf4b37df6 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Thu, 28 Feb 2019 08:52:46 +0100 Subject: [PATCH] Revive the global search. Fixed leftovers from the viewModel restructure. Repositories always have a verboseName now. Does not implement new logic to follow related models (e.g. motions->submitters). --- client/src/app/core/app-config.ts | 1 + .../core/core-services/app-load.service.ts | 7 ++- .../agenda/item-repository.service.ts | 8 ++-- .../base-agenda-content-object-repository.ts | 8 +--- .../app/core/repositories/base-repository.ts | 2 + .../common/chatmessage-repository.service.ts | 8 ++-- .../config/config-repository.service.ts | 8 ++-- .../history/history-repository.service.ts | 8 ++-- .../mediafile-repository.service.ts | 8 ++-- .../motions/category-repository.service.ts | 8 ++-- ...hange-recommendation-repository.service.ts | 8 ++-- ...tion-comment-section-repository.service.ts | 8 ++-- .../statute-paragraph-repository.service.ts | 8 ++-- .../motions/workflow-repository.service.ts | 8 ++-- .../projector/countdown-repository.service.ts | 8 ++-- .../projector-message-repository.service.ts | 8 ++-- .../projector/projector-repository.service.ts | 8 ++-- .../tags/tag-repository.service.ts | 8 ++-- .../users/group-repository.service.ts | 8 ++-- .../users/personal-note-repository.service.ts | 8 ++-- .../users/user-repository.service.ts | 9 ++-- .../app/core/ui-services/search.service.ts | 46 +++++++++++++------ .../site/assignments/assignments.config.ts | 2 +- .../assignments/models/view-assignment.ts | 2 +- .../components/search/search.component.html | 8 ++-- .../components/search/search.component.ts | 4 +- .../app/site/mediafiles/mediafile.config.ts | 1 + .../site/mediafiles/models/view-mediafile.ts | 2 +- client/src/app/site/tags/models/view-tag.ts | 2 +- client/src/app/site/users/models/view-user.ts | 2 +- 30 files changed, 139 insertions(+), 85 deletions(-) diff --git a/client/src/app/core/app-config.ts b/client/src/app/core/app-config.ts index 99a049f06..76f82807e 100644 --- a/client/src/app/core/app-config.ts +++ b/client/src/app/core/app-config.ts @@ -19,6 +19,7 @@ export interface ModelEntry extends BaseModelEntry { export interface SearchableModelEntry extends BaseModelEntry { viewModel: ViewModelConstructor; searchOrder: number; + openInNewTab?: boolean; } /** diff --git a/client/src/app/core/core-services/app-load.service.ts b/client/src/app/core/core-services/app-load.service.ts index 42d1ee659..bda621a1b 100644 --- a/client/src/app/core/core-services/app-load.service.ts +++ b/client/src/app/core/core-services/app-load.service.ts @@ -79,7 +79,12 @@ export class AppLoadService { repository ); if (this.isSearchableModelEntry(entry)) { - this.searchService.registerModel(entry.collectionString, entry.viewModel, entry.searchOrder); + this.searchService.registerModel( + entry.collectionString, + repository, + entry.searchOrder, + entry.openInNewTab + ); } }); } diff --git a/client/src/app/core/repositories/agenda/item-repository.service.ts b/client/src/app/core/repositories/agenda/item-repository.service.ts index 716cd4ba4..a6a358247 100644 --- a/client/src/app/core/repositories/agenda/item-repository.service.ts +++ b/client/src/app/core/repositories/agenda/item-repository.service.ts @@ -54,6 +54,10 @@ export class ItemRepositoryService extends BaseRepository { super(DS, mapperService, viewModelStoreService, Item); } + public getVerboseName = (plural: boolean = false) => { + return this.translate.instant(plural ? 'Items' : 'Item'); + }; + protected setupDependencyObservation(): void { this.DS.secondaryModelChangeSubject.subscribe(model => { const viewModel = this.viewModelStoreService.get(model.collectionString, model.id); @@ -75,9 +79,7 @@ export class ItemRepositoryService extends BaseRepository { public createViewModel(item: Item): ViewItem { const contentObject = this.getContentObject(item); const viewItem = new ViewItem(item, contentObject); - viewItem.getVerboseName = (plural: boolean = false) => { - return this.translate.instant(plural ? 'Items' : 'Item'); - }; + viewItem.getVerboseName = this.getVerboseName; viewItem.getTitle = () => { if (viewItem.contentObject) { return viewItem.contentObject.getAgendaTitle(); diff --git a/client/src/app/core/repositories/base-agenda-content-object-repository.ts b/client/src/app/core/repositories/base-agenda-content-object-repository.ts index 67c84ff83..a58c6b44c 100644 --- a/client/src/app/core/repositories/base-agenda-content-object-repository.ts +++ b/client/src/app/core/repositories/base-agenda-content-object-repository.ts @@ -7,12 +7,7 @@ import { BaseRepository } from './base-repository'; export function isBaseAgendaContentObjectRepository(obj: any): obj is BaseAgendaContentObjectRepository { const repo = obj as BaseAgendaContentObjectRepository; - return ( - !!obj && - repo.getVerboseName !== undefined && - repo.getAgendaTitle !== undefined && - repo.getAgendaTitleWithType !== undefined - ); + return !!obj && repo.getAgendaTitle !== undefined && repo.getAgendaTitleWithType !== undefined; } export abstract class BaseAgendaContentObjectRepository< @@ -21,7 +16,6 @@ export abstract class BaseAgendaContentObjectRepository< > extends BaseRepository { public abstract getAgendaTitle: (model: Partial | Partial) => string; public abstract getAgendaTitleWithType: (model: Partial | Partial) => string; - public abstract getVerboseName: (plural?: boolean) => string; /** */ diff --git a/client/src/app/core/repositories/base-repository.ts b/client/src/app/core/repositories/base-repository.ts index d21a1b206..24de04d11 100644 --- a/client/src/app/core/repositories/base-repository.ts +++ b/client/src/app/core/repositories/base-repository.ts @@ -46,6 +46,8 @@ export abstract class BaseRepository string; + /** * Construction routine for the base repository * diff --git a/client/src/app/core/repositories/common/chatmessage-repository.service.ts b/client/src/app/core/repositories/common/chatmessage-repository.service.ts index 0c1fd75d0..cc80235f4 100644 --- a/client/src/app/core/repositories/common/chatmessage-repository.service.ts +++ b/client/src/app/core/repositories/common/chatmessage-repository.service.ts @@ -21,11 +21,13 @@ export class ChatMessageRepositoryService extends BaseRepository { + return this.translate.instant(plural ? 'Chatmessages' : 'Chatmessage'); + }; + protected createViewModel(message: ChatMessage): ViewChatMessage { const viewChatMessage = new ViewChatMessage(message); - viewChatMessage.getVerboseName = (plural: boolean = false) => { - return this.translate.instant(plural ? 'Chatmessages' : 'Chatmessage'); - }; + viewChatMessage.getVerboseName = this.getVerboseName; return viewChatMessage; } diff --git a/client/src/app/core/repositories/config/config-repository.service.ts b/client/src/app/core/repositories/config/config-repository.service.ts index a30c0726d..d94e24cfe 100644 --- a/client/src/app/core/repositories/config/config-repository.service.ts +++ b/client/src/app/core/repositories/config/config-repository.service.ts @@ -112,15 +112,17 @@ export class ConfigRepositoryService extends BaseRepository }); } + public getVerboseName = (plural: boolean = false) => { + return this.translate.instant(plural ? 'Configs' : 'Config'); + }; + /** * Creates a new ViewConfig of a given Config object * @param config */ public createViewModel(config: Config): ViewConfig { const viewConfig = new ViewConfig(config); - viewConfig.getVerboseName = (plural: boolean = false) => { - return this.translate.instant(plural ? 'Configs' : 'Config'); - }; + viewConfig.getVerboseName = this.getVerboseName; return viewConfig; } diff --git a/client/src/app/core/repositories/history/history-repository.service.ts b/client/src/app/core/repositories/history/history-repository.service.ts index c0b93a2cb..26582039d 100644 --- a/client/src/app/core/repositories/history/history-repository.service.ts +++ b/client/src/app/core/repositories/history/history-repository.service.ts @@ -41,6 +41,10 @@ export class HistoryRepositoryService extends BaseRepository { + return this.translate.instant(plural ? 'Histories' : 'History'); + }; + /** * Creates a new ViewHistory objects out of a historyObject * @@ -50,9 +54,7 @@ export class HistoryRepositoryService extends BaseRepository { - return this.translate.instant(plural ? 'Histories' : 'History'); // Whats about the plural case?? - }; + viewHistory.getVerboseName = this.getVerboseName; return viewHistory; } diff --git a/client/src/app/core/repositories/mediafiles/mediafile-repository.service.ts b/client/src/app/core/repositories/mediafiles/mediafile-repository.service.ts index 4a314c441..c1ed85997 100644 --- a/client/src/app/core/repositories/mediafiles/mediafile-repository.service.ts +++ b/client/src/app/core/repositories/mediafiles/mediafile-repository.service.ts @@ -39,6 +39,10 @@ export class MediafileRepositoryService extends BaseRepository { + return this.translate.instant(plural ? 'Files' : 'File'); + }; + /** * Creates mediafile ViewModels out of given mediafile objects * @@ -48,9 +52,7 @@ export class MediafileRepositoryService extends BaseRepository { - return this.translate.instant(plural ? 'Files' : 'File'); - }; + viewMediafile.getVerboseName = this.getVerboseName; return viewMediafile; } diff --git a/client/src/app/core/repositories/motions/category-repository.service.ts b/client/src/app/core/repositories/motions/category-repository.service.ts index 7159ed55e..e54543393 100644 --- a/client/src/app/core/repositories/motions/category-repository.service.ts +++ b/client/src/app/core/repositories/motions/category-repository.service.ts @@ -52,11 +52,13 @@ export class CategoryRepositoryService extends BaseRepository { + return this.translate.instant(plural ? 'Categories' : 'Category'); + }; + protected createViewModel(category: Category): ViewCategory { const viewCategory = new ViewCategory(category); - viewCategory.getVerboseName = (plural: boolean = false) => { - return this.translate.instant(plural ? 'Categories' : 'Category'); - }; + viewCategory.getVerboseName = this.getVerboseName; return viewCategory; } diff --git a/client/src/app/core/repositories/motions/change-recommendation-repository.service.ts b/client/src/app/core/repositories/motions/change-recommendation-repository.service.ts index fa80ad058..8ae9f45d3 100644 --- a/client/src/app/core/repositories/motions/change-recommendation-repository.service.ts +++ b/client/src/app/core/repositories/motions/change-recommendation-repository.service.ts @@ -53,6 +53,10 @@ export class ChangeRecommendationRepositoryService extends BaseRepository< super(DS, mapperService, viewModelStoreService, MotionChangeRecommendation, [Category, User, Workflow]); } + public getVerboseName = (plural: boolean = false) => { + return this.translate.instant(plural ? 'Change recommendations' : 'Change recommendation'); + }; + /** * Creates this view wrapper based on an actual Change Recommendation model * @@ -60,9 +64,7 @@ export class ChangeRecommendationRepositoryService extends BaseRepository< */ protected createViewModel(model: MotionChangeRecommendation): ViewMotionChangeRecommendation { const viewMotionChangeRecommendation = new ViewMotionChangeRecommendation(model); - viewMotionChangeRecommendation.getVerboseName = (plural: boolean = false) => { - return this.translate.instant(plural ? 'Change recommendations' : 'Change recommendation'); - }; + viewMotionChangeRecommendation.getVerboseName = this.getVerboseName; return viewMotionChangeRecommendation; } diff --git a/client/src/app/core/repositories/motions/motion-comment-section-repository.service.ts b/client/src/app/core/repositories/motions/motion-comment-section-repository.service.ts index 2cb5ac009..060b7b21c 100644 --- a/client/src/app/core/repositories/motions/motion-comment-section-repository.service.ts +++ b/client/src/app/core/repositories/motions/motion-comment-section-repository.service.ts @@ -51,6 +51,10 @@ export class MotionCommentSectionRepositoryService extends BaseRepository< super(DS, mapperService, viewModelStoreService, MotionCommentSection, [Group]); } + public getVerboseName = (plural: boolean = false) => { + return this.translate.instant(plural ? 'Comment sections' : 'Comment section'); + }; + /** * Creates the ViewModel for the MotionComment Section * @@ -61,9 +65,7 @@ export class MotionCommentSectionRepositoryService extends BaseRepository< const readGroups = this.viewModelStoreService.getMany(ViewGroup, section.read_groups_id); const writeGroups = this.viewModelStoreService.getMany(ViewGroup, section.write_groups_id); const viewMotionCommentSection = new ViewMotionCommentSection(section, readGroups, writeGroups); - viewMotionCommentSection.getVerboseName = (plural: boolean = false) => { - return this.translate.instant(plural ? 'Comment sections' : 'Comment section'); - }; + viewMotionCommentSection.getVerboseName = this.getVerboseName; return viewMotionCommentSection; } diff --git a/client/src/app/core/repositories/motions/statute-paragraph-repository.service.ts b/client/src/app/core/repositories/motions/statute-paragraph-repository.service.ts index 1c3297ad5..45feedf89 100644 --- a/client/src/app/core/repositories/motions/statute-paragraph-repository.service.ts +++ b/client/src/app/core/repositories/motions/statute-paragraph-repository.service.ts @@ -40,11 +40,13 @@ export class StatuteParagraphRepositoryService extends BaseRepository { + return this.translate.instant(plural ? 'Statute paragraphs' : 'Statute paragraph'); + }; + protected createViewModel(statuteParagraph: StatuteParagraph): ViewStatuteParagraph { const viewStatuteParagraph = new ViewStatuteParagraph(statuteParagraph); - viewStatuteParagraph.getVerboseName = (plural: boolean = false) => { - return this.translate.instant(plural ? 'Statute paragraphs' : 'Statute paragraph'); - }; + viewStatuteParagraph.getVerboseName = this.getVerboseName; return viewStatuteParagraph; } diff --git a/client/src/app/core/repositories/motions/workflow-repository.service.ts b/client/src/app/core/repositories/motions/workflow-repository.service.ts index efdc01c4d..4155866ab 100644 --- a/client/src/app/core/repositories/motions/workflow-repository.service.ts +++ b/client/src/app/core/repositories/motions/workflow-repository.service.ts @@ -52,6 +52,10 @@ export class WorkflowRepositoryService extends BaseRepository { + return this.translate.instant(plural ? 'Workflows' : 'Workflow'); + }; + /** * Creates a ViewWorkflow from a given Workflow * @@ -59,9 +63,7 @@ export class WorkflowRepositoryService extends BaseRepository { - return this.translate.instant(plural ? 'Workflows' : 'Workflow'); - }; + viewWorkflow.getVerboseName = this.getVerboseName; return viewWorkflow; } diff --git a/client/src/app/core/repositories/projector/countdown-repository.service.ts b/client/src/app/core/repositories/projector/countdown-repository.service.ts index 699498296..ba2e25c91 100644 --- a/client/src/app/core/repositories/projector/countdown-repository.service.ts +++ b/client/src/app/core/repositories/projector/countdown-repository.service.ts @@ -25,11 +25,13 @@ export class CountdownRepositoryService extends BaseRepository { + return this.translate.instant(plural ? 'Countdowns' : 'Countdown'); + }; + protected createViewModel(countdown: Countdown): ViewCountdown { const viewCountdown = new ViewCountdown(countdown); - viewCountdown.getVerboseName = (plural: boolean = false) => { - return this.translate.instant(plural ? 'Countdowns' : 'Countdown'); - }; + viewCountdown.getVerboseName = this.getVerboseName; return viewCountdown; } diff --git a/client/src/app/core/repositories/projector/projector-message-repository.service.ts b/client/src/app/core/repositories/projector/projector-message-repository.service.ts index d8f90f779..c3ee6343a 100644 --- a/client/src/app/core/repositories/projector/projector-message-repository.service.ts +++ b/client/src/app/core/repositories/projector/projector-message-repository.service.ts @@ -23,11 +23,13 @@ export class ProjectorMessageRepositoryService extends BaseRepository { + return this.translate.instant(plural ? 'Messages' : 'Message'); + }; + protected createViewModel(message: ProjectorMessage): ViewProjectorMessage { const viewProjectorMessage = new ViewProjectorMessage(message); - viewProjectorMessage.getVerboseName = (plural: boolean = false) => { - return this.translate.instant(plural ? 'Messages' : 'Message'); - }; + viewProjectorMessage.getVerboseName = this.getVerboseName; return viewProjectorMessage; } diff --git a/client/src/app/core/repositories/projector/projector-repository.service.ts b/client/src/app/core/repositories/projector/projector-repository.service.ts index bbff447e7..e3f0d18b0 100644 --- a/client/src/app/core/repositories/projector/projector-repository.service.ts +++ b/client/src/app/core/repositories/projector/projector-repository.service.ts @@ -46,11 +46,13 @@ export class ProjectorRepositoryService extends BaseRepository { + return this.translate.instant(plural ? 'Projectors' : 'Projector'); + }; + public createViewModel(projector: Projector): ViewProjector { const viewProjector = new ViewProjector(projector); - viewProjector.getVerboseName = (plural: boolean = false) => { - return this.translate.instant(plural ? 'Projectors' : 'Projector'); - }; + viewProjector.getVerboseName = this.getVerboseName; return viewProjector; } diff --git a/client/src/app/core/repositories/tags/tag-repository.service.ts b/client/src/app/core/repositories/tags/tag-repository.service.ts index 39129fb3b..97ed3636b 100644 --- a/client/src/app/core/repositories/tags/tag-repository.service.ts +++ b/client/src/app/core/repositories/tags/tag-repository.service.ts @@ -43,11 +43,13 @@ export class TagRepositoryService extends BaseRepository { super(DS, mapperService, viewModelStoreService, Tag); } + public getVerboseName = (plural: boolean = false) => { + return this.translate.instant(plural ? 'Tags' : 'Tag'); + }; + protected createViewModel(tag: Tag): ViewTag { const viewTag = new ViewTag(tag); - viewTag.getVerboseName = (plural: boolean = false) => { - return this.translate.instant(plural ? 'Tags' : 'Tag'); - }; + viewTag.getVerboseName = this.getVerboseName; return viewTag; } diff --git a/client/src/app/core/repositories/users/group-repository.service.ts b/client/src/app/core/repositories/users/group-repository.service.ts index 3eaf5a0eb..6eeb2c5aa 100644 --- a/client/src/app/core/repositories/users/group-repository.service.ts +++ b/client/src/app/core/repositories/users/group-repository.service.ts @@ -60,11 +60,13 @@ export class GroupRepositoryService extends BaseRepository { this.sortPermsPerApp(); } + public getVerboseName = (plural: boolean = false) => { + return this.translate.instant(plural ? 'Groups' : 'Group'); + }; + public createViewModel(group: Group): ViewGroup { const viewGroup = new ViewGroup(group); - viewGroup.getVerboseName = (plural: boolean = false) => { - return this.translate.instant(plural ? 'Groups' : 'Group'); - }; + viewGroup.getVerboseName = this.getVerboseName; return viewGroup; } diff --git a/client/src/app/core/repositories/users/personal-note-repository.service.ts b/client/src/app/core/repositories/users/personal-note-repository.service.ts index 960e46831..193f286a4 100644 --- a/client/src/app/core/repositories/users/personal-note-repository.service.ts +++ b/client/src/app/core/repositories/users/personal-note-repository.service.ts @@ -28,11 +28,13 @@ export class PersonalNoteRepositoryService extends BaseRepository { + return this.translate.instant(plural ? 'Personal notes' : 'Personal note'); + }; + protected createViewModel(personalNote: PersonalNote): ViewPersonalNote { const viewPersonalNote = new ViewPersonalNote(); - viewPersonalNote.getVerboseName = (plural: boolean = false) => { - return this.translate.instant(plural ? 'Personal notes' : 'Personal note'); - }; + viewPersonalNote.getVerboseName = this.getVerboseName; return viewPersonalNote; } diff --git a/client/src/app/core/repositories/users/user-repository.service.ts b/client/src/app/core/repositories/users/user-repository.service.ts index a941e2a23..13299111b 100644 --- a/client/src/app/core/repositories/users/user-repository.service.ts +++ b/client/src/app/core/repositories/users/user-repository.service.ts @@ -51,13 +51,14 @@ export class UserRepositoryService extends BaseRepository { super(DS, mapperService, viewModelStoreService, User, [Group]); } + public getVerboseName = (plural: boolean = false) => { + return this.translate.instant(plural ? 'Participants' : 'Participant'); + }; + public createViewModel(user: User): ViewUser { const groups = this.viewModelStoreService.getMany(ViewGroup, user.groups_id); const viewUser = new ViewUser(user, groups); - viewUser.getVerboseName = (plural: boolean = false) => { - return this.translate.instant(plural ? 'Participants' : 'Participant'); - }; - + viewUser.getVerboseName = this.getVerboseName; viewUser.getNumberForName = (nr: number) => { return `${this.translate.instant('No.')} ${nr}`; }; diff --git a/client/src/app/core/ui-services/search.service.ts b/client/src/app/core/ui-services/search.service.ts index 1c766177c..8f1f1035e 100644 --- a/client/src/app/core/ui-services/search.service.ts +++ b/client/src/app/core/ui-services/search.service.ts @@ -1,6 +1,8 @@ import { Injectable } from '@angular/core'; import { Searchable } from '../../site/base/searchable'; import { BaseViewModel } from 'app/site/base/base-view-model'; +import { BaseRepository } from '../repositories/base-repository'; +import { ViewModelStoreService } from '../core-services/view-model-store.service'; /** * The representation every searchable model should use to represent their data. @@ -25,6 +27,11 @@ export interface SearchModel { * The plural verbose name of the model. */ verboseNamePlural: string; + + /** + * Whether to open the detail page in a new tab. + */ + openInNewTab: boolean; } /** @@ -42,6 +49,11 @@ export interface SearchResult { */ verboseName: string; + /** + * Whether to open the detail page in a new tab. + */ + openInNewTab: boolean; + /** * All matched models. */ @@ -63,12 +75,13 @@ export class SearchService { verboseNameSingular: string; verboseNamePlural: string; displayOrder: number; + openInNewTab: boolean; }[] = []; /** - * @param DS The DataStore to search in. + * @param viewModelStore The store to search in. */ - public constructor() {} + public constructor(private viewModelStore: ViewModelStoreService) {} /** * Registers a model by the given attributes. @@ -79,15 +92,17 @@ export class SearchService { */ public registerModel( collectionString: string, - ctor: new (...args: any[]) => Searchable & BaseViewModel, - displayOrder: number + repo: BaseRepository, + displayOrder: number, + openInNewTab: boolean = false ): void { // const instance = new ctor(); this.searchModels.push({ collectionString: collectionString, - verboseNameSingular: 'TODO', // instance.getVerboseName(), - verboseNamePlural: 'TODO', // instance.getVerboseName(true), - displayOrder: displayOrder + verboseNameSingular: repo.getVerboseName(), + verboseNamePlural: repo.getVerboseName(true), + displayOrder: displayOrder, + openInNewTab: openInNewTab }); this.searchModels.sort((a, b) => a.displayOrder - b.displayOrder); } @@ -99,7 +114,8 @@ export class SearchService { return this.searchModels.map(searchModel => ({ collectionString: searchModel.collectionString, verboseNameSingular: searchModel.verboseNameSingular, - verboseNamePlural: searchModel.verboseNamePlural + verboseNamePlural: searchModel.verboseNamePlural, + openInNewTab: searchModel.openInNewTab })); } @@ -112,19 +128,19 @@ export class SearchService { */ public search(query: string, inCollectionStrings: string[]): SearchResult[] { query = query.toLowerCase(); - /*return this.searchModels + return this.searchModels .filter(s => inCollectionStrings.includes(s.collectionString)) .map(searchModel => { - const results = this.viewModelStore.filter(searchModel.collectionString, model => - model.formatForSearch().some(text => text.toLowerCase().includes(query)) - ); + const results = this.viewModelStore + .getAll(searchModel.collectionString) + .map(x => x as (BaseViewModel & Searchable)) + .filter(model => model.formatForSearch().some(text => text.toLowerCase().includes(query))); return { collectionString: searchModel.collectionString, verboseName: results.length === 1 ? searchModel.verboseNameSingular : searchModel.verboseNamePlural, + openInNewTab: searchModel.openInNewTab, models: results }; - });*/ - throw new Error('Todo'); - return []; + }); } } diff --git a/client/src/app/site/assignments/assignments.config.ts b/client/src/app/site/assignments/assignments.config.ts index 4e26b2ef1..1a0a221e3 100644 --- a/client/src/app/site/assignments/assignments.config.ts +++ b/client/src/app/site/assignments/assignments.config.ts @@ -10,7 +10,7 @@ export const AssignmentsAppConfig: AppConfig = { collectionString: 'assignments/assignment', model: Assignment, viewModel: ViewAssignment, - searchOrder: 3, + // searchOrder: 3, // TODO: enable, if there is a detail page and so on. repository: AssignmentRepositoryService } ], diff --git a/client/src/app/site/assignments/models/view-assignment.ts b/client/src/app/site/assignments/models/view-assignment.ts index b46206703..2d4b7d0e3 100644 --- a/client/src/app/site/assignments/models/view-assignment.ts +++ b/client/src/app/site/assignments/models/view-assignment.ts @@ -76,7 +76,7 @@ export class ViewAssignment extends BaseAgendaViewModel { }; public formatForSearch(): SearchRepresentation { - throw new Error('TODO'); + return [this.title]; } public getDetailStateURL(): string { diff --git a/client/src/app/site/common/components/search/search.component.html b/client/src/app/site/common/components/search/search.component.html index edb463a28..f8de8b680 100644 --- a/client/src/app/site/common/components/search/search.component.html +++ b/client/src/app/site/common/components/search/search.component.html @@ -44,10 +44,10 @@ - + + {{ model.getTitle() }} + + {{ model.getTitle() }} diff --git a/client/src/app/site/common/components/search/search.component.ts b/client/src/app/site/common/components/search/search.component.ts index ec53c305e..c6639c3f6 100644 --- a/client/src/app/site/common/components/search/search.component.ts +++ b/client/src/app/site/common/components/search/search.component.ts @@ -114,7 +114,9 @@ export class SearchComponent extends BaseViewComponent implements OnInit { this.searchResults = this.searchService.search(this.query, collectionStrings); // Because the results are per model, we need to accumulate the total number of all search results. - this.searchResultCount = this.searchResults.map(sr => sr.models.length).reduce((acc, current) => acc + current); + this.searchResultCount = this.searchResults + .map(sr => sr.models.length) + .reduce((acc, current) => acc + current, 0); // Update the URL. this.router.navigate([], { diff --git a/client/src/app/site/mediafiles/mediafile.config.ts b/client/src/app/site/mediafiles/mediafile.config.ts index 07719ef83..ef10de611 100644 --- a/client/src/app/site/mediafiles/mediafile.config.ts +++ b/client/src/app/site/mediafiles/mediafile.config.ts @@ -11,6 +11,7 @@ export const MediafileAppConfig: AppConfig = { model: Mediafile, viewModel: ViewMediafile, searchOrder: 5, + openInNewTab: true, repository: MediafileRepositoryService } ], diff --git a/client/src/app/site/mediafiles/models/view-mediafile.ts b/client/src/app/site/mediafiles/models/view-mediafile.ts index 0c2686987..5a17ca0eb 100644 --- a/client/src/app/site/mediafiles/models/view-mediafile.ts +++ b/client/src/app/site/mediafiles/models/view-mediafile.ts @@ -85,7 +85,7 @@ export class ViewMediafile extends BaseProjectableViewModel implements Searchabl } public getDetailStateURL(): string { - throw new Error('TODO'); + return this.downloadUrl; } public getSlide(): ProjectorElementBuildDeskriptor { diff --git a/client/src/app/site/tags/models/view-tag.ts b/client/src/app/site/tags/models/view-tag.ts index 5464b982f..1959fbf6d 100644 --- a/client/src/app/site/tags/models/view-tag.ts +++ b/client/src/app/site/tags/models/view-tag.ts @@ -46,7 +46,7 @@ export class ViewTag extends BaseViewModel implements Searchable { } public getDetailStateURL(): string { - throw new Error('TODO'); + return `/tags`; } /** diff --git a/client/src/app/site/users/models/view-user.ts b/client/src/app/site/users/models/view-user.ts index c75792280..57f65ad23 100644 --- a/client/src/app/site/users/models/view-user.ts +++ b/client/src/app/site/users/models/view-user.ts @@ -189,7 +189,7 @@ export class ViewUser extends BaseProjectableViewModel implements Searchable { } public getDetailStateURL(): string { - throw new Error('TODO'); + return `/users/${this.id}`; } public getSlide(): ProjectorElementBuildDeskriptor {