Refactor
This commit is contained in:
parent
fee6eb6fae
commit
761bddd7c6
|
|
@ -8,7 +8,7 @@ import 'package:invoiceninja/redux/client/client_state.dart';
|
|||
EntityUIState clientUIReducer(ClientUIState state, action) {
|
||||
return state.rebuild((b) => b
|
||||
..listUIState.replace(clientListReducer(state.listUIState, action))
|
||||
..editing.replace(editingReducer(state.editing, action))
|
||||
..editing.replace(editingReducer(state.selected, action))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ abstract class ClientState implements Built<ClientState, ClientStateBuilder> {
|
|||
abstract class ClientUIState extends Object with EntityUIState implements Built<ClientUIState, ClientUIStateBuilder> {
|
||||
|
||||
@nullable
|
||||
ClientEntity get editing;
|
||||
ClientEntity get selected;
|
||||
|
||||
factory ClientUIState() {
|
||||
return _$ClientUIState._(
|
||||
listUIState: ListUIState(ClientFields.name),
|
||||
editing: ClientEntity(),
|
||||
selected: ClientEntity(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,10 +96,10 @@ class _$ClientUIStateSerializer implements StructuredSerializer<ClientUIState> {
|
|||
serializers.serialize(object.listUIState,
|
||||
specifiedType: const FullType(ListUIState)),
|
||||
];
|
||||
if (object.editing != null) {
|
||||
if (object.selected != null) {
|
||||
result
|
||||
..add('editing')
|
||||
..add(serializers.serialize(object.editing,
|
||||
..add(serializers.serialize(object.selected,
|
||||
specifiedType: const FullType(ClientEntity)));
|
||||
}
|
||||
|
||||
|
|
@ -246,14 +246,14 @@ class ClientStateBuilder implements Builder<ClientState, ClientStateBuilder> {
|
|||
|
||||
class _$ClientUIState extends ClientUIState {
|
||||
@override
|
||||
final ClientEntity editing;
|
||||
final ClientEntity selected;
|
||||
@override
|
||||
final ListUIState listUIState;
|
||||
|
||||
factory _$ClientUIState([void updates(ClientUIStateBuilder b)]) =>
|
||||
(new ClientUIStateBuilder()..update(updates)).build();
|
||||
|
||||
_$ClientUIState._({this.editing, this.listUIState}) : super._() {
|
||||
_$ClientUIState._({this.selected, this.listUIState}) : super._() {
|
||||
if (listUIState == null)
|
||||
throw new BuiltValueNullFieldError('ClientUIState', 'listUIState');
|
||||
}
|
||||
|
|
@ -269,18 +269,18 @@ class _$ClientUIState extends ClientUIState {
|
|||
bool operator ==(dynamic other) {
|
||||
if (identical(other, this)) return true;
|
||||
if (other is! ClientUIState) return false;
|
||||
return editing == other.editing && listUIState == other.listUIState;
|
||||
return selected == other.selected && listUIState == other.listUIState;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return $jf($jc($jc(0, editing.hashCode), listUIState.hashCode));
|
||||
return $jf($jc($jc(0, selected.hashCode), listUIState.hashCode));
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (newBuiltValueToStringHelper('ClientUIState')
|
||||
..add('editing', editing)
|
||||
..add('editing', selected)
|
||||
..add('listUIState', listUIState))
|
||||
.toString();
|
||||
}
|
||||
|
|
@ -305,7 +305,7 @@ class ClientUIStateBuilder
|
|||
|
||||
ClientUIStateBuilder get _$this {
|
||||
if (_$v != null) {
|
||||
_editing = _$v.editing?.toBuilder();
|
||||
_editing = _$v.selected?.toBuilder();
|
||||
_listUIState = _$v.listUIState?.toBuilder();
|
||||
_$v = null;
|
||||
}
|
||||
|
|
@ -329,7 +329,7 @@ class ClientUIStateBuilder
|
|||
try {
|
||||
_$result = _$v ??
|
||||
new _$ClientUIState._(
|
||||
editing: _editing?.build(), listUIState: listUIState.build());
|
||||
selected: _editing?.build(), listUIState: listUIState.build());
|
||||
} catch (_) {
|
||||
String _$failedField;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import 'package:invoiceninja/redux/invoice/invoice_state.dart';
|
|||
EntityUIState invoiceUIReducer(InvoiceUIState state, action) {
|
||||
return state.rebuild((b) => b
|
||||
..listUIState.replace(invoiceListReducer(state.listUIState, action))
|
||||
..editing.replace(editingReducer(state.editing, action))
|
||||
..editing.replace(editingReducer(state.selected, action))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ abstract class InvoiceState implements Built<InvoiceState, InvoiceStateBuilder>
|
|||
abstract class InvoiceUIState extends Object with EntityUIState implements Built<InvoiceUIState, InvoiceUIStateBuilder> {
|
||||
|
||||
@nullable
|
||||
InvoiceEntity get editing;
|
||||
InvoiceEntity get selected;
|
||||
|
||||
factory InvoiceUIState() {
|
||||
return _$InvoiceUIState._(
|
||||
listUIState: ListUIState(InvoiceFields.invoiceNumber),
|
||||
editing: InvoiceEntity(),
|
||||
selected: InvoiceEntity(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,10 +98,10 @@ class _$InvoiceUIStateSerializer
|
|||
serializers.serialize(object.listUIState,
|
||||
specifiedType: const FullType(ListUIState)),
|
||||
];
|
||||
if (object.editing != null) {
|
||||
if (object.selected != null) {
|
||||
result
|
||||
..add('editing')
|
||||
..add(serializers.serialize(object.editing,
|
||||
..add(serializers.serialize(object.selected,
|
||||
specifiedType: const FullType(InvoiceEntity)));
|
||||
}
|
||||
|
||||
|
|
@ -250,14 +250,14 @@ class InvoiceStateBuilder
|
|||
|
||||
class _$InvoiceUIState extends InvoiceUIState {
|
||||
@override
|
||||
final InvoiceEntity editing;
|
||||
final InvoiceEntity selected;
|
||||
@override
|
||||
final ListUIState listUIState;
|
||||
|
||||
factory _$InvoiceUIState([void updates(InvoiceUIStateBuilder b)]) =>
|
||||
(new InvoiceUIStateBuilder()..update(updates)).build();
|
||||
|
||||
_$InvoiceUIState._({this.editing, this.listUIState}) : super._() {
|
||||
_$InvoiceUIState._({this.selected, this.listUIState}) : super._() {
|
||||
if (listUIState == null)
|
||||
throw new BuiltValueNullFieldError('InvoiceUIState', 'listUIState');
|
||||
}
|
||||
|
|
@ -274,18 +274,18 @@ class _$InvoiceUIState extends InvoiceUIState {
|
|||
bool operator ==(dynamic other) {
|
||||
if (identical(other, this)) return true;
|
||||
if (other is! InvoiceUIState) return false;
|
||||
return editing == other.editing && listUIState == other.listUIState;
|
||||
return selected == other.selected && listUIState == other.listUIState;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return $jf($jc($jc(0, editing.hashCode), listUIState.hashCode));
|
||||
return $jf($jc($jc(0, selected.hashCode), listUIState.hashCode));
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (newBuiltValueToStringHelper('InvoiceUIState')
|
||||
..add('editing', editing)
|
||||
..add('editing', selected)
|
||||
..add('listUIState', listUIState))
|
||||
.toString();
|
||||
}
|
||||
|
|
@ -310,7 +310,7 @@ class InvoiceUIStateBuilder
|
|||
|
||||
InvoiceUIStateBuilder get _$this {
|
||||
if (_$v != null) {
|
||||
_editing = _$v.editing?.toBuilder();
|
||||
_editing = _$v.selected?.toBuilder();
|
||||
_listUIState = _$v.listUIState?.toBuilder();
|
||||
_$v = null;
|
||||
}
|
||||
|
|
@ -334,7 +334,7 @@ class InvoiceUIStateBuilder
|
|||
try {
|
||||
_$result = _$v ??
|
||||
new _$InvoiceUIState._(
|
||||
editing: _editing?.build(), listUIState: listUIState.build());
|
||||
selected: _editing?.build(), listUIState: listUIState.build());
|
||||
} catch (_) {
|
||||
String _$failedField;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import 'package:invoiceninja/redux/product/product_state.dart';
|
|||
EntityUIState productUIReducer(ProductUIState state, action) {
|
||||
return state.rebuild((b) => b
|
||||
..listUIState.replace(productListReducer(state.listUIState, action))
|
||||
..editing.replace(editingReducer(state.editing, action))
|
||||
..editing.replace(editingReducer(state.selected, action))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ abstract class ProductState implements Built<ProductState, ProductStateBuilder>
|
|||
abstract class ProductUIState extends Object with EntityUIState implements Built<ProductUIState, ProductUIStateBuilder> {
|
||||
|
||||
@nullable
|
||||
ProductEntity get editing;
|
||||
ProductEntity get selected;
|
||||
|
||||
factory ProductUIState() {
|
||||
return _$ProductUIState._(
|
||||
listUIState: ListUIState(ProductFields.productKey),
|
||||
editing: ProductEntity(),
|
||||
selected: ProductEntity(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,10 +98,10 @@ class _$ProductUIStateSerializer
|
|||
serializers.serialize(object.listUIState,
|
||||
specifiedType: const FullType(ListUIState)),
|
||||
];
|
||||
if (object.editing != null) {
|
||||
if (object.selected != null) {
|
||||
result
|
||||
..add('editing')
|
||||
..add(serializers.serialize(object.editing,
|
||||
..add(serializers.serialize(object.selected,
|
||||
specifiedType: const FullType(ProductEntity)));
|
||||
}
|
||||
|
||||
|
|
@ -250,14 +250,14 @@ class ProductStateBuilder
|
|||
|
||||
class _$ProductUIState extends ProductUIState {
|
||||
@override
|
||||
final ProductEntity editing;
|
||||
final ProductEntity selected;
|
||||
@override
|
||||
final ListUIState listUIState;
|
||||
|
||||
factory _$ProductUIState([void updates(ProductUIStateBuilder b)]) =>
|
||||
(new ProductUIStateBuilder()..update(updates)).build();
|
||||
|
||||
_$ProductUIState._({this.editing, this.listUIState}) : super._() {
|
||||
_$ProductUIState._({this.selected, this.listUIState}) : super._() {
|
||||
if (listUIState == null)
|
||||
throw new BuiltValueNullFieldError('ProductUIState', 'listUIState');
|
||||
}
|
||||
|
|
@ -274,18 +274,18 @@ class _$ProductUIState extends ProductUIState {
|
|||
bool operator ==(dynamic other) {
|
||||
if (identical(other, this)) return true;
|
||||
if (other is! ProductUIState) return false;
|
||||
return editing == other.editing && listUIState == other.listUIState;
|
||||
return selected == other.selected && listUIState == other.listUIState;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return $jf($jc($jc(0, editing.hashCode), listUIState.hashCode));
|
||||
return $jf($jc($jc(0, selected.hashCode), listUIState.hashCode));
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (newBuiltValueToStringHelper('ProductUIState')
|
||||
..add('editing', editing)
|
||||
..add('editing', selected)
|
||||
..add('listUIState', listUIState))
|
||||
.toString();
|
||||
}
|
||||
|
|
@ -310,7 +310,7 @@ class ProductUIStateBuilder
|
|||
|
||||
ProductUIStateBuilder get _$this {
|
||||
if (_$v != null) {
|
||||
_editing = _$v.editing?.toBuilder();
|
||||
_editing = _$v.selected?.toBuilder();
|
||||
_listUIState = _$v.listUIState?.toBuilder();
|
||||
_$v = null;
|
||||
}
|
||||
|
|
@ -334,7 +334,7 @@ class ProductUIStateBuilder
|
|||
try {
|
||||
_$result = _$v ??
|
||||
new _$ProductUIState._(
|
||||
editing: _editing?.build(), listUIState: listUIState.build());
|
||||
selected: _editing?.build(), listUIState: listUIState.build());
|
||||
} catch (_) {
|
||||
String _$failedField;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class ClientEditVM {
|
|||
});
|
||||
|
||||
factory ClientEditVM.fromStore(Store<AppState> store) {
|
||||
final client = store.state.clientUIState.editing;
|
||||
final client = store.state.clientUIState.selected;
|
||||
|
||||
return ClientEditVM(
|
||||
client: client,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class ClientViewVM {
|
|||
});
|
||||
|
||||
factory ClientViewVM.fromStore(Store<AppState> store) {
|
||||
final client = store.state.clientUIState.editing;
|
||||
final client = store.state.clientUIState.selected;
|
||||
|
||||
return ClientViewVM(
|
||||
isLoading: store.state.isLoading,
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class InvoiceEditVM {
|
|||
|
||||
factory InvoiceEditVM.fromStore(Store<AppState> store) {
|
||||
AppState state = store.state;
|
||||
final invoice = state.invoiceUIState.editing;
|
||||
final invoice = state.invoiceUIState.selected;
|
||||
|
||||
return InvoiceEditVM(
|
||||
isLoading: state.isLoading,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class ProductEditVM {
|
|||
});
|
||||
|
||||
factory ProductEditVM.fromStore(Store<AppState> store) {
|
||||
final product = store.state.productUIState.editing;
|
||||
final product = store.state.productUIState.selected;
|
||||
|
||||
return ProductEditVM(
|
||||
isLoading: store.state.isLoading,
|
||||
|
|
|
|||
Loading…
Reference in New Issue