-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement searchable multiselect widget (#3123)
* Implement multiselectview Start implementation on multi-select view. Includes the checkbox and listeners Signed-off-by: Elly Kitoto <[email protected]> * Change preview data Signed-off-by: Elly Kitoto <[email protected]> * Use TristateCheckbox on MultiSelect view Signed-off-by: Elly Kitoto <[email protected]> * Implement functionality for generating map required in multiselectview Signed-off-by: Elly Kitoto <[email protected]> * Implement bottomsheet for multi select widget Signed-off-by: Elly Kitoto <[email protected]> * Fix multi-select checkbox select color Signed-off-by: Elly Kitoto <[email protected]> * Implement functionality for node selection Signed-off-by: Elly Kitoto <[email protected]> * Refactor multi select implementation Use Tree data structure as required. Search Tree instead of searching the map. Render the UI from the Tree. Signed-off-by: Elly Kitoto <[email protected]> * Improve UX on multi selector widget search Hide keyboard when search action is triggered. Reset data when search text is empty. Signed-off-by: Elly Kitoto <[email protected]> * Refactor MultiSelect UI to use Compose Scaffold Signed-off-by: Elly Kitoto <[email protected]> * Use ProtoDataStore to store SyncLocations Also refactored how root nodes are identified. Use configuration instead of defaulting to a node without a parent node as the root node. Signed-off-by: Elly Kitoto <[email protected]> * Use selected locations from multi-select widget to sync resources Add comma separated values for _syncLocations query parameter for all requests for the configured sync Resources. Signed-off-by: Elly Kitoto <[email protected]> * Refactor ApplicationConfiguration.syncStrategies to syncStrategy Signed-off-by: Elly Kitoto <[email protected]> * Fix child node checked state issue * Show progress dialog * Add no results view * Refactor initial sync logic + disable sync progresss dialog * Disable progress dialog on initial sync * Fix spotless formatting errors * Add Practitioner to SyncStrategy * Fix failing tests Signed-off-by: Elly Kitoto <[email protected]> --------- Signed-off-by: Elly Kitoto <[email protected]> Co-authored-by: Benjamin Mwalimu <[email protected]> Co-authored-by: Hamza Ahmed Khan <[email protected]> Co-authored-by: Hamza Ahmed Khan <[email protected]>
- Loading branch information
1 parent
5c2da08
commit b6719ff
Showing
38 changed files
with
1,689 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
.../smartregister/fhircore/engine/datastore/serializers/SyncLocationIdDataStoreSerializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2021-2024 Ona Systems, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.smartregister.fhircore.engine.datastore.serializers | ||
|
||
import androidx.datastore.core.Serializer | ||
import java.io.InputStream | ||
import java.io.OutputStream | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.withContext | ||
import org.apache.commons.lang3.SerializationException | ||
import org.smartregister.fhircore.engine.domain.model.SyncLocationToggleableState | ||
import org.smartregister.fhircore.engine.util.extension.encodeJson | ||
import org.smartregister.fhircore.engine.util.extension.json | ||
import timber.log.Timber | ||
|
||
object SyncLocationIdDataStoreSerializer : Serializer<List<SyncLocationToggleableState>> { | ||
|
||
override val defaultValue: List<SyncLocationToggleableState> | ||
get() = emptyList() | ||
|
||
override suspend fun readFrom(input: InputStream): List<SyncLocationToggleableState> { | ||
return try { | ||
json.decodeFromString<List<SyncLocationToggleableState>>(input.readBytes().decodeToString()) | ||
} catch (serializationException: SerializationException) { | ||
Timber.e(serializationException) | ||
defaultValue | ||
} | ||
} | ||
|
||
override suspend fun writeTo(t: List<SyncLocationToggleableState>, output: OutputStream) { | ||
withContext(Dispatchers.IO) { output.write(t.encodeJson().encodeToByteArray()) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ine/src/main/java/org/smartregister/fhircore/engine/domain/model/MultiSelectViewConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2021-2024 Ona Systems, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.smartregister.fhircore.engine.domain.model | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* @property resourceConfig The configuration for FHIR resource to be loaded | ||
* @property parentIdFhirPathExpression FhirPath expression for extracting the ID for the parent | ||
* resource | ||
* @property contentFhirPathExpression FhirPath expression for extracting the content displayed on | ||
* the multi select widget e.g. the name of the Location in a Location hierarchy | ||
* @property rootNodeFhirPathExpression A key value pair containing a FHIRPath expression for | ||
* extracting the value used to identify if the current resource is Root. The key is the FHIRPath | ||
* expression while value is the content to compare against. | ||
*/ | ||
@Serializable | ||
@Parcelize | ||
data class MultiSelectViewConfig( | ||
val resourceConfig: FhirResourceConfig, | ||
val parentIdFhirPathExpression: String, | ||
val contentFhirPathExpression: String, | ||
val rootNodeFhirPathExpression: KeyValueConfig, | ||
) : java.io.Serializable, Parcelable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.