Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Fixing fields visibility
  • Loading branch information
adalpari committed Oct 8, 2025
commit bb3c22b7800a3b4aea25faa498acda9b5a17b392
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,14 @@ class TermsDataViewActivity : BaseAppCompatActivity() {
singleLine = false
)

DetailRow(
label = stringResource(R.string.term_count_label),
value = state.count.toString()
)

ParentDropdownField(
label = stringResource(R.string.term_parent_label),
availableParents = state.availableParents,
selectedParentId = state.parentId,
onParentIdChange = { viewModel.updateTermParent(it) }
)
if (!state.availableParents.isNullOrEmpty() && state.parentId != null) {
ParentDropdownField(
label = stringResource(R.string.term_parent_label),
availableParents = state.availableParents,
selectedParentId = state.parentId,
onParentIdChange = { viewModel.updateTermParent(it) }
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ data class TermDetailUiState(
val slug: String = "",
val description: String = "",
val count: Long = 0L,
val parentId: Long = 0L,
val availableParents: List<ParentOption> = emptyList(),
val isLoading: Boolean = false
val parentId: Long? = null,
val availableParents: List<ParentOption>? = null,
)

data class ParentOption(
Expand Down Expand Up @@ -90,19 +89,22 @@ class TermsViewModel @Inject constructor(
fun navigateToTermDetail(termId: Long) {
val term = currentTerms.firstOrNull { it.id == termId } ?: return

val availableParents = currentTerms
.filter { it.id != termId }
.map { ParentOption(id = it.id, name = it.name) }
val availableParents = if (isHierarchical) {
currentTerms
.filter { it.id != termId }
.map { ParentOption(id = it.id, name = it.name) }
} else {
null
}

_termDetailState.value = TermDetailUiState(
termId = term.id,
name = term.name,
slug = term.slug,
description = term.description,
count = term.count,
parentId = term.parent ?: 0L,
parentId = term.parent,
availableParents = availableParents,
isLoading = false
)
}

Expand Down