unify update config after fetching a poll config

This commit is contained in:
Baptiste Lemoine 2020-02-04 11:35:29 +01:00
parent 63e1a5e899
commit dd9e8950f4
7 changed files with 14 additions and 38 deletions

View File

@ -54,6 +54,7 @@ import {ErasableInputComponent} from './ui/erasable-input/erasable-input.compone
import {ConfirmDialogModule} from 'primeng/confirmdialog'; import {ConfirmDialogModule} from 'primeng/confirmdialog';
import {DialogModule} from 'primeng/dialog'; import {DialogModule} from 'primeng/dialog';
import {DateValueAccessorModule} from "angular-date-value-accessor"; import {DateValueAccessorModule} from "angular-date-value-accessor";
import {CopyTextComponent} from './ui/copy-text/copy-text.component';
export class MyMissingTranslationHandler implements MissingTranslationHandler { export class MyMissingTranslationHandler implements MissingTranslationHandler {
handle(params: MissingTranslationHandlerParams) { handle(params: MissingTranslationHandlerParams) {
@ -97,6 +98,7 @@ export function HttpLoaderFactory(http: HttpClient) {
VotingCommentComponent, VotingCommentComponent,
ResettableInputDirective, ResettableInputDirective,
ErasableInputComponent, ErasableInputComponent,
CopyTextComponent,
], ],
imports: [ imports: [

View File

@ -54,6 +54,7 @@ export class PollConfig {
urlSlugPublic = null; urlSlugPublic = null;
urlPublic = environment.baseHref + '/#/poll/id/3'; urlPublic = environment.baseHref + '/#/poll/id/3';
urlAdmin = environment.baseHref + '/#/admin/d65es45fd45sdf45sd345f312sdf31sgfd345'; urlAdmin = environment.baseHref + '/#/admin/d65es45fd45sdf45sd345f312sdf31sgfd345';
adminKey = '';
canModifyAnswers = 1;// everybody, self, nobody (= just admin) canModifyAnswers = 1;// everybody, self, nobody (= just admin)
whoModifiesAnswers = "self";// everybody, self, nobody (= just admin) whoModifiesAnswers = "self";// everybody, self, nobody (= just admin)
whoCanChangeAnswers = 'everybody';// everybody, self, nobody (= just admin) whoCanChangeAnswers = 'everybody';// everybody, self, nobody (= just admin)

View File

@ -21,15 +21,7 @@
<a href="{{config.urlAdmin}}" >{{config.urlAdmin}} <a href="{{config.urlAdmin}}" >{{config.urlAdmin}}
</a > </a >
</p > </p >
<button <framadate-copy-text [textToCopy]='config.urlAdmin' ></framadate-copy-text >
class="btn btn--primary"
(click)="copyLink(config.urlAdmin)"
[ngxClipboard]
cbContent="{{config.urlAdmin}}"
>
<i class="fa fa-copy" ></i >
Copier le lien
</button >
<a href="{{config.urlAdmin}}" > <a href="{{config.urlAdmin}}" >
Voir le sondage coté administrateur·ice Voir le sondage coté administrateur·ice
</a > </a >
@ -48,15 +40,7 @@
</a > </a >
</p > </p >
<button <framadate-copy-text [textToCopy]='config.urlPublic' ></framadate-copy-text >
class="btn btn--primary"
(click)="copyLink(config.urlPublic)"
[ngxClipboard]
cbContent="{{config.urlPublic}}"
>
<i class="fa fa-copy" ></i >
Copier le lien
</button >
<a href="{{config.urlPublic}}" > <a href="{{config.urlPublic}}" >
Voir le sondage Voir le sondage
</a > </a >

View File

@ -34,7 +34,6 @@
<!-- </ul >--> <!-- </ul >-->
<!-- </nav >--> <!-- </nav >-->
</div > </div >
<section class="name" > <section class="name" >
<label for="name" > <label for="name" >
@ -143,14 +142,8 @@
{{config.currentPoll.urlPublic}} {{config.currentPoll.urlPublic}}
</a > </a >
</p > </p >
<button
class=" btn btn--primary btn--outline" <framadate-copy-text [textToCopy]='config.currentPoll.urlPublic' ></framadate-copy-text >
[ngxClipboard]
[cbContent]="config.currentPoll.urlPublic"
id="copyLink" >
<i class='fa fa-copy' ></i >
{{"admin.copy_link" |translate}}
</button >
<h3 class="margin-top-x6 margin-btm-x3" > <h3 class="margin-top-x6 margin-btm-x3" >
Exporter/Imprimer Exporter/Imprimer
</h3 > </h3 >

View File

@ -20,7 +20,7 @@ export class PollDisplayComponent extends BaseComponent implements OnInit {
public activeRoute: ActivatedRoute) { public activeRoute: ActivatedRoute) {
super(config); super(config);
this.activeRoute.paramMap.subscribe(params => { this.activeRoute.paramMap.subscribe(params => {
console.log('params', params) console.log('params', params);
this.config.pollId = params.get('poll'); this.config.pollId = params.get('poll');
this.config.pollSlug = params.get('pollSlug'); this.config.pollSlug = params.get('pollSlug');
if (!this.config.loading) { if (!this.config.loading) {
@ -41,24 +41,21 @@ export class PollDisplayComponent extends BaseComponent implements OnInit {
const pollSlug = this.activeRoute.snapshot.params.pollSlug; const pollSlug = this.activeRoute.snapshot.params.pollSlug;
if (!environment.production) { if (!environment.production) {
console.log('mockPoll3', mockPoll3) console.log('mockPoll3', mockPoll3);
this.config.currentPoll = mockPoll3; this.config.currentPoll = mockPoll3;
return; return;
} }
if (id) { if (id) {
this.config.loading = true; this.config.loading = true;
this.config.pollId = id;
// store it in the poll property here // store it in the poll property here
this.config.getPollById(id).subscribe( this.config.getPollById(id).subscribe(
(res: any) => { (res: any) => {
console.log('res', res); console.log('res', res);
this.config.updateCurrentPollFromResponse(res);
this.config.currentPoll = res;
this.config.loading = false; this.config.loading = false;
}, (e) => { }, (e) => {
// handle need for a password // handle need for a password
console.log('e', e) console.log('e', e);
this.config.handleError(e) this.config.handleError(e)
} }
); );
@ -66,10 +63,8 @@ export class PollDisplayComponent extends BaseComponent implements OnInit {
this.config.loading = true; this.config.loading = true;
this.config.getPollByURL(pollSlug).subscribe( this.config.getPollByURL(pollSlug).subscribe(
(res: any) => { (res: any) => {
console.log('res', res)
this.config.pollId = res.id;
this.config.currentPoll = res;
this.config.loading = false; this.config.loading = false;
this.config.updateCurrentPollFromResponse(res);
}, (e) => { }, (e) => {
// handle need for a password // handle need for a password
this.config.handleError(e) this.config.handleError(e)

View File

@ -121,7 +121,7 @@
<a [href]="'/#/vote/poll/slug/' + config.customUrl" > <a [href]="'/#/vote/poll/slug/' + config.customUrl" >
{{environment.baseHref + '#/vote/poll/slug/' + config.customUrl}} {{environment.baseHref + '#/vote/poll/slug/' + config.customUrl}}
</a > </a >
<framadate-copy-text [textToCopy]='config.urlPublic' ></framadate-copy-text >
</div > </div >
<br > <br >
<label for="passwordAccess" > <label for="passwordAccess" >

View File

@ -288,6 +288,7 @@ export class ConfigService extends PollConfig {
if (res.poll.customUrl) { if (res.poll.customUrl) {
this.urlSlugPublic = this.baseHref + '#/vote/poll/id/' + res.poll.customUrl; this.urlSlugPublic = this.baseHref + '#/vote/poll/id/' + res.poll.customUrl;
} }
this.adminKey = res.admin_key;
this.urlAdmin = this.baseHref + '#/admin/' + res.admin_key; this.urlAdmin = this.baseHref + '#/admin/' + res.admin_key;
} }