Schedules

This commit is contained in:
Hillel Coren 2023-02-16 14:50:07 +02:00
parent 679e3ee6bb
commit ec1274b6b5
2 changed files with 106 additions and 96 deletions

View File

@ -102,6 +102,7 @@ class _ScheduleEditState extends State<ScheduleEdit> {
return ScrollableListView(
children: <Widget>[
FormCard(
isLast: schedule.template.isEmpty,
children: <Widget>[
DecoratedFormField(
keyboardType: TextInputType.text,
@ -123,6 +124,15 @@ class _ScheduleEditState extends State<ScheduleEdit> {
child: Text(localization.lookup(entry.value)),
))
.toList()),
DatePicker(
labelText: localization.nextRun,
onSelected: (date, _) {
viewModel.onChanged(
schedule.rebuild((b) => b..nextRun = date));
},
selectedDate: schedule.nextRun,
firstDate: DateTime.now(),
),
AppDropdownButton<String>(
labelText: localization.frequency,
value: schedule.frequencyId,
@ -140,16 +150,8 @@ class _ScheduleEditState extends State<ScheduleEdit> {
.toList()),
],
),
if (schedule.template.isNotEmpty) ...[
FormCard(children: [
DatePicker(
labelText: localization.nextSendDate,
onSelected: (date, _) {
viewModel.onChanged(
schedule.rebuild((b) => b..nextRun = date));
},
selectedDate: schedule.nextRun,
firstDate: DateTime.now(),
),
AppDropdownButton<DateRange>(
labelText: localization.dateRange,
blankValue: null,
@ -208,7 +210,8 @@ class _ScheduleEditState extends State<ScheduleEdit> {
isLast: true,
children: [
ClientPicker(
key: ValueKey('__client_picker_${_clientClearedAt}__'),
key:
ValueKey('__client_picker_${_clientClearedAt}__'),
isRequired: false,
clientId: null,
clientState: state.clientState,
@ -218,7 +221,8 @@ class _ScheduleEditState extends State<ScheduleEdit> {
(b) => b..parameters.clients.add(value.id)));
}
setState(() {
_clientClearedAt = DateTime.now().toIso8601String();
_clientClearedAt =
DateTime.now().toIso8601String();
});
}),
SizedBox(height: 20),
@ -231,14 +235,15 @@ class _ScheduleEditState extends State<ScheduleEdit> {
trailing: IconButton(
icon: Icon(Icons.clear),
onPressed: () {
viewModel.onChanged(schedule.rebuild(
(b) => b..parameters.clients.remove(clientId)));
viewModel.onChanged(schedule.rebuild((b) =>
b..parameters.clients.remove(clientId)));
},
),
),
],
)
],
],
);
},
),

View File

@ -16,6 +16,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = {
'en': {
// STARTER: lang key - do not remove comment
'next_run': 'Next Run',
'all_clients': 'All Clients',
'show_aging_table': 'Show Aging Table',
'show_payments_table': 'Show Payments Table',
@ -94529,6 +94530,10 @@ String get allClients =>
_localizedValues[localeCode]['all_clients'] ??
_localizedValues['en']['all_clients'];
String get nextRun =>
_localizedValues[localeCode]['next_run'] ??
_localizedValues['en']['next_run'];
// STARTER: lang field - do not remove comment
String lookup(String key) {