From 604df9d48bdce00432fe636ad4e0b60089653243 Mon Sep 17 00:00:00 2001 From: Sean Date: Wed, 22 Jan 2020 11:57:51 +0100 Subject: [PATCH] Enhance voting ux --- .../app/core/ui-services/voting.service.ts | 3 + .../breadcrumb/breadcrumb.component.html | 25 ++--- .../breadcrumb/breadcrumb.component.scss | 27 +---- .../breadcrumb/breadcrumb.component.ts | 16 +-- .../components/charts/charts.component.html | 1 + .../components/charts/charts.component.ts | 7 ++ .../check-input/check-input.component.html | 1 + .../src/app/shared/models/poll/base-poll.ts | 7 ++ .../assignment-poll-detail.component.html | 2 +- .../site/motions/models/view-motion-poll.ts | 4 + .../motion-poll-detail.component.html | 100 +++++++++--------- .../motion-poll-detail.component.scss | 42 ++++++-- .../motion-poll-detail.component.ts | 7 +- .../motion-poll-dialog.component.html | 9 +- .../motion-poll-vote.component.html | 35 +++--- .../motion-poll-vote.component.scss | 18 ++++ .../motion-poll-vote.component.ts | 48 +++++++-- .../motion-poll/motion-poll.component.html | 75 ++++++------- .../motion-poll/motion-poll.component.scss | 29 ++--- .../motion-poll/motion-poll.component.ts | 1 - .../polls/components/base-poll.component.ts | 6 -- .../poll-form/poll-form.component.html | 2 +- 22 files changed, 249 insertions(+), 216 deletions(-) diff --git a/client/src/app/core/ui-services/voting.service.ts b/client/src/app/core/ui-services/voting.service.ts index a413a10c8..772af1597 100644 --- a/client/src/app/core/ui-services/voting.service.ts +++ b/client/src/app/core/ui-services/voting.service.ts @@ -13,6 +13,9 @@ export enum VotingError { USER_HAS_VOTED } +/** + * TODO: It appears that the only message that makes sense for the user to see it the last one. + */ export const VotingErrorVerbose = { 1: "You can't vote on this poll right now because it's not in the 'Started' state.", 2: "You can't vote on this poll because its type is set to analog voting.", diff --git a/client/src/app/shared/components/breadcrumb/breadcrumb.component.html b/client/src/app/shared/components/breadcrumb/breadcrumb.component.html index d9c21bde4..67c604bb5 100644 --- a/client/src/app/shared/components/breadcrumb/breadcrumb.component.html +++ b/client/src/app/shared/components/breadcrumb/breadcrumb.component.html @@ -1,17 +1,14 @@ - + + + diff --git a/client/src/app/shared/components/breadcrumb/breadcrumb.component.scss b/client/src/app/shared/components/breadcrumb/breadcrumb.component.scss index a7e5f50a3..a7ccf127e 100644 --- a/client/src/app/shared/components/breadcrumb/breadcrumb.component.scss +++ b/client/src/app/shared/components/breadcrumb/breadcrumb.component.scss @@ -1,25 +1,4 @@ -$breadcrumb-content: var(--breadcrumb-content); - -.breadcrumb-list { - display: flex; - flex-wrap: wrap; - list-style: none; -} - -.breadcrumb { - & + & { - padding-left: 8px; - &::before { - padding-right: 8px; - content: $breadcrumb-content; - } - } - - span.has-action { - cursor: pointer; - } - - &.active { - color: inherit; - } +.active-breadcrumb { + // Theme + color: rgba($color: #317796, $alpha: 1); } diff --git a/client/src/app/shared/components/breadcrumb/breadcrumb.component.ts b/client/src/app/shared/components/breadcrumb/breadcrumb.component.ts index 47c2ad5b0..6b33d4524 100644 --- a/client/src/app/shared/components/breadcrumb/breadcrumb.component.ts +++ b/client/src/app/shared/components/breadcrumb/breadcrumb.component.ts @@ -23,6 +23,8 @@ export class BreadcrumbComponent implements OnInit { @Input() public set breadcrumbs(labels: string[] | Breadcrumb[]) { this.breadcrumbList = []; + + // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-3.html#caveats for (const breadcrumb of labels) { if (typeof breadcrumb === 'string') { this.breadcrumbList.push({ label: breadcrumb, action: null }); @@ -45,16 +47,6 @@ export class BreadcrumbComponent implements OnInit { this.breadcrumbList[index].active = true; } - /** - * Sets the separator for the breadcrumbs. - * - * @param style The new separator as string (character). - */ - @Input() - public set breadcrumbStyle(style: string) { - document.documentElement.style.setProperty('--breadcrumb-content', `'${style}'`); - } - /** * The list of the breadcrumbs built by the input. */ @@ -63,9 +55,7 @@ export class BreadcrumbComponent implements OnInit { /** * Default constructor. */ - public constructor() { - this.breadcrumbStyle = '/'; - } + public constructor() {} /** * OnInit. diff --git a/client/src/app/shared/components/charts/charts.component.html b/client/src/app/shared/components/charts/charts.component.html index 2420f1bae..7d1e49c2d 100644 --- a/client/src/app/shared/components/charts/charts.component.html +++ b/client/src/app/shared/components/charts/charts.component.html @@ -15,6 +15,7 @@ {{ checkboxLabel }} diff --git a/client/src/app/shared/models/poll/base-poll.ts b/client/src/app/shared/models/poll/base-poll.ts index 75b35cf03..be98afe08 100644 --- a/client/src/app/shared/models/poll/base-poll.ts +++ b/client/src/app/shared/models/poll/base-poll.ts @@ -52,6 +52,13 @@ export abstract class BasePoll = any> extends public onehundred_percent_base: PercentBase; public user_has_voted: boolean; + /** + * Determine if the state is finished or published + */ + public get stateHasVotes(): boolean { + return this.state === PollState.Finished || this.state === PollState.Published; + } + protected getDecimalFields(): (keyof BasePoll)[] { return ['votesvalid', 'votesinvalid', 'votescast']; } diff --git a/client/src/app/site/assignments/components/assignment-poll-detail/assignment-poll-detail.component.html b/client/src/app/site/assignments/components/assignment-poll-detail/assignment-poll-detail.component.html index 7fcc3ce2c..64ea46abf 100644 --- a/client/src/app/site/assignments/components/assignment-poll-detail/assignment-poll-detail.component.html +++ b/client/src/app/site/assignments/components/assignment-poll-detail/assignment-poll-detail.component.html @@ -26,7 +26,7 @@

{{ poll.title }}

- +
{{ 'Current state' | translate }}: {{ poll.stateVerbose | translate }}
diff --git a/client/src/app/site/motions/models/view-motion-poll.ts b/client/src/app/site/motions/models/view-motion-poll.ts index 01e465380..6085dce58 100644 --- a/client/src/app/site/motions/models/view-motion-poll.ts +++ b/client/src/app/site/motions/models/view-motion-poll.ts @@ -23,6 +23,10 @@ export class ViewMotionPoll extends ViewBasePoll implements MotionPo private tableKeys = ['yes', 'no', 'abstain']; private voteKeys = ['votesvalid', 'votesinvalid', 'votescast']; + public get hasVotes(): boolean { + return !!this.options[0].votes.length; + } + public initChartLabels(): string[] { return ['Votes']; } diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll-detail/motion-poll-detail.component.html b/client/src/app/site/motions/modules/motion-poll/motion-poll-detail/motion-poll-detail.component.html index 6280bd024..7a14db653 100644 --- a/client/src/app/site/motions/modules/motion-poll/motion-poll-detail/motion-poll-detail.component.html +++ b/client/src/app/site/motions/modules/motion-poll/motion-poll-detail/motion-poll-detail.component.html @@ -1,13 +1,6 @@ - +
-

{{ motionTitle }}

+

{{ 'Motion' | translate }} {{ motion.id }}