Flutter web
This commit is contained in:
parent
e9cdf8eebc
commit
9bd7476a6b
|
|
@ -301,21 +301,20 @@ void viewEntitiesByType({
|
|||
}
|
||||
}
|
||||
|
||||
void viewEntityById(
|
||||
{BuildContext context,
|
||||
String entityId,
|
||||
EntityType entityType,
|
||||
bool force = false,
|
||||
bool showError = true}) {
|
||||
void viewEntityById({
|
||||
BuildContext context,
|
||||
String entityId,
|
||||
EntityType entityType,
|
||||
bool force = false,
|
||||
}) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final navigator = Navigator.of(context);
|
||||
|
||||
if (!store.state.getEntityMap(entityType).containsKey(entityId)) {
|
||||
if (showError) {
|
||||
showErrorDialog(
|
||||
context: context,
|
||||
message: AppLocalization.of(context).failedToFindRecord);
|
||||
}
|
||||
if (entityId != null &&
|
||||
!store.state.getEntityMap(entityType).containsKey(entityId)) {
|
||||
showErrorDialog(
|
||||
context: context,
|
||||
message: AppLocalization.of(context).failedToFindRecord);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -444,7 +444,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
//return 'Payment: ${uiState.paymentUIState.editing.paymentables}';
|
||||
//return 'isAuthenticated: ${authState.isAuthenticated}';
|
||||
//return 'MultiSelect: ${productListState.isInMultiselect()} SelectedIds: ${productListState.selectedIds}';
|
||||
return 'History: $historyList';
|
||||
//return 'History: $historyList';
|
||||
return 'Route: ${uiState.currentRoute} Prev: ${uiState.previousRoute}';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
|
|||
BuiltList<HistoryRecord> _addToHistory(
|
||||
BuiltList<HistoryRecord> list, HistoryRecord record) {
|
||||
// don't track new records
|
||||
if (record.id.startsWith('-')) {
|
||||
if (record.id == null || record.id.startsWith('-')) {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@ abstract class HistoryRecord
|
|||
|
||||
HistoryRecord._();
|
||||
|
||||
@nullable
|
||||
String get id;
|
||||
|
||||
EntityType get entityType;
|
||||
|
|
|
|||
|
|
@ -363,8 +363,6 @@ class _$HistoryRecordSerializer implements StructuredSerializer<HistoryRecord> {
|
|||
Iterable<Object> serialize(Serializers serializers, HistoryRecord object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[
|
||||
'id',
|
||||
serializers.serialize(object.id, specifiedType: const FullType(String)),
|
||||
'entityType',
|
||||
serializers.serialize(object.entityType,
|
||||
specifiedType: const FullType(EntityType)),
|
||||
|
|
@ -372,7 +370,12 @@ class _$HistoryRecordSerializer implements StructuredSerializer<HistoryRecord> {
|
|||
serializers.serialize(object.timestamp,
|
||||
specifiedType: const FullType(int)),
|
||||
];
|
||||
|
||||
if (object.id != null) {
|
||||
result
|
||||
..add('id')
|
||||
..add(serializers.serialize(object.id,
|
||||
specifiedType: const FullType(String)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -833,9 +836,6 @@ class _$HistoryRecord extends HistoryRecord {
|
|||
(new HistoryRecordBuilder()..update(updates)).build();
|
||||
|
||||
_$HistoryRecord._({this.id, this.entityType, this.timestamp}) : super._() {
|
||||
if (id == null) {
|
||||
throw new BuiltValueNullFieldError('HistoryRecord', 'id');
|
||||
}
|
||||
if (entityType == null) {
|
||||
throw new BuiltValueNullFieldError('HistoryRecord', 'entityType');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,11 +156,10 @@ class MainScreen extends StatelessWidget {
|
|||
}
|
||||
|
||||
viewEntityById(
|
||||
entityType: history.entityType,
|
||||
entityId: history.id,
|
||||
context: context,
|
||||
showError:
|
||||
false); // in case the history record has since been deleted
|
||||
entityType: history.entityType,
|
||||
entityId: history.id,
|
||||
context: context,
|
||||
);
|
||||
|
||||
return false;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -74,15 +74,16 @@ class _ClientListState extends State<ClientList> {
|
|||
|
||||
if (!viewModel.isLoaded) {
|
||||
return viewModel.isLoading ? LoadingIndicator() : SizedBox();
|
||||
} else if (clientList.isEmpty) {
|
||||
} else if (viewModel.clientMap.isEmpty) {
|
||||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||
}
|
||||
|
||||
if (state.shouldSelectEntity(EntityType.client)) {
|
||||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.client,
|
||||
entityId: clientList.first);
|
||||
context: context,
|
||||
entityType: EntityType.client,
|
||||
entityId: clientList.isEmpty ? null : clientList.first,
|
||||
);
|
||||
}
|
||||
|
||||
final listOrTable = () {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class DocumentList extends StatelessWidget {
|
|||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.document,
|
||||
entityId: documentList.first);
|
||||
entityId: documentList.isEmpty ? null : documentList.first);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -51,7 +51,7 @@ class DocumentList extends StatelessWidget {
|
|||
? LoadingIndicator()
|
||||
: RefreshIndicator(
|
||||
onRefresh: () => viewModel.onRefreshed(context),
|
||||
child: viewModel.documentList.isEmpty
|
||||
child: viewModel.documentMap.isEmpty
|
||||
? HelpText(AppLocalization.of(context).noRecordsFound)
|
||||
: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
|
|
|
|||
|
|
@ -85,13 +85,20 @@ class _ExpenseListState extends State<ExpenseList> {
|
|||
final store = StoreProvider.of<AppState>(context);
|
||||
final listUIState = store.state.uiState.expenseUIState.listUIState;
|
||||
final isInMultiselect = listUIState.isInMultiselect();
|
||||
final expenseList = widget.viewModel.expenseList;
|
||||
final viewModel = widget.viewModel;
|
||||
final expenseList = viewModel.expenseList;
|
||||
|
||||
if (!viewModel.isLoaded) {
|
||||
return viewModel.isLoading ? LoadingIndicator() : SizedBox();
|
||||
} else if (viewModel.expenseMap.isEmpty) {
|
||||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||
}
|
||||
|
||||
if (state.shouldSelectEntity(EntityType.expense)) {
|
||||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.expense,
|
||||
entityId: expenseList.first);
|
||||
entityId: expenseList.isEmpty ? null : expenseList.first);
|
||||
}
|
||||
|
||||
widgets.add(Expanded(
|
||||
|
|
@ -99,7 +106,7 @@ class _ExpenseListState extends State<ExpenseList> {
|
|||
? LoadingIndicator()
|
||||
: RefreshIndicator(
|
||||
onRefresh: () => widget.viewModel.onRefreshed(context),
|
||||
child: widget.viewModel.expenseList.isEmpty
|
||||
child: widget.viewModel.expenseMap.isEmpty
|
||||
? HelpText(AppLocalization.of(context).noRecordsFound)
|
||||
: state.prefState.moduleLayout == ModuleLayout.list
|
||||
? ListView.separated(
|
||||
|
|
|
|||
|
|
@ -78,15 +78,16 @@ class _EntityListState extends State<InvoiceList> {
|
|||
|
||||
if (!viewModel.isLoaded) {
|
||||
return viewModel.isLoading ? LoadingIndicator() : SizedBox();
|
||||
} else if (invoiceList.isEmpty) {
|
||||
} else if (viewModel.invoiceMap.isEmpty) {
|
||||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||
}
|
||||
|
||||
if (state.shouldSelectEntity(EntityType.invoice)) {
|
||||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.invoice,
|
||||
entityId: invoiceList.first);
|
||||
context: context,
|
||||
entityType: EntityType.invoice,
|
||||
entityId: invoiceList.isEmpty ? null : invoiceList.first,
|
||||
);
|
||||
}
|
||||
|
||||
final listOrTable = () {
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class _PaymentListState extends State<PaymentList> {
|
|||
|
||||
if (!viewModel.isLoaded) {
|
||||
return viewModel.isLoading ? LoadingIndicator() : SizedBox();
|
||||
} else if (paymentList.isEmpty) {
|
||||
} else if (viewModel.paymentMap.isEmpty) {
|
||||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ class _PaymentListState extends State<PaymentList> {
|
|||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.payment,
|
||||
entityId: paymentList.first);
|
||||
entityId: paymentList.isEmpty ? null : paymentList.first);
|
||||
}
|
||||
|
||||
final listOrTable = () {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class _ProductListState extends State<ProductList> {
|
|||
|
||||
if (!viewModel.isLoaded) {
|
||||
return viewModel.isLoading ? LoadingIndicator() : SizedBox();
|
||||
} else if (productList.isEmpty) {
|
||||
} else if (viewModel.productMap.isEmpty) {
|
||||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ class _ProductListState extends State<ProductList> {
|
|||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.product,
|
||||
entityId: productList.first);
|
||||
entityId: productList.isEmpty ? null : productList.first);
|
||||
}
|
||||
|
||||
final listOrTable = () {
|
||||
|
|
@ -153,7 +153,6 @@ class _ProductListState extends State<ProductList> {
|
|||
header: DatatableHeader(
|
||||
entityType: EntityType.product,
|
||||
),
|
||||
|
||||
),
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,15 +68,22 @@ class _ProjectListState extends State<ProjectList> {
|
|||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final viewModel = widget.viewModel;
|
||||
final listState = widget.viewModel.listState;
|
||||
final isInMultiselect = listState.isInMultiselect();
|
||||
final projectList = widget.viewModel.projectList;
|
||||
|
||||
if (!viewModel.isLoaded) {
|
||||
return viewModel.isLoading ? LoadingIndicator() : SizedBox();
|
||||
} else if (viewModel.projectMap.isEmpty) {
|
||||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||
}
|
||||
|
||||
if (state.shouldSelectEntity(EntityType.project)) {
|
||||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.project,
|
||||
entityId: projectList.first);
|
||||
entityId: projectList.isEmpty ? null : projectList.first);
|
||||
}
|
||||
|
||||
return Column(
|
||||
|
|
@ -93,7 +100,7 @@ class _ProjectListState extends State<ProjectList> {
|
|||
? LoadingIndicator()
|
||||
: RefreshIndicator(
|
||||
onRefresh: () => widget.viewModel.onRefreshed(context),
|
||||
child: widget.viewModel.projectList.isEmpty
|
||||
child: widget.viewModel.projectMap.isEmpty
|
||||
? HelpText(AppLocalization.of(context).noRecordsFound)
|
||||
: state.prefState.moduleLayout == ModuleLayout.list
|
||||
? ListView.separated(
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class _TaskListState extends State<TaskList> {
|
|||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.task,
|
||||
entityId: taskList.first);
|
||||
entityId: taskList.isEmpty ? null : taskList.first);
|
||||
}
|
||||
|
||||
return Column(
|
||||
|
|
@ -93,7 +93,7 @@ class _TaskListState extends State<TaskList> {
|
|||
? LoadingIndicator()
|
||||
: RefreshIndicator(
|
||||
onRefresh: () => widget.viewModel.onRefreshed(context),
|
||||
child: widget.viewModel.taskList.isEmpty
|
||||
child: widget.viewModel.taskMap.isEmpty
|
||||
? HelpText(AppLocalization.of(context).noRecordsFound)
|
||||
: state.prefState.moduleLayout == ModuleLayout.list
|
||||
? ListView.separated(
|
||||
|
|
|
|||
|
|
@ -66,15 +66,22 @@ class _VendorListState extends State<VendorList> {
|
|||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final listUIState = store.state.uiState.vendorUIState.listUIState;
|
||||
final viewModel = widget.viewModel;
|
||||
final listUIState = state.uiState.vendorUIState.listUIState;
|
||||
final isInMultiselect = listUIState.isInMultiselect();
|
||||
final vendorList = widget.viewModel.vendorList;
|
||||
final vendorList = viewModel.vendorList;
|
||||
|
||||
if (!viewModel.isLoaded) {
|
||||
return viewModel.isLoading ? LoadingIndicator() : SizedBox();
|
||||
} else if (viewModel.vendorMap.isEmpty) {
|
||||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||
}
|
||||
|
||||
if (state.shouldSelectEntity(EntityType.vendor)) {
|
||||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.vendor,
|
||||
entityId: vendorList.first);
|
||||
entityId: vendorList.isEmpty ? null : vendorList.first);
|
||||
}
|
||||
|
||||
return Column(
|
||||
|
|
@ -84,7 +91,7 @@ class _VendorListState extends State<VendorList> {
|
|||
? LoadingIndicator()
|
||||
: RefreshIndicator(
|
||||
onRefresh: () => widget.viewModel.onRefreshed(context),
|
||||
child: widget.viewModel.vendorList.isEmpty
|
||||
child: widget.viewModel.vendorMap.isEmpty
|
||||
? HelpText(AppLocalization.of(context).noRecordsFound)
|
||||
: state.prefState.moduleLayout == ModuleLayout.list
|
||||
? ListView.separated(
|
||||
|
|
|
|||
Loading…
Reference in New Issue