From d107978f2c66dfa80abb47ddc2cce107f8a5eec1 Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Sat, 23 Nov 2019 14:30:19 +0100 Subject: [PATCH] :zap: selector custom component for ui, half the visibility page --- src/app/app.module.ts | 12 ++-- src/app/calendar/calendar.component.html | 1 - src/app/calendar/calendar.component.html.save | 1 - src/app/calendar/calendar.component.ts | 15 ---- src/app/config/PollConfig.ts | 27 ++++---- .../visibility/visibility.component.html | 68 +++++++++++++------ src/app/ui/selector/selector.component.html | 9 +++ .../selector/selector.component.scss} | 0 .../selector/selector.component.spec.ts} | 12 ++-- src/app/ui/selector/selector.component.ts | 30 ++++++++ 10 files changed, 115 insertions(+), 60 deletions(-) delete mode 100644 src/app/calendar/calendar.component.html delete mode 100644 src/app/calendar/calendar.component.html.save delete mode 100644 src/app/calendar/calendar.component.ts create mode 100644 src/app/ui/selector/selector.component.html rename src/app/{calendar/calendar.component.scss => ui/selector/selector.component.scss} (100%) rename src/app/{calendar/calendar.component.spec.ts => ui/selector/selector.component.spec.ts} (55%) create mode 100644 src/app/ui/selector/selector.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 66f42676..d448b962 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,5 +1,5 @@ import {BrowserModule} from '@angular/platform-browser'; -import {LOCALE_ID, NgModule} from '@angular/core'; +import {NgModule} from '@angular/core'; import {AppRoutingModule} from './app-routing.module'; import {AppComponent} from './app.component'; @@ -19,7 +19,6 @@ import {PicturesComponent} from './pages/pictures/pictures.component'; import {AnswersComponent} from './pages/answers/answers.component'; import {EndConfirmationComponent} from './pages/end-confirmation/end-confirmation.component'; import {CreateOrRetrieveComponent} from './pages/create-or-retrieve/create-or-retrieve.component'; -import {CalendarComponent} from './calendar/calendar.component'; import localeFr from '@angular/common/locales/fr'; import localeEn from '@angular/common/locales/en'; import {VotingSummaryComponent} from './pages/voting-summary/voting-summary.component'; @@ -29,7 +28,7 @@ import {PasswordComponent} from './pages/password/password.component'; import {HomeComponent} from './pages/home/home.component'; import {VoteChoiceComponent} from './vote-choice/vote-choice.component'; import {HttpClient, HttpClientModule} from '@angular/common/http'; -import { MarkdownModule } from 'ngx-markdown'; +import {MarkdownModule} from 'ngx-markdown'; import { MissingTranslationHandler, MissingTranslationHandlerParams, @@ -38,9 +37,10 @@ import { TranslateService } from '@ngx-translate/core'; import {TranslateHttpLoader} from '@ngx-translate/http-loader'; -import { PollGraphicComponent } from './poll-graphic/poll-graphic.component'; +import {PollGraphicComponent} from './poll-graphic/poll-graphic.component'; -import { AdminComponent } from './pages/admin/admin.component'; +import {AdminComponent} from './pages/admin/admin.component'; +import {SelectorComponent} from './ui/selector/selector.component'; export class MyMissingTranslationHandler implements MissingTranslationHandler { handle(params: MissingTranslationHandlerParams) { @@ -70,7 +70,6 @@ export function HttpLoaderFactory(http: HttpClient) { AnswersComponent, EndConfirmationComponent, CreateOrRetrieveComponent, - CalendarComponent, VotingSummaryComponent, VotingGraphComponent, VotingChoiceComponent, @@ -79,6 +78,7 @@ export function HttpLoaderFactory(http: HttpClient) { PollGraphicComponent, VoteChoiceComponent, AdminComponent, + SelectorComponent, ], imports: [ diff --git a/src/app/calendar/calendar.component.html b/src/app/calendar/calendar.component.html deleted file mode 100644 index 6d8082c2..00000000 --- a/src/app/calendar/calendar.component.html +++ /dev/null @@ -1 +0,0 @@ -

calendar works!

diff --git a/src/app/calendar/calendar.component.html.save b/src/app/calendar/calendar.component.html.save deleted file mode 100644 index 8b137891..00000000 --- a/src/app/calendar/calendar.component.html.save +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/app/calendar/calendar.component.ts b/src/app/calendar/calendar.component.ts deleted file mode 100644 index a16dd09f..00000000 --- a/src/app/calendar/calendar.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'framadate-calendar', - templateUrl: './calendar.component.html', - styleUrls: ['./calendar.component.scss'] -}) -export class CalendarComponent implements OnInit { - - constructor() { } - - ngOnInit() { - } - -} diff --git a/src/app/config/PollConfig.ts b/src/app/config/PollConfig.ts index 3b504118..3cd871e0 100644 --- a/src/app/config/PollConfig.ts +++ b/src/app/config/PollConfig.ts @@ -27,6 +27,18 @@ export const defaultDates = [ timeList: [{literal: 'matin'}, {literal: 'midi'}, {literal: 'soir'}] } ]; +export const defaultAnswers = [{ + id: 0, + text: 'réponse de démo 1' +}, + { + id: 1, + text: 'réponse 2' + }, + { + id: 2, + text: 'la réponse D' + }]; /** * configuration of the poll, add new fields at will @@ -43,23 +55,14 @@ export class PollConfig { allowSeveralHours = 'false'; // access visibility = 'link_only'; // visible to anyone with the link: + voteChoices = 'only_yes'; // possible answers to a vote choice: only "yes", "yes, maybe, no" password = ''; customUrl = ''; whoCanChangeAnswers = 'everybody';// everybody, self, nobody (= just admin) dateList: DateOption[] = defaultDates; // sets of days as strings, config to set identical time for days in a special days poll timeList: DateOption[] = timeOfDay; // ranges of time expressed as strings - answers: any = [{ - id: 0, - text: 'réponse de démo 1' - }, - { - id: 1, - text: 'réponse 2' - }, - { - id: 2, - text: 'la réponse D' - }]; + + answers: any = defaultAnswers; } diff --git a/src/app/pages/visibility/visibility.component.html b/src/app/pages/visibility/visibility.component.html index d2d794fd..e87e7972 100644 --- a/src/app/pages/visibility/visibility.component.html +++ b/src/app/pages/visibility/visibility.component.html @@ -1,30 +1,60 @@

{{"visibility.top_txt"|translate}} - {{"visibility.title"|translate}} - - {{"visibility.visibility_want"|translate}} - {{"visibility.visibility_link"|translate}} - {{"visibility.visibility_nobody"|translate}} - {{"visibility.visibility_see"|translate}} -

+
-
-

- {{"visibility.votes"|translate}} -

- {{"visibility.votes_possible"|translate}} - {{"visibility.votes_possible_single"|translate}} - {{"visibility.votes_possible_normal"|translate}} - {{"visibility.votes_possible_full"|translate}} - +

+ {{"visibility.title"|translate}} +

+ + {{"visibility.visibility_want"|translate}} + + + + {{"visibility.visibility_see"|translate}} +
-
-

+
+

+ {{"visibility.votes"|translate}} +

+ + {{"visibility.votes_possible"|translate}} + + +
+
+ {{"visibility.archiving"|translate}} -

+ + {{"visibility.archiving_start"|translate}} {{"visibility.archiving_can"|translate}} {{"visibility.archiving_can_not"|translate}} diff --git a/src/app/ui/selector/selector.component.html b/src/app/ui/selector/selector.component.html new file mode 100644 index 00000000..b75b2232 --- /dev/null +++ b/src/app/ui/selector/selector.component.html @@ -0,0 +1,9 @@ + diff --git a/src/app/calendar/calendar.component.scss b/src/app/ui/selector/selector.component.scss similarity index 100% rename from src/app/calendar/calendar.component.scss rename to src/app/ui/selector/selector.component.scss diff --git a/src/app/calendar/calendar.component.spec.ts b/src/app/ui/selector/selector.component.spec.ts similarity index 55% rename from src/app/calendar/calendar.component.spec.ts rename to src/app/ui/selector/selector.component.spec.ts index 205a029d..13b5c414 100644 --- a/src/app/calendar/calendar.component.spec.ts +++ b/src/app/ui/selector/selector.component.spec.ts @@ -1,20 +1,20 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { CalendarComponent } from './calendar.component'; +import { SelectorComponent } from './selector.component'; -describe('CalendarComponent', () => { - let component: CalendarComponent; - let fixture: ComponentFixture; +describe('SelectorComponent', () => { + let component: SelectorComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ CalendarComponent ] + declarations: [ SelectorComponent ] }) .compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(CalendarComponent); + fixture = TestBed.createComponent(SelectorComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/src/app/ui/selector/selector.component.ts b/src/app/ui/selector/selector.component.ts new file mode 100644 index 00000000..1f4faf8a --- /dev/null +++ b/src/app/ui/selector/selector.component.ts @@ -0,0 +1,30 @@ +import {Component, Input, OnInit} from '@angular/core'; + +interface Item { + label: string, + value: string +} + +interface SelectorConfig { + label: string, + name: string, + id: string, + selectorNgModel: any, + listItems: Item[] +} + +@Component({ + selector: 'framadate-selector', + templateUrl: './selector.component.html', + styleUrls: ['./selector.component.scss'] +}) +export class SelectorComponent implements OnInit { + @Input() selectorConfig: SelectorConfig; + + constructor() { + } + + ngOnInit() { + } + +}