initial working daterange
This commit is contained in:
parent
4b117f0673
commit
8a5de3a6dd
@ -11,6 +11,7 @@ import { DatePipe } from '@angular/common';
|
|||||||
import { DialogModule } from 'primeng/dialog';
|
import { DialogModule } from 'primeng/dialog';
|
||||||
|
|
||||||
interface TripBaseWithDates extends TripBase {
|
interface TripBaseWithDates extends TripBase {
|
||||||
|
daterange?: Date[];
|
||||||
from?: Date;
|
from?: Date;
|
||||||
to?: Date;
|
to?: Date;
|
||||||
}
|
}
|
||||||
@ -81,7 +82,9 @@ export class TripsComponent implements OnInit {
|
|||||||
next: (new_trip: TripBase) => {
|
next: (new_trip: TripBase) => {
|
||||||
let dayCount = 0;
|
let dayCount = 0;
|
||||||
|
|
||||||
if (trip.from && trip.to) {
|
if (trip.daterange && trip.daterange.length === 2) {
|
||||||
|
trip.to = new Date(trip.daterange[1]);
|
||||||
|
trip.from = new Date(trip.daterange[0]);
|
||||||
const obs$ = this.generateDaysLabel(trip.from!, trip.to!).map((label) =>
|
const obs$ = this.generateDaysLabel(trip.from!, trip.to!).map((label) =>
|
||||||
this.apiService.postTripDay({ id: -1, label: label, items: [] }, new_trip.id),
|
this.apiService.postTripDay({ id: -1, label: label, items: [] }, new_trip.id),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -12,13 +12,8 @@
|
|||||||
@if (tripForm.get("id")?.value === -1) {
|
@if (tripForm.get("id")?.value === -1) {
|
||||||
<div class="grid md:col-span-4 grid-cols-2 gap-2">
|
<div class="grid md:col-span-4 grid-cols-2 gap-2">
|
||||||
<p-floatlabel variant="in">
|
<p-floatlabel variant="in">
|
||||||
<p-datepicker id="from" formControlName="from" [iconDisplay]="'input'" [showIcon]="true" appendTo="body" fluid />
|
<p-datepicker id="daterange" formControlName="daterange" [iconDisplay]="'input'" [showIcon]="true" selectionMode="range" appendTo="body" fluid />
|
||||||
<label for="from">From</label>
|
<label for="daterange">Date Range</label>
|
||||||
</p-floatlabel>
|
|
||||||
|
|
||||||
<p-floatlabel variant="in">
|
|
||||||
<p-datepicker id="to" formControlName="to" [iconDisplay]="'input'" [showIcon]="true" appendTo="body" fluid />
|
|
||||||
<label for="to">To</label>
|
|
||||||
</p-floatlabel>
|
</p-floatlabel>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,8 +33,7 @@ export class TripCreateModalComponent {
|
|||||||
image: '',
|
image: '',
|
||||||
currency: null,
|
currency: null,
|
||||||
image_id: null,
|
image_id: null,
|
||||||
from: null,
|
daterange: null,
|
||||||
to: null,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const patchValue = this.config.data?.trip;
|
const patchValue = this.config.data?.trip;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user