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).
This commit is contained in:
parent
f532a60b36
commit
2e0353618d
@ -19,6 +19,7 @@ export interface ModelEntry extends BaseModelEntry {
|
|||||||
export interface SearchableModelEntry extends BaseModelEntry {
|
export interface SearchableModelEntry extends BaseModelEntry {
|
||||||
viewModel: ViewModelConstructor<BaseViewModel & Searchable>;
|
viewModel: ViewModelConstructor<BaseViewModel & Searchable>;
|
||||||
searchOrder: number;
|
searchOrder: number;
|
||||||
|
openInNewTab?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +79,12 @@ export class AppLoadService {
|
|||||||
repository
|
repository
|
||||||
);
|
);
|
||||||
if (this.isSearchableModelEntry(entry)) {
|
if (this.isSearchableModelEntry(entry)) {
|
||||||
this.searchService.registerModel(entry.collectionString, entry.viewModel, entry.searchOrder);
|
this.searchService.registerModel(
|
||||||
|
entry.collectionString,
|
||||||
|
repository,
|
||||||
|
entry.searchOrder,
|
||||||
|
entry.openInNewTab
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,10 @@ export class ItemRepositoryService extends BaseRepository<ViewItem, Item> {
|
|||||||
super(DS, mapperService, viewModelStoreService, Item);
|
super(DS, mapperService, viewModelStoreService, Item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Items' : 'Item');
|
||||||
|
};
|
||||||
|
|
||||||
protected setupDependencyObservation(): void {
|
protected setupDependencyObservation(): void {
|
||||||
this.DS.secondaryModelChangeSubject.subscribe(model => {
|
this.DS.secondaryModelChangeSubject.subscribe(model => {
|
||||||
const viewModel = this.viewModelStoreService.get(model.collectionString, model.id);
|
const viewModel = this.viewModelStoreService.get(model.collectionString, model.id);
|
||||||
@ -75,9 +79,7 @@ export class ItemRepositoryService extends BaseRepository<ViewItem, Item> {
|
|||||||
public createViewModel(item: Item): ViewItem {
|
public createViewModel(item: Item): ViewItem {
|
||||||
const contentObject = this.getContentObject(item);
|
const contentObject = this.getContentObject(item);
|
||||||
const viewItem = new ViewItem(item, contentObject);
|
const viewItem = new ViewItem(item, contentObject);
|
||||||
viewItem.getVerboseName = (plural: boolean = false) => {
|
viewItem.getVerboseName = this.getVerboseName;
|
||||||
return this.translate.instant(plural ? 'Items' : 'Item');
|
|
||||||
};
|
|
||||||
viewItem.getTitle = () => {
|
viewItem.getTitle = () => {
|
||||||
if (viewItem.contentObject) {
|
if (viewItem.contentObject) {
|
||||||
return viewItem.contentObject.getAgendaTitle();
|
return viewItem.contentObject.getAgendaTitle();
|
||||||
|
@ -7,12 +7,7 @@ import { BaseRepository } from './base-repository';
|
|||||||
|
|
||||||
export function isBaseAgendaContentObjectRepository(obj: any): obj is BaseAgendaContentObjectRepository<any, any> {
|
export function isBaseAgendaContentObjectRepository(obj: any): obj is BaseAgendaContentObjectRepository<any, any> {
|
||||||
const repo = obj as BaseAgendaContentObjectRepository<any, any>;
|
const repo = obj as BaseAgendaContentObjectRepository<any, any>;
|
||||||
return (
|
return !!obj && repo.getAgendaTitle !== undefined && repo.getAgendaTitleWithType !== undefined;
|
||||||
!!obj &&
|
|
||||||
repo.getVerboseName !== undefined &&
|
|
||||||
repo.getAgendaTitle !== undefined &&
|
|
||||||
repo.getAgendaTitleWithType !== undefined
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class BaseAgendaContentObjectRepository<
|
export abstract class BaseAgendaContentObjectRepository<
|
||||||
@ -21,7 +16,6 @@ export abstract class BaseAgendaContentObjectRepository<
|
|||||||
> extends BaseRepository<V, M> {
|
> extends BaseRepository<V, M> {
|
||||||
public abstract getAgendaTitle: (model: Partial<M> | Partial<V>) => string;
|
public abstract getAgendaTitle: (model: Partial<M> | Partial<V>) => string;
|
||||||
public abstract getAgendaTitleWithType: (model: Partial<M> | Partial<V>) => string;
|
public abstract getAgendaTitleWithType: (model: Partial<M> | Partial<V>) => string;
|
||||||
public abstract getVerboseName: (plural?: boolean) => string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -46,6 +46,8 @@ export abstract class BaseRepository<V extends BaseViewModel, M extends BaseMode
|
|||||||
return this._collectionString;
|
return this._collectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract getVerboseName: (plural?: boolean) => string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construction routine for the base repository
|
* Construction routine for the base repository
|
||||||
*
|
*
|
||||||
|
@ -21,11 +21,13 @@ export class ChatMessageRepositoryService extends BaseRepository<ViewChatMessage
|
|||||||
super(DS, mapperService, viewModelStoreService, ChatMessage);
|
super(DS, mapperService, viewModelStoreService, ChatMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createViewModel(message: ChatMessage): ViewChatMessage {
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
const viewChatMessage = new ViewChatMessage(message);
|
|
||||||
viewChatMessage.getVerboseName = (plural: boolean = false) => {
|
|
||||||
return this.translate.instant(plural ? 'Chatmessages' : 'Chatmessage');
|
return this.translate.instant(plural ? 'Chatmessages' : 'Chatmessage');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected createViewModel(message: ChatMessage): ViewChatMessage {
|
||||||
|
const viewChatMessage = new ViewChatMessage(message);
|
||||||
|
viewChatMessage.getVerboseName = this.getVerboseName;
|
||||||
return viewChatMessage;
|
return viewChatMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,15 +112,17 @@ export class ConfigRepositoryService extends BaseRepository<ViewConfig, Config>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Configs' : 'Config');
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ViewConfig of a given Config object
|
* Creates a new ViewConfig of a given Config object
|
||||||
* @param config
|
* @param config
|
||||||
*/
|
*/
|
||||||
public createViewModel(config: Config): ViewConfig {
|
public createViewModel(config: Config): ViewConfig {
|
||||||
const viewConfig = new ViewConfig(config);
|
const viewConfig = new ViewConfig(config);
|
||||||
viewConfig.getVerboseName = (plural: boolean = false) => {
|
viewConfig.getVerboseName = this.getVerboseName;
|
||||||
return this.translate.instant(plural ? 'Configs' : 'Config');
|
|
||||||
};
|
|
||||||
return viewConfig;
|
return viewConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,10 @@ export class HistoryRepositoryService extends BaseRepository<ViewHistory, Histor
|
|||||||
super(DS, mapperService, viewModelStoreService, History, [User]);
|
super(DS, mapperService, viewModelStoreService, History, [User]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Histories' : 'History');
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ViewHistory objects out of a historyObject
|
* Creates a new ViewHistory objects out of a historyObject
|
||||||
*
|
*
|
||||||
@ -50,9 +54,7 @@ export class HistoryRepositoryService extends BaseRepository<ViewHistory, Histor
|
|||||||
public createViewModel(history: History): ViewHistory {
|
public createViewModel(history: History): ViewHistory {
|
||||||
const user = this.viewModelStoreService.get(ViewUser, history.user_id);
|
const user = this.viewModelStoreService.get(ViewUser, history.user_id);
|
||||||
const viewHistory = new ViewHistory(history, user);
|
const viewHistory = new ViewHistory(history, user);
|
||||||
viewHistory.getVerboseName = (plural: boolean = false) => {
|
viewHistory.getVerboseName = this.getVerboseName;
|
||||||
return this.translate.instant(plural ? 'Histories' : 'History'); // Whats about the plural case??
|
|
||||||
};
|
|
||||||
return viewHistory;
|
return viewHistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,10 @@ export class MediafileRepositoryService extends BaseRepository<ViewMediafile, Me
|
|||||||
super(DS, mapperService, viewModelStoreService, Mediafile, [User]);
|
super(DS, mapperService, viewModelStoreService, Mediafile, [User]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Files' : 'File');
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates mediafile ViewModels out of given mediafile objects
|
* Creates mediafile ViewModels out of given mediafile objects
|
||||||
*
|
*
|
||||||
@ -48,9 +52,7 @@ export class MediafileRepositoryService extends BaseRepository<ViewMediafile, Me
|
|||||||
public createViewModel(file: Mediafile): ViewMediafile {
|
public createViewModel(file: Mediafile): ViewMediafile {
|
||||||
const uploader = this.viewModelStoreService.get(ViewUser, file.uploader_id);
|
const uploader = this.viewModelStoreService.get(ViewUser, file.uploader_id);
|
||||||
const viewMediafile = new ViewMediafile(file, uploader);
|
const viewMediafile = new ViewMediafile(file, uploader);
|
||||||
viewMediafile.getVerboseName = (plural: boolean = false) => {
|
viewMediafile.getVerboseName = this.getVerboseName;
|
||||||
return this.translate.instant(plural ? 'Files' : 'File');
|
|
||||||
};
|
|
||||||
return viewMediafile;
|
return viewMediafile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,11 +52,13 @@ export class CategoryRepositoryService extends BaseRepository<ViewCategory, Cate
|
|||||||
super(DS, mapperService, viewModelStoreService, Category);
|
super(DS, mapperService, viewModelStoreService, Category);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createViewModel(category: Category): ViewCategory {
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
const viewCategory = new ViewCategory(category);
|
|
||||||
viewCategory.getVerboseName = (plural: boolean = false) => {
|
|
||||||
return this.translate.instant(plural ? 'Categories' : 'Category');
|
return this.translate.instant(plural ? 'Categories' : 'Category');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected createViewModel(category: Category): ViewCategory {
|
||||||
|
const viewCategory = new ViewCategory(category);
|
||||||
|
viewCategory.getVerboseName = this.getVerboseName;
|
||||||
return viewCategory;
|
return viewCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,10 @@ export class ChangeRecommendationRepositoryService extends BaseRepository<
|
|||||||
super(DS, mapperService, viewModelStoreService, MotionChangeRecommendation, [Category, User, Workflow]);
|
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
|
* 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 {
|
protected createViewModel(model: MotionChangeRecommendation): ViewMotionChangeRecommendation {
|
||||||
const viewMotionChangeRecommendation = new ViewMotionChangeRecommendation(model);
|
const viewMotionChangeRecommendation = new ViewMotionChangeRecommendation(model);
|
||||||
viewMotionChangeRecommendation.getVerboseName = (plural: boolean = false) => {
|
viewMotionChangeRecommendation.getVerboseName = this.getVerboseName;
|
||||||
return this.translate.instant(plural ? 'Change recommendations' : 'Change recommendation');
|
|
||||||
};
|
|
||||||
return viewMotionChangeRecommendation;
|
return viewMotionChangeRecommendation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,10 @@ export class MotionCommentSectionRepositoryService extends BaseRepository<
|
|||||||
super(DS, mapperService, viewModelStoreService, MotionCommentSection, [Group]);
|
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
|
* 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 readGroups = this.viewModelStoreService.getMany(ViewGroup, section.read_groups_id);
|
||||||
const writeGroups = this.viewModelStoreService.getMany(ViewGroup, section.write_groups_id);
|
const writeGroups = this.viewModelStoreService.getMany(ViewGroup, section.write_groups_id);
|
||||||
const viewMotionCommentSection = new ViewMotionCommentSection(section, readGroups, writeGroups);
|
const viewMotionCommentSection = new ViewMotionCommentSection(section, readGroups, writeGroups);
|
||||||
viewMotionCommentSection.getVerboseName = (plural: boolean = false) => {
|
viewMotionCommentSection.getVerboseName = this.getVerboseName;
|
||||||
return this.translate.instant(plural ? 'Comment sections' : 'Comment section');
|
|
||||||
};
|
|
||||||
return viewMotionCommentSection;
|
return viewMotionCommentSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,11 +40,13 @@ export class StatuteParagraphRepositoryService extends BaseRepository<ViewStatut
|
|||||||
super(DS, mapperService, viewModelStoreService, StatuteParagraph);
|
super(DS, mapperService, viewModelStoreService, StatuteParagraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createViewModel(statuteParagraph: StatuteParagraph): ViewStatuteParagraph {
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
const viewStatuteParagraph = new ViewStatuteParagraph(statuteParagraph);
|
|
||||||
viewStatuteParagraph.getVerboseName = (plural: boolean = false) => {
|
|
||||||
return this.translate.instant(plural ? 'Statute paragraphs' : 'Statute paragraph');
|
return this.translate.instant(plural ? 'Statute paragraphs' : 'Statute paragraph');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected createViewModel(statuteParagraph: StatuteParagraph): ViewStatuteParagraph {
|
||||||
|
const viewStatuteParagraph = new ViewStatuteParagraph(statuteParagraph);
|
||||||
|
viewStatuteParagraph.getVerboseName = this.getVerboseName;
|
||||||
return viewStatuteParagraph;
|
return viewStatuteParagraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,10 @@ export class WorkflowRepositoryService extends BaseRepository<ViewWorkflow, Work
|
|||||||
super(DS, mapperService, viewModelStoreService, Workflow);
|
super(DS, mapperService, viewModelStoreService, Workflow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
|
return this.translate.instant(plural ? 'Workflows' : 'Workflow');
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a ViewWorkflow from a given Workflow
|
* Creates a ViewWorkflow from a given Workflow
|
||||||
*
|
*
|
||||||
@ -59,9 +63,7 @@ export class WorkflowRepositoryService extends BaseRepository<ViewWorkflow, Work
|
|||||||
*/
|
*/
|
||||||
protected createViewModel(workflow: Workflow): ViewWorkflow {
|
protected createViewModel(workflow: Workflow): ViewWorkflow {
|
||||||
const viewWorkflow = new ViewWorkflow(workflow);
|
const viewWorkflow = new ViewWorkflow(workflow);
|
||||||
viewWorkflow.getVerboseName = (plural: boolean = false) => {
|
viewWorkflow.getVerboseName = this.getVerboseName;
|
||||||
return this.translate.instant(plural ? 'Workflows' : 'Workflow');
|
|
||||||
};
|
|
||||||
return viewWorkflow;
|
return viewWorkflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,11 +25,13 @@ export class CountdownRepositoryService extends BaseRepository<ViewCountdown, Co
|
|||||||
super(DS, mapperService, viewModelStoreService, Countdown);
|
super(DS, mapperService, viewModelStoreService, Countdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createViewModel(countdown: Countdown): ViewCountdown {
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
const viewCountdown = new ViewCountdown(countdown);
|
|
||||||
viewCountdown.getVerboseName = (plural: boolean = false) => {
|
|
||||||
return this.translate.instant(plural ? 'Countdowns' : 'Countdown');
|
return this.translate.instant(plural ? 'Countdowns' : 'Countdown');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected createViewModel(countdown: Countdown): ViewCountdown {
|
||||||
|
const viewCountdown = new ViewCountdown(countdown);
|
||||||
|
viewCountdown.getVerboseName = this.getVerboseName;
|
||||||
return viewCountdown;
|
return viewCountdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,11 +23,13 @@ export class ProjectorMessageRepositoryService extends BaseRepository<ViewProjec
|
|||||||
super(DS, mapperService, viewModelStoreService, ProjectorMessage);
|
super(DS, mapperService, viewModelStoreService, ProjectorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createViewModel(message: ProjectorMessage): ViewProjectorMessage {
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
const viewProjectorMessage = new ViewProjectorMessage(message);
|
|
||||||
viewProjectorMessage.getVerboseName = (plural: boolean = false) => {
|
|
||||||
return this.translate.instant(plural ? 'Messages' : 'Message');
|
return this.translate.instant(plural ? 'Messages' : 'Message');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected createViewModel(message: ProjectorMessage): ViewProjectorMessage {
|
||||||
|
const viewProjectorMessage = new ViewProjectorMessage(message);
|
||||||
|
viewProjectorMessage.getVerboseName = this.getVerboseName;
|
||||||
return viewProjectorMessage;
|
return viewProjectorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,11 +46,13 @@ export class ProjectorRepositoryService extends BaseRepository<ViewProjector, Pr
|
|||||||
super(DS, mapperService, viewModelStoreService, Projector);
|
super(DS, mapperService, viewModelStoreService, Projector);
|
||||||
}
|
}
|
||||||
|
|
||||||
public createViewModel(projector: Projector): ViewProjector {
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
const viewProjector = new ViewProjector(projector);
|
|
||||||
viewProjector.getVerboseName = (plural: boolean = false) => {
|
|
||||||
return this.translate.instant(plural ? 'Projectors' : 'Projector');
|
return this.translate.instant(plural ? 'Projectors' : 'Projector');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public createViewModel(projector: Projector): ViewProjector {
|
||||||
|
const viewProjector = new ViewProjector(projector);
|
||||||
|
viewProjector.getVerboseName = this.getVerboseName;
|
||||||
return viewProjector;
|
return viewProjector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,11 +43,13 @@ export class TagRepositoryService extends BaseRepository<ViewTag, Tag> {
|
|||||||
super(DS, mapperService, viewModelStoreService, Tag);
|
super(DS, mapperService, viewModelStoreService, Tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createViewModel(tag: Tag): ViewTag {
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
const viewTag = new ViewTag(tag);
|
|
||||||
viewTag.getVerboseName = (plural: boolean = false) => {
|
|
||||||
return this.translate.instant(plural ? 'Tags' : 'Tag');
|
return this.translate.instant(plural ? 'Tags' : 'Tag');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected createViewModel(tag: Tag): ViewTag {
|
||||||
|
const viewTag = new ViewTag(tag);
|
||||||
|
viewTag.getVerboseName = this.getVerboseName;
|
||||||
return viewTag;
|
return viewTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,11 +60,13 @@ export class GroupRepositoryService extends BaseRepository<ViewGroup, Group> {
|
|||||||
this.sortPermsPerApp();
|
this.sortPermsPerApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public createViewModel(group: Group): ViewGroup {
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
const viewGroup = new ViewGroup(group);
|
|
||||||
viewGroup.getVerboseName = (plural: boolean = false) => {
|
|
||||||
return this.translate.instant(plural ? 'Groups' : 'Group');
|
return this.translate.instant(plural ? 'Groups' : 'Group');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public createViewModel(group: Group): ViewGroup {
|
||||||
|
const viewGroup = new ViewGroup(group);
|
||||||
|
viewGroup.getVerboseName = this.getVerboseName;
|
||||||
return viewGroup;
|
return viewGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,11 +28,13 @@ export class PersonalNoteRepositoryService extends BaseRepository<ViewPersonalNo
|
|||||||
super(DS, mapperService, viewModelStoreService, PersonalNote);
|
super(DS, mapperService, viewModelStoreService, PersonalNote);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected createViewModel(personalNote: PersonalNote): ViewPersonalNote {
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
const viewPersonalNote = new ViewPersonalNote();
|
|
||||||
viewPersonalNote.getVerboseName = (plural: boolean = false) => {
|
|
||||||
return this.translate.instant(plural ? 'Personal notes' : 'Personal note');
|
return this.translate.instant(plural ? 'Personal notes' : 'Personal note');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected createViewModel(personalNote: PersonalNote): ViewPersonalNote {
|
||||||
|
const viewPersonalNote = new ViewPersonalNote();
|
||||||
|
viewPersonalNote.getVerboseName = this.getVerboseName;
|
||||||
return viewPersonalNote;
|
return viewPersonalNote;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,13 +51,14 @@ export class UserRepositoryService extends BaseRepository<ViewUser, User> {
|
|||||||
super(DS, mapperService, viewModelStoreService, User, [Group]);
|
super(DS, mapperService, viewModelStoreService, User, [Group]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public createViewModel(user: User): ViewUser {
|
public getVerboseName = (plural: boolean = false) => {
|
||||||
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');
|
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 = this.getVerboseName;
|
||||||
viewUser.getNumberForName = (nr: number) => {
|
viewUser.getNumberForName = (nr: number) => {
|
||||||
return `${this.translate.instant('No.')} ${nr}`;
|
return `${this.translate.instant('No.')} ${nr}`;
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Searchable } from '../../site/base/searchable';
|
import { Searchable } from '../../site/base/searchable';
|
||||||
import { BaseViewModel } from 'app/site/base/base-view-model';
|
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.
|
* 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.
|
* The plural verbose name of the model.
|
||||||
*/
|
*/
|
||||||
verboseNamePlural: string;
|
verboseNamePlural: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to open the detail page in a new tab.
|
||||||
|
*/
|
||||||
|
openInNewTab: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,6 +49,11 @@ export interface SearchResult {
|
|||||||
*/
|
*/
|
||||||
verboseName: string;
|
verboseName: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to open the detail page in a new tab.
|
||||||
|
*/
|
||||||
|
openInNewTab: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All matched models.
|
* All matched models.
|
||||||
*/
|
*/
|
||||||
@ -63,12 +75,13 @@ export class SearchService {
|
|||||||
verboseNameSingular: string;
|
verboseNameSingular: string;
|
||||||
verboseNamePlural: string;
|
verboseNamePlural: string;
|
||||||
displayOrder: number;
|
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.
|
* Registers a model by the given attributes.
|
||||||
@ -79,15 +92,17 @@ export class SearchService {
|
|||||||
*/
|
*/
|
||||||
public registerModel(
|
public registerModel(
|
||||||
collectionString: string,
|
collectionString: string,
|
||||||
ctor: new (...args: any[]) => Searchable & BaseViewModel,
|
repo: BaseRepository<any, any>,
|
||||||
displayOrder: number
|
displayOrder: number,
|
||||||
|
openInNewTab: boolean = false
|
||||||
): void {
|
): void {
|
||||||
// const instance = new ctor();
|
// const instance = new ctor();
|
||||||
this.searchModels.push({
|
this.searchModels.push({
|
||||||
collectionString: collectionString,
|
collectionString: collectionString,
|
||||||
verboseNameSingular: 'TODO', // instance.getVerboseName(),
|
verboseNameSingular: repo.getVerboseName(),
|
||||||
verboseNamePlural: 'TODO', // instance.getVerboseName(true),
|
verboseNamePlural: repo.getVerboseName(true),
|
||||||
displayOrder: displayOrder
|
displayOrder: displayOrder,
|
||||||
|
openInNewTab: openInNewTab
|
||||||
});
|
});
|
||||||
this.searchModels.sort((a, b) => a.displayOrder - b.displayOrder);
|
this.searchModels.sort((a, b) => a.displayOrder - b.displayOrder);
|
||||||
}
|
}
|
||||||
@ -99,7 +114,8 @@ export class SearchService {
|
|||||||
return this.searchModels.map(searchModel => ({
|
return this.searchModels.map(searchModel => ({
|
||||||
collectionString: searchModel.collectionString,
|
collectionString: searchModel.collectionString,
|
||||||
verboseNameSingular: searchModel.verboseNameSingular,
|
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[] {
|
public search(query: string, inCollectionStrings: string[]): SearchResult[] {
|
||||||
query = query.toLowerCase();
|
query = query.toLowerCase();
|
||||||
/*return this.searchModels
|
return this.searchModels
|
||||||
.filter(s => inCollectionStrings.includes(s.collectionString))
|
.filter(s => inCollectionStrings.includes(s.collectionString))
|
||||||
.map(searchModel => {
|
.map(searchModel => {
|
||||||
const results = this.viewModelStore.filter(searchModel.collectionString, model =>
|
const results = this.viewModelStore
|
||||||
model.formatForSearch().some(text => text.toLowerCase().includes(query))
|
.getAll(searchModel.collectionString)
|
||||||
);
|
.map(x => x as (BaseViewModel & Searchable))
|
||||||
|
.filter(model => model.formatForSearch().some(text => text.toLowerCase().includes(query)));
|
||||||
return {
|
return {
|
||||||
collectionString: searchModel.collectionString,
|
collectionString: searchModel.collectionString,
|
||||||
verboseName: results.length === 1 ? searchModel.verboseNameSingular : searchModel.verboseNamePlural,
|
verboseName: results.length === 1 ? searchModel.verboseNameSingular : searchModel.verboseNamePlural,
|
||||||
|
openInNewTab: searchModel.openInNewTab,
|
||||||
models: results
|
models: results
|
||||||
};
|
};
|
||||||
});*/
|
});
|
||||||
throw new Error('Todo');
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ export const AssignmentsAppConfig: AppConfig = {
|
|||||||
collectionString: 'assignments/assignment',
|
collectionString: 'assignments/assignment',
|
||||||
model: Assignment,
|
model: Assignment,
|
||||||
viewModel: ViewAssignment,
|
viewModel: ViewAssignment,
|
||||||
searchOrder: 3,
|
// searchOrder: 3, // TODO: enable, if there is a detail page and so on.
|
||||||
repository: AssignmentRepositoryService
|
repository: AssignmentRepositoryService
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -76,7 +76,7 @@ export class ViewAssignment extends BaseAgendaViewModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public formatForSearch(): SearchRepresentation {
|
public formatForSearch(): SearchRepresentation {
|
||||||
throw new Error('TODO');
|
return [this.title];
|
||||||
}
|
}
|
||||||
|
|
||||||
public getDetailStateURL(): string {
|
public getDetailStateURL(): string {
|
||||||
|
@ -44,10 +44,10 @@
|
|||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<mat-list>
|
<mat-list>
|
||||||
<mat-list-item *ngFor="let model of searchResult.models">
|
<mat-list-item *ngFor="let model of searchResult.models">
|
||||||
<a
|
<a *ngIf="!searchResult.openInNewTab" [routerLink]="model.getDetailStateURL()">
|
||||||
[routerLink]="model.getDetailStateURL()"
|
{{ model.getTitle() }}
|
||||||
target="{{ searchResult.collectionString === 'mediafiles/mediafile' ? '_blank' : '' }}"
|
</a>
|
||||||
>
|
<a *ngIf="searchResult.openInNewTab" [routerLink]="model.getDetailStateURL()" target="_blank" >
|
||||||
{{ model.getTitle() }}
|
{{ model.getTitle() }}
|
||||||
</a>
|
</a>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
|
@ -114,7 +114,9 @@ export class SearchComponent extends BaseViewComponent implements OnInit {
|
|||||||
this.searchResults = this.searchService.search(this.query, collectionStrings);
|
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.
|
// 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.
|
// Update the URL.
|
||||||
this.router.navigate([], {
|
this.router.navigate([], {
|
||||||
|
@ -11,6 +11,7 @@ export const MediafileAppConfig: AppConfig = {
|
|||||||
model: Mediafile,
|
model: Mediafile,
|
||||||
viewModel: ViewMediafile,
|
viewModel: ViewMediafile,
|
||||||
searchOrder: 5,
|
searchOrder: 5,
|
||||||
|
openInNewTab: true,
|
||||||
repository: MediafileRepositoryService
|
repository: MediafileRepositoryService
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -85,7 +85,7 @@ export class ViewMediafile extends BaseProjectableViewModel implements Searchabl
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getDetailStateURL(): string {
|
public getDetailStateURL(): string {
|
||||||
throw new Error('TODO');
|
return this.downloadUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSlide(): ProjectorElementBuildDeskriptor {
|
public getSlide(): ProjectorElementBuildDeskriptor {
|
||||||
|
@ -46,7 +46,7 @@ export class ViewTag extends BaseViewModel implements Searchable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getDetailStateURL(): string {
|
public getDetailStateURL(): string {
|
||||||
throw new Error('TODO');
|
return `/tags`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -189,7 +189,7 @@ export class ViewUser extends BaseProjectableViewModel implements Searchable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getDetailStateURL(): string {
|
public getDetailStateURL(): string {
|
||||||
throw new Error('TODO');
|
return `/users/${this.id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSlide(): ProjectorElementBuildDeskriptor {
|
public getSlide(): ProjectorElementBuildDeskriptor {
|
||||||
|
Loading…
Reference in New Issue
Block a user