Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Androapp 4826 display message when event has no sections or data elements config issue #3481

Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2284b8f
add: [ANDROAPP-4826] string added
DavidAparicioAlbaAsenjo Jan 29, 2024
8baf232
add: [ANDROAPP-4826] no section infobar added
DavidAparicioAlbaAsenjo Jan 29, 2024
28a23fc
delete: [ANDROAPP-4826] dummy section removed
DavidAparicioAlbaAsenjo Jan 29, 2024
0a75c67
update: [ANDROAPP-4826] code formated, infobar added
DavidAparicioAlbaAsenjo Jan 30, 2024
aabb3f9
Merge branch 'develop' into ANDROAPP-4826-Display-message-when-event-…
DavidAparicioAlbaAsenjo Jan 30, 2024
11ccb77
[ANDROAPP-5760] DashboardRepositoryImpl refactor to kotlin, new test …
xavimolloy Dec 14, 2023
93a372f
Move shouldSuccessfullyCreateANewEvent to unit test
Balcan Jan 29, 2024
2c94bda
Move shouldNotBeAbleToCreateNewEventsWhenFull to unit tests
Balcan Jan 29, 2024
95e3f34
Move shouldSuccessfullySyncAChangedTEI to unit tests
Balcan Jan 31, 2024
6dcf25d
update: [ANDROAPP-4826] focus next restored
DavidAparicioAlbaAsenjo Jan 31, 2024
eac7a07
fix test
Balcan Feb 1, 2024
32503c7
fix test
Balcan Feb 2, 2024
c852df0
Merge pull request #3482 from dhis2/ANDROAPP-5760
andresmr Feb 2, 2024
4ac8abd
Remove deep links
andresmr Feb 5, 2024
5feab0b
update version code
andresmr Feb 5, 2024
d90d828
Merge pull request #3488 from dhis2/remove_deep_links
andresmr Feb 5, 2024
e028271
[ANDROAPP-5645] Close enrollment data section if already completed (#…
Balcan Feb 5, 2024
69520d9
feat: [ANDROAPP-5683] legend description (#3486)
mmmateos Feb 5, 2024
1f50e29
fix: [ANDROAPP-5900] adapt Input providers to new TextFieldValue usage
xavimolloy Feb 2, 2024
be69d70
fix: [ANDROAPP-5900] update mobile ui 0.2-20240206.071329-16
xavimolloy Feb 6, 2024
90bdca6
Merge branch 'main' into develop-2.9.1
xavimolloy Feb 6, 2024
84aab55
fix: [ANDROAPP-5900] set initial selection to value length
xavimolloy Feb 6, 2024
4ce45c2
Merge pull request #3485 from dhis2/ANDROAPP-5900-Some-values-are-und…
andresmr Feb 6, 2024
4fcb25e
updates paging on search to paging3
ferdyrod Jan 19, 2024
a022c25
update search tests
ferdyrod Jan 22, 2024
eafa25d
fix code smells
ferdyrod Jan 23, 2024
1765614
updates sdk and prevents scroll to top when paginating
ferdyrod Jan 26, 2024
1f5d2c7
Updates sdk
ferdyrod Feb 6, 2024
7b8f83c
Merge branch 'develop' into develop-2.9.1
xavimolloy Feb 6, 2024
271fff1
Merge pull request #3491 from dhis2/develop-2.9.1
andresmr Feb 7, 2024
daa4428
Merge branch 'develop' into ANDROAPP-5536
ferdyrod Feb 7, 2024
74be855
Merge pull request #3469 from dhis2/ANDROAPP-5536
andresmr Feb 8, 2024
b7722f9
update and adapt design library version
andresmr Feb 8, 2024
c6ab8bc
fix tests
andresmr Feb 8, 2024
44bbb1f
Merge pull request #3492 from dhis2/update_design_library
andresmr Feb 8, 2024
23d412c
adds helpertext to table's input field (#3487)
ferdyrod Feb 12, 2024
e46ba93
add: [ANDROAPP-4826] string added
DavidAparicioAlbaAsenjo Jan 29, 2024
09cbd09
add: [ANDROAPP-4826] no section infobar added
DavidAparicioAlbaAsenjo Jan 29, 2024
9ec039b
delete: [ANDROAPP-4826] dummy section removed
DavidAparicioAlbaAsenjo Jan 29, 2024
bd9a5e6
update: [ANDROAPP-4826] code formated, infobar added
DavidAparicioAlbaAsenjo Jan 30, 2024
dbc2f78
update: [ANDROAPP-4826] focus next restored
DavidAparicioAlbaAsenjo Jan 31, 2024
f1efe26
add: [ANDROAPP-4826] no section infobar added
DavidAparicioAlbaAsenjo Jan 29, 2024
ca6a6a0
delete: [ANDROAPP-4826] dummy section removed
DavidAparicioAlbaAsenjo Jan 29, 2024
3b95666
update: [ANDROAPP-4826] code formated, infobar added
DavidAparicioAlbaAsenjo Jan 30, 2024
e8f0244
Merge branch 'ANDROAPP-4826-Display-message-when-event-has-no-section…
DavidAparicioAlbaAsenjo Feb 13, 2024
031e2ca
update: [ANDROAPP-4826] design system version updated, custom message…
DavidAparicioAlbaAsenjo Feb 13, 2024
c1bd858
update: [ANDROAPP-4826] code formatted
DavidAparicioAlbaAsenjo Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 95 additions & 37 deletions form/src/main/java/org/dhis2/form/ui/Form.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.Icon
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ErrorOutline
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
Expand All @@ -29,13 +33,17 @@ import androidx.compose.ui.unit.dp
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import org.dhis2.commons.resources.ResourceManager
import org.dhis2.form.R
import org.dhis2.form.model.FieldUiModel
import org.dhis2.form.model.FormSection
import org.dhis2.form.ui.event.RecyclerViewUiEvents
import org.dhis2.form.ui.intent.FormIntent
import org.dhis2.form.ui.provider.inputfield.FieldProvider
import org.hisp.dhis.mobile.ui.designsystem.component.InfoBar
import org.hisp.dhis.mobile.ui.designsystem.component.InfoBarData
import org.hisp.dhis.mobile.ui.designsystem.component.Section
import org.hisp.dhis.mobile.ui.designsystem.component.SectionState
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor

@OptIn(ExperimentalFoundationApi::class)
@Composable
Expand All @@ -59,20 +67,20 @@ fun Form(
}
}
}
val focusNext = remember { mutableStateOf(false) }
LazyColumn(
modifier = Modifier
.fillMaxSize()
.background(Color.White)
.clickable(
interactionSource = MutableInteractionSource(),
indication = null,
onClick = { focusManager.clearFocus() },
),
contentPadding = PaddingValues(horizontal = 16.dp, vertical = 16.dp),
state = scrollState,
) {
if (sections.isNotEmpty()) {
if (sections.isNotEmpty()) {
val focusNext = remember { mutableStateOf(false) }
LazyColumn(
modifier = Modifier
.fillMaxSize()
.background(Color.White)
.clickable(
interactionSource = MutableInteractionSource(),
indication = null,
onClick = { focusManager.clearFocus() },
),
contentPadding = PaddingValues(horizontal = 16.dp, vertical = 16.dp),
state = scrollState,
) {
this.itemsIndexed(
items = sections,
key = { _, fieldUiModel -> fieldUiModel.uid },
Expand Down Expand Up @@ -100,7 +108,7 @@ fun Form(
Section(
title = section.title,
isLastSection = getNextSection(section, sections) == null,
description = section.description,
description = if (sections.size >= 2 && section.fields.isNotEmpty()) section.description else null,
completedFields = section.completedFields(),
totalFields = section.fields.size,
state = section.state,
Expand All @@ -111,29 +119,55 @@ fun Form(
intentHandler.invoke(FormIntent.OnSection(section.uid))
},
content = {
section.fields.forEachIndexed { index, fieldUiModel ->
fieldUiModel.setCallback(callback)
FieldProvider(
modifier = Modifier.animateItemPlacement(
animationSpec = tween(
durationMillis = 500,
easing = LinearOutSlowInEasing,
if (sections.size >= 2 && section.fields.isNotEmpty()) {
section.fields.forEachIndexed { index, fieldUiModel ->
fieldUiModel.setCallback(callback)
FieldProvider(
modifier = Modifier.animateItemPlacement(
animationSpec = tween(
durationMillis = 500,
easing = LinearOutSlowInEasing,
),
),
),
fieldUiModel = fieldUiModel,
uiEventHandler = uiEventHandler,
intentHandler = intentHandler,
resources = resources,
focusManager = focusManager,
onNextClicked = {
if (index == section.fields.size - 1) {
onNextSection()
focusNext.value = true
} else {
focusManager.moveFocus(FocusDirection.Down)
}
},
)
fieldUiModel = fieldUiModel,
uiEventHandler = uiEventHandler,
intentHandler = intentHandler,
resources = resources,
focusManager = focusManager,
onNextClicked = {
if (index == section.fields.size - 1) {
onNextSection()
focusNext.value = true
} else {
focusManager.moveFocus(FocusDirection.Down)
}
},
)
}
} else {
Column(
modifier = Modifier
.height(120.dp),
) {
InfoBar(
infoBarData = InfoBarData(
text = resources.getString(R.string.form_without_fields),
icon = {
Icon(
imageVector = Icons.Outlined.ErrorOutline,
contentDescription = "no fields",
tint = SurfaceColor.Warning,
)
},
color = SurfaceColor.Warning,
backgroundColor = SurfaceColor.WarningContainer,
actionText = null,
onClick = null,
),
modifier = Modifier
.background(SurfaceColor.WarningContainer),
)
}
}
},
)
Expand All @@ -142,6 +176,30 @@ fun Form(
Spacer(modifier = Modifier.height(120.dp))
}
}
} else {
Column(
modifier = Modifier
.height(120.dp),
) {
InfoBar(
infoBarData = InfoBarData(
text = resources.getString(R.string.form_without_fields),
icon = {
Icon(
imageVector = Icons.Outlined.ErrorOutline,
contentDescription = "no fields",
tint = SurfaceColor.Warning,
)
},
color = SurfaceColor.Warning,
backgroundColor = SurfaceColor.WarningContainer,
actionText = null,
onClick = null,
),
modifier = Modifier
.background(SurfaceColor.WarningContainer),
)
}
}
}

Expand Down
10 changes: 0 additions & 10 deletions form/src/main/java/org/dhis2/form/ui/mapper/FormSectionMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ class FormSectionMapper {
)
}
}
} else {
sections.add(
FormSection(
uid = "DUMMY",
title = "TITLE",
description = null,
state = SectionState.NO_HEADER,
fields = items.filterIsInstance<FieldUiModelImpl>(),
),
)
}

return sections
Expand Down
1 change: 1 addition & 0 deletions ui-components/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<string name="action_cancel">Cancel</string>
<string name="hint_search">Search</string>
<string name="action_clear_all">Clear all</string>
<string name="form_without_fields">This form has no fields configured</string>
<plurals name="error_count">
<item quantity="one">%s error</item>
<item quantity="other">%s errors</item>
Expand Down
Loading