diff --git a/src/app/core/models/configuration.model.ts b/src/app/core/models/configuration.model.ts index 8ec766f2..c78595d7 100644 --- a/src/app/core/models/configuration.model.ts +++ b/src/app/core/models/configuration.model.ts @@ -3,26 +3,32 @@ import { DateService } from '../services/date.service'; export class PollConfiguration { constructor( - public isAboutDate: boolean = false, - public isProtectedByPassword: boolean = false, + public allowComments: boolean = true, + public areResultsPublic: boolean = true, + public dateCreated: Date = new Date(Date.now()), public password: string = '', + public isAboutDate: boolean = false, + public isAllowingtoChangeOwnAnswers: boolean = true, + public isMaybeAnswerAvailable: boolean = false, + public isProtectedByPassword: boolean = false, public isOwnerNotifiedByEmailOnNewVote: boolean = false, public isOwnerNotifiedByEmailOnNewComment: boolean = false, - public isMaybeAnswerAvailable: boolean = false, - public areResultsPublic: boolean = true, - public isAllowingtoChangeOwnAnswers: boolean = true, + public isZeroKnoledge: boolean = true, + public hasSeveralHours: boolean = false, + public hasMaxCountOfAnswers: boolean = false, public whoCanChangeAnswers: string = 'everybody', - public dateCreated: Date = new Date(Date.now()), - public expiresDaysDelay: number = environment.poll.defaultConfig.expiracyInDays, + public maxCountOfAnswers: number = environment.poll.defaultConfig.maxCountOfAnswers, + public expiresDaysDelay: number = environment.poll.defaultConfig.expiresDaysDelay, public expiracyAfterLastModificationInDays: number = environment.poll.defaultConfig .expiracyAfterLastModificationInDays, - public expires: Date = DateService.addDaysToDate( - environment.poll.defaultConfig.expiracyInDays, + // date after creation day when people will not be able to vote anymore + public expiracyDate: Date = DateService.addDaysToDate( + environment.poll.defaultConfig.expiresDaysDelay, new Date(Date.now()) ) ) {} public static isArchived(configuration: PollConfiguration): boolean { - return configuration.expires ? DateService.isDateInPast(configuration.expires) : undefined; + return configuration.expiracyDate ? DateService.isDateInPast(configuration.expiracyDate) : undefined; } } diff --git a/src/app/core/models/poll.model.ts b/src/app/core/models/poll.model.ts index f7afe108..69674ca9 100644 --- a/src/app/core/models/poll.model.ts +++ b/src/app/core/models/poll.model.ts @@ -14,6 +14,9 @@ export class Poll { public creatorPseudo?: string, public creatorEmail?: string, public isAboutDate?: boolean, + public isZeroKnoledge?: boolean, + public allowSeveralHours?: boolean, + public archiveNumberOfDays?: number, public configuration: PollConfiguration = new PollConfiguration(), public comments: Comment[] = [], public choices: Choice[] = [], diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index d597e52d..501ff08b 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -64,7 +64,7 @@ export class PollService implements Resolve { console.log('getAllAvailablePolls res', res); }); } catch (e) { - console.log('getAllAvailablePolls e', e); + console.error('getAllAvailablePolls e', e); } } diff --git a/src/app/features/administration/form/advanced-config/advanced-config.component.html b/src/app/features/administration/form/advanced-config/advanced-config.component.html index 35a44b7b..30f01084 100644 --- a/src/app/features/administration/form/advanced-config/advanced-config.component.html +++ b/src/app/features/administration/form/advanced-config/advanced-config.component.html @@ -52,8 +52,8 @@ consultable @@ -149,8 +149,8 @@ -
- + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -
-
- - {{ timeList.length }} - - - {{ 'dates.count_time' | translate }} - (pour chaque jour) - -
-
- - - -
- -
-
-
- - - -
-
-
-
- - {{ dateList.length }} + +
+
+ + {{ timeList.length }} - - {{ 'dates.count_dates' | translate }} + + {{ 'dates.count_time' | translate }} + (pour chaque jour) -
+
+
+			form.value.hasSeveralHours :
+				{{ form.value.hasSeveralHours | json }}
+			
+ -
- {{ id }}) - - - -
-
- - -
+ + +
+ + + + + + + + + + + + + + + + + + + +
+ + {{ dateList.length }} + + + {{ 'dates.count_dates' | translate }} + + +
+ {{ id }}) + + + +
+
+ +
- +
diff --git a/src/app/features/administration/form/form.component.html b/src/app/features/administration/form/form.component.html index a79c0e8c..72988e42 100644 --- a/src/app/features/administration/form/form.component.html +++ b/src/app/features/administration/form/form.component.html @@ -1,44 +1,11 @@
-
+

{{ 'creation.title' | translate }}

-

- {{ 'creation.want' | translate }} -

- - - - -
-
-
-
-				form values :
-					{{ form.value | json }}
-				
-
-				poll initial values :
-				{{ poll | json }}
-				
-
- - - - - -
- -
-
-
+ +
+
+

+ {{ 'creation.want' | translate }} +

+ + + + + + + + +
+
+
+
+				form values :
+					{{ form.value | json }}
+				
+
+				poll initial values :
+				{{ poll | json }}
+				
+
+
-
+
le formulaire est invalide
 		 {{ form.errors | json }}
diff --git a/src/app/features/administration/form/form.component.ts b/src/app/features/administration/form/form.component.ts
index 3755d291..2a17a7d7 100644
--- a/src/app/features/administration/form/form.component.ts
+++ b/src/app/features/administration/form/form.component.ts
@@ -20,7 +20,7 @@ export class FormComponent implements OnInit {
 	public poll?: Poll;
 	public form: FormGroup;
 
-	public advancedDisplayEnabled = true;
+	public advancedDisplayEnabled = false;
 
 	constructor(
 		private fb: FormBuilder,
@@ -53,10 +53,11 @@ export class FormComponent implements OnInit {
 			whoModifiesAnswers: ['', [Validators.required]],
 			whoCanChangeAnswers: ['', [Validators.required]],
 			isAboutDate: [true, [Validators.required]],
+			isProtectedByPassword: [false, [Validators.required]],
 			startDateInterval: ['', [Validators.required]],
 			endDateInterval: ['', [Validators.required]],
-			isProtectedByPassword: [false, [Validators.required]],
-			hasMaxCountOfAnswers: [true, [Validators.required]],
+			hasMaxCountOfAnswers: [true, [Validators.required, Validators.min(1)]],
+			hasSeveralHours: [false, [Validators.required]],
 			allowComments: [true, [Validators.required]],
 			maxCountOfAnswers: [150, [Validators.required]],
 			isOwnerNotifiedByEmailOnNewVote: [false, [Validators.required]],
@@ -74,7 +75,7 @@ export class FormComponent implements OnInit {
 	}
 
 	/**
-	 * add example values to the form
+	 * add example values to the form, overrides defaults of PollConfiguration
 	 */
 	setDemoValues(): void {
 		this.form.patchValue({
@@ -84,6 +85,7 @@ export class FormComponent implements OnInit {
 			creatorPseudo: 'Chuck Norris',
 			creatorEmail: 'chucknorris@example.com',
 			isAboutDate: true,
+			hasSeveralHours: true,
 			configuration: {
 				whoModifiesAnswers: 'everybody',
 				whoCanChangeAnswers: 'everybody',
diff --git a/src/app/features/administration/stepper/stepper.component.ts b/src/app/features/administration/stepper/stepper.component.ts
index eb797594..d527c416 100644
--- a/src/app/features/administration/stepper/stepper.component.ts
+++ b/src/app/features/administration/stepper/stepper.component.ts
@@ -50,7 +50,7 @@ export class StepperComponent implements OnInit {
 			],
 			areResultsPublic: [this.poll ? this.poll.configuration.areResultsPublic : true, [Validators.required]],
 			expiracyNumberOfDays: [
-				this.poll ? DateService.diffInDays(new Date(), this.poll.configuration.expires) : 60,
+				this.poll ? DateService.diffInDays(new Date(), this.poll.configuration.expiracyDate) : 60,
 				[Validators.required],
 			],
 		});
diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts
index 605f23be..cd51ae38 100644
--- a/src/environments/environment.prod.ts
+++ b/src/environments/environment.prod.ts
@@ -39,7 +39,7 @@ export const environment = {
 	},
 	poll: {
 		defaultConfig: {
-			expiracyInDays: 60,
+			expiresDaysDelay: 60,
 			expiracyAfterLastModificationInDays: 180,
 		},
 	},
diff --git a/src/environments/environment.ts b/src/environments/environment.ts
index 86d5495a..9bb7c9a4 100644
--- a/src/environments/environment.ts
+++ b/src/environments/environment.ts
@@ -54,7 +54,8 @@ export const environment = {
 	},
 	poll: {
 		defaultConfig: {
-			expiracyInDays: 60,
+			maxCountOfAnswers: 150,
+			expiresDaysDelay: 60,
 			expiracyAfterLastModificationInDays: 180,
 		},
 	},