diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectWrapper.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectWrapper.kt index e4dc73c82a..9afb3e6914 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectWrapper.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectWrapper.kt @@ -199,6 +199,9 @@ sealed class ObjectWrapper { else -> emptyList() } + + val allRecommendedRelations: List + get() = recommendedRelations + recommendedFeaturedRelations + recommendedHiddenRelations + recommendedFileRelations } data class Relation(override val map: Struct) : ObjectWrapper() { diff --git a/feature-object-type/src/main/java/com/anytypeio/anytype/feature_object_type/ui/header/HorizontalButtons.kt b/feature-object-type/src/main/java/com/anytypeio/anytype/feature_object_type/ui/header/HorizontalButtons.kt index d7aa576b0a..910efe840b 100644 --- a/feature-object-type/src/main/java/com/anytypeio/anytype/feature_object_type/ui/header/HorizontalButtons.kt +++ b/feature-object-type/src/main/java/com/anytypeio/anytype/feature_object_type/ui/header/HorizontalButtons.kt @@ -54,6 +54,32 @@ fun HorizontalButtons( shape = RoundedCornerShape(size = 8.dp) ) + if (uiFieldsButtonState is UiFieldsButtonState.Visible) { + Row( + modifier = modifierButton.noRippleThrottledClickable { + onTypeEvent(TypeEvent.OnFieldsButtonClick) + }, + verticalAlignment = Alignment.CenterVertically + ) { + Text( + modifier = Modifier + .wrapContentSize() + .padding(start = 12.dp), + text = stringResource(R.string.button_fields), + style = PreviewTitle2Medium, + color = colorResource(R.color.text_primary) + ) + Text( + modifier = Modifier + .wrapContentSize() + .padding(start = 6.dp, end = 12.dp), + text = uiFieldsButtonState.count.toString(), + style = PreviewTitle2Medium, + color = colorResource(R.color.glyph_active) + ) + } + } + if (uiLayoutButtonState is UiLayoutButtonState.Visible) { Row( modifier = modifierButton.noRippleThrottledClickable { @@ -81,31 +107,6 @@ fun HorizontalButtons( ) } } - if (uiFieldsButtonState is UiFieldsButtonState.Visible) { - Row( - modifier = modifierButton.noRippleThrottledClickable { - onTypeEvent(TypeEvent.OnFieldsButtonClick) - }, - verticalAlignment = Alignment.CenterVertically - ) { - Text( - modifier = Modifier - .wrapContentSize() - .padding(start = 12.dp), - text = stringResource(R.string.button_fields), - style = PreviewTitle2Medium, - color = colorResource(R.color.text_primary) - ) - Text( - modifier = Modifier - .wrapContentSize() - .padding(start = 6.dp, end = 12.dp), - text = uiFieldsButtonState.count.toString(), - style = PreviewTitle2Medium, - color = colorResource(R.color.glyph_active) - ) - } - } if (uiTemplatesButtonState is UiTemplatesButtonState.Visible) { Row( diff --git a/feature-properties/src/main/java/com/anytypeio/anytype/feature_properties/EditTypePropertiesViewModel.kt b/feature-properties/src/main/java/com/anytypeio/anytype/feature_properties/EditTypePropertiesViewModel.kt index 4626b76a42..432912416a 100644 --- a/feature-properties/src/main/java/com/anytypeio/anytype/feature_properties/EditTypePropertiesViewModel.kt +++ b/feature-properties/src/main/java/com/anytypeio/anytype/feature_properties/EditTypePropertiesViewModel.kt @@ -3,7 +3,6 @@ package com.anytypeio.anytype.feature_properties import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.anytypeio.anytype.core_models.Id -import com.anytypeio.anytype.core_models.Key import com.anytypeio.anytype.core_models.ObjectWrapper import com.anytypeio.anytype.core_models.Relations import com.anytypeio.anytype.core_ui.extensions.simpleIcon @@ -89,13 +88,12 @@ class EditTypePropertiesViewModel( ) { _, _, queryText -> val objType = storeOfObjectTypes.get(id = vmParams.objectTypeId) if (objType != null) { - val typeKeys = - objType.recommendedRelations + objType.recommendedFeaturedRelations + objType.recommendedFileRelations + objType.recommendedHiddenRelations - queryText to filterProperties( - allProperties = storeOfRelations.getAll(), - typeKeys = typeKeys, + val filteredAllSpaceProperties = filterSpacePropertiesByTypeIds( + allSpaceProperties = storeOfRelations.getAll(), + objTypeIds = objType.allRecommendedRelations, queryText = queryText ) + queryText to filteredAllSpaceProperties } else { Timber.w("Object type:[${vmParams.objectTypeId}] not found in the store") queryText to emptyList() @@ -106,10 +104,10 @@ class EditTypePropertiesViewModel( UiEditTypePropertiesErrorState.Reason.Other("Error while filtering properties") ) } - .collect { (queryText, filteredProperties) -> + .collect { (queryText, filteredAllSpaceProperties) -> - val sortedExistingItems = filteredProperties.mapNotNull { field -> - field.mapToStateItem( + val sortedExistingItems = filteredAllSpaceProperties.mapNotNull { property -> + property.mapToStateItem( stringResourceProvider = stringResourceProvider ) }.sortedBy { it.title } @@ -174,14 +172,14 @@ class EditTypePropertiesViewModel( } } - private fun filterProperties( - allProperties: List, - typeKeys: List, + private fun filterSpacePropertiesByTypeIds( + allSpaceProperties: List, + objTypeIds: List, queryText: String - ): List = allProperties.filter { field -> - field.key !in typeKeys && - field.isValidToUse && - (queryText.isBlank() || field.name?.contains(queryText, ignoreCase = true) == true) + ): List = allSpaceProperties.filter { property -> + property.id !in objTypeIds && + property.isValidToUse && + (queryText.isBlank() || property.name?.contains(queryText, ignoreCase = true) == true) } fun hideError() { diff --git a/localization/src/main/res/values/strings.xml b/localization/src/main/res/values/strings.xml index c3141237fa..8e39acd6c5 100644 --- a/localization/src/main/res/values/strings.xml +++ b/localization/src/main/res/values/strings.xml @@ -788,7 +788,7 @@ Set Collection Layout - Fields + Properties Layout Templates Restore from archive @@ -1876,7 +1876,7 @@ Please provide specific details of your needs here. New field Preview field Save - Delete + Unlink from type Add to the current type Remove Local fields