copy text in pollService, handle pass link

This commit is contained in:
Tykayn 2022-02-10 11:15:48 +01:00 committed by tykayn
parent 01a2e40b71
commit 60d846694a
7 changed files with 87 additions and 71 deletions

View File

@ -20,8 +20,17 @@
</a> </a>
</span> </span>
</div> </div>
<div class="pull-right"> <div class="pull-right right-end-bar">
<app-language-selector></app-language-selector> <!-- <button-->
<!-- *ngIf="linkToHome"-->
<!-- class="has-no-border nav-button cancel-button "-->
<!-- [routerLink]="'/'"-->
<!-- id="display_cancel_popup_button"-->
<!-- aria-haspopup="dialog"-->
<!-- >-->
<!-- {{ 'nav.leave' | translate }} <i class="fa fa-times"></i>-->
<!-- </button>-->
<app-language-selector class=""></app-language-selector>
</div> </div>
</div> </div>
<div class="mobile-menu" *ngIf="mobileMenuVisible"> <div class="mobile-menu" *ngIf="mobileMenuVisible">

View File

@ -15,10 +15,11 @@ import { environment } from '../../../../environments/environment';
export class HeaderComponent implements OnInit { export class HeaderComponent implements OnInit {
@Input() public appTitle = environment.appTitle; @Input() public appTitle = environment.appTitle;
@Input() public appLogo = environment.appLogo; @Input() public appLogo = environment.appLogo;
@Input() public linkToHome: boolean = true;
mobileMenuVisible = false; mobileMenuVisible = false;
public environment = environment; public environment = environment;
constructor(private userService: UserService) {} constructor() {}
public ngOnInit(): void {} public ngOnInit(): void {}
} }

View File

@ -22,6 +22,8 @@ import { Owner } from '../models/owner.model';
import { Stack } from '../models/stack.model'; import { Stack } from '../models/stack.model';
import { Vote } from '../models/vote.model'; import { Vote } from '../models/vote.model';
import { defaultTimeOfDay } from '../../../../mocks/old-stuff/config/defaultConfigs'; import { defaultTimeOfDay } from '../../../../mocks/old-stuff/config/defaultConfigs';
import { ClipboardService } from 'ngx-clipboard';
import { TranslateService } from '@ngx-translate/core';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@ -63,6 +65,8 @@ export class PollService implements Resolve<Poll> {
private titleService: Title, private titleService: Title,
public DateUtilitiesService: DateUtilitiesService, public DateUtilitiesService: DateUtilitiesService,
public route: ActivatedRoute, public route: ActivatedRoute,
private _clipboardService: ClipboardService,
private translate: TranslateService,
@Inject(DOCUMENT) private document: any, @Inject(DOCUMENT) private document: any,
private fb: FormBuilder private fb: FormBuilder
) { ) {
@ -611,19 +615,23 @@ export class PollService implements Resolve<Poll> {
// http://localhost:4200/#/poll/citron/consultation/secure/1c01ed9c94fc640a1be864f197ff808c // http://localhost:4200/#/poll/citron/consultation/secure/1c01ed9c94fc640a1be864f197ff808c
let url = ''; let url = '';
let suffix_password = '';
if (this._poll && this._poll.getValue) { if (this._poll && this._poll.getValue) {
const polltemp = this._poll.getValue(); const currentPoll = this._poll.getValue();
if (polltemp) { if (currentPoll.password) {
url = `${environment.frontDomain}/#/poll/${polltemp.custom_url}/consultation`; // handle pass access
suffix_password = '/prompt';
}
if (currentPoll) {
url = `${environment.frontDomain}/#/poll/${currentPoll.custom_url}/consultation${suffix_password}`;
} else { } else {
url = `${environment.frontDomain}/#/poll/${this.form.value.custom_url}/consultation`; url = `${environment.frontDomain}/#/poll/${this.form.value.custom_url}/consultation${suffix_password}`;
} }
} else { } 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); console.log('getParticipationUrl', url);
// TODO handle pass access
return url; return url;
} }
@ -786,4 +794,17 @@ export class PollService implements Resolve<Poll> {
console.log('newpoll', newpoll); console.log('newpoll', newpoll);
return 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}`);
});
}
} }

View File

@ -41,7 +41,7 @@
<div class="column is-narrow"> <div class="column is-narrow">
<button <button
class="is-primary button" class="is-primary button"
(click)="copyText(pollService.getParticipationUrl())" (click)="pollService.copyText(pollService.getParticipationUrl())"
> >
{{ 'success.copy' | translate }} {{ 'success.copy' | translate }}
</button> </button>

View File

@ -23,9 +23,8 @@ export class SuccessComponent {
constructor( constructor(
public pollService: PollService, public pollService: PollService,
private dateUtils: DateUtilitiesService, private dateUtils: DateUtilitiesService,
private _clipboardService: ClipboardService,
private toastService: ToastService, private toastService: ToastService,
private translate: TranslateService,
private titleService: Title private titleService: Title
) { ) {
this.titleService.setTitle( this.titleService.setTitle(
@ -36,17 +35,4 @@ export class SuccessComponent {
sendToEmail() { sendToEmail() {
alert('todo'); 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}`);
});
}
} }

