forked from tykayn/funky-framadate-front
⚡ example of navigation
This commit is contained in:
parent
c048c35b9d
commit
42f229f686
@ -1,12 +1,17 @@
|
|||||||
<!--The content below is only a placeholder and can be replaced.-->
|
|
||||||
<div style="text-align:center">
|
<div style="text-align:center">
|
||||||
<h1 >
|
<a [routerLink]="'home'"
|
||||||
<span i18n>Bienvenue sur </span>
|
class="home_link"
|
||||||
<span class="logo_first">Frama</span>
|
aria-roledescription="home">
|
||||||
<span class="logo_second">date</span>
|
<h1>
|
||||||
</h1>
|
<span i18n>Bienvenue sur </span>
|
||||||
<p i18n>
|
<span class="logo_first">Frama</span>
|
||||||
Ceci est une démo
|
<span class="logo_second">date</span>
|
||||||
</p>
|
</h1>
|
||||||
|
</a>
|
||||||
|
<i i18n>
|
||||||
|
Ceci est une démo
|
||||||
|
</i>
|
||||||
</div>
|
</div>
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
|
<framadate-navigation></framadate-navigation>
|
||||||
|
<framadate-debugger></framadate-debugger>
|
||||||
|
@ -12,6 +12,8 @@ import {NavigationComponent} from './ui/navigation/navigation.component';
|
|||||||
import {RouterModule} from '@angular/router';
|
import {RouterModule} from '@angular/router';
|
||||||
import {Routes} from './config/Routes';
|
import {Routes} from './config/Routes';
|
||||||
import {CommonModule} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
|
import { DatesComponent } from './pages/dates/dates.component';
|
||||||
|
import { DebuggerComponent } from './debugger/debugger.component';
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@ -22,6 +24,8 @@ import {CommonModule} from '@angular/common';
|
|||||||
PageKindComponent,
|
PageKindComponent,
|
||||||
HeaderComponent,
|
HeaderComponent,
|
||||||
NavigationComponent,
|
NavigationComponent,
|
||||||
|
DatesComponent,
|
||||||
|
DebuggerComponent,
|
||||||
|
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
|
39
src/app/config.service.ts
Normal file
39
src/app/config.service.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* une option de date dans les sondages spéciaux
|
||||||
|
*/
|
||||||
|
export interface DateOption {
|
||||||
|
text: string;
|
||||||
|
start?: string;
|
||||||
|
end?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* le service transverse à chaque page qui permet de syncroniser la configuration de sondage souhaitée
|
||||||
|
*/
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class ConfigService {
|
||||||
|
step = 0;
|
||||||
|
stepMax = 3;
|
||||||
|
pollType = 'classic';
|
||||||
|
title = '';
|
||||||
|
description = '';
|
||||||
|
allowSeveralHours = true;
|
||||||
|
dateList: DateOption[] = [];
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
set(key, val) {
|
||||||
|
this[key] = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendForm() {
|
||||||
|
// todo
|
||||||
|
console.log('sends the form');
|
||||||
|
alert('envoi de formulaire en XHR à faire');
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +0,0 @@
|
|||||||
/**
|
|
||||||
* used as a global form configuration object to generate the form to send
|
|
||||||
*/
|
|
||||||
export var PollConfig = {
|
|
||||||
poll_type: "simple",
|
|
||||||
allow_stuff: true,
|
|
||||||
};
|
|
@ -1,12 +1,15 @@
|
|||||||
import {FormContainerComponent} from '../form-container/form-container.component';
|
import {FormContainerComponent} from '../form-container/form-container.component';
|
||||||
import {PageKindComponent} from '../pages/page-kind/page-kind.component';
|
import {PageKindComponent} from '../pages/page-kind/page-kind.component';
|
||||||
|
import {DatesComponent} from '../pages/dates/dates.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* each step in the form is a component inheriting from the base
|
* each step in the form is a component
|
||||||
*/
|
*/
|
||||||
export const Routes =
|
export const Routes =
|
||||||
[
|
[
|
||||||
{path: '', component: FormContainerComponent},
|
{path: '', component: FormContainerComponent},
|
||||||
{path: 'step/1', component: PageKindComponent}
|
{path: 'home', component: FormContainerComponent},
|
||||||
]
|
{path: 'step/date', component: DatesComponent},
|
||||||
|
{path: 'step/kind', component: PageKindComponent}
|
||||||
|
]
|
||||||
;
|
;
|
||||||
|
@ -1,92 +1,56 @@
|
|||||||
<div class="description">
|
<div class="description">
|
||||||
<router-outlet></router-outlet>
|
<fieldset>
|
||||||
<h2 class="title" i18n>
|
|
||||||
titre de question
|
<router-outlet></router-outlet>
|
||||||
</h2>
|
<span class="pre-selector" i18n>
|
||||||
<span class="pre-selector" i18n>
|
Je veux créer un sondage
|
||||||
Je veux créer un sondage
|
</span>
|
||||||
|
<select
|
||||||
|
id="selector"
|
||||||
|
name="selector"
|
||||||
|
[(ngModel)]="config.pollType"
|
||||||
|
>
|
||||||
|
<option value="dates">
|
||||||
|
spécial dates
|
||||||
|
</option>
|
||||||
|
<option value="classic">
|
||||||
|
classique
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<span class="post-selector">
|
||||||
</span>
|
</span>
|
||||||
<select id="selector" name="selector" [(ngModel)]="pollConfig.poll_type">
|
<hr>
|
||||||
<option value="dates">
|
<div>
|
||||||
spécial dates
|
|
||||||
</option>
|
|
||||||
<option value="classic">
|
|
||||||
classique
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<span class="post-selector">
|
|
||||||
</span>
|
|
||||||
<hr>
|
|
||||||
<label for="poll_title" class="title-label" i18n>
|
|
||||||
Dont le titre sera
|
|
||||||
</label>
|
|
||||||
<input type="text" id="poll_title" name="poll_title" [(ngModel)]="pollConfig.title">
|
|
||||||
|
|
||||||
<label for="poll_description" class="title-label" i18n>
|
<label for="poll_title" class="title-label" i18n>
|
||||||
et la description serait
|
Dont le titre sera
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="poll_description" name="poll_description" [(ngModel)]="pollConfig.description" max="1000">
|
<input
|
||||||
|
type="text"
|
||||||
|
id="poll_title"
|
||||||
|
name="poll_title"
|
||||||
|
[(ngModel)]="config.title">
|
||||||
|
|
||||||
<hr>
|
</div>
|
||||||
<span i18n>
|
<div>
|
||||||
Choix cornélien:
|
|
||||||
</span>
|
|
||||||
<!-- todo: factoriser les boutons-->
|
|
||||||
<button
|
|
||||||
(click)="selectOption('poll_type' , 'classic')"
|
|
||||||
[class.active]="pollConfig.type_classic"
|
|
||||||
[disabled]="!formIsValid"
|
|
||||||
class="btn btn-primary next"
|
|
||||||
>
|
|
||||||
<span i18n>
|
|
||||||
sondage classique
|
|
||||||
</span>
|
|
||||||
<span *ngIf="pollConfig.poll_type == 'classic'">
|
|
||||||
[x]
|
|
||||||
</span>
|
|
||||||
|
|
||||||
</button>
|
<label for="poll_description" class="title-label" i18n>
|
||||||
<button
|
et la description serait
|
||||||
(click)="selectOption('poll_type' ,'dates')"
|
</label>
|
||||||
[class.active]="pollConfig.type_dates"
|
<textarea
|
||||||
[disabled]="!formIsValid"
|
id="poll_description"
|
||||||
class="btn btn-primary next"
|
name="poll_description"
|
||||||
>
|
[(ngModel)]="config.description"
|
||||||
<span i18n>
|
cols="50" lines="5"></textarea>
|
||||||
sondage spécial date
|
|
||||||
</span>
|
|
||||||
<span *ngIf="pollConfig.poll_type == 'dates'">
|
|
||||||
[x]
|
|
||||||
</span>
|
|
||||||
|
|
||||||
</button>
|
</div>
|
||||||
|
|
||||||
</div>
|
<a
|
||||||
<hr>
|
[routerLink]="'/step/kind'"
|
||||||
<framadate-navigation></framadate-navigation>
|
class="btn striked"
|
||||||
<hr>
|
i18n="start_form">
|
||||||
<div class="well debug">
|
C'est parti
|
||||||
<strong>
|
</a>
|
||||||
|
<hr>
|
||||||
<span i18n>
|
</fieldset>
|
||||||
infos de debug
|
|
||||||
</span>
|
|
||||||
</strong>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
étape actuelle {{progressionStep}} / {{progressionStepMax}}
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
formulaire valide : {{formIsValid}}
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
type de formulaire: {{pollConfig.poll_type}}
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
pollConfig:
|
|
||||||
<pre>
|
|
||||||
{{pollConfig|json}}
|
|
||||||
</pre>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {ProgressionService} from '../progression.service';
|
import {ConfigService} from '../config.service';
|
||||||
|
|
||||||
// import {PollConfig} from '../config/PollConfig';
|
// import {PollConfig} from '../config/PollConfig';
|
||||||
|
|
||||||
@ -14,18 +14,10 @@ import {ProgressionService} from '../progression.service';
|
|||||||
*/
|
*/
|
||||||
export class FormContainerComponent implements OnInit {
|
export class FormContainerComponent implements OnInit {
|
||||||
|
|
||||||
// todo make a class in the config folder of this
|
|
||||||
private pollConfig: any = {
|
|
||||||
poll_type: 'classic',
|
|
||||||
title: '',
|
|
||||||
description: '',
|
|
||||||
allow_stuff: true,
|
|
||||||
};
|
|
||||||
private progressionStep = 0;
|
private progressionStep = 0;
|
||||||
private progressionStepMax = 0;
|
|
||||||
private formIsValid = true;
|
|
||||||
|
|
||||||
constructor(private progression: ProgressionService) {
|
|
||||||
|
constructor(private config: ConfigService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,11 +32,6 @@ export class FormContainerComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectOption(key: string, val: any) {
|
|
||||||
this.pollConfig[key] = val;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
checkValidity() {
|
checkValidity() {
|
||||||
// TODO with form controls
|
// TODO with form controls
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {ConfigService} from '../../config.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'framadate-base-page',
|
selector: 'framadate-base-page',
|
||||||
templateUrl: './base-page.component.html',
|
templateUrl: './base-page.component.html',
|
||||||
styleUrls: ['./base-page.component.scss']
|
styleUrls: ['./base-page.component.scss']
|
||||||
})
|
})
|
||||||
/**
|
/**
|
||||||
* base page is aware of the state of the filling
|
* base page is aware of the state of the filling
|
||||||
*/
|
*/
|
||||||
export class BasePageComponent implements OnInit {
|
export class BasePageComponent implements OnInit {
|
||||||
|
|
||||||
constructor() { }
|
constructor(private config: ConfigService) {
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
30
src/app/pages/dates/dates.component.html
Normal file
30
src/app/pages/dates/dates.component.html
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<div i18n>
|
||||||
|
Config spécialement pour les dates
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<select name="multi_hours" id="multi_hours"
|
||||||
|
[(ngModel)]="config.allowSeveralHours">
|
||||||
|
<option value="yes"></option>
|
||||||
|
<option value="no"></option>
|
||||||
|
</select>
|
||||||
|
<label for="multi_hours" i18n>
|
||||||
|
Je souhaite mettre des créneaux horaires différents pour chaque jour
|
||||||
|
</label>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
(click)="addDate()"
|
||||||
|
i18n>
|
||||||
|
Ajouter une plage de dates
|
||||||
|
</button>
|
||||||
|
<div class="dates-list">
|
||||||
|
{{config.dateList.length}}
|
||||||
|
<span i18n>
|
||||||
|
choix de Dates
|
||||||
|
</span>
|
||||||
|
<div
|
||||||
|
*ngFor="let choice of config.dateList"
|
||||||
|
class="date-choice">
|
||||||
|
{{choice.text}}
|
||||||
|
</div>
|
||||||
|
</div>
|
0
src/app/pages/dates/dates.component.scss
Normal file
0
src/app/pages/dates/dates.component.scss
Normal file
25
src/app/pages/dates/dates.component.spec.ts
Normal file
25
src/app/pages/dates/dates.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { DatesComponent } from './dates.component';
|
||||||
|
|
||||||
|
describe('DatesComponent', () => {
|
||||||
|
let component: DatesComponent;
|
||||||
|
let fixture: ComponentFixture<DatesComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ DatesComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(DatesComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
22
src/app/pages/dates/dates.component.ts
Normal file
22
src/app/pages/dates/dates.component.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
import {ConfigService} from '../../config.service';
|
||||||
|
import {BasePageComponent} from '../base-page/base-page.component';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'framadate-dates',
|
||||||
|
templateUrl: './dates.component.html',
|
||||||
|
styleUrls: ['./dates.component.scss']
|
||||||
|
})
|
||||||
|
export class DatesComponent extends BasePageComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(config: ConfigService) {
|
||||||
|
super(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
addDate() {
|
||||||
|
console.log('TODO');
|
||||||
|
}
|
||||||
|
}
|
@ -1 +1,2 @@
|
|||||||
<p>page-kind works!</p>
|
<p>cette étape est en cours de développement. <br> S'inspirer de la page de FormContainer pour réaliser d'autres pages
|
||||||
|
</p>
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {BasePageComponent} from '../base-page/base-page.component';
|
import {BasePageComponent} from '../base-page/base-page.component';
|
||||||
|
import {ConfigService} from '../../config.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'framadate-page-kind',
|
selector: 'framadate-page-kind',
|
||||||
templateUrl: './page-kind.component.html',
|
templateUrl: './page-kind.component.html',
|
||||||
styleUrls: ['./page-kind.component.scss']
|
styleUrls: ['./page-kind.component.scss']
|
||||||
})
|
})
|
||||||
export class PageKindComponent extends BasePageComponent implements OnInit {
|
export class PageKindComponent extends BasePageComponent implements OnInit {
|
||||||
|
|
||||||
constructor() {
|
constructor(config: ConfigService) {
|
||||||
super();
|
super(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { ProgressionService } from './progression.service';
|
import { ConfigService } from './config.service';
|
||||||
|
|
||||||
describe('ProgressionService', () => {
|
describe('ConfigService', () => {
|
||||||
beforeEach(() => TestBed.configureTestingModule({}));
|
beforeEach(() => TestBed.configureTestingModule({}));
|
||||||
|
|
||||||
it('should be created', () => {
|
it('should be created', () => {
|
||||||
const service: ProgressionService = TestBed.get(ProgressionService);
|
const service: ConfigService = TestBed.get(ConfigService);
|
||||||
expect(service).toBeTruthy();
|
expect(service).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
import {Injectable} from '@angular/core';
|
|
||||||
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class ProgressionService {
|
|
||||||
private step: number;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +1,39 @@
|
|||||||
<div class="choices">
|
<div class="choices">
|
||||||
<button
|
|
||||||
(click)="nextPage()"
|
<a
|
||||||
[disabled]="!formIsValid"
|
class="btn btn-primary"
|
||||||
class="btn btn-primary next"
|
[routerLink]="'/step/date'">
|
||||||
>
|
Aller aux dates
|
||||||
|
</a>
|
||||||
|
<a
|
||||||
|
class="btn btn-primary"
|
||||||
|
[routerLink]="'/step/kind'">
|
||||||
|
Aller aux options classiques
|
||||||
|
</a>
|
||||||
|
<a
|
||||||
|
class="btn btn-primary"
|
||||||
|
[routerLink]="'/home'">
|
||||||
|
Accueil
|
||||||
|
</a>
|
||||||
|
<br>
|
||||||
|
<button
|
||||||
|
(click)="nextPage()"
|
||||||
|
[disabled]="!formIsValid"
|
||||||
|
class="btn btn-primary next"
|
||||||
|
>
|
||||||
<span i18n>
|
<span i18n>
|
||||||
précédent
|
précédent
|
||||||
</span>
|
</span>
|
||||||
<i class="fa fa-arrow-right"></i>
|
<i class="fa fa-arrow-right"></i>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
(click)="nextPage()"
|
(click)="nextPage()"
|
||||||
[disabled]="!formIsValid"
|
[disabled]="!formIsValid"
|
||||||
class="btn btn-primary next"
|
class="btn btn-primary next"
|
||||||
>
|
>
|
||||||
<span i18n>
|
<span i18n>
|
||||||
suivant
|
suivant
|
||||||
</span>
|
</span>
|
||||||
<i class="fa fa-arrow-right"></i>
|
<i class="fa fa-arrow-right"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
7
src/assets/_font.scss
Normal file
7
src/assets/_font.scss
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
body {
|
||||||
|
font-family: "DejaVu Sans Light", "Arial", "DejaVu Sans Mono";
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
font-family: "Brie Light", "Arial", "DejaVu Sans Mono";
|
||||||
|
}
|
@ -1,21 +1,40 @@
|
|||||||
input{
|
input, textarea,
|
||||||
background: $light;
|
select {
|
||||||
padding: 0.5em;
|
@extend .funky-box;
|
||||||
border:0;
|
|
||||||
border-bottom: 3px solid $main_color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
select{
|
.funky-box {
|
||||||
background: $light;
|
background: $light;
|
||||||
padding: 0.5em;
|
padding: 1em;
|
||||||
border:0;
|
border-radius: 0.25em;
|
||||||
|
border: 1px solid $main_color;
|
||||||
border-bottom: 3px solid $main_color_strong;
|
border-bottom: 3px solid $main_color_strong;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
color: $main_color_strong;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn{
|
// buttons
|
||||||
|
.btn {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 1em;
|
||||||
|
border-radius: 0.25em;
|
||||||
background: $main_color_strong;
|
background: $main_color_strong;
|
||||||
color: $light;
|
color: $light;
|
||||||
border: 0;
|
border: 0;
|
||||||
margin: 0 0.5em;
|
margin: 1em;
|
||||||
min-height: 1.5rem;
|
min-height: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home_link {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.striked {
|
||||||
|
background: linear-gradient($main_color, $main_color_strong);
|
||||||
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* You can add global styles to this file, and also import other style files */
|
/* You can add global styles to this file, and also import other style files */
|
||||||
@import "assets/variables";
|
@import "assets/variables";
|
||||||
|
@import "assets/font";
|
||||||
@import "assets/global_layout";
|
@import "assets/global_layout";
|
||||||
@import "assets/logo";
|
@import "assets/logo";
|
||||||
@import "assets/debug";
|
@import "assets/debug";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user