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