Flutter web
This commit is contained in:
parent
9bd7476a6b
commit
9e78bc7e41
|
|
@ -120,14 +120,17 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
||||||
BuiltList<HistoryRecord> get historyList =>
|
BuiltList<HistoryRecord> get historyList =>
|
||||||
prefState.companyPrefs[uiState.selectedCompanyIndex].historyList;
|
prefState.companyPrefs[uiState.selectedCompanyIndex].historyList;
|
||||||
|
|
||||||
bool shouldSelectEntity(EntityType entityType) {
|
bool shouldSelectEntity({EntityType entityType, bool hasRecords}) {
|
||||||
final entityList = getEntityList(entityType);
|
final entityList = getEntityList(entityType);
|
||||||
final entityUIState = getUIState(entityType);
|
final entityUIState = getUIState(entityType);
|
||||||
|
|
||||||
if (prefState.isMobile || entityList.isEmpty || uiState.isEditing) {
|
if (prefState.isMobile || entityList.isEmpty || uiState.isEditing) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entityList.contains(entityUIState.selectedId)) {
|
if (entityUIState.selectedId == null && !hasRecords) {
|
||||||
|
return false;
|
||||||
|
} else if (!entityList.contains(entityUIState.selectedId)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (historyList.isEmpty ||
|
} else if (historyList.isEmpty ||
|
||||||
!historyList.first.isEqualTo(
|
!historyList.first.isEqualTo(
|
||||||
|
|
|
||||||
|
|
@ -141,17 +141,18 @@ class MainScreen extends StatelessWidget {
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
final state = store.state;
|
final state = store.state;
|
||||||
final historyList = state.historyList;
|
final historyList = state.historyList;
|
||||||
final editingOrSettings =
|
final notViewingEntity = state.uiState.isEditing ||
|
||||||
state.uiState.isEditing || state.uiState.isInSettings;
|
state.uiState.isInSettings ||
|
||||||
|
(historyList[0].entityType.toString() != state.uiState.mainRoute);
|
||||||
|
|
||||||
if (historyList.isEmpty ||
|
if (historyList.isEmpty ||
|
||||||
historyList.length == 1 && !editingOrSettings) {
|
historyList.length == 1 && !notViewingEntity) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final history = historyList[editingOrSettings ? 0 : 1];
|
final history = historyList[notViewingEntity ? 0 : 1];
|
||||||
|
|
||||||
if (!editingOrSettings) {
|
if (!notViewingEntity) {
|
||||||
store.dispatch(PopLastHistory());
|
store.dispatch(PopLastHistory());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,8 @@ class _ClientListState extends State<ClientList> {
|
||||||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.shouldSelectEntity(EntityType.client)) {
|
if (state.shouldSelectEntity(
|
||||||
|
entityType: EntityType.client, hasRecords: clientList.isNotEmpty)) {
|
||||||
viewEntityById(
|
viewEntityById(
|
||||||
context: context,
|
context: context,
|
||||||
entityType: EntityType.client,
|
entityType: EntityType.client,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@ class DocumentList extends StatelessWidget {
|
||||||
final isInMultiselect = listUIState.isInMultiselect();
|
final isInMultiselect = listUIState.isInMultiselect();
|
||||||
final documentList = viewModel.documentList;
|
final documentList = viewModel.documentList;
|
||||||
|
|
||||||
if (state.shouldSelectEntity(EntityType.document)) {
|
if (state.shouldSelectEntity(
|
||||||
|
entityType: EntityType.document, hasRecords: documentList.isNotEmpty)) {
|
||||||
viewEntityById(
|
viewEntityById(
|
||||||
context: context,
|
context: context,
|
||||||
entityType: EntityType.document,
|
entityType: EntityType.document,
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,8 @@ class _ExpenseListState extends State<ExpenseList> {
|
||||||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.shouldSelectEntity(EntityType.expense)) {
|
if (state.shouldSelectEntity(
|
||||||
|
entityType: EntityType.expense, hasRecords: expenseList.isNotEmpty)) {
|
||||||
viewEntityById(
|
viewEntityById(
|
||||||
context: context,
|
context: context,
|
||||||
entityType: EntityType.expense,
|
entityType: EntityType.expense,
|
||||||
|
|
@ -195,10 +196,9 @@ class _ExpenseListState extends State<ExpenseList> {
|
||||||
source: dataTableSource,
|
source: dataTableSource,
|
||||||
header: DatatableHeader(
|
header: DatatableHeader(
|
||||||
entityType: EntityType.expense,
|
entityType: EntityType.expense,
|
||||||
onClearPressed: widget
|
onClearPressed:
|
||||||
.viewModel.onClearEntityFilterPressed,
|
widget.viewModel.onClearEntityFilterPressed,
|
||||||
),
|
),
|
||||||
|
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,8 @@ class _EntityListState extends State<InvoiceList> {
|
||||||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.shouldSelectEntity(EntityType.invoice)) {
|
if (state.shouldSelectEntity(
|
||||||
|
entityType: EntityType.invoice, hasRecords: invoiceList.isNotEmpty)) {
|
||||||
viewEntityById(
|
viewEntityById(
|
||||||
context: context,
|
context: context,
|
||||||
entityType: EntityType.invoice,
|
entityType: EntityType.invoice,
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,8 @@ class _PaymentListState extends State<PaymentList> {
|
||||||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.shouldSelectEntity(EntityType.payment)) {
|
if (state.shouldSelectEntity(
|
||||||
|
entityType: EntityType.payment, hasRecords: paymentList.isNotEmpty)) {
|
||||||
viewEntityById(
|
viewEntityById(
|
||||||
context: context,
|
context: context,
|
||||||
entityType: EntityType.payment,
|
entityType: EntityType.payment,
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,8 @@ class _ProductListState extends State<ProductList> {
|
||||||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.shouldSelectEntity(EntityType.product)) {
|
if (state.shouldSelectEntity(
|
||||||
|
entityType: EntityType.product, hasRecords: productList.isNotEmpty)) {
|
||||||
viewEntityById(
|
viewEntityById(
|
||||||
context: context,
|
context: context,
|
||||||
entityType: EntityType.product,
|
entityType: EntityType.product,
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ class _ProjectListState extends State<ProjectList> {
|
||||||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.shouldSelectEntity(EntityType.project)) {
|
if (state.shouldSelectEntity(entityType: EntityType.project, hasRecords: projectList.isNotEmpty)) {
|
||||||
viewEntityById(
|
viewEntityById(
|
||||||
context: context,
|
context: context,
|
||||||
entityType: EntityType.project,
|
entityType: EntityType.project,
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class _TaskListState extends State<TaskList> {
|
||||||
final isInMultiselect = listUIState.isInMultiselect();
|
final isInMultiselect = listUIState.isInMultiselect();
|
||||||
final taskList = widget.viewModel.taskList;
|
final taskList = widget.viewModel.taskList;
|
||||||
|
|
||||||
if (state.shouldSelectEntity(EntityType.task)) {
|
if (state.shouldSelectEntity(entityType: EntityType.task, hasRecords: taskList.isNotEmpty)) {
|
||||||
viewEntityById(
|
viewEntityById(
|
||||||
context: context,
|
context: context,
|
||||||
entityType: EntityType.task,
|
entityType: EntityType.task,
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,8 @@ class _VendorListState extends State<VendorList> {
|
||||||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.shouldSelectEntity(EntityType.vendor)) {
|
if (state.shouldSelectEntity(
|
||||||
|
entityType: EntityType.vendor, hasRecords: vendorList.isNotEmpty)) {
|
||||||
viewEntityById(
|
viewEntityById(
|
||||||
context: context,
|
context: context,
|
||||||
entityType: EntityType.vendor,
|
entityType: EntityType.vendor,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue