mirror of
https://github.com/Iconica-Development/flutter_availability.git
synced 2025-05-19 13:13:44 +02:00
fix: clear start and end before applying a template to an availability selection
The start and end might already be set before selecting a template, it should always be cleared and if the template is uniform it can update the start and endtime to the correct value
This commit is contained in:
parent
3280d40d1f
commit
85297c35fa
1 changed files with 17 additions and 2 deletions
|
@ -150,7 +150,7 @@ class AvailabilityViewModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return copyWith(
|
return clearTimeAndBreak().copyWith(
|
||||||
templates: [template],
|
templates: [template],
|
||||||
breaks: breaks,
|
breaks: breaks,
|
||||||
conflictingPauses: conflictingPauses,
|
conflictingPauses: conflictingPauses,
|
||||||
|
@ -161,12 +161,27 @@ class AvailabilityViewModel {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
/// Removes the templates from the availability
|
||||||
AvailabilityViewModel removeTemplates() => copyWith(
|
AvailabilityViewModel removeTemplates() => copyWith(
|
||||||
templates: [],
|
templates: [],
|
||||||
templateSelected: false,
|
templateSelected: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Removes the time and breaks from the availability
|
||||||
|
AvailabilityViewModel clearTimeAndBreak() => AvailabilityViewModel(
|
||||||
|
selectedRange: selectedRange,
|
||||||
|
templates: templates,
|
||||||
|
ids: ids,
|
||||||
|
userId: userId,
|
||||||
|
startTime: null,
|
||||||
|
endTime: null,
|
||||||
|
breaks: [],
|
||||||
|
clearAvailability: clearAvailability,
|
||||||
|
conflictingPauses: conflictingPauses,
|
||||||
|
conflictingTime: conflictingTime,
|
||||||
|
templateSelected: templateSelected,
|
||||||
|
);
|
||||||
|
|
||||||
/// create a AvailabilityModel from the current AvailabilityViewModel
|
/// create a AvailabilityModel from the current AvailabilityViewModel
|
||||||
AvailabilityModel toModel() {
|
AvailabilityModel toModel() {
|
||||||
var startDate = DateTime(
|
var startDate = DateTime(
|
||||||
|
|
Loading…
Reference in a new issue