Skip to content

Commit

Permalink
* Fix form issues w/ new observations
Browse files Browse the repository at this point in the history
* Do not add default forms to an observation more than once.
* Filter archived forms when adding to new observation.
  • Loading branch information
newmanw committed Sep 21, 2022
1 parent cf43fb1 commit 923b8ca
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ Adheres to [Semantic Versioning](http://semver.org/).

##### Bug Fixes

## [7.1.7](https://github.com/ngageoint/mage-android/releases/tag/7.1.7)

##### Features

##### Bug Fixes
* Do not add default forms to an observation more than once.
* Filter archived forms when adding to new observation.

## [7.1.6](https://github.com/ngageoint/mage-android/releases/tag/7.1.6)

##### Features
Expand Down
4 changes: 2 additions & 2 deletions mage/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
}

group 'mil.nga.giat.mage'
version '7.1.6'
version '7.1.7'
ext {
sourceRefspec = Grgit.open(currentDir: project.rootDir).head().id

Expand Down Expand Up @@ -69,7 +69,7 @@ android {
applicationId "mil.nga.giat.mage"
versionName project.version
versionCode VERSION_CODE as int
minSdkVersion 24
minSdkVersion 25
targetSdkVersion 30
multiDexEnabled true
resValue "string", "serverURLDefaultValue", serverURL
Expand Down
5 changes: 4 additions & 1 deletion mage/src/main/java/mil/nga/giat/mage/form/FormViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,14 @@ open class FormViewModel @Inject constructor(
event.forms.mapNotNull { form ->
fromJson(form.json)
}
.filterNot { it.archived }
.forEachIndexed { index, form ->
formDefinitions.add(form)

val defaultForm = FormPreferences(context, event.id, form.id).getDefaults()
repeat((form.min ?: 0) + if (form.default) 1 else 0) {
val formMin = form.min ?: 0
val formCount = formMin + if (form.default && formMin == 0) 1 else 0
repeat(formCount) {
val formState = FormState.fromForm(eventId = event.remoteId, form = form, defaultForm = defaultForm)
formState.expanded.value = index == 0
forms.add(formState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,12 @@ class FormPickerBottomSheetFragment: BottomSheetDialogFragment() {

val forms = jsonForms
.asSequence()
.map { form ->
.mapNotNull { form ->
JsonParser.parseString(form.json).asJsonObjectOrNull()?.let { json ->
Form.fromJson(json)
}
}
.filterNotNull()
.filter { !it.archived }
.filterNot { it.archived }
.map { form ->
val formMax = form.max
val totalOfForm = viewModel.observationState.value?.forms?.value?.filter { it.definition.id == form.id }?.size ?: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ private void parseAuthenticationStrategies(JSONObject json) {
* @param json json value
*/
private void populateValues(String sharedPreferenceName, JSONObject json) {
@SuppressWarnings("unchecked")
Iterator<String> iter = json.keys();
while (iter.hasNext()) {
String key = iter.next();
Expand Down

0 comments on commit 923b8ca

Please sign in to comment.