Reports
This commit is contained in:
parent
984f0cc993
commit
fce21cba73
|
|
@ -84,7 +84,6 @@ class _MultiSelectListState extends State<_MultiSelectList> {
|
|||
.toList(),
|
||||
value: null,
|
||||
onChanged: (dynamic value) {
|
||||
print('## selected $value');
|
||||
if (selected.contains(value)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -109,7 +108,7 @@ class _MultiSelectListState extends State<_MultiSelectList> {
|
|||
child: Text(
|
||||
localization.lookup(option),
|
||||
textAlign: TextAlign.left,
|
||||
style: Theme.of(context).textTheme.headline5,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
|
|
|
|||
|
|
@ -123,21 +123,23 @@ class ReportsScreen extends StatelessWidget {
|
|||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
FlatButton(
|
||||
child: Text(localization.editColumns.toUpperCase()),
|
||||
onPressed: () {
|
||||
multiselectDialog(
|
||||
context: context,
|
||||
onSelected: (selected) {
|
||||
print('## ON SELECTED: $selected');
|
||||
},
|
||||
options: reportResult.allColumns,
|
||||
selected: reportResult.columns,
|
||||
title: localization.editColumns,
|
||||
addTitle: localization.addColumn,
|
||||
);
|
||||
},
|
||||
)
|
||||
Builder(builder: (BuildContext context) {
|
||||
return FlatButton(
|
||||
child: Text(localization.editColumns.toUpperCase()),
|
||||
onPressed: () {
|
||||
multiselectDialog(
|
||||
context: context,
|
||||
onSelected: (selected) {
|
||||
viewModel.onReportColumnsChanged(context, selected);
|
||||
},
|
||||
options: reportResult.allColumns,
|
||||
selected: reportResult.columns,
|
||||
title: localization.editColumns,
|
||||
addTitle: localization.addColumn,
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
FormCard(
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
|
@ -6,8 +7,13 @@ import 'package:invoiceninja_flutter/data/models/dashboard_model.dart';
|
|||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/reports/reports_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/reports/reports_selectors.dart';
|
||||
import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/app_builder.dart';
|
||||
import 'package:invoiceninja_flutter/ui/reports/client_report.dart';
|
||||
import 'package:invoiceninja_flutter/ui/reports/reports_screen.dart';
|
||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||
import 'package:invoiceninja_flutter/utils/dialogs.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
import 'reports_screen.dart';
|
||||
|
|
@ -32,11 +38,13 @@ class ReportsScreenVM {
|
|||
ReportsScreenVM({
|
||||
@required this.state,
|
||||
@required this.onSettingsChanged,
|
||||
@required this.onReportColumnsChanged,
|
||||
@required this.reportResult,
|
||||
});
|
||||
|
||||
final AppState state;
|
||||
final ReportResult reportResult;
|
||||
final Function(BuildContext, List<String>) onReportColumnsChanged;
|
||||
final Function({
|
||||
String report,
|
||||
DateRange dateRange,
|
||||
|
|
@ -61,6 +69,35 @@ class ReportsScreenVM {
|
|||
return ReportsScreenVM(
|
||||
state: state,
|
||||
reportResult: reportResult,
|
||||
onReportColumnsChanged: (context, columns) {
|
||||
final completer = snackBarCompleter<Null>(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
final user = state.user.rebuild((b) => b
|
||||
..userCompany
|
||||
.settings
|
||||
.reportColumns[state.uiState.reportsUIState.report] =
|
||||
BuiltList<String>(columns));
|
||||
if (state.authState.hasRecentlyEnteredPassword) {
|
||||
store.dispatch(
|
||||
SaveUserSettingsRequest(
|
||||
completer: completer,
|
||||
user: user,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
passwordCallback(
|
||||
context: context,
|
||||
callback: (password) {
|
||||
store.dispatch(
|
||||
SaveUserSettingsRequest(
|
||||
completer: completer,
|
||||
user: user,
|
||||
password: password,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
onSettingsChanged: ({
|
||||
String report,
|
||||
DateRange dateRange,
|
||||
|
|
|
|||
|
|
@ -45,8 +45,6 @@ class UserDetailsVM {
|
|||
user: state.uiState.settingsUIState.user,
|
||||
onChanged: (user) => store.dispatch(UpdateUserSettings(user: user)),
|
||||
onSavePressed: (context) {
|
||||
print(
|
||||
'hasRecentlyEnteredPassword: ${state.authState.hasRecentlyEnteredPassword}');
|
||||
final completer = snackBarCompleter<Null>(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
completer.future.then((_) {
|
||||
|
|
|
|||
|
|
@ -28,13 +28,14 @@ Completer<Null> refreshCompleter(BuildContext context) {
|
|||
|
||||
Completer<T> snackBarCompleter<T>(BuildContext context, String message,
|
||||
{bool shouldPop = false}) {
|
||||
final scaffold = Scaffold.of(context);
|
||||
final Completer<T> completer = Completer<T>();
|
||||
|
||||
completer.future.then((_) {
|
||||
if (shouldPop) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
scaffold.showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
message: message,
|
||||
)));
|
||||
|
|
|
|||
Loading…
Reference in New Issue