Merge pull request #4451 from FinnStutzenstein/moreSearch

Search in related objects
This commit is contained in:
Emanuel Schütze 2019-03-04 21:56:37 +01:00 committed by GitHub
commit d081b90ff1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 { MotionComment } from './motion-comment';
import { MotionPoll } from './motion-poll';
import { BaseModel } from '../base/base-model';
export interface MotionComment {
id: number;
comment: string;
section_id: number;
read_groups_id: number[];
}
/**
* Representation of Motion.
*
@ -57,15 +63,4 @@ export class Motion extends BaseModel {
})
.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.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));
}

View File

@ -140,8 +140,4 @@ export class ViewConfig extends BaseViewModel {
}
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 {
return [this.title];
const searchValues = [this.title];
if (this.uploader) {
searchValues.push(this.uploader.full_name);
}
return searchValues;
}
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 { ViewMotionCommentSection } from '../../models/view-motion-comment-section';
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 { BaseViewComponent } from 'app/site/base/base-view';
import { MotionPdfExportService } from '../../services/motion-pdf-export.service';
import { MotionComment } from 'app/shared/models/motions/motion';
/**
* Component for the motion comments view

View File

@ -70,11 +70,4 @@ export class ViewCategory extends BaseViewModel implements Searchable {
* @param update
*/
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 {
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 } from 'app/shared/models/motions/motion';
import { Motion, MotionComment } from 'app/shared/models/motions/motion';
import { PersonalNoteContent } from 'app/shared/models/users/personal-note';
import { ViewMotionCommentSection } from './view-motion-comment-section';
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
*
* TODO!!!!
*
* @override
*/
public formatForSearch(): SearchRepresentation {
@ -406,6 +403,19 @@ export class ViewMotion extends BaseAgendaViewModel implements Searchable {
if (this.amendment_paragraphs) {
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;
}

View File

@ -50,11 +50,11 @@ export class ViewStatuteParagraph extends BaseViewModel implements Searchable {
};
public formatForSearch(): SearchRepresentation {
throw new Error('TODO');
return [this.title];
}
public getDetailStateURL(): string {
throw new Error('TODO');
return '/motions/statute-paragraphs';
}
/**
@ -62,11 +62,4 @@ export class ViewStatuteParagraph extends BaseViewModel implements Searchable {
* @param section
*/
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;
};
/**
* Duplicate this motion into a copy of itself
*/
public copy(): ViewWorkflow {
return new ViewWorkflow(this._workflow);
}
/**
* Updates the local objects if required
*