mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
show expiracy day after creation
This commit is contained in:
parent
09a507109a
commit
5d02fc3167
84
mocks/newDatePollCreation.ts
Normal file
84
mocks/newDatePollCreation.ts
Normal file
@ -0,0 +1,84 @@
|
||||
export default {
|
||||
allow_comments: true,
|
||||
allowComments: true,
|
||||
allowed_answers: [],
|
||||
areResultsPublic: true,
|
||||
choices: [],
|
||||
choices_grouped: [],
|
||||
comments: [],
|
||||
creation_date: '2021-05-18T20:40:51.385Z',
|
||||
custom_url: 'sdfsfdsfg',
|
||||
dateChoices: [
|
||||
{
|
||||
date_object: '2021-05-19T20:40:18.500Z',
|
||||
literal: '2021-05-19',
|
||||
timeSlices: {},
|
||||
},
|
||||
{
|
||||
date_object: '2021-05-20T20:40:18.500Z',
|
||||
literal: '2021-05-20',
|
||||
timeSlices: {},
|
||||
},
|
||||
{
|
||||
date_object: '2021-05-21T20:40:18.500Z',
|
||||
literal: '2021-05-21',
|
||||
timeSlices: {},
|
||||
},
|
||||
{
|
||||
date_object: '2021-05-22T20:40:18.500Z',
|
||||
literal: '2021-05-22',
|
||||
timeSlices: {},
|
||||
},
|
||||
{
|
||||
date_object: '2021-05-18T20:40:33.557Z',
|
||||
literal: '',
|
||||
timeSlices: [],
|
||||
},
|
||||
{
|
||||
date_object: '2021-05-18T20:40:33.557Z',
|
||||
literal: '',
|
||||
timeSlices: [],
|
||||
},
|
||||
{
|
||||
date_object: '2021-05-18T20:40:33.557Z',
|
||||
literal: '',
|
||||
timeSlices: [],
|
||||
},
|
||||
],
|
||||
default_expiracy_days_from_now: 60,
|
||||
description: 'RSVP',
|
||||
has_several_hours: false,
|
||||
hasSeveralHours: false,
|
||||
id: 0,
|
||||
is_zero_knowledge: false,
|
||||
isMaybeAnswerAvailable: false,
|
||||
isOwnerNotifiedByEmailOnNewComment: false,
|
||||
isOwnerNotifiedByEmailOnNewVote: false,
|
||||
kind: 'date',
|
||||
max_count_of_answers: true,
|
||||
maxCountOfAnswers: 150,
|
||||
modification_policy: 'everybody',
|
||||
owner: {
|
||||
email: 'example@example.com',
|
||||
polls: [],
|
||||
pseudo: 'pseudo',
|
||||
},
|
||||
password: '',
|
||||
stacks: [],
|
||||
timeSlices: [
|
||||
{
|
||||
literal: 'matin',
|
||||
},
|
||||
{
|
||||
literal: 'midi',
|
||||
},
|
||||
{
|
||||
literal: 'après-midi',
|
||||
},
|
||||
{
|
||||
literal: 'soir',
|
||||
},
|
||||
],
|
||||
title: 'sdfsfdsfg',
|
||||
votes: [],
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
export interface DateChoice {
|
||||
literal: string;
|
||||
timeList: TimeSlices[];
|
||||
timeSlices: TimeSlices[];
|
||||
date_object: Date;
|
||||
}
|
||||
|
||||
@ -47,17 +47,17 @@ export const defaultDates: DateChoice[] = [
|
||||
{
|
||||
literal: `${currentYear}-${currentMonth}-${currentDay}`,
|
||||
date_object: new Date(),
|
||||
timeList: defaultTimeOfDay,
|
||||
timeSlices: defaultTimeOfDay,
|
||||
},
|
||||
{
|
||||
literal: `${currentYear}-${currentMonth}-${currentDay + 1}`,
|
||||
date_object: new Date(),
|
||||
timeList: defaultTimeOfDay,
|
||||
timeSlices: defaultTimeOfDay,
|
||||
},
|
||||
{
|
||||
literal: `${currentYear}-${currentMonth}-${currentDay + 2}`,
|
||||
date_object: new Date(),
|
||||
timeList: defaultTimeOfDay,
|
||||
timeSlices: defaultTimeOfDay,
|
||||
},
|
||||
];
|
||||
|
||||
@ -65,17 +65,17 @@ export const otherDefaultDates: DateChoice[] = [
|
||||
{
|
||||
literal: `${currentYear}-${currentMonth}-${currentDay}`,
|
||||
date_object: new Date(),
|
||||
timeList: defaultTimeOfDay,
|
||||
timeSlices: defaultTimeOfDay,
|
||||
},
|
||||
{
|
||||
literal: `${currentYear}-${currentMonth}-${currentDay + 1}`,
|
||||
date_object: new Date(currentYear, currentMonth, currentDay + 1),
|
||||
timeList: otherTimeOfDay,
|
||||
timeSlices: otherTimeOfDay,
|
||||
},
|
||||
{
|
||||
literal: `${currentYear}-${currentMonth}-${currentDay + 2}`,
|
||||
date_object: new Date(),
|
||||
timeList: moreTimeOfDay,
|
||||
timeSlices: moreTimeOfDay,
|
||||
},
|
||||
];
|
||||
export const defaultAnswers: PollAnswer[] = [
|
||||
|
@ -104,22 +104,22 @@ export class DateUtilitiesService {
|
||||
return [
|
||||
{
|
||||
literal: this.formateDateToInputStringNg(ladate),
|
||||
timeList: Object.create(defaultTimeOfDay),
|
||||
timeSlices: Object.create(defaultTimeOfDay),
|
||||
date_object: ladate,
|
||||
},
|
||||
{
|
||||
literal: this.formateDateToInputStringNg(ladate2),
|
||||
timeList: Object.create(defaultTimeOfDay),
|
||||
timeSlices: Object.create(defaultTimeOfDay),
|
||||
date_object: ladate2,
|
||||
},
|
||||
{
|
||||
literal: this.formateDateToInputStringNg(ladate3),
|
||||
timeList: Object.create(defaultTimeOfDay),
|
||||
timeSlices: Object.create(defaultTimeOfDay),
|
||||
date_object: ladate3,
|
||||
},
|
||||
{
|
||||
literal: this.formateDateToInputStringNg(ladate4),
|
||||
timeList: Object.create(defaultTimeOfDay),
|
||||
timeSlices: Object.create(defaultTimeOfDay),
|
||||
date_object: ladate4,
|
||||
},
|
||||
];
|
||||
|
@ -14,6 +14,7 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { StorageService } from './storage.service';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
import { DateUtilitiesService } from './date.utilities.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@ -29,6 +30,7 @@ export class PollService implements Resolve<Poll> {
|
||||
private storageService: StorageService,
|
||||
private userService: UserService,
|
||||
private uuidService: UuidService,
|
||||
private dateUtils: DateUtilitiesService,
|
||||
private titleService: Title,
|
||||
private toastService: ToastService
|
||||
) {
|
||||
|
@ -61,14 +61,14 @@ export class DateSelectComponent implements OnInit {
|
||||
|
||||
removeAllTimes() {
|
||||
this.timeSlices = [];
|
||||
this.dateList.map((elem) => (elem.timeList = []));
|
||||
this.dateList.map((elem) => (elem.timeSlices = []));
|
||||
|
||||
this.toastService.display('périodes horaires vidées');
|
||||
}
|
||||
|
||||
resetTimes(slices = Object.create(defaultTimeOfDay)) {
|
||||
this.timeSlices = slices;
|
||||
this.dateList.map((elem) => (elem.timeList = Object.create(slices)));
|
||||
this.dateList.map((elem) => (elem.timeSlices = Object.create(slices)));
|
||||
this.toastService.display('périodes horaires réinitialisées');
|
||||
}
|
||||
}
|
||||
|
@ -64,10 +64,10 @@ export class DayListComponent {
|
||||
* @param id number
|
||||
*/
|
||||
addTimeToDate(choice: DateChoice, id: number) {
|
||||
if (!choice.timeList) {
|
||||
choice.timeList = [];
|
||||
if (!choice.timeSlices) {
|
||||
choice.timeSlices = [];
|
||||
}
|
||||
choice.timeList.push({
|
||||
choice.timeSlices.push({
|
||||
literal: '',
|
||||
});
|
||||
const selector = '[ng-reflect-choice_label="dateTime_' + id + '_ dateList_' + (this.timeList.length - 1) + '"]';
|
||||
@ -126,7 +126,7 @@ export class DayListComponent {
|
||||
addChoice(optionalLabel = ''): void {
|
||||
this.storageService.dateChoices.push({
|
||||
literal: '',
|
||||
timeList: [],
|
||||
timeSlices: [],
|
||||
date_object: new Date(),
|
||||
});
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
<br />
|
||||
<p class="note">
|
||||
Note : Le sondage sera supprimé {{ poll.default_expiracy_days_from_now }} jours après la date de sa
|
||||
dernière modification.
|
||||
dernière modification. Le {{ getExpiracyDateFromPoll(poll) | date: 'short' }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="public">
|
||||
|
@ -3,6 +3,7 @@ import { PollService } from '../../../core/services/poll.service';
|
||||
import { Poll } from '../../../core/models/poll.model';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
import { DateUtilitiesService } from '../../../core/services/date.utilities.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-success',
|
||||
@ -14,7 +15,7 @@ export class SuccessComponent {
|
||||
mailToRecieve: string;
|
||||
window: any = window;
|
||||
environment = environment;
|
||||
constructor(public pollService: PollService, private titleService: Title) {
|
||||
constructor(public pollService: PollService, private dateUtils: DateUtilitiesService, private titleService: Title) {
|
||||
this.titleService.setTitle(environment.appTitle + ' - 🎉 succès de création de sondage -');
|
||||
|
||||
this.pollService.poll.subscribe((newpoll: Poll) => {
|
||||
@ -25,4 +26,8 @@ export class SuccessComponent {
|
||||
sendToEmail() {
|
||||
alert('todo');
|
||||
}
|
||||
|
||||
getExpiracyDateFromPoll(poll: Poll): Date {
|
||||
return this.dateUtils.addDaysToDate(poll.default_expiracy_days_from_now, new Date());
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ export const environment = {
|
||||
frontDomain: 'http://tktest.lan',
|
||||
production: false,
|
||||
display_routes: false,
|
||||
autofill: false,
|
||||
autofill: true,
|
||||
showDemoWarning: false,
|
||||
autoSendNewPoll: false,
|
||||
interval_days_default: 7,
|
||||
|
Loading…
Reference in New Issue
Block a user