Dashboard
This commit is contained in:
parent
bb92d0e998
commit
ebc9601ce9
|
|
@ -617,7 +617,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
//return 'Client Count: ${userCompanyState.clientState.list.length}, Last Updated: ${userCompanyState.lastUpdated}';
|
||||
//return 'Token: ${credentials.token} - ${userCompanyStates.map((state) => state?.token?.token ?? '').where((name) => name.isNotEmpty).join(',')}';
|
||||
//return 'Payment Terms: ${company.settings.defaultPaymentTerms}';
|
||||
return 'Dashboard: ${dashboardUIState.selectedEntities}';
|
||||
return 'Dashboard: ${uiState.selectedEntities}';
|
||||
return '\n\nURL: ${authState.url}\nRoute: ${uiState.currentRoute}\nPrev: ${uiState.previousRoute}\nis Large: ${(company?.isLarge ?? false) ? 'Yes' : 'No'}\nCompany: $companyUpdated${userCompanyState.isStale ? ' [S]' : ''}\nStatic: $staticUpdated${staticState.isStale ? ' [S]' : ''}\n';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:invoiceninja_flutter/redux/company/company_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/dashboard/dashboard_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/dashboard/dashboard_state.dart';
|
||||
|
|
@ -21,11 +20,6 @@ DashboardUIState dashboardUIReducer(DashboardUIState state, dynamic action) {
|
|||
} else if (action.currencyId != null) {
|
||||
return state.rebuild((b) => b..currencyId = action.currencyId);
|
||||
}
|
||||
} else if (action is UpdateDashboardSelection) {
|
||||
return state.rebuild((b) => b
|
||||
..selectedEntities[action.entityType] = action.entityIds == null
|
||||
? null
|
||||
: BuiltList<String>(action.entityIds));
|
||||
} else if (action is SelectCompany) {
|
||||
//return state.rebuild((b) => b..currencyId = action.company.currencyId);
|
||||
// TODO re-enable
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/dashboard_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
|
|
@ -22,7 +21,6 @@ abstract class DashboardUIState
|
|||
compareCustomEndDate: convertDateTimeToSqlDate(),
|
||||
offset: 0,
|
||||
currencyId: kCurrencyAll,
|
||||
selectedEntities: BuiltMap<EntityType, List<String>>(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -50,8 +48,6 @@ abstract class DashboardUIState
|
|||
|
||||
String get currencyId;
|
||||
|
||||
BuiltMap<EntityType, BuiltList<String>> get selectedEntities;
|
||||
|
||||
static Serializer<DashboardUIState> get serializer => _$dashboardUIStateSerializer;
|
||||
|
||||
bool matchesCurrency(String match) {
|
||||
|
|
|
|||
|
|
@ -46,12 +46,6 @@ class _$DashboardUIStateSerializer
|
|||
'currencyId',
|
||||
serializers.serialize(object.currencyId,
|
||||
specifiedType: const FullType(String)),
|
||||
'selectedEntities',
|
||||
serializers.serialize(object.selectedEntities,
|
||||
specifiedType: const FullType(BuiltMap, const [
|
||||
const FullType(EntityType),
|
||||
const FullType(BuiltList, const [const FullType(String)])
|
||||
])),
|
||||
];
|
||||
|
||||
return result;
|
||||
|
|
@ -106,13 +100,6 @@ class _$DashboardUIStateSerializer
|
|||
result.currencyId = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case 'selectedEntities':
|
||||
result.selectedEntities.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(BuiltMap, const [
|
||||
const FullType(EntityType),
|
||||
const FullType(BuiltList, const [const FullType(String)])
|
||||
])));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -139,8 +126,6 @@ class _$DashboardUIState extends DashboardUIState {
|
|||
final int offset;
|
||||
@override
|
||||
final String currencyId;
|
||||
@override
|
||||
final BuiltMap<EntityType, BuiltList<String>> selectedEntities;
|
||||
|
||||
factory _$DashboardUIState(
|
||||
[void Function(DashboardUIStateBuilder) updates]) =>
|
||||
|
|
@ -155,8 +140,7 @@ class _$DashboardUIState extends DashboardUIState {
|
|||
this.compareCustomStartDate,
|
||||
this.compareCustomEndDate,
|
||||
this.offset,
|
||||
this.currencyId,
|
||||
this.selectedEntities})
|
||||
this.currencyId})
|
||||
: super._() {
|
||||
if (dateRange == null) {
|
||||
throw new BuiltValueNullFieldError('DashboardUIState', 'dateRange');
|
||||
|
|
@ -189,10 +173,6 @@ class _$DashboardUIState extends DashboardUIState {
|
|||
if (currencyId == null) {
|
||||
throw new BuiltValueNullFieldError('DashboardUIState', 'currencyId');
|
||||
}
|
||||
if (selectedEntities == null) {
|
||||
throw new BuiltValueNullFieldError(
|
||||
'DashboardUIState', 'selectedEntities');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -215,8 +195,7 @@ class _$DashboardUIState extends DashboardUIState {
|
|||
compareCustomStartDate == other.compareCustomStartDate &&
|
||||
compareCustomEndDate == other.compareCustomEndDate &&
|
||||
offset == other.offset &&
|
||||
currencyId == other.currencyId &&
|
||||
selectedEntities == other.selectedEntities;
|
||||
currencyId == other.currencyId;
|
||||
}
|
||||
|
||||
int __hashCode;
|
||||
|
|
@ -229,17 +208,15 @@ class _$DashboardUIState extends DashboardUIState {
|
|||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc($jc(0, dateRange.hashCode),
|
||||
customStartDate.hashCode),
|
||||
customEndDate.hashCode),
|
||||
enableComparison.hashCode),
|
||||
compareDateRange.hashCode),
|
||||
compareCustomStartDate.hashCode),
|
||||
compareCustomEndDate.hashCode),
|
||||
offset.hashCode),
|
||||
currencyId.hashCode),
|
||||
selectedEntities.hashCode));
|
||||
$jc($jc(0, dateRange.hashCode),
|
||||
customStartDate.hashCode),
|
||||
customEndDate.hashCode),
|
||||
enableComparison.hashCode),
|
||||
compareDateRange.hashCode),
|
||||
compareCustomStartDate.hashCode),
|
||||
compareCustomEndDate.hashCode),
|
||||
offset.hashCode),
|
||||
currencyId.hashCode));
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -253,8 +230,7 @@ class _$DashboardUIState extends DashboardUIState {
|
|||
..add('compareCustomStartDate', compareCustomStartDate)
|
||||
..add('compareCustomEndDate', compareCustomEndDate)
|
||||
..add('offset', offset)
|
||||
..add('currencyId', currencyId)
|
||||
..add('selectedEntities', selectedEntities))
|
||||
..add('currencyId', currencyId))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -305,14 +281,6 @@ class DashboardUIStateBuilder
|
|||
String get currencyId => _$this._currencyId;
|
||||
set currencyId(String currencyId) => _$this._currencyId = currencyId;
|
||||
|
||||
MapBuilder<EntityType, BuiltList<String>> _selectedEntities;
|
||||
MapBuilder<EntityType, BuiltList<String>> get selectedEntities =>
|
||||
_$this._selectedEntities ??=
|
||||
new MapBuilder<EntityType, BuiltList<String>>();
|
||||
set selectedEntities(
|
||||
MapBuilder<EntityType, BuiltList<String>> selectedEntities) =>
|
||||
_$this._selectedEntities = selectedEntities;
|
||||
|
||||
DashboardUIStateBuilder();
|
||||
|
||||
DashboardUIStateBuilder get _$this {
|
||||
|
|
@ -326,7 +294,6 @@ class DashboardUIStateBuilder
|
|||
_compareCustomEndDate = _$v.compareCustomEndDate;
|
||||
_offset = _$v.offset;
|
||||
_currencyId = _$v.currencyId;
|
||||
_selectedEntities = _$v.selectedEntities?.toBuilder();
|
||||
_$v = null;
|
||||
}
|
||||
return this;
|
||||
|
|
@ -347,31 +314,17 @@ class DashboardUIStateBuilder
|
|||
|
||||
@override
|
||||
_$DashboardUIState build() {
|
||||
_$DashboardUIState _$result;
|
||||
try {
|
||||
_$result = _$v ??
|
||||
new _$DashboardUIState._(
|
||||
dateRange: dateRange,
|
||||
customStartDate: customStartDate,
|
||||
customEndDate: customEndDate,
|
||||
enableComparison: enableComparison,
|
||||
compareDateRange: compareDateRange,
|
||||
compareCustomStartDate: compareCustomStartDate,
|
||||
compareCustomEndDate: compareCustomEndDate,
|
||||
offset: offset,
|
||||
currencyId: currencyId,
|
||||
selectedEntities: selectedEntities.build());
|
||||
} catch (_) {
|
||||
String _$failedField;
|
||||
try {
|
||||
_$failedField = 'selectedEntities';
|
||||
selectedEntities.build();
|
||||
} catch (e) {
|
||||
throw new BuiltValueNestedFieldError(
|
||||
'DashboardUIState', _$failedField, e.toString());
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
final _$result = _$v ??
|
||||
new _$DashboardUIState._(
|
||||
dateRange: dateRange,
|
||||
customStartDate: customStartDate,
|
||||
customEndDate: customEndDate,
|
||||
enableComparison: enableComparison,
|
||||
compareDateRange: compareDateRange,
|
||||
compareCustomStartDate: compareCustomStartDate,
|
||||
compareCustomEndDate: compareCustomEndDate,
|
||||
offset: offset,
|
||||
currencyId: currencyId);
|
||||
replace(_$result);
|
||||
return _$result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/client/client_actions.dart';
|
||||
|
|
@ -21,11 +22,10 @@ import 'package:invoiceninja_flutter/redux/project/project_reducer.dart';
|
|||
import 'package:invoiceninja_flutter/redux/quote/quote_reducer.dart';
|
||||
import 'package:invoiceninja_flutter/redux/task/task_reducer.dart';
|
||||
import 'package:invoiceninja_flutter/redux/vendor/vendor_reducer.dart';
|
||||
|
||||
// STARTER: import - do not remove comment
|
||||
import 'package:invoiceninja_flutter/redux/webhook/webhook_reducer.dart';
|
||||
|
||||
import 'package:invoiceninja_flutter/redux/token/token_reducer.dart';
|
||||
|
||||
import 'package:invoiceninja_flutter/redux/payment_term/payment_term_reducer.dart';
|
||||
import 'package:invoiceninja_flutter/redux/design/design_reducer.dart';
|
||||
import 'package:invoiceninja_flutter/redux/credit/credit_reducer.dart';
|
||||
|
|
@ -89,6 +89,16 @@ UIState uiReducer(UIState state, dynamic action) {
|
|||
.replace(settingsUIReducer(state.settingsUIState, action)));
|
||||
}
|
||||
|
||||
Reducer<BuiltMap<EntityType, BuiltList<String>>> selectedEntitiesReducer =
|
||||
combineReducers([
|
||||
TypedReducer<BuiltMap<EntityType, BuiltList<String>>,
|
||||
UpdateDashboardSelection>((state, action) {
|
||||
return state.rebuild((b) => b
|
||||
..[action.entityType] =
|
||||
action.entityIds == null ? null : BuiltList(action.entityIds));
|
||||
}),
|
||||
]);
|
||||
|
||||
Reducer<String> filterReducer = combineReducers([
|
||||
TypedReducer<String, FilterCompany>((filter, action) {
|
||||
return action.filter;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:built_value/built_value.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
|
|
@ -36,6 +37,7 @@ abstract class UIState implements Built<UIState, UIStateBuilder> {
|
|||
currentRoute: currentRoute ?? LoginScreen.route,
|
||||
previousRoute: '',
|
||||
dashboardUIState: DashboardUIState(),
|
||||
selectedEntities: BuiltMap<EntityType, BuiltList<String>>(),
|
||||
productUIState: ProductUIState(),
|
||||
clientUIState: ClientUIState(),
|
||||
invoiceUIState: InvoiceUIState(),
|
||||
|
|
@ -69,6 +71,8 @@ abstract class UIState implements Built<UIState, UIStateBuilder> {
|
|||
|
||||
int get selectedCompanyIndex;
|
||||
|
||||
BuiltMap<EntityType, BuiltList<String>> get selectedEntities;
|
||||
|
||||
String get currentRoute;
|
||||
|
||||
String get previousRoute;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,12 @@ class _$UIStateSerializer implements StructuredSerializer<UIState> {
|
|||
'selectedCompanyIndex',
|
||||
serializers.serialize(object.selectedCompanyIndex,
|
||||
specifiedType: const FullType(int)),
|
||||
'selectedEntities',
|
||||
serializers.serialize(object.selectedEntities,
|
||||
specifiedType: const FullType(BuiltMap, const [
|
||||
const FullType(EntityType),
|
||||
const FullType(BuiltList, const [const FullType(String)])
|
||||
])),
|
||||
'currentRoute',
|
||||
serializers.serialize(object.currentRoute,
|
||||
specifiedType: const FullType(String)),
|
||||
|
|
@ -133,6 +139,13 @@ class _$UIStateSerializer implements StructuredSerializer<UIState> {
|
|||
result.selectedCompanyIndex = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int;
|
||||
break;
|
||||
case 'selectedEntities':
|
||||
result.selectedEntities.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(BuiltMap, const [
|
||||
const FullType(EntityType),
|
||||
const FullType(BuiltList, const [const FullType(String)])
|
||||
])));
|
||||
break;
|
||||
case 'currentRoute':
|
||||
result.currentRoute = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
|
|
@ -261,6 +274,8 @@ class _$UIState extends UIState {
|
|||
@override
|
||||
final int selectedCompanyIndex;
|
||||
@override
|
||||
final BuiltMap<EntityType, BuiltList<String>> selectedEntities;
|
||||
@override
|
||||
final String currentRoute;
|
||||
@override
|
||||
final String previousRoute;
|
||||
|
|
@ -322,6 +337,7 @@ class _$UIState extends UIState {
|
|||
|
||||
_$UIState._(
|
||||
{this.selectedCompanyIndex,
|
||||
this.selectedEntities,
|
||||
this.currentRoute,
|
||||
this.previousRoute,
|
||||
this.filterEntityId,
|
||||
|
|
@ -354,6 +370,9 @@ class _$UIState extends UIState {
|
|||
if (selectedCompanyIndex == null) {
|
||||
throw new BuiltValueNullFieldError('UIState', 'selectedCompanyIndex');
|
||||
}
|
||||
if (selectedEntities == null) {
|
||||
throw new BuiltValueNullFieldError('UIState', 'selectedEntities');
|
||||
}
|
||||
if (currentRoute == null) {
|
||||
throw new BuiltValueNullFieldError('UIState', 'currentRoute');
|
||||
}
|
||||
|
|
@ -443,6 +462,7 @@ class _$UIState extends UIState {
|
|||
if (identical(other, this)) return true;
|
||||
return other is UIState &&
|
||||
selectedCompanyIndex == other.selectedCompanyIndex &&
|
||||
selectedEntities == other.selectedEntities &&
|
||||
currentRoute == other.currentRoute &&
|
||||
previousRoute == other.previousRoute &&
|
||||
filterEntityId == other.filterEntityId &&
|
||||
|
|
@ -494,7 +514,7 @@ class _$UIState extends UIState {
|
|||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, selectedCompanyIndex.hashCode), currentRoute.hashCode), previousRoute.hashCode), filterEntityId.hashCode), filterEntityType.hashCode), filter.hashCode), filterClearedAt.hashCode), dashboardUIState.hashCode), productUIState.hashCode), clientUIState.hashCode),
|
||||
$jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, selectedCompanyIndex.hashCode), selectedEntities.hashCode), currentRoute.hashCode), previousRoute.hashCode), filterEntityId.hashCode), filterEntityType.hashCode), filter.hashCode), filterClearedAt.hashCode), dashboardUIState.hashCode), productUIState.hashCode), clientUIState.hashCode),
|
||||
invoiceUIState.hashCode),
|
||||
webhookUIState.hashCode),
|
||||
tokenUIState.hashCode),
|
||||
|
|
@ -520,6 +540,7 @@ class _$UIState extends UIState {
|
|||
String toString() {
|
||||
return (newBuiltValueToStringHelper('UIState')
|
||||
..add('selectedCompanyIndex', selectedCompanyIndex)
|
||||
..add('selectedEntities', selectedEntities)
|
||||
..add('currentRoute', currentRoute)
|
||||
..add('previousRoute', previousRoute)
|
||||
..add('filterEntityId', filterEntityId)
|
||||
|
|
@ -560,6 +581,14 @@ class UIStateBuilder implements Builder<UIState, UIStateBuilder> {
|
|||
set selectedCompanyIndex(int selectedCompanyIndex) =>
|
||||
_$this._selectedCompanyIndex = selectedCompanyIndex;
|
||||
|
||||
MapBuilder<EntityType, BuiltList<String>> _selectedEntities;
|
||||
MapBuilder<EntityType, BuiltList<String>> get selectedEntities =>
|
||||
_$this._selectedEntities ??=
|
||||
new MapBuilder<EntityType, BuiltList<String>>();
|
||||
set selectedEntities(
|
||||
MapBuilder<EntityType, BuiltList<String>> selectedEntities) =>
|
||||
_$this._selectedEntities = selectedEntities;
|
||||
|
||||
String _currentRoute;
|
||||
String get currentRoute => _$this._currentRoute;
|
||||
set currentRoute(String currentRoute) => _$this._currentRoute = currentRoute;
|
||||
|
|
@ -726,6 +755,7 @@ class UIStateBuilder implements Builder<UIState, UIStateBuilder> {
|
|||
UIStateBuilder get _$this {
|
||||
if (_$v != null) {
|
||||
_selectedCompanyIndex = _$v.selectedCompanyIndex;
|
||||
_selectedEntities = _$v.selectedEntities?.toBuilder();
|
||||
_currentRoute = _$v.currentRoute;
|
||||
_previousRoute = _$v.previousRoute;
|
||||
_filterEntityId = _$v.filterEntityId;
|
||||
|
|
@ -779,6 +809,7 @@ class UIStateBuilder implements Builder<UIState, UIStateBuilder> {
|
|||
_$result = _$v ??
|
||||
new _$UIState._(
|
||||
selectedCompanyIndex: selectedCompanyIndex,
|
||||
selectedEntities: selectedEntities.build(),
|
||||
currentRoute: currentRoute,
|
||||
previousRoute: previousRoute,
|
||||
filterEntityId: filterEntityId,
|
||||
|
|
@ -810,6 +841,9 @@ class UIStateBuilder implements Builder<UIState, UIStateBuilder> {
|
|||
} catch (_) {
|
||||
String _$failedField;
|
||||
try {
|
||||
_$failedField = 'selectedEntities';
|
||||
selectedEntities.build();
|
||||
|
||||
_$failedField = 'dashboardUIState';
|
||||
dashboardUIState.build();
|
||||
_$failedField = 'productUIState';
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ class _InvoiceSidebar extends StatelessWidget {
|
|||
final state = store.state;
|
||||
final invoices = memoizedUpcomingInvoices(state.invoiceState.map);
|
||||
final selectedIds =
|
||||
state.dashboardUIState.selectedEntities[EntityType.invoice];
|
||||
state.uiState.selectedEntities[EntityType.invoice];
|
||||
|
||||
return _DashboardSidebar(
|
||||
label1: localization.upcomingInvoices,
|
||||
|
|
|
|||
Loading…
Reference in New Issue