From 60d846694a5a7cbf3d47d98aa9471d50940f865b Mon Sep 17 00:00:00 2001 From: Tykayn Date: Thu, 10 Feb 2022 11:15:48 +0100 Subject: [PATCH] copy text in pollService, handle pass link --- .../components/header/header.component.html | 13 ++- .../components/header/header.component.ts | 3 +- src/app/core/services/poll.service.ts | 33 +++++-- .../success/success.component.html | 2 +- .../success/success.component.ts | 16 +--- .../consultation/consultation.component.html | 89 +++++++++---------- src/assets/i18n/fr.json | 2 +- 7 files changed, 87 insertions(+), 71 deletions(-) diff --git a/src/app/core/components/header/header.component.html b/src/app/core/components/header/header.component.html index 7680e60a..9afbba69 100644 --- a/src/app/core/components/header/header.component.html +++ b/src/app/core/components/header/header.component.html @@ -20,8 +20,17 @@ -
- +
+ + + + + + + + + +
diff --git a/src/app/core/components/header/header.component.ts b/src/app/core/components/header/header.component.ts index 1cfa575f..02c49e7c 100644 --- a/src/app/core/components/header/header.component.ts +++ b/src/app/core/components/header/header.component.ts @@ -15,10 +15,11 @@ import { environment } from '../../../../environments/environment'; export class HeaderComponent implements OnInit { @Input() public appTitle = environment.appTitle; @Input() public appLogo = environment.appLogo; + @Input() public linkToHome: boolean = true; mobileMenuVisible = false; public environment = environment; - constructor(private userService: UserService) {} + constructor() {} public ngOnInit(): void {} } diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 3de7e7fc..de6510bb 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -22,6 +22,8 @@ import { Owner } from '../models/owner.model'; import { Stack } from '../models/stack.model'; import { Vote } from '../models/vote.model'; import { defaultTimeOfDay } from '../../../../mocks/old-stuff/config/defaultConfigs'; +import { ClipboardService } from 'ngx-clipboard'; +import { TranslateService } from '@ngx-translate/core'; @Injectable({ providedIn: 'root', @@ -63,6 +65,8 @@ export class PollService implements Resolve { private titleService: Title, public DateUtilitiesService: DateUtilitiesService, public route: ActivatedRoute, + private _clipboardService: ClipboardService, + private translate: TranslateService, @Inject(DOCUMENT) private document: any, private fb: FormBuilder ) { @@ -611,19 +615,23 @@ export class PollService implements Resolve { // http://localhost:4200/#/poll/citron/consultation/secure/1c01ed9c94fc640a1be864f197ff808c let url = ''; + let suffix_password = ''; if (this._poll && this._poll.getValue) { - const polltemp = this._poll.getValue(); - if (polltemp) { - url = `${environment.frontDomain}/#/poll/${polltemp.custom_url}/consultation`; + const currentPoll = this._poll.getValue(); + if (currentPoll.password) { + // handle pass access + suffix_password = '/prompt'; + } + if (currentPoll) { + url = `${environment.frontDomain}/#/poll/${currentPoll.custom_url}/consultation${suffix_password}`; } else { - url = `${environment.frontDomain}/#/poll/${this.form.value.custom_url}/consultation`; + url = `${environment.frontDomain}/#/poll/${this.form.value.custom_url}/consultation${suffix_password}`; } } else { - url = `${environment.frontDomain}/#/poll/${this.form.value.custom_url}/consultation`; + url = `${environment.frontDomain}/#/poll/${this.form.value.custom_url}/consultation${suffix_password}`; } console.log('getParticipationUrl', url); - // TODO handle pass access return url; } @@ -786,4 +794,17 @@ export class PollService implements Resolve { console.log('newpoll', newpoll); return newpoll; } + + /** + * copy public url of new poll + * @param textToCopy + */ + copyText(textToCopy: string) { + this._clipboardService.copyFromContent(textToCopy); + console.log("this.translate.get('success.copy_message')", this.translate.get('success.copy_message')); + this.translate.get('success.copy_message').subscribe((resp) => { + console.log('resp', resp); + this.toastService.display(`${resp} ${textToCopy}`); + }); + } } diff --git a/src/app/features/administration/success/success.component.html b/src/app/features/administration/success/success.component.html index 9c764bc0..dd9da3fa 100644 --- a/src/app/features/administration/success/success.component.html +++ b/src/app/features/administration/success/success.component.html @@ -41,7 +41,7 @@
diff --git a/src/app/features/administration/success/success.component.ts b/src/app/features/administration/success/success.component.ts index a0009763..800e1b2b 100644 --- a/src/app/features/administration/success/success.component.ts +++ b/src/app/features/administration/success/success.component.ts @@ -23,9 +23,8 @@ export class SuccessComponent { constructor( public pollService: PollService, private dateUtils: DateUtilitiesService, - private _clipboardService: ClipboardService, + private toastService: ToastService, - private translate: TranslateService, private titleService: Title ) { this.titleService.setTitle( @@ -36,17 +35,4 @@ export class SuccessComponent { sendToEmail() { alert('todo'); } - - /** - * copy public url of new poll - * @param participationUrl - */ - copyText(participationUrl: string) { - this._clipboardService.copyFromContent(participationUrl); - console.log("this.translate.get('success.copy_message')", this.translate.get('success.copy_message')); - this.translate.get('success.copy_message').subscribe((resp) => { - console.log('resp', resp); - this.toastService.display(`${resp} ${participationUrl}`); - }); - } } diff --git a/src/app/features/consultation/consultation.component.html b/src/app/features/consultation/consultation.component.html index 895a46c1..dc408489 100644 --- a/src/app/features/consultation/consultation.component.html +++ b/src/app/features/consultation/consultation.component.html @@ -1,52 +1,26 @@ -
-
-
-
- - - -

- - {{ 'creation.title' | translate }} - - - - - {{ pollService.form.value.title }} - - - {{ 'nav.no_title' | translate }} - - -

-
-
- - -
-
-
-
+
+
+ +
+
+ +
+
+ +
+
+

@@ -58,6 +32,31 @@ {{ 'participation.menu_label' | translate }} +

diff --git a/src/assets/i18n/fr.json b/src/assets/i18n/fr.json index 176ff1e9..368104b8 100755 --- a/src/assets/i18n/fr.json +++ b/src/assets/i18n/fr.json @@ -796,7 +796,7 @@ "GL": "gl", "HU": "hu", "IT": "It", - "JA": "Ja", + "JA": "Ja", "NL": "Nl", "OC": "Oc", "SV": "Sv"