Skip to content

Commit

Permalink
Androapp 5065 (#31)
Browse files Browse the repository at this point in the history
* Set old Facility

* Test of old facility

* Set old facility

* Update paperwork.json

* Update HomeActivity.kt

* Write logic for table content

* get facility from viewModel

* Update paperwork.json

* [ANDROAPP-5065] ktlint check

Co-authored-by: andresmr <[email protected]>
Co-authored-by: Andrés Miguel Rubio <[email protected]>
  • Loading branch information
3 people committed Feb 8, 2023
1 parent a6cf0c2 commit f594afa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/src/main/assets/paperwork.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"buildTime":"2022-12-01 10:29","gitSha":"5bcdbca40"}
{"buildTime":"2022-12-01 11:16","gitSha":"261ea3c0b"}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class HomeViewModel @Inject constructor(
private val _scanText = MutableStateFlow("")
val scanText = _scanText.asStateFlow()

private val _oldSelectedFacility = MutableStateFlow("")
val oldSelectedFacility = _oldSelectedFacility.asStateFlow()

private val _transactionDate = MutableStateFlow(LocalDateTime.now())
val transactionDate: StateFlow<LocalDateTime>
get() = _transactionDate
Expand Down Expand Up @@ -244,4 +247,7 @@ class HomeViewModel @Inject constructor(
fun setDestinationSelected(status: Boolean) {
_hasDestinationSelected.value = status
}
fun setOldSelectedFacility(text: String) {
_oldSelectedFacility.value = text
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ fun DropdownComponentFacilities(

val interactionSource = remember { MutableInteractionSource() }
if (interactionSource.collectIsPressedAsState().value) {
viewModel.setFacilitySelected(false)
openOrgUnitTreeSelector(supportFragmentManager, homeContext, data, viewModel)
}

Expand Down Expand Up @@ -260,6 +261,7 @@ fun DropdownComponentFacilities(
trailingIcon = {
IconButton(
onClick = {
viewModel.setFacilitySelected(false)
openOrgUnitTreeSelector(
supportFragmentManager,
homeContext,
Expand Down Expand Up @@ -480,12 +482,16 @@ fun openOrgUnitTreeSelector(
viewModel.setFacility(orgUnitDialog.selectedOrgUnitModel)
viewModel.fromFacilitiesLabel(orgUnitDialog.selectedOrgUnitName)
viewModel.setSelectedText(orgUnitDialog.selectedOrgUnitName)
viewModel.setOldSelectedFacility(orgUnitDialog.selectedOrgUnitName)
orgUnitData = orgUnitDialog.selectedOrgUnitModel
viewModel.setFacilitySelected(true)
}
orgUnitDialog.dismiss()
}
.setNegativeListener {
if (viewModel.oldSelectedFacility.value != "") {
viewModel.setFacilitySelected(true)
}
orgUnitDialog.dismiss()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ fun MainContent(
if (viewModel.toolbarTitle.collectAsState().value.name
== TransactionType.DISTRIBUTION.name
) {
if (hasFacilitySelected && hasDestinationSelected == true) {
if (viewModel.hasFacilitySelected.collectAsState().value &&
hasDestinationSelected == true
) {
updateTableState(manageStockViewModel, viewModel)
ManageStockTable(manageStockViewModel) {
scope.launch { backdropState.conceal() }
Expand All @@ -211,7 +213,7 @@ fun MainContent(
} else if (viewModel.toolbarTitle.collectAsState().value.name
== TransactionType.CORRECTION.name
) {
if (hasFacilitySelected) {
if (viewModel.hasFacilitySelected.collectAsState().value) {
updateTableState(manageStockViewModel, viewModel)
ManageStockTable(manageStockViewModel) {
scope.launch { backdropState.conceal() }
Expand All @@ -220,7 +222,7 @@ fun MainContent(
} else if (viewModel.toolbarTitle.collectAsState().value.name
== TransactionType.DISCARD.name
) {
if (hasFacilitySelected) {
if (viewModel.hasFacilitySelected.collectAsState().value) {
updateTableState(manageStockViewModel, viewModel)
ManageStockTable(manageStockViewModel) {
scope.launch { backdropState.conceal() }
Expand Down

0 comments on commit f594afa

Please sign in to comment.