make common app-nav-steps component

This commit is contained in:
Tykayn 2021-12-02 15:52:08 +01:00 committed by tykayn
parent 1307b9f1a3
commit 0cb295cce0
16 changed files with 130 additions and 108 deletions

View File

@ -35,6 +35,7 @@ import { OptionLinkComponent } from './form/option-link/option-link.component';
import { TextListComponent } from './form/text-list/text-list.component';
import { HoursComponent } from './form/hours/hours.component';
import { ActionsMenuComponent } from './actions-menu/actions-menu.component';
import { NavStepsComponent } from './nav-steps/nav-steps.component';
@NgModule({
declarations: [
@ -65,6 +66,7 @@ import { ActionsMenuComponent } from './actions-menu/actions-menu.component';
TextListComponent,
HoursComponent,
ActionsMenuComponent,
NavStepsComponent,
],
imports: [
AdministrationRoutingModule,

View File

@ -3,23 +3,18 @@
<section class="supplement">
<app-stepper [step_current]="5" [step_max]="pollService.step_max"></app-stepper>
<app-errors-list [form]="pollService.form"></app-errors-list>
<fieldset class="advanced-config">
<fieldset class="complete well" *ngIf="environment.advanced_options_display">
<div class="advanced-config">
<h2>
Configuration avancée
</h2>
<div class="complete" *ngIf="environment.advanced_options_display">
<app-advanced-config [form]="pollService.form"></app-advanced-config>
</fieldset>
</fieldset>
<div class="columns">
<div class="column">
<button class="button is-default is-fullwidth" [routerLink]="['/administration/step/4']">
Précédent
</button>
</div>
<div class="column">
<button class="button is-primary is-fullwidth" [routerLink]="['/administration/step/6']">
Suivant
</button>
</div>
</div>
<app-nav-steps
[next_step_number]="pollService.step_current + 1"
[previous_step_number]="pollService.step_current - 1"
></app-nav-steps>
</section>
</div>
</div>

View File

@ -120,16 +120,8 @@
</div>
</div>
</div>
<div class="columns">
<div class="column">
<button class="button is-secondary is-fullwidth" [routerLink]="['/administration/step/3']">
Précédent
</button>
</div>
<div class="column">
<button class="btn is-primary is-fullwidth" [routerLink]="['/administration/step/5']">
Suivant
</button>
</div>
</div>
<app-nav-steps
[next_step_number]="pollService.step_current + 1"
[previous_step_number]="pollService.step_current - 1"
></app-nav-steps>
</div>

View File

@ -73,14 +73,11 @@
></button>
</ng-template>
</p-confirmDialog>
<div class="bottom-step-buttons">
<div class="columns">
<div class="column"></div>
<div class="column">
<button class="button is-primary is-fullwidth" [routerLink]="['/administration/step/2']">
Suivant
</button>
</div>
</div>
</div>
<app-nav-steps
[display_previous_button]="false"
[display_next_button]="true"
[next_step_number]="pollService.step_current + 1"
[previous_step_number]="pollService.step_current - 1"
></app-nav-steps>
</div>

View File

@ -1,4 +1,4 @@
<div class="step-container min-height step-resume">
<div class="step min-height step-resume">
<app-stepper [step_current]="7" [step_max]="pollService.step_max"></app-stepper>
<div class="columns content">
<div class="column">
@ -80,20 +80,12 @@
</div>
</div>
</div>
<div class="columns">
<div class="column">
<button class="button is-secondary is-fullwidth" [routerLink]="['/administration/step/6']">
précédent
</button>
</div>
<div class="column">
<button class="button is-finish is-fullwidth" (click)="createPoll()">
<!-- [disabled]="!pollService.form.valid"-->
<i class="fa fa-save"></i>
Enregistrer le sondage
</button>
</div>
</div>
<app-nav-steps
[next_step_number]="pollService.step_current + 1"
[previous_step_number]="pollService.step_current - 1"
[is_finish_step]="true"
[endAction]="createPoll"
></app-nav-steps>
</div>
</div>
</div>

View File

@ -1,4 +1,4 @@
<div class="step-container min-height">
<div class="step min-height">
<app-stepper [step_current]="6" [step_max]="pollService.step_max"></app-stepper>
<div class="min-height">
<form action="#" [formGroup]="pollService.form">
@ -18,16 +18,8 @@
<input class="input" type="text" id="email" formControlName="creatorEmail" />
</form>
</div>
<div class="columns">
<div class="column">
<button class="button is-secondary is-fullwidth" [routerLink]="['/administration/step/5']">
Précédent
</button>
</div>
<div class="column">
<button class="btn is-primary is-fullwidth" [routerLink]="['/administration/step/7']">
Suivant
</button>
</div>
</div>
<app-nav-steps
[next_step_number]="pollService.step_current + 1"
[previous_step_number]="pollService.step_current - 1"
></app-nav-steps>
</div>

View File

@ -35,16 +35,7 @@
></app-day-list>
</div>
</div>
<div class="columns">
<div class="column">
<button class="button is-secondary is-fullwidth" [routerLink]="['/administration/step/2']">
précédent
</button>
</div>
<div class="column">
<!-- [disabled]="form.invalid"-->
<button class="button is-primary is-fullwidth" [routerLink]="['/administration/step/4']">
suivant
</button>
</div>
</div>
<app-nav-steps
[next_step_number]="pollService.step_current + 1"
[previous_step_number]="pollService.step_current - 1"
></app-nav-steps>

View File

@ -41,20 +41,9 @@
</div>
</div>
</div>
<div class="bottom-step-buttons">
<div class="columns">
<div class="column">
<button class="button is-secondary is-fullwidth" [routerLink]="['/administration/step/1']">
précédent
</button>
</div>
<div class="column">
<!-- [disabled]="form.invalid"-->
<button class="button is-primary is-fullwidth" [routerLink]="['/administration/step/3']">
suivant
</button>
</div>
</div>
</div>
<app-nav-steps
[next_step_number]="pollService.step_current + 1"
[previous_step_number]="pollService.step_current - 1"
></app-nav-steps>
</form>
</div>

View File

@ -0,0 +1,30 @@
<div class="bottom-step-buttons">
<div class="columns">
<div class="column">
<button
*ngIf="display_previous_button"
class="button is-secondary is-fullwidth"
[routerLink]="['/administration/step/' + previous_step_number]"
>
Précédent
</button>
</div>
<div class="column">
<button
*ngIf="display_next_button"
class="button is-fullwidth"
[ngClass]="{ 'is-finish': is_finish_step, 'is-primary': !is_finish_step }"
[routerLink]="['/administration/step/' + next_step_number]"
(click)="is_finish_step ? runEndAction() : null"
>
<span *ngIf="is_finish_step">
<i class="fa fa-save"></i>
Enregistrer le sondage
</span>
<span *ngIf="!is_finish_step">
Suivant
</span>
</button>
</div>
</div>
</div>

View File

@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NavStepsComponent } from './nav-steps.component';
describe('NavStepsComponent', () => {
let component: NavStepsComponent;
let fixture: ComponentFixture<NavStepsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [NavStepsComponent],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NavStepsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,29 @@
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 'app-nav-steps',
templateUrl: './nav-steps.component.html',
styleUrls: ['./nav-steps.component.scss'],
})
export class NavStepsComponent implements OnInit {
@Input()
display_next_button = true;
@Input()
previous_step_number = 1;
@Input()
next_step_number = 1;
@Input()
display_previous_button = true;
@Input()
is_finish_step = false;
@Input()
endAction: Function;
constructor() {}
ngOnInit(): void {}
runEndAction() {
return this.endAction();
}
}

View File

@ -62,18 +62,10 @@
<h3 class="step-counter-text">Étape {{ step_current }} sur {{ step_max }}</h3>
</div>
<div class="column is-narrow has-text-right">
<p-button class="cancel-button" (click)="showCancelDialog()">
Annuler <i class="fa fa-times"></i>
</p-button>
<a class="cancel-button" (click)="showCancelDialog()"> Annuler <i class="fa fa-times"></i> </a>
</div>
</div>
</div>
<p-confirmDialog
[style]="{ width: '50vw' }"
key="positionDialog"
[baseZIndex]="10000"
rejectButtonStyleClass="p-button-outlined"
></p-confirmDialog>
<div class="step-bar-container" style="width: 100%;">
<div class="step-bar-progress" [ngStyle]="{ width: (step_current / step_max) * 100 + '%' }"></div>
</div>

View File

@ -30,6 +30,8 @@ export class StepperComponent {
showCancelDialog() {
this.confirmationService.confirm({
header: 'Quitter ?',
acceptLabel: 'Quitter',
rejectLabel: 'Rester',
message: 'Souhaitez-vous vraiment quitter le sondage ? Toutes les informations seront effacées.',
accept: () => this.goToHome(),
reject: () => console.log('rejected'),

View File

@ -15,7 +15,7 @@ const apiV1 = {
};
export const environment = {
advanced_options_display: false,
advanced_options_display: true,
appLogo: 'assets/img/logo.png',
appTitle: 'FramaDate',
appVersion: '2.2.1',

View File

@ -297,14 +297,9 @@ mat-checkbox {
}
.advanced-config {
.box {
background: $light;
border: 3px solid $primary-color;
}
.work-in-progress {
padding: 1em 2em;
background: $border-color;
border-left: 3px solid $warning-dark;
color: $light;
}
}