Transactions

This commit is contained in:
Hillel Coren 2022-09-23 15:42:03 +03:00
parent 76c3944e14
commit 6db3ab4b9d
5 changed files with 38 additions and 8 deletions

View File

@ -103,7 +103,6 @@ abstract class BankAccountEntity extends Object
return name;
}
/*
@override
List<EntityAction> getActions(
{UserCompanyEntity userCompany,
@ -112,9 +111,14 @@ abstract class BankAccountEntity extends Object
bool multiselect = false}) {
final actions = <EntityAction>[];
if (!isDeleted) {
if (!multiselect && includeEdit && userCompany.canEditEntity(this)) {
actions.add(EntityAction.edit);
}
}
return actions..addAll(super.getActions(userCompany: userCompany));
}
*/
int compareTo(
BankAccountEntity bankAccount, String sortField, bool sortAscending) {

View File

@ -320,10 +320,7 @@ abstract class ProductEntity extends Object
final actions = <EntityAction>[];
if (!isDeleted) {
if (!multiselect &&
!multiselect &&
includeEdit &&
userCompany.canEditEntity(this)) {
if (!multiselect && includeEdit && userCompany.canEditEntity(this)) {
actions.add(EntityAction.edit);
}

View File

@ -8,6 +8,7 @@ import 'package:flutter/material.dart';
import 'package:built_collection/built_collection.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:invoiceninja_flutter/ui/bank_account/bank_account_screen.dart';
import 'package:invoiceninja_flutter/ui/bank_account/edit/bank_account_edit.dart';
import 'package:redux/redux.dart';
// Project imports:
@ -952,6 +953,14 @@ void createEntityByType({
),
));
break;
case EntityType.bankAccount:
store.dispatch(EditBankAccount(
force: force,
bankAccount: BankAccountEntity(state: state),
));
break;
default:
print('## Create by type not handled for $entityType');
}
});
}

View File

@ -26,8 +26,11 @@ class ViewBankAccount implements PersistUI, PersistPrefs {
}
class EditBankAccount implements PersistUI, PersistPrefs {
EditBankAccount(
{@required this.bankAccount, this.completer, this.force = false});
EditBankAccount({
@required this.bankAccount,
this.completer,
this.force = false,
});
final BankAccountEntity bankAccount;
final Completer completer;

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:invoiceninja_flutter/ui/bank_account/edit/bank_account_edit_vm.dart';
import 'package:redux/redux.dart';
import 'package:invoiceninja_flutter/main_app.dart';
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
@ -16,6 +17,7 @@ List<Middleware<AppState>> createStoreBankAccountsMiddleware([
]) {
final viewBankAccountList = _viewBankAccountList();
final viewBankAccount = _viewBankAccount();
final editBankAccount = _editBankAccount();
final loadBankAccounts = _loadBankAccounts(repository);
final loadBankAccount = _loadBankAccount(repository);
final saveBankAccount = _saveBankAccount(repository);
@ -26,6 +28,7 @@ List<Middleware<AppState>> createStoreBankAccountsMiddleware([
return [
TypedMiddleware<AppState, ViewBankAccountList>(viewBankAccountList),
TypedMiddleware<AppState, ViewBankAccount>(viewBankAccount),
TypedMiddleware<AppState, EditBankAccount>(editBankAccount),
TypedMiddleware<AppState, LoadBankAccounts>(loadBankAccounts),
TypedMiddleware<AppState, LoadBankAccount>(loadBankAccount),
TypedMiddleware<AppState, SaveBankAccountRequest>(saveBankAccount),
@ -35,6 +38,20 @@ List<Middleware<AppState>> createStoreBankAccountsMiddleware([
];
}
Middleware<AppState> _editBankAccount() {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as EditBankAccount;
next(action);
store.dispatch(UpdateCurrentRoute(BankAccountEditScreen.route));
if (store.state.prefState.isMobile) {
navigatorKey.currentState.pushNamed(BankAccountEditScreen.route);
}
};
}
Middleware<AppState> _viewBankAccount() {
return (Store<AppState> store, dynamic dynamicAction,
NextDispatcher next) async {