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

View File

@ -54,6 +54,7 @@ export class PollConfig {
urlSlugPublic = null;
urlPublic = environment.baseHref + '/#/poll/id/3';
urlAdmin = environment.baseHref + '/#/admin/d65es45fd45sdf45sd345f312sdf31sgfd345';
adminKey = '';
canModifyAnswers = 1;// everybody, self, nobody (= just admin)
whoModifiesAnswers = "self";// 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 >
</p >
<button
class="btn btn--primary"
(click)="copyLink(config.urlAdmin)"
[ngxClipboard]
cbContent="{{config.urlAdmin}}"
>
<i class="fa fa-copy" ></i >
Copier le lien
</button >
<framadate-copy-text [textToCopy]='config.urlAdmin' ></framadate-copy-text >
<a href="{{config.urlAdmin}}" >
Voir le sondage coté administrateur·ice
</a >
@ -48,15 +40,7 @@
</a >
</p >
<button
class="btn btn--primary"
(click)="copyLink(config.urlPublic)"
[ngxClipboard]
cbContent="{{config.urlPublic}}"
>
<i class="fa fa-copy" ></i >
Copier le lien
</button >
<framadate-copy-text [textToCopy]='config.urlPublic' ></framadate-copy-text >
<a href="{{config.urlPublic}}" >
Voir le sondage
</a >

View File

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

View File

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

View File

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

View File

@ -288,6 +288,7 @@ export class ConfigService extends PollConfig {
if (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;
}