From 22182463a9662ccaa92bd373af9ff18be10f6dc8 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Thu, 24 Jan 2019 11:15:52 +0100 Subject: [PATCH] cleanup, removed motion log from client --- .../app/core/services/pdf-document.service.ts | 4 +- .../sorting-list/sorting-list.component.ts | 1 - client/src/app/shared/models/agenda/item.ts | 2 +- .../app/shared/models/motions/motion-log.ts | 18 ---- .../src/app/shared/models/motions/motion.ts | 9 -- client/src/app/shared/models/users/user.ts | 18 ++-- .../agenda-list/agenda-list.component.html | 4 +- .../speaker-list/speaker-list.component.ts | 30 +++---- .../src/app/site/agenda/models/view-item.ts | 13 ++- .../app/site/agenda/models/view-speaker.ts | 2 +- .../services/agenda-repository.service.ts | 87 +++++++++---------- .../config-field/config-field.component.html | 2 +- .../config-field/config-field.component.ts | 2 +- .../src/app/site/config/models/view-config.ts | 8 -- .../site/mediafiles/models/view-mediafile.ts | 2 + .../motion-block-detail.component.html | 7 -- .../motion-detail.component.html | 10 --- .../motion-detail/motion-detail.component.ts | 16 ---- .../motion-log/motion-log.component.html | 12 --- .../motion-log/motion-log.component.scss | 3 - .../motion-log/motion-log.component.spec.ts | 27 ------ .../motion-log/motion-log.component.ts | 25 ------ .../app/site/motions/models/view-motion.ts | 2 +- client/src/app/site/motions/motions.module.ts | 4 +- .../services/motion-repository.service.ts | 6 +- .../motions/services/personal-note.service.ts | 2 +- client/src/app/site/users/models/view-user.ts | 4 +- 27 files changed, 90 insertions(+), 230 deletions(-) delete mode 100644 client/src/app/shared/models/motions/motion-log.ts delete mode 100644 client/src/app/site/motions/components/motion-log/motion-log.component.html delete mode 100644 client/src/app/site/motions/components/motion-log/motion-log.component.scss delete mode 100644 client/src/app/site/motions/components/motion-log/motion-log.component.spec.ts delete mode 100644 client/src/app/site/motions/components/motion-log/motion-log.component.ts diff --git a/client/src/app/core/services/pdf-document.service.ts b/client/src/app/core/services/pdf-document.service.ts index b7fd85b6e..6266ef46a 100644 --- a/client/src/app/core/services/pdf-document.service.ts +++ b/client/src/app/core/services/pdf-document.service.ts @@ -314,11 +314,11 @@ export class PdfDocumentService { */ public async download(docDefinition: object, filename: string, metadata?: object): Promise { const doc = await this.getStandardPaper(docDefinition, metadata); - await new Promise(resolve => { + await new Promise(resolve => { const pdf = pdfMake.createPdf(doc); pdf.getBlob(blob => { saveAs(blob, `${filename}.pdf`, { autoBOM: true }); - resolve(true); + resolve(); }); }); } diff --git a/client/src/app/shared/components/sorting-list/sorting-list.component.ts b/client/src/app/shared/components/sorting-list/sorting-list.component.ts index 33e00577d..d15be8d8d 100644 --- a/client/src/app/shared/components/sorting-list/sorting-list.component.ts +++ b/client/src/app/shared/components/sorting-list/sorting-list.component.ts @@ -131,7 +131,6 @@ export class SortingListComponent implements OnInit, OnDestroy { if (this.array.length !== newValues.length || this.live) { this.array = []; this.array = newValues.map(val => val); - console.log(newValues); } else if (this.array.length === 0) { this.array.push(new EmptySelectable(this.translate)); } diff --git a/client/src/app/shared/models/agenda/item.ts b/client/src/app/shared/models/agenda/item.ts index 1bdadb796..be62b9cf1 100644 --- a/client/src/app/shared/models/agenda/item.ts +++ b/client/src/app/shared/models/agenda/item.ts @@ -57,7 +57,7 @@ export class Item extends BaseModel { /** * Gets the amount of waiting speakers */ - public get speakerAmount(): number { + public get waitingSpeakerAmount(): number { return this.speakers.filter(speaker => speaker.state === SpeakerState.WAITING).length; } diff --git a/client/src/app/shared/models/motions/motion-log.ts b/client/src/app/shared/models/motions/motion-log.ts deleted file mode 100644 index 70cab00e5..000000000 --- a/client/src/app/shared/models/motions/motion-log.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Deserializer } from '../base/deserializer'; - -/** - * Representation of a Motion Log. - * TODO: better documentation - * - * @ignore - */ -export class MotionLog extends Deserializer { - public message_list: string[]; - public person_id: number; - public time: string; - public message: string; // a pre-translated message in the servers' defined language - - public constructor(input?: any) { - super(input); - } -} diff --git a/client/src/app/shared/models/motions/motion.ts b/client/src/app/shared/models/motions/motion.ts index b48250223..0b9177db1 100644 --- a/client/src/app/shared/models/motions/motion.ts +++ b/client/src/app/shared/models/motions/motion.ts @@ -1,5 +1,4 @@ import { MotionSubmitter } from './motion-submitter'; -import { MotionLog } from './motion-log'; import { MotionComment } from './motion-comment'; import { AgendaBaseModel } from '../base/agenda-base-model'; import { SearchRepresentation } from '../../../core/services/search.service'; @@ -40,7 +39,6 @@ export class Motion extends AgendaBaseModel { public attachments_id: number[]; public polls: MotionPoll[]; public agenda_item_id: number; - public log_messages: MotionLog[]; public weight: number; public sort_parent_id: number; public created: string; @@ -107,13 +105,6 @@ export class Motion extends AgendaBaseModel { public deserialize(input: any): void { Object.assign(this, input); - this.log_messages = []; - if (input.log_messages instanceof Array) { - input.log_messages.forEach(logData => { - this.log_messages.push(new MotionLog(logData)); - }); - } - this.comments = []; if (input.comments instanceof Array) { input.comments.forEach(commentData => { diff --git a/client/src/app/shared/models/users/user.ts b/client/src/app/shared/models/users/user.ts index 75add5053..c79f027aa 100644 --- a/client/src/app/shared/models/users/user.ts +++ b/client/src/app/shared/models/users/user.ts @@ -38,22 +38,22 @@ export class User extends BaseModel implements Searchable { public get full_name(): string { let name = this.short_name; - const addition: string[] = []; + const additions: string[] = []; // addition: add number and structure level const structure_level = this.structure_level ? this.structure_level.trim() : ''; if (structure_level) { - addition.push(structure_level); + additions.push(structure_level); } const number = this.number ? this.number.trim() : null; if (number) { // TODO Translate - addition.push('No.' + ' ' + number); + additions.push('No. ' + number); } - if (addition.length > 0) { - name += ' (' + addition.join(' · ') + ')'; + if (additions.length > 0) { + name += ' (' + additions.join(' · ') + ')'; } return name.trim(); } @@ -85,7 +85,9 @@ export class User extends BaseModel implements Searchable { let shortName = `${firstName} ${lastName}`; - if (!shortName) { + if (shortName.length <= 1) { + // We have at least one space from the concatination of + // first- and lastname. shortName = this.username; } @@ -93,11 +95,11 @@ export class User extends BaseModel implements Searchable { shortName = `${title} ${shortName}`; } - return shortName || this.username; + return shortName; } public getTitle(): string { - return this.full_name || this.username; + return this.full_name; } public getListViewTitle(): string { diff --git a/client/src/app/site/agenda/components/agenda-list/agenda-list.component.html b/client/src/app/site/agenda/components/agenda-list/agenda-list.component.html index e9145d822..75af7c72c 100644 --- a/client/src/app/site/agenda/components/agenda-list/agenda-list.component.html +++ b/client/src/app/site/agenda/components/agenda-list/agenda-list.component.html @@ -61,7 +61,7 @@ Speakers @@ -179,7 +179,7 @@ diff --git a/client/src/app/site/config/components/config-field/config-field.component.ts b/client/src/app/site/config/components/config-field/config-field.component.ts index 69ed29782..72a95c180 100644 --- a/client/src/app/site/config/components/config-field/config-field.component.ts +++ b/client/src/app/site/config/components/config-field/config-field.component.ts @@ -137,7 +137,7 @@ export class ConfigFieldComponent extends BaseComponent implements OnInit { * Triggers a reset to the default value (if a default value is present) */ public onResetButton(): void { - if (this.configItem.hasDefault) { + if (this.configItem.defaultValue !== undefined) { this.onChange(this.configItem.defaultValue); } } diff --git a/client/src/app/site/config/models/view-config.ts b/client/src/app/site/config/models/view-config.ts index e98fad628..a41758125 100644 --- a/client/src/app/site/config/models/view-config.ts +++ b/client/src/app/site/config/models/view-config.ts @@ -89,15 +89,7 @@ export class ViewConfig extends BaseViewModel { return this._choices; } - /** - * @returns true if a default value exists - */ - public get hasDefault(): boolean { - return this._defaultValue !== undefined; - } - public get defaultValue(): any { - // TODO type is ugly return this._defaultValue; } diff --git a/client/src/app/site/mediafiles/models/view-mediafile.ts b/client/src/app/site/mediafiles/models/view-mediafile.ts index cd5f6f250..eb1a10b2e 100644 --- a/client/src/app/site/mediafiles/models/view-mediafile.ts +++ b/client/src/app/site/mediafiles/models/view-mediafile.ts @@ -116,6 +116,8 @@ export class ViewMediafile extends BaseViewModel { public updateValues(update: Mediafile): void { if (update instanceof Mediafile && this.mediafile.id === update.id) { this._mediafile = update; + } else if (update instanceof User && this.uploader.id === update.id) { + this._uploader = update; } } diff --git a/client/src/app/site/motions/components/motion-block-detail/motion-block-detail.component.html b/client/src/app/site/motions/components/motion-block-detail/motion-block-detail.component.html index a12024798..3ebc18eca 100644 --- a/client/src/app/site/motions/components/motion-block-detail/motion-block-detail.component.html +++ b/client/src/app/site/motions/components/motion-block-detail/motion-block-detail.component.html @@ -1,7 +1,4 @@ - - -

{{ block.title }}

@@ -20,8 +17,6 @@
- - - -
diff --git a/client/src/app/site/motions/components/motion-detail/motion-detail.component.html b/client/src/app/site/motions/components/motion-detail/motion-detail.component.html index 1a142bab1..b0ea0274c 100644 --- a/client/src/app/site/motions/components/motion-detail/motion-detail.component.html +++ b/client/src/app/site/motions/components/motion-detail/motion-detail.component.html @@ -137,15 +137,6 @@ - - - - - - - @@ -158,7 +149,6 @@ -
diff --git a/client/src/app/site/motions/components/motion-detail/motion-detail.component.ts b/client/src/app/site/motions/components/motion-detail/motion-detail.component.ts index 74a662dbc..29c7c9158 100644 --- a/client/src/app/site/motions/components/motion-detail/motion-detail.component.ts +++ b/client/src/app/site/motions/components/motion-detail/motion-detail.component.ts @@ -98,22 +98,6 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit { return this._motion; } - /** - * @returns treu if the motion log is present and the user is allowed to see it - */ - public get canShowLog(): boolean { - if ( - this.motion && - !this.editMotion && - this.perms.isAllowed('manage') && - this.motion.motion.log_messages && - this.motion.motion.log_messages.length - ) { - return true; - } - return false; - } - /** * @returns the current recommendation label (with extension) */ diff --git a/client/src/app/site/motions/components/motion-log/motion-log.component.html b/client/src/app/site/motions/components/motion-log/motion-log.component.html deleted file mode 100644 index 233a20ed6..000000000 --- a/client/src/app/site/motions/components/motion-log/motion-log.component.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - Motion log - - -
- {{message.message}} -
-
- -
diff --git a/client/src/app/site/motions/components/motion-log/motion-log.component.scss b/client/src/app/site/motions/components/motion-log/motion-log.component.scss deleted file mode 100644 index 579d7d3a4..000000000 --- a/client/src/app/site/motions/components/motion-log/motion-log.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.small-messages { - font-size: x-small; -} diff --git a/client/src/app/site/motions/components/motion-log/motion-log.component.spec.ts b/client/src/app/site/motions/components/motion-log/motion-log.component.spec.ts deleted file mode 100644 index 34913e6ff..000000000 --- a/client/src/app/site/motions/components/motion-log/motion-log.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -// import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -// import { E2EImportsModule } from 'e2e-imports.module'; -// import { MotionLogComponent } from './motion-log.component'; - -describe('MotionLogComponent skipped', () => { - // TODO testing fails if personalNotesModule (also having the MetaTextBlockComponent) - // is running its' test at the same time. One of the two tests fail, but run fine if tested - // separately; so this is some async duplication stuff - // - // let component: MotionLogComponent; - // let fixture: ComponentFixture; - // beforeEach(async(() => { - // TestBed.configureTestingModule({ - // declarations: [MotionLogComponent], - // imports: [E2EImportsModule] - // }).compileComponents(); - // })); - // beforeEach(() => { - // fixture = TestBed.createComponent(MotionLogComponent); - // component = fixture.componentInstance; - // fixture.detectChanges(); - // }); - // it('should create', () => { - // expect(component).toBeTruthy(); - // }); -}); diff --git a/client/src/app/site/motions/components/motion-log/motion-log.component.ts b/client/src/app/site/motions/components/motion-log/motion-log.component.ts deleted file mode 100644 index 237d3f748..000000000 --- a/client/src/app/site/motions/components/motion-log/motion-log.component.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { ViewMotion } from '../../models/view-motion'; - -/** - * Component showing the log messages of a motion - */ -@Component({ - selector: 'os-motion-log', - templateUrl: './motion-log.component.html', - styleUrls: ['motion-log.component.scss'] -}) -export class MotionLogComponent { - public expanded = false; - - /** - * The viewMotion to show the log messages for - */ - @Input() - public motion: ViewMotion; - - /** - * empty constructor - */ - public constructor() {} -} diff --git a/client/src/app/site/motions/models/view-motion.ts b/client/src/app/site/motions/models/view-motion.ts index 4e73fad4e..1ff4294c8 100644 --- a/client/src/app/site/motions/models/view-motion.ts +++ b/client/src/app/site/motions/models/view-motion.ts @@ -198,7 +198,7 @@ export class ViewMotion extends BaseProjectableModel { } public get agendaSpeakerAmount(): number { - return this.item ? this.item.speakerAmount : null; + return this.item ? this.item.waitingSpeakerAmount : null; } public get parent_id(): number { diff --git a/client/src/app/site/motions/motions.module.ts b/client/src/app/site/motions/motions.module.ts index 25e3eec61..6c85b2824 100644 --- a/client/src/app/site/motions/motions.module.ts +++ b/client/src/app/site/motions/motions.module.ts @@ -22,7 +22,6 @@ import { MotionImportListComponent } from './components/motion-import-list/motio import { ManageSubmittersComponent } from './components/manage-submitters/manage-submitters.component'; import { MotionPollComponent } from './components/motion-poll/motion-poll.component'; import { MotionPollDialogComponent } from './components/motion-poll/motion-poll-dialog.component'; -import { MotionLogComponent } from './components/motion-log/motion-log.component'; @NgModule({ imports: [CommonModule, MotionsRoutingModule, SharedModule], @@ -45,8 +44,7 @@ import { MotionLogComponent } from './components/motion-log/motion-log.component MotionImportListComponent, ManageSubmittersComponent, MotionPollComponent, - MotionPollDialogComponent, - MotionLogComponent + MotionPollDialogComponent ], entryComponents: [ MotionChangeRecommendationComponent, diff --git a/client/src/app/site/motions/services/motion-repository.service.ts b/client/src/app/site/motions/services/motion-repository.service.ts index 6bb4bf65f..718fef2ee 100644 --- a/client/src/app/site/motions/services/motion-repository.service.ts +++ b/client/src/app/site/motions/services/motion-repository.service.ts @@ -737,11 +737,11 @@ export class MotionRepositoryService extends BaseRepository * @returns the translated state with the extension attached */ public getExtendedStateLabel(motion: ViewMotion): string { - let rec = this.translate.instant(motion.state.name); + let state = this.translate.instant(motion.state.name); if (motion.stateExtension && motion.state.show_state_extension_field) { - rec += ' ' + this.solveExtensionPlaceHolder(motion.stateExtension); + state += ' ' + this.solveExtensionPlaceHolder(motion.stateExtension); } - return rec; + return state; } /** diff --git a/client/src/app/site/motions/services/personal-note.service.ts b/client/src/app/site/motions/services/personal-note.service.ts index e6601cc3c..f7857fa8b 100644 --- a/client/src/app/site/motions/services/personal-note.service.ts +++ b/client/src/app/site/motions/services/personal-note.service.ts @@ -103,7 +103,7 @@ export class PersonalNoteService { ); this.subjects[model.collectionString][model.id] = subject; } - return this.subjects[model.collectionString][model.id]; + return this.subjects[model.collectionString][model.id].asObservable(); } /** diff --git a/client/src/app/site/users/models/view-user.ts b/client/src/app/site/users/models/view-user.ts index 17fe55363..b4c49b6d7 100644 --- a/client/src/app/site/users/models/view-user.ts +++ b/client/src/app/site/users/models/view-user.ts @@ -36,11 +36,11 @@ export class ViewUser extends BaseProjectableModel { } public get full_name(): string { - return this.user ? this.user.full_name || this.username : null; + return this.user ? this.user.full_name : null; } public get short_name(): string { - return this.user ? this.user.short_name || this.username : null; + return this.user ? this.user.short_name : null; } public get email(): string {