View File

@ -1,52 +1,26 @@
<div class="step-info"> <app-header [linkToHome]="true"></app-header>
<div class="container">
<div class="columns">
<div class="column">
<a
class="logo-home-link navbar-item pull-left is-hidden-mobile"
[routerLink]="['/']"
routerLinkActive="active"
>
<img
class="stepper-app-logo logo"
*ngIf="environment.appLogo"
src="{{ environment.appLogo }}"
alt="accueil {{ environment.appTitle }}"
/>
</a>
<h1>
<span class="step-title-poll" *ngIf="pollService.step_current == 1">
{{ 'creation.title' | translate }}
</span>
<span *ngIf="pollService.step_current > 1">
<span class="step-title-poll poll-title-filled" *ngIf="pollService.form.value.title.length">
{{ pollService.form.value.title }}
</span>
<span class="step-title-poll poll-title-empty" *ngIf="!pollService.form.value.title.length">
{{ 'nav.no_title' | translate }}
</span>
</span>
</h1>
</div>
<div class="column has-text-right">
<app-language-selector class="nav-button"></app-language-selector>
<button
class="has-no-border nav-button cancel-button"
[routerLink]="'/'"
id="display_cancel_popup_button"
aria-haspopup="dialog"
>
{{ 'nav.leave' | translate }} <i class="fa fa-times"></i>
</button>
</div>
</div>
</div>
</div>
<section class="poll_loaded padded consultation" *ngIf="!fetching && poll"> <section class="poll_loaded padded consultation" *ngIf="!fetching && poll">
<div class="step"> <div class="step">
<section class="main-title-poll rounded-block"> <section class="main-title-poll rounded-block">
<div class="rounded-block">
<label for="public_share_link">
{{ 'success.link' | translate }}
</label>
<div class="columns">
<div class="column">
<input type="text" [value]="pollService.getParticipationUrl()" id="public_share_link" />
</div>
<div class="column is-narrow">
<button
class="is-primary button"
(click)="pollService.copyText(pollService.getParticipationUrl())"
>
{{ 'success.copy' | translate }}
</button>
</div>
</div>
</div>
<div class="columns"> <div class="columns">
<div class="column"> <div class="column">
<h2 class="title is-2"> <h2 class="title is-2">
@ -58,6 +32,31 @@
{{ 'participation.menu_label' | translate }} {{ 'participation.menu_label' | translate }}
<i class="fa fa-chevron-down"></i> <i class="fa fa-chevron-down"></i>
</button> </button>
<div class="dropdown is-active">
<div class="dropdown-trigger">
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu2">
<span>Content</span>
<span class="icon is-small">
<i class="fas fa-angle-down" aria-hidden="true"></i>
</span>
</button>
</div>
<div class="dropdown-menu" id="dropdown-menu2" role="menu">
<div class="dropdown-content">
<div class="dropdown-item">
<p>You can insert <strong>any type of content</strong> within the dropdown menu.</p>
</div>
<hr class="dropdown-divider" />
<div class="dropdown-item">
<p>You simply need to use a <code>&lt;div&gt;</code> instead.</p>
</div>
<hr class="dropdown-divider" />
<a href="#" class="dropdown-item">
This is a link
</a>
</div>
</div>
</div>
</div> </div>
</div> </div>