Skip to content

Commit d3d6206

Browse files
committed
Poll display complete (i18n needs to be checked)
1 parent b921937 commit d3d6206

33 files changed

+142
-305
lines changed

projects/stream-chat-angular/src/assets/i18n/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,7 @@ export const en = {
161161
'Failed to add option ({{ message }})':
162162
'Failed to add option ({{ message }})',
163163
'Option already exists': 'Option already exists',
164+
'You have reached the maximum number of votes allowed':
165+
'You have reached the maximum number of votes allowed',
164166
},
165167
};

projects/stream-chat-angular/src/lib/modal/modal.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#modalInner
1515
class="str-chat__modal__inner"
1616
(click)="$event.stopPropagation()"
17+
(keyup.enter)="$event.stopPropagation()"
1718
>
1819
<ng-container *ngIf="content; else elseContent">
1920
<ng-container *ngTemplateOutlet="content"></ng-container>

projects/stream-chat-angular/src/lib/polls/base-poll.component.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import { Subscription } from 'rxjs';
1515
import { CustomTemplatesService } from '../custom-templates.service';
1616
import { NotificationService } from '../notification.service';
1717

18+
/**
19+
*
20+
*/
1821
@Component({
1922
selector: 'stream-base-poll',
2023
template: '',
@@ -30,6 +33,7 @@ export abstract class BasePollComponent
3033
private pollStateUnsubscribe?: () => void;
3134
private isViewInited = false;
3235
private capabilitySubscription?: Subscription;
36+
protected dismissNotificationFn: (() => void) | undefined;
3337

3438
constructor(
3539
public customTemplatesService: CustomTemplatesService,
@@ -56,6 +60,7 @@ export abstract class BasePollComponent
5660
} else {
5761
this.pollStateUnsubscribe?.();
5862
}
63+
this.dismissNotificationFn?.();
5964
}
6065
}
6166

@@ -65,6 +70,8 @@ export abstract class BasePollComponent
6570

6671
ngOnDestroy(): void {
6772
this.pollStateUnsubscribe?.();
73+
this.dismissNotificationFn?.();
74+
this.capabilitySubscription?.unsubscribe();
6875
}
6976

7077
protected get poll(): Poll | undefined {
@@ -83,6 +90,16 @@ export abstract class BasePollComponent
8390
}
8491
}
8592

93+
protected addNotification(
94+
...args: Parameters<
95+
typeof this.notificationService.addTemporaryNotification
96+
>
97+
) {
98+
this.dismissNotificationFn?.();
99+
this.dismissNotificationFn =
100+
this.notificationService.addTemporaryNotification(...args);
101+
}
102+
86103
protected abstract stateStoreSelector(
87104
poll: Poll,
88105
markForCheck: () => void

projects/stream-chat-angular/src/lib/polls/poll-actions/add-option/add-option.component.spec.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

projects/stream-chat-angular/src/lib/polls/poll-actions/add-option/add-option.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import { BasePollComponent } from '../../base-poll.component';
99
import { Poll, PollOption } from 'stream-chat';
1010
import { createUniqueValidator } from '../../unique.validator';
1111

12+
/**
13+
*
14+
*/
1215
@Component({
1316
selector: 'stream-add-option',
1417
templateUrl: './add-option.component.html',

projects/stream-chat-angular/src/lib/polls/poll-actions/poll-actions.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
</ng-template>
7777

7878
<ng-template #allOptions>
79-
<div class="str-chat__modal__poll-option-list">
79+
<div class="str-chat__modal__poll-option-list str-chat-angular__poll-actions">
8080
<div class="str-chat__modal-header">
8181
<div class="str-chat__modal-header__title" translate>Poll options</div>
8282
</div>
@@ -87,6 +87,7 @@
8787
[messageId]="messageId"
8888
[maxOptionsDisplayed]="undefined"
8989
></stream-poll-options-list>
90+
<stream-notification-list></stream-notification-list>
9091
</div>
9192
</div>
9293
</ng-template>

projects/stream-chat-angular/src/lib/polls/poll-actions/poll-actions.component.spec.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

projects/stream-chat-angular/src/lib/polls/poll-actions/poll-actions.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ type Action =
2323
| 'viewResults'
2424
| 'endVote';
2525

26+
/**
27+
*
28+
*/
2629
@Component({
2730
selector: 'stream-poll-actions',
2831
templateUrl: './poll-actions.component.html',
@@ -80,6 +83,8 @@ export class PollActionsComponent extends BasePollComponent {
8083
created_by: state.created_by,
8184
name: state.name,
8285
own_answer: state.ownAnswer,
86+
max_votes_allowed: state.max_votes_allowed,
87+
own_votes_by_option_id: state.ownVotesByOptionId,
8388
}),
8489
(state) => {
8590
this.options = state.options;

projects/stream-chat-angular/src/lib/polls/poll-actions/poll-answers-list/poll-answers-list.component.spec.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

projects/stream-chat-angular/src/lib/polls/poll-actions/poll-answers-list/poll-answers-list.component.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,26 @@ import {
33
Component,
44
EventEmitter,
55
HostBinding,
6+
OnChanges,
67
Output,
78
SimpleChanges,
89
} from '@angular/core';
910
import { BasePollComponent } from '../../base-poll.component';
1011
import { Poll, PollAnswer } from 'stream-chat';
1112

13+
/**
14+
*
15+
*/
1216
@Component({
1317
selector: 'stream-poll-answers-list',
1418
templateUrl: './poll-answers-list.component.html',
1519
styles: [],
1620
changeDetection: ChangeDetectionStrategy.OnPush,
1721
})
18-
export class PollAnswersListComponent extends BasePollComponent {
22+
export class PollAnswersListComponent
23+
extends BasePollComponent
24+
implements OnChanges
25+
{
1926
@HostBinding('class') class = 'str-chat__modal__poll-answer-list';
2027
@Output() upsertOwnAnswer = new EventEmitter<void>();
2128
isLoading = false;
@@ -27,7 +34,7 @@ export class PollAnswersListComponent extends BasePollComponent {
2734
ngOnChanges(changes: SimpleChanges): void {
2835
super.ngOnChanges(changes);
2936
if (changes['pollId']) {
30-
this.queryAnswers();
37+
void this.queryAnswers();
3138
}
3239
}
3340

0 commit comments

Comments
 (0)