Schedules

This commit is contained in:
Hillel Coren 2023-02-15 20:45:16 +02:00
parent 5073214ef4
commit d7af7bd0bc
3 changed files with 47 additions and 3 deletions

View File

@ -23,6 +23,7 @@ class ClientPicker extends StatelessWidget {
this.onAddPressed,
this.autofocus,
this.excludeIds = const [],
this.isRequired = true,
});
final String clientId;
@ -31,6 +32,7 @@ class ClientPicker extends StatelessWidget {
final Function(Completer<SelectableEntity> completer) onAddPressed;
final bool autofocus;
final List<String> excludeIds;
final bool isRequired;
@override
Widget build(BuildContext context) {
@ -46,7 +48,7 @@ class ClientPicker extends StatelessWidget {
entityList: memoizedDropdownClientList(clientState.map, clientState.list,
state.userState.map, state.staticState),
entityMap: clientState.map,
validator: (String val) => val.trim().isEmpty
validator: (String val) => isRequired && val.trim().isEmpty
? AppLocalization.of(context).pleaseSelectAClient
: null,
onSelected: onSelected,

View File

@ -4,12 +4,15 @@ import 'package:invoiceninja_flutter/data/models/dashboard_model.dart';
import 'package:invoiceninja_flutter/ui/app/edit_scaffold.dart';
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
import 'package:invoiceninja_flutter/ui/app/forms/app_dropdown_button.dart';
import 'package:invoiceninja_flutter/ui/app/forms/bool_dropdown_button.dart';
import 'package:invoiceninja_flutter/ui/app/forms/client_picker.dart';
import 'package:invoiceninja_flutter/ui/app/forms/date_picker.dart';
import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart';
import 'package:invoiceninja_flutter/ui/schedule/edit/schedule_edit_vm.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:invoiceninja_flutter/utils/completers.dart';
import 'package:invoiceninja_flutter/ui/app/scrollable_listview.dart';
import 'package:invoiceninja_flutter/utils/strings.dart';
class ScheduleEdit extends StatefulWidget {
const ScheduleEdit({
@ -36,14 +39,12 @@ class _ScheduleEditState extends State<ScheduleEdit> {
@override
void didChangeDependencies() {
_controllers = [
// STARTER: array - do not remove comment
_nameController,
];
_controllers.forEach((controller) => controller.removeListener(_onChanged));
final schedule = widget.viewModel.schedule;
// STARTER: read value - do not remove comment
_nameController.text = schedule.name;
_controllers.forEach((controller) => controller.addListener(_onChanged));
@ -75,6 +76,7 @@ class _ScheduleEditState extends State<ScheduleEdit> {
@override
Widget build(BuildContext context) {
final viewModel = widget.viewModel;
final state = viewModel.state;
final localization = AppLocalization.of(context);
final schedule = viewModel.schedule;
final parameters = schedule.parameters;
@ -137,6 +139,7 @@ class _ScheduleEditState extends State<ScheduleEdit> {
],
),
FormCard(
isLast: true,
children: [
DatePicker(
labelText: localization.nextSendDate,
@ -185,6 +188,35 @@ class _ScheduleEditState extends State<ScheduleEdit> {
))
.toList(),
),
SizedBox(height: 20),
BoolDropdownButton(
label: localization.showAgingTable,
value: parameters.showAgingTable,
onChanged: (value) {
viewModel.onChanged(schedule.rebuild(
(b) => b..parameters.showAgingTable = value));
}),
BoolDropdownButton(
label: localization.showPaymentsTable,
value: parameters.showPaymentsTable,
onChanged: (value) {
viewModel.onChanged(schedule.rebuild(
(b) => b..parameters.showPaymentsTable = value));
}),
SizedBox(height: 20),
ClientPicker(
isRequired: false,
clientId: null,
clientState: state.clientState,
onSelected: (value) {
viewModel.onChanged(schedule.rebuild(
(b) => b..parameters.clients.add(value.id)));
print('## SELECTED: $value');
}),
for (var clientId in parameters.clients)
ListTile(
title: Text(clientId),
),
],
)
],

View File

@ -16,6 +16,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = {
'en': {
// STARTER: lang key - do not remove comment
'show_aging_table': 'Show Aging Table',
'show_payments_table': 'Show Payments Table',
'email_statement': 'Email Statement',
'once': 'Once',
'schedule': 'Schedule',
@ -94514,6 +94516,14 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['email_statement'] ??
_localizedValues['en']['email_statement'];
String get showAgingTable =>
_localizedValues[localeCode]['show_aging_table'] ??
_localizedValues['en']['show_aging_table'];
String get showPaymentsTable =>
_localizedValues[localeCode]['show_payments_table'] ??
_localizedValues['en']['show_payments_table'];
// STARTER: lang field - do not remove comment