From 3c9f6ed278d3fbca489c80cd737c7ba3872b1bb8 Mon Sep 17 00:00:00 2001 From: Sean Date: Mon, 16 Mar 2020 18:40:31 +0100 Subject: [PATCH] Some overall improvements Common: delete unused motion poll list Poll Create form: Fix ugly multi line mat hints (workaround, see https://github.com/angular/components/issues/5227 ) Poll List: Fix too tiny column size user_has_voted_valid (ceck icon) was not shown Motion Poll Card: Enhance subtitle layout (type + state) Assignment Poll Card: Open warning after clicking the hint icon Assignment Poll Chart: Show Absolute values and percents in chart label Assignment Detail: Add new ballot button with plus icon instead of chart icon --- .../shared/pipes/poll-percent-base.pipe.ts | 18 +++-- .../assignment-detail.component.html | 2 +- .../assignment-poll-detail.component.ts | 15 ++--- .../assignment-poll.component.ts | 10 ++- .../services/assignment-poll.service.ts | 8 ++- .../motion-poll-detail.component.ts | 8 +-- .../motion-poll-list.component.html | 36 ---------- .../motion-poll-list.component.scss | 0 .../motion-poll-list.component.spec.ts | 27 -------- .../motion-poll-list.component.ts | 45 ------------- .../motion-poll/motion-poll-routing.module.ts | 2 - .../modules/motion-poll/motion-poll.module.ts | 3 +- .../motion-poll/motion-poll.component.html | 43 ++++++------ .../motions/services/motion-poll.service.ts | 8 ++- .../components/base-poll-detail.component.ts | 5 +- .../poll-list/poll-list.component.html | 27 ++++++-- .../poll-list/poll-list.component.ts | 2 +- .../app/site/polls/services/poll.service.ts | 66 +++++++++++++++---- client/src/styles.scss | 26 ++++++++ 19 files changed, 168 insertions(+), 183 deletions(-) delete mode 100644 client/src/app/site/motions/modules/motion-poll/motion-poll-list/motion-poll-list.component.html delete mode 100644 client/src/app/site/motions/modules/motion-poll/motion-poll-list/motion-poll-list.component.scss delete mode 100644 client/src/app/site/motions/modules/motion-poll/motion-poll-list/motion-poll-list.component.spec.ts delete mode 100644 client/src/app/site/motions/modules/motion-poll/motion-poll-list/motion-poll-list.component.ts diff --git a/client/src/app/shared/pipes/poll-percent-base.pipe.ts b/client/src/app/shared/pipes/poll-percent-base.pipe.ts index cfec9d13c..2c15d8f0f 100644 --- a/client/src/app/shared/pipes/poll-percent-base.pipe.ts +++ b/client/src/app/shared/pipes/poll-percent-base.pipe.ts @@ -21,26 +21,24 @@ import { PollData } from 'app/site/polls/services/poll.service'; name: 'pollPercentBase' }) export class PollPercentBasePipe implements PipeTransform { - private decimalPlaces = 3; - public constructor( private assignmentPollService: AssignmentPollService, private motionPollService: MotionPollService ) {} public transform(value: number, poll: PollData): string | null { - let totalByBase: number; + // logic handles over the pollService to avoid circular dependencies + let voteValueInPercent: string; if ((poll).assignment) { - totalByBase = this.assignmentPollService.getPercentBase(poll); + voteValueInPercent = this.assignmentPollService.getVoteValueInPercent(value, poll); } else { - totalByBase = this.motionPollService.getPercentBase(poll); + voteValueInPercent = this.motionPollService.getVoteValueInPercent(value, poll); } - if (totalByBase && totalByBase > 0) { - const percentNumber = (value / totalByBase) * 100; - const result = percentNumber % 1 === 0 ? percentNumber : percentNumber.toFixed(this.decimalPlaces); - return `(${result} %)`; + if (voteValueInPercent) { + return `(${voteValueInPercent})`; + } else { + return null; } - return null; } } diff --git a/client/src/app/site/assignments/components/assignment-detail/assignment-detail.component.html b/client/src/app/site/assignments/components/assignment-detail/assignment-detail.component.html index eae31d2ec..74bf74784 100644 --- a/client/src/app/site/assignments/components/assignment-detail/assignment-detail.component.html +++ b/client/src/app/site/assignments/components/assignment-detail/assignment-detail.component.html @@ -75,7 +75,7 @@
diff --git a/client/src/app/site/assignments/components/assignment-poll-detail/assignment-poll-detail.component.ts b/client/src/app/site/assignments/components/assignment-poll-detail/assignment-poll-detail.component.ts index 93fd8a2d4..57549902b 100644 --- a/client/src/app/site/assignments/components/assignment-poll-detail/assignment-poll-detail.component.ts +++ b/client/src/app/site/assignments/components/assignment-poll-detail/assignment-poll-detail.component.ts @@ -14,7 +14,7 @@ import { PromptService } from 'app/core/ui-services/prompt.service'; import { ChartType } from 'app/shared/components/charts/charts.component'; import { VoteValue } from 'app/shared/models/poll/base-vote'; import { BasePollDetailComponent } from 'app/site/polls/components/base-poll-detail.component'; -import { PollService, PollTableData, VotingResult } from 'app/site/polls/services/poll.service'; +import { PollTableData, VotingResult } from 'app/site/polls/services/poll.service'; import { AssignmentPollDialogService } from '../../services/assignment-poll-dialog.service'; import { AssignmentPollService } from '../../services/assignment-poll.service'; import { ViewAssignmentPoll } from '../../models/view-assignment-poll'; @@ -25,7 +25,7 @@ import { ViewAssignmentPoll } from '../../models/view-assignment-poll'; styleUrls: ['./assignment-poll-detail.component.scss'], encapsulation: ViewEncapsulation.None }) -export class AssignmentPollDetailComponent extends BasePollDetailComponent { +export class AssignmentPollDetailComponent extends BasePollDetailComponent { public columnDefinitionSingleVotes: PblColumnDefinition[]; public filterProps = ['user.getFullName']; @@ -47,10 +47,9 @@ export class AssignmentPollDetailComponent extends BasePollDetailComponent('assignment_poll_default_100_percent_base') .subscribe(base => (this.defaultPercentBase = base)); diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll-detail/motion-poll-detail.component.ts b/client/src/app/site/motions/modules/motion-poll/motion-poll-detail/motion-poll-detail.component.ts index bab3e1408..408347d86 100644 --- a/client/src/app/site/motions/modules/motion-poll/motion-poll-detail/motion-poll-detail.component.ts +++ b/client/src/app/site/motions/modules/motion-poll/motion-poll-detail/motion-poll-detail.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { Component, ViewEncapsulation } from '@angular/core'; import { MatSnackBar } from '@angular/material'; import { Title } from '@angular/platform-browser'; import { ActivatedRoute, Router } from '@angular/router'; @@ -14,8 +14,8 @@ import { PromptService } from 'app/core/ui-services/prompt.service'; import { ViewMotion } from 'app/site/motions/models/view-motion'; import { ViewMotionPoll } from 'app/site/motions/models/view-motion-poll'; import { MotionPollDialogService } from 'app/site/motions/services/motion-poll-dialog.service'; +import { MotionPollService } from 'app/site/motions/services/motion-poll.service'; import { BasePollDetailComponent } from 'app/site/polls/components/base-poll-detail.component'; -import { PollService } from 'app/site/polls/services/poll.service'; @Component({ selector: 'os-motion-poll-detail', @@ -23,7 +23,7 @@ import { PollService } from 'app/site/polls/services/poll.service'; styleUrls: ['./motion-poll-detail.component.scss'], encapsulation: ViewEncapsulation.None }) -export class MotionPollDetailComponent extends BasePollDetailComponent implements OnInit { +export class MotionPollDetailComponent extends BasePollDetailComponent { public motion: ViewMotion; public columnDefinition: PblColumnDefinition[] = [ { @@ -49,7 +49,7 @@ export class MotionPollDetailComponent extends BasePollDetailComponent -
Motions poll list
- - - - - - -
- - {{ poll.title }} -
-
- {{ poll.stateVerbose }} -
-
- - - - - diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll-list/motion-poll-list.component.scss b/client/src/app/site/motions/modules/motion-poll/motion-poll-list/motion-poll-list.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll-list/motion-poll-list.component.spec.ts b/client/src/app/site/motions/modules/motion-poll/motion-poll-list/motion-poll-list.component.spec.ts deleted file mode 100644 index 819250015..000000000 --- a/client/src/app/site/motions/modules/motion-poll/motion-poll-list/motion-poll-list.component.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { E2EImportsModule } from 'e2e-imports.module'; - -import { MotionPollListComponent } from './motion-poll-list.component'; - -describe('MotionPollListComponent', () => { - let component: MotionPollListComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [E2EImportsModule], - declarations: [MotionPollListComponent] - }).compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(MotionPollListComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll-list/motion-poll-list.component.ts b/client/src/app/site/motions/modules/motion-poll/motion-poll-list/motion-poll-list.component.ts deleted file mode 100644 index 0f6cbefd8..000000000 --- a/client/src/app/site/motions/modules/motion-poll/motion-poll-list/motion-poll-list.component.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { MatSnackBar } from '@angular/material'; -import { Title } from '@angular/platform-browser'; - -import { TranslateService } from '@ngx-translate/core'; -import { PblColumnDefinition } from '@pebula/ngrid'; - -import { StorageService } from 'app/core/core-services/storage.service'; -import { MotionPollRepositoryService } from 'app/core/repositories/motions/motion-poll-repository.service'; -import { BaseListViewComponent } from 'app/site/base/base-list-view'; -import { ViewMotionPoll } from 'app/site/motions/models/view-motion-poll'; - -@Component({ - selector: 'os-motion-poll-list', - templateUrl: './motion-poll-list.component.html', - styleUrls: ['./motion-poll-list.component.scss'] -}) -export class MotionPollListComponent extends BaseListViewComponent implements OnInit { - public tableColumnDefinition: PblColumnDefinition[] = [ - { - prop: 'title', - width: 'auto' - }, - { - prop: 'state', - width: 'auto' - } - ]; - - public polls: ViewMotionPoll[] = []; - - public constructor( - title: Title, - protected translate: TranslateService, - matSnackbar: MatSnackBar, - storage: StorageService, - public repo: MotionPollRepositoryService - ) { - super(title, translate, matSnackbar, storage); - } - - public ngOnInit(): void { - this.subscriptions.push(this.repo.getViewModelListObservable().subscribe(polls => (this.polls = polls))); - } -} diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll-routing.module.ts b/client/src/app/site/motions/modules/motion-poll/motion-poll-routing.module.ts index 120eac726..95a4197db 100644 --- a/client/src/app/site/motions/modules/motion-poll/motion-poll-routing.module.ts +++ b/client/src/app/site/motions/modules/motion-poll/motion-poll-routing.module.ts @@ -2,10 +2,8 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { MotionPollDetailComponent } from './motion-poll-detail/motion-poll-detail.component'; -import { MotionPollListComponent } from './motion-poll-list/motion-poll-list.component'; const routes: Routes = [ - { path: '', component: MotionPollListComponent, pathMatch: 'full' }, { path: 'new', component: MotionPollDetailComponent }, { path: ':id', component: MotionPollDetailComponent } ]; diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll.module.ts b/client/src/app/site/motions/modules/motion-poll/motion-poll.module.ts index 170b4b8d3..1c781d657 100644 --- a/client/src/app/site/motions/modules/motion-poll/motion-poll.module.ts +++ b/client/src/app/site/motions/modules/motion-poll/motion-poll.module.ts @@ -4,7 +4,6 @@ import { NgModule } from '@angular/core'; import { SharedModule } from 'app/shared/shared.module'; import { PollsModule } from 'app/site/polls/polls.module'; import { MotionPollDetailComponent } from './motion-poll-detail/motion-poll-detail.component'; -import { MotionPollListComponent } from './motion-poll-list/motion-poll-list.component'; import { MotionPollRoutingModule } from './motion-poll-routing.module'; import { MotionPollVoteComponent } from './motion-poll-vote/motion-poll-vote.component'; import { MotionPollComponent } from './motion-poll/motion-poll.component'; @@ -12,6 +11,6 @@ import { MotionPollComponent } from './motion-poll/motion-poll.component'; @NgModule({ imports: [CommonModule, SharedModule, MotionPollRoutingModule, PollsModule], exports: [MotionPollComponent], - declarations: [MotionPollComponent, MotionPollDetailComponent, MotionPollListComponent, MotionPollVoteComponent] + declarations: [MotionPollComponent, MotionPollDetailComponent, MotionPollVoteComponent] }) export class MotionPollModule {} diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll/motion-poll.component.html b/client/src/app/site/motions/modules/motion-poll/motion-poll/motion-poll.component.html index 08b1af24f..ffe9db2b6 100644 --- a/client/src/app/site/motions/modules/motion-poll/motion-poll/motion-poll.component.html +++ b/client/src/app/site/motions/modules/motion-poll/motion-poll/motion-poll.component.html @@ -2,33 +2,13 @@
-
+
{{ poll.title | translate }} - -
- - - - - - - {{ poll.typeVerbose | translate }} · - - - - - {{ poll.stateVerbose | translate }} - -
@@ -39,6 +19,27 @@
+ +
+ + + + + + + {{ poll.typeVerbose | translate }} · + + + + + {{ poll.stateVerbose | translate }} + +
+