Search in related objects

This commit is contained in:
FinnStutzenstein 2019-03-04 13:14:09 +01:00
parent 4174f70d2b
commit 9198058bd7
11 changed files with 30 additions and 68 deletions

View File

@ -1,15 +0,0 @@
import { Deserializer } from '../base/deserializer';
/**
* Representation of a Motion Comment.
*/
export class MotionComment extends Deserializer {
public id: number;
public comment: string;
public section_id: number;
public read_groups_id: number[];
public constructor(input?: any) {
super(input);
}
}

View File

@ -1,8 +1,14 @@
import { MotionSubmitter } from './motion-submitter'; import { MotionSubmitter } from './motion-submitter';
import { MotionComment } from './motion-comment';
import { MotionPoll } from './motion-poll'; import { MotionPoll } from './motion-poll';
import { BaseModel } from '../base/base-model'; import { BaseModel } from '../base/base-model';
export interface MotionComment {
id: number;
comment: string;
section_id: number;
read_groups_id: number[];
}
/** /**
* Representation of Motion. * Representation of Motion.
* *
@ -57,15 +63,4 @@ export class Motion extends BaseModel {
}) })
.map((submitter: MotionSubmitter) => submitter.user_id); .map((submitter: MotionSubmitter) => submitter.user_id);
} }
public deserialize(input: any): void {
Object.assign(this, input);
this.comments = [];
if (input.comments instanceof Array) {
input.comments.forEach(commentData => {
this.comments.push(new MotionComment(commentData));
});
}
}
} }

View File

@ -80,7 +80,7 @@ export class SearchComponent extends BaseViewComponent implements OnInit {
this.registeredModels = this.searchService.getRegisteredModels().map(rm => ({ ...rm, enabled: true })); this.registeredModels = this.searchService.getRegisteredModels().map(rm => ({ ...rm, enabled: true }));
this.DS.changedOrDeletedObservable.pipe(auditTime(1)).subscribe(() => this.search()); this.DS.changedOrDeletedObservable.pipe(auditTime(100)).subscribe(() => this.search());
this.quickSearchSubject.pipe(debounceTime(250)).subscribe(query => this.search(query)); this.quickSearchSubject.pipe(debounceTime(250)).subscribe(query => this.search(query));
} }

View File

@ -140,8 +140,4 @@ export class ViewConfig extends BaseViewModel {
} }
this._hasConstantsInfo = true; this._hasConstantsInfo = true;
} }
public copy(): ViewConfig {
return new ViewConfig(this._config);
}
} }

View File

@ -81,7 +81,11 @@ export class ViewMediafile extends BaseProjectableViewModel implements Searchabl
}; };
public formatForSearch(): SearchRepresentation { public formatForSearch(): SearchRepresentation {
return [this.title]; const searchValues = [this.title];
if (this.uploader) {
searchValues.push(this.uploader.full_name);
}
return searchValues;
} }
public getDetailStateURL(): string { public getDetailStateURL(): string {

View File

@ -8,10 +8,10 @@ import { TranslateService } from '@ngx-translate/core';
import { MotionCommentSectionRepositoryService } from 'app/core/repositories/motions/motion-comment-section-repository.service'; import { MotionCommentSectionRepositoryService } from 'app/core/repositories/motions/motion-comment-section-repository.service';
import { ViewMotionCommentSection } from '../../models/view-motion-comment-section'; import { ViewMotionCommentSection } from '../../models/view-motion-comment-section';
import { OperatorService } from 'app/core/core-services/operator.service'; import { OperatorService } from 'app/core/core-services/operator.service';
import { MotionComment } from 'app/shared/models/motions/motion-comment';
import { ViewMotion } from '../../models/view-motion'; import { ViewMotion } from '../../models/view-motion';
import { BaseViewComponent } from 'app/site/base/base-view'; import { BaseViewComponent } from 'app/site/base/base-view';
import { MotionPdfExportService } from '../../services/motion-pdf-export.service'; import { MotionPdfExportService } from '../../services/motion-pdf-export.service';
import { MotionComment } from 'app/shared/models/motions/motion';
/** /**
* Component for the motion comments view * Component for the motion comments view

View File

@ -70,11 +70,4 @@ export class ViewCategory extends BaseViewModel implements Searchable {
* @param update * @param update
*/ */
public updateDependencies(update: BaseViewModel): void {} public updateDependencies(update: BaseViewModel): void {}
/**
* Duplicate this motion into a copy of itself
*/
public copy(): ViewCategory {
return new ViewCategory(this._category);
}
} }

