mirror of
https://github.com/Iconica-Development/flutter_availability.git
synced 2025-05-19 21:23: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
40d80801a0
commit
17fc6ad9f6
1 changed files with 17 additions and 2 deletions
|
@ -150,7 +150,7 @@ class AvailabilityViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
return copyWith(
|
||||
return clearTimeAndBreak().copyWith(
|
||||
templates: [template],
|
||||
breaks: breaks,
|
||||
conflictingPauses: conflictingPauses,
|
||||
|
@ -161,12 +161,27 @@ class AvailabilityViewModel {
|
|||
);
|
||||
}
|
||||
|
||||
///
|
||||
/// Removes the templates from the availability
|
||||
AvailabilityViewModel removeTemplates() => copyWith(
|
||||
templates: [],
|
||||
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
|
||||
AvailabilityModel toModel() {
|
||||
var startDate = DateTime(
|
||||
|
|
Loading…
Reference in a new issue