CW-277-Allow-editing-nodes (#827)

* allow editing nodes

* fix buttons size

* fix comments
This commit is contained in:
Serhii
2023-03-15 15:24:38 +02:00
committed by GitHub
parent 305c3f1515
commit f458e5b349
29 changed files with 150 additions and 85 deletions
@@ -5,13 +5,16 @@ import 'package:mobx/mobx.dart';
import 'package:cw_core/node.dart';
import 'package:cw_core/wallet_type.dart';
import 'node_list_view_model.dart';
part 'node_create_or_edit_view_model.g.dart';
class NodeCreateOrEditViewModel = NodeCreateOrEditViewModelBase
with _$NodeCreateOrEditViewModel;
abstract class NodeCreateOrEditViewModelBase with Store {
NodeCreateOrEditViewModelBase(this._nodeSource, this._walletType, this._settingsStore)
NodeCreateOrEditViewModelBase(this._nodeSource, this._walletType, this._settingsStore,
this.nodeListViewModel)
: state = InitialExecutionState(),
connectionState = InitialExecutionState(),
useSSL = false,
@@ -65,6 +68,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
final WalletType _walletType;
final Box<Node> _nodeSource;
final SettingsStore _settingsStore;
final NodeListViewModel nodeListViewModel;
@action
void reset() {
@@ -77,9 +81,30 @@ abstract class NodeCreateOrEditViewModelBase with Store {
}
@action
Future<void> save({bool saveAsCurrent = false}) async {
void setPort (String val) => port = val;
@action
void setAddress (String val) => address = val;
@action
void setLogin (String val) => login = val;
@action
void setPassword (String val) => password = val;
@action
void setSSL (bool val) => useSSL = val;
@action
void setTrusted (bool val) => trusted = val;
@action
Future<void> save({Node? editingNode, bool saveAsCurrent = false}) async {
try {
state = IsExecutingState();
if (editingNode != null) {
await nodeListViewModel.delete(editingNode);
}
final node =
Node(uri: uri, type: _walletType, login: login, password: password,
useSSL: useSSL, trusted: trusted);