View File

@ -79,11 +79,4 @@ export class ViewMotionCommentSection extends BaseViewModel {
public updateGroup(group: ViewGroup): void { public updateGroup(group: ViewGroup): void {
console.log('implement update group of motion comment section'); console.log('implement update group of motion comment section');
} }
/**
* Duplicate this motion into a copy of itself
*/
public copy(): ViewMotionCommentSection {
return new ViewMotionCommentSection(this._section, this._readGroups, this._writeGroups);
}
} }

View File

@ -1,5 +1,4 @@
import { MotionComment } from 'app/shared/models/motions/motion-comment'; import { Motion, MotionComment } from 'app/shared/models/motions/motion';
import { Motion } from 'app/shared/models/motions/motion';
import { PersonalNoteContent } from 'app/shared/models/users/personal-note'; import { PersonalNoteContent } from 'app/shared/models/users/personal-note';
import { ViewMotionCommentSection } from './view-motion-comment-section'; import { ViewMotionCommentSection } from './view-motion-comment-section';
import { WorkflowState } from 'app/shared/models/motions/workflow-state'; import { WorkflowState } from 'app/shared/models/motions/workflow-state';
@ -397,8 +396,6 @@ export class ViewMotion extends BaseAgendaViewModel implements Searchable {
/** /**
* Formats the category for search * Formats the category for search
* *
* TODO!!!!
*
* @override * @override
*/ */
public formatForSearch(): SearchRepresentation { public formatForSearch(): SearchRepresentation {
@ -406,6 +403,19 @@ export class ViewMotion extends BaseAgendaViewModel implements Searchable {
if (this.amendment_paragraphs) { if (this.amendment_paragraphs) {
searchValues = searchValues.concat(this.amendment_paragraphs.filter(x => !!x)); searchValues = searchValues.concat(this.amendment_paragraphs.filter(x => !!x));
} }
searchValues = searchValues.concat(this.submitters.map(user => user.full_name));
searchValues = searchValues.concat(this.supporters.map(user => user.full_name));
searchValues = searchValues.concat(this.tags.map(tag => tag.getTitle()));
searchValues = searchValues.concat(this.motion.comments.map(comment => comment.comment));
if (this.motion_block) {
searchValues.push(this.motion_block.getTitle());
}
if (this.category) {
searchValues.push(this.category.getTitle());
}
if (this.state) {
searchValues.push(this.state.name);
}
return searchValues; return searchValues;
} }

View File

@ -50,11 +50,11 @@ export class ViewStatuteParagraph extends BaseViewModel implements Searchable {
}; };
public formatForSearch(): SearchRepresentation { public formatForSearch(): SearchRepresentation {
throw new Error('TODO'); return [this.title];
} }
public getDetailStateURL(): string { public getDetailStateURL(): string {
throw new Error('TODO'); return '/motions/statute-paragraphs';
} }
/** /**
@ -62,11 +62,4 @@ export class ViewStatuteParagraph extends BaseViewModel implements Searchable {
* @param section * @param section
*/ */
public updateDependencies(update: BaseViewModel): void {} public updateDependencies(update: BaseViewModel): void {}
/**
* Duplicate this motion into a copy of itself
*/
public copy(): ViewStatuteParagraph {
return new ViewStatuteParagraph(this._paragraph);
}
} }

View File

@ -57,13 +57,6 @@ export class ViewWorkflow extends BaseViewModel {
return this.name; return this.name;
}; };
/**
* Duplicate this motion into a copy of itself
*/
public copy(): ViewWorkflow {
return new ViewWorkflow(this._workflow);
}
/** /**
* Updates the local objects if required * Updates the local objects if required
* *