include advanced choices and toggle visibility of sub component

This commit is contained in:
Tykayn 2021-02-04 19:04:20 +01:00 committed by tykayn
parent 1717f738d1
commit feb0de8270
5 changed files with 148 additions and 126 deletions

View File

@ -1,3 +1,4 @@
<form [formGroup]="form">
<fieldset class="complete well"> <fieldset class="complete well">
<h2>{{ 'creation.advanced' | translate }}</h2> <h2>{{ 'creation.advanced' | translate }}</h2>
<label for="descr">Description (optionnel)</label> <label for="descr">Description (optionnel)</label>
@ -87,3 +88,4 @@
La réponse « peut-être » sera disponible La réponse « peut-être » sera disponible
</mat-checkbox> </mat-checkbox>
</fieldset> </fieldset>
</form>

View File

@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { Poll } from '../../../../core/models/poll.model';
import { FormGroup } from '@angular/forms';
@Component({ @Component({
selector: 'app-advanced-config', selector: 'app-advanced-config',
@ -7,7 +9,10 @@ import { Component, OnInit } from '@angular/core';
}) })
export class AdvancedConfigComponent implements OnInit { export class AdvancedConfigComponent implements OnInit {
public urlPrefix: string = window.location.origin + '/participation/'; public urlPrefix: string = window.location.origin + '/participation/';
@Input()
public poll?: Poll;
@Input()
public form: FormGroup;
constructor() {} constructor() {}
ngOnInit(): void {} ngOnInit(): void {}

View File

@ -1,8 +1,18 @@
<form [formGroup]="form"> <form [formGroup]="form">
<h1>
{{ 'creation.title' | translate }}
</h1>
<p class="subtitle">
{{ 'creation.want' | translate }}
</p>
<div class="columns"> <div class="columns">
<span> <div class="column">
<p>
{{ 'creation.choose_title' | translate }} {{ 'creation.choose_title' | translate }}
</span> </p>
<br />
<label class="hidden" for="title">Titre</label> <label class="hidden" for="title">Titre</label>
<input <input
#title #title
@ -14,11 +24,18 @@
(change)="updateSlug()" (change)="updateSlug()"
required required
/> />
<button mat-button *ngIf="title.value" matSuffix mat-icon-button aria-label="Clear" (click)="title.value = ''"> <button
mat-button
*ngIf="title.value"
matSuffix
mat-icon-button
aria-label="Clear"
(click)="title.value = ''"
>
<i class="fa fa-close"></i> <i class="fa fa-close"></i>
</button> </button>
</div>
<div> <div class="column">
<label class="" for="creatorEmail"> <label class="" for="creatorEmail">
<span> <span>
{{ 'creation.name' | translate }} {{ 'creation.name' | translate }}

View File

@ -16,6 +16,7 @@ import { Poll } from '../../../../core/models/poll.model';
export class BaseConfigComponent implements OnInit { export class BaseConfigComponent implements OnInit {
@Input() @Input()
public poll?: Poll; public poll?: Poll;
@Input()
public form: FormGroup; public form: FormGroup;
constructor( constructor(

View File

@ -1,17 +1,6 @@
<div class="admin-form padded"> <div class="admin-form padded">
<h1> <form [formGroup]="form">
{{ 'creation.title' | translate }} <app-base-config [poll]="poll" [form]="form"></app-base-config>
</h1>
<div class="validation">
<div class="has-background-danger" *ngIf="!form.valid">
le formulaire est invalide
<pre>
{{ form.errors | json }}
</pre
>
</div>
</div>
<app-base-config></app-base-config>
<!-- <app-kind-select></app-kind-select>--> <!-- <app-kind-select></app-kind-select>-->
<!-- choix spécialement pour les dates--> <!-- choix spécialement pour les dates-->
@ -21,11 +10,10 @@
<i class="fa fa-save"></i> <i class="fa fa-save"></i>
{{ 'creation.advanced' | translate }} {{ 'creation.advanced' | translate }}
</button> </button>
<!-- <app-advanced-config ng-if="advancedDisplayEnabled"></app-advanced-config>--> <app-advanced-config [poll]="poll" [form]="form" *ngIf="advancedDisplayEnabled"></app-advanced-config>
<hr /> <hr />
<form [formGroup]="form">
<div class="columns"> <div class="columns">
<div class="column"></div> <div class="column"></div>
<div class="column"> <div class="column">
@ -39,5 +27,14 @@
</button> </button>
</div> </div>
</div> </div>
<div class="validation">
<div class="has-background-danger" *ngIf="!form.valid">
le formulaire est invalide
<pre>
{{ form.errors | json }}
</pre
>
</div>
</div>
</form> </form>
</div> </div>