From 303457afd652a0cdd31daa3747d4f46823dee51e Mon Sep 17 00:00:00 2001 From: Tykayn Date: Tue, 19 Oct 2021 12:41:14 +0200 Subject: [PATCH] put poll actions in pollService, nav on step one two three --- src/app/app.component.html | 33 +++------ src/app/core/services/poll.service.ts | 10 +-- .../administration-routing.module.ts | 1 + .../administration/administration.module.ts | 2 + .../dev-menu/dev-menu.component.html | 14 ++++ .../dev-menu/dev-menu.component.scss | 0 .../dev-menu/dev-menu.component.spec.ts | 24 +++++++ .../dev-menu/dev-menu.component.ts | 14 ++++ .../administration/form/form.component.html | 15 +--- .../form/step-one/step-one.component.html | 25 ++++++- .../form/step-one/step-one.component.ts | 7 +- .../form/step-three/step-three.component.html | 70 +++++++++++++------ .../form/step-three/step-three.component.ts | 4 +- .../form/step-two/step-two.component.html | 21 ++++-- src/styles/dev-utilities/_debug.scss | 16 ++--- src/styles/partials/_form-controls.scss | 4 +- 16 files changed, 176 insertions(+), 84 deletions(-) create mode 100644 src/app/features/administration/dev-menu/dev-menu.component.html create mode 100644 src/app/features/administration/dev-menu/dev-menu.component.scss create mode 100644 src/app/features/administration/dev-menu/dev-menu.component.spec.ts create mode 100644 src/app/features/administration/dev-menu/dev-menu.component.ts diff --git a/src/app/app.component.html b/src/app/app.component.html index 477450fe..b95071d5 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,23 +1,10 @@ - - - - - - -
-
- -
- -
-
- menu - développeur -
-
- - -
-
-
-
+
+
+ +
+ +
+ + +
+
diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 5c9eda45..9ff8d134 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -1,4 +1,4 @@ -import { ChangeDetectorRef, Inject, Injectable } from '@angular/core'; +import { Inject, Injectable } from '@angular/core'; import { ActivatedRoute, ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router'; import { BehaviorSubject, Observable, Subscription } from 'rxjs'; @@ -120,6 +120,11 @@ export class PollService implements Resolve { return form; } + public updateSlug(): void { + console.log('this.form.value', this.form.value); + this.form.patchValue({ custom_url: this.makeSlug(this.form) }); + } + /** * auto fetch a poll when route is looking for one in the administration pattern * @param route @@ -334,7 +339,6 @@ export class PollService implements Resolve { initFormDefault(showDemoValues = true): void { this.form = this.createFormGroup(); - console.log('this.form ', this.form); this.setDefaultDatesForInterval(); if (showDemoValues) { @@ -363,7 +367,6 @@ export class PollService implements Resolve { }); } this.choices.push(newControlGroup); - console.log('this.choices.length', this.choices.length); this.focusOnChoice(this.choices.length - 1); } @@ -406,7 +409,6 @@ export class PollService implements Resolve { const pollUrl: Subscription = await this.apiService.createPoll(this._poll.getValue()); // TODO: Maybe handle the url to update currentPoll according to backend response if (pollUrl) { - console.log('pollUrl', pollUrl); this.toastService.display('Le sondage a été enregistré.'); } else { this.toastService.display('Le sondage n’a été correctement enregistré, veuillez ré-essayer.'); diff --git a/src/app/features/administration/administration-routing.module.ts b/src/app/features/administration/administration-routing.module.ts index af3a55d7..63d10598 100644 --- a/src/app/features/administration/administration-routing.module.ts +++ b/src/app/features/administration/administration-routing.module.ts @@ -12,6 +12,7 @@ const routes: Routes = [ { path: '', component: AdministrationComponent, + redirectTo: 'step/1', }, { path: 'step', diff --git a/src/app/features/administration/administration.module.ts b/src/app/features/administration/administration.module.ts index 1a76397b..da8cb01b 100644 --- a/src/app/features/administration/administration.module.ts +++ b/src/app/features/administration/administration.module.ts @@ -15,6 +15,7 @@ import { StepTwoComponent } from './form/step-two/step-two.component'; import { StepThreeComponent } from './form/step-three/step-three.component'; import { StepFourComponent } from './form/step-four/step-four.component'; import { StepFiveComponent } from './form/step-five/step-five.component'; +import { DevMenuComponent } from './dev-menu/dev-menu.component'; @NgModule({ declarations: [ @@ -27,6 +28,7 @@ import { StepFiveComponent } from './form/step-five/step-five.component'; StepThreeComponent, StepFourComponent, StepFiveComponent, + DevMenuComponent, ], imports: [ AdministrationRoutingModule, diff --git a/src/app/features/administration/dev-menu/dev-menu.component.html b/src/app/features/administration/dev-menu/dev-menu.component.html new file mode 100644 index 00000000..fc2da89b --- /dev/null +++ b/src/app/features/administration/dev-menu/dev-menu.component.html @@ -0,0 +1,14 @@ + + + + + + + +
+
+
+ + menu développeur +
+
diff --git a/src/app/features/administration/dev-menu/dev-menu.component.scss b/src/app/features/administration/dev-menu/dev-menu.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/src/app/features/administration/dev-menu/dev-menu.component.spec.ts b/src/app/features/administration/dev-menu/dev-menu.component.spec.ts new file mode 100644 index 00000000..70c5e0b9 --- /dev/null +++ b/src/app/features/administration/dev-menu/dev-menu.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DevMenuComponent } from './dev-menu.component'; + +describe('DevMenuComponent', () => { + let component: DevMenuComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [DevMenuComponent], + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DevMenuComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/features/administration/dev-menu/dev-menu.component.ts b/src/app/features/administration/dev-menu/dev-menu.component.ts new file mode 100644 index 00000000..a84d0715 --- /dev/null +++ b/src/app/features/administration/dev-menu/dev-menu.component.ts @@ -0,0 +1,14 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-dev-menu', + templateUrl: './dev-menu.component.html', + styleUrls: ['./dev-menu.component.scss'], +}) +export class DevMenuComponent implements OnInit { + devModeEnabled: boolean = false; + + constructor() {} + + ngOnInit(): void {} +} diff --git a/src/app/features/administration/form/form.component.html b/src/app/features/administration/form/form.component.html index 1b609363..8e79451b 100644 --- a/src/app/features/administration/form/form.component.html +++ b/src/app/features/administration/form/form.component.html @@ -12,21 +12,10 @@