mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-609 Sets | Enhancement | Viewer atomic changes (#2866)
* DROID-609 updateView event, fields * DROID-609 legacy * DROID-609 set, update fields in state * DROID-609 code style * DROID-609 add test * DROID-609 view update commands * DROID-609 fix commands proto * DROID-609 data view update commands, data + mw * DROID-609 add param to command * DROID-609 update data view use case update * DROID-609 data view update use case, invoke * DROID-609 fix after mw update * DROID-609 data view commands, data module * DROID-609 fix tests * DROID-609 filters legacy * DROID-609 add id param to filter model * DROID-609 legacy * DROID-609 legacy * DROID-609 legacy * DROID-609 param id added to sort model * DROID-609 show toast command * DROID-609 update events * DROID-609 sorts logic * DROID-609 filters and relations commands * DROID-609 update data view use case * DROID-609 sorts view fixes * DROID-609 fix commands * DROID-609 mw commands * DROID-609 rename * DROID-609 rename * DROID-609 fix tests * DROID-609 test fix * DROID-609 fix test * DROID-609 pr fixes * DROID-609 pr fix * DROID-609 ci start * DROID-609 ci off * DROID-609 pr fix
This commit is contained in:
parent
ba3b4a3f6c
commit
948b5ade22
78 changed files with 1528 additions and 1161 deletions
|
@ -128,7 +128,7 @@ class CreateSelectedFilterTest {
|
|||
// Defining viewer containing one filter
|
||||
|
||||
val filter = DVFilter(
|
||||
relationKey = relationKey,
|
||||
relation = relationKey,
|
||||
value = true,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = DVFilterCondition.EQUAL
|
||||
|
@ -221,7 +221,7 @@ class CreateSelectedFilterTest {
|
|||
// Defining viewer containing one filter
|
||||
|
||||
val filter = DVFilter(
|
||||
relationKey = relationKey,
|
||||
relation = relationKey,
|
||||
value = true,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = DVFilterCondition.EQUAL
|
||||
|
|
|
@ -105,7 +105,7 @@ class FilterListTest {
|
|||
// Defining viewer containing one filter
|
||||
|
||||
val filter = DVFilter(
|
||||
relationKey = relationKey,
|
||||
relation = relationKey,
|
||||
value = true,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = DVFilterCondition.EQUAL
|
||||
|
@ -196,7 +196,7 @@ class FilterListTest {
|
|||
// Defining viewer containing one filter
|
||||
|
||||
val filter = DVFilter(
|
||||
relationKey = relationKey,
|
||||
relation = relationKey,
|
||||
value = false,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = DVFilterCondition.NOT_EQUAL
|
||||
|
@ -287,7 +287,7 @@ class FilterListTest {
|
|||
// Defining viewer containing one filter
|
||||
|
||||
val filter = DVFilter(
|
||||
relationKey = relationKey,
|
||||
relation = relationKey,
|
||||
value = null,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = DVFilterCondition.EQUAL
|
||||
|
|
|
@ -136,7 +136,7 @@ class ModifyInputValueFilterTest {
|
|||
val textToType = "Bar"
|
||||
|
||||
val filter = DVFilter(
|
||||
relationKey = relationKey,
|
||||
relation = relationKey,
|
||||
value = initialFilterText,
|
||||
condition = DVFilterCondition.EQUAL
|
||||
)
|
||||
|
@ -257,7 +257,7 @@ class ModifyInputValueFilterTest {
|
|||
val textToType = "2"
|
||||
|
||||
val filter = DVFilter(
|
||||
relationKey = relationKey,
|
||||
relation = relationKey,
|
||||
value = initialFilterText,
|
||||
condition = DVFilterCondition.EQUAL
|
||||
)
|
||||
|
|
|
@ -151,7 +151,7 @@ class ModifyStatusFilterTest {
|
|||
// Defining viewer containing one filter
|
||||
|
||||
val filter = DVFilter(
|
||||
relationKey = relationKey,
|
||||
relation = relationKey,
|
||||
value = listOf(option1.id),
|
||||
condition = DVFilterCondition.EQUAL
|
||||
)
|
||||
|
|
|
@ -156,7 +156,7 @@ class ModifyTagFilterTest {
|
|||
name = MockDataFactory.randomString(),
|
||||
filters = listOf(
|
||||
DVFilter(
|
||||
relationKey = relationKey,
|
||||
relation = relationKey,
|
||||
value = listOf(option1.id),
|
||||
condition = DVFilterCondition.ALL_IN
|
||||
)
|
||||
|
|
|
@ -3,11 +3,8 @@ package com.anytypeio.anytype.di.feature
|
|||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.ModifyDataViewViewerRelationOrder
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.relations.DeleteRelationFromDataView
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetSettingsViewModel
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
|
@ -40,26 +37,15 @@ object ObjectSetSettingsModule {
|
|||
state: StateFlow<ObjectSet>,
|
||||
session: ObjectSetSession,
|
||||
dispatcher: Dispatcher<Payload>,
|
||||
modifyViewerRelationOrder: ModifyDataViewViewerRelationOrder,
|
||||
updateDataViewViewer: UpdateDataViewViewer,
|
||||
deleteRelationFromDataView: DeleteRelationFromDataView,
|
||||
store: StoreOfRelations,
|
||||
analytics: Analytics
|
||||
): ObjectSetSettingsViewModel.Factory = ObjectSetSettingsViewModel.Factory(
|
||||
state = state,
|
||||
session = session,
|
||||
dispatcher = dispatcher,
|
||||
modifyViewerRelationOrder = modifyViewerRelationOrder,
|
||||
updateDataViewViewer = updateDataViewViewer,
|
||||
deleteRelationFromDataView = deleteRelationFromDataView,
|
||||
analytics = analytics,
|
||||
store = store,
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerModal
|
||||
fun provideModifyViewerRelationOrderUseCase(
|
||||
repo: BlockRepository
|
||||
): ModifyDataViewViewerRelationOrder = ModifyDataViewViewerRelationOrder(repo = repo)
|
||||
}
|
|
@ -3,8 +3,7 @@ package com.anytypeio.anytype.di.feature
|
|||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewViewerSort
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
|
@ -37,22 +36,15 @@ object SelectSortRelationModule {
|
|||
state: StateFlow<ObjectSet>,
|
||||
session: ObjectSetSession,
|
||||
dispatcher: Dispatcher<Payload>,
|
||||
addDataViewViewerSort: AddDataViewViewerSort,
|
||||
updateDataViewViewer: UpdateDataViewViewer,
|
||||
storeOfRelations: StoreOfRelations,
|
||||
analytics: Analytics
|
||||
): SelectSortRelationViewModel.Factory = SelectSortRelationViewModel.Factory(
|
||||
state = state,
|
||||
session = session,
|
||||
dispatcher = dispatcher,
|
||||
addDataViewViewerSort = addDataViewViewerSort,
|
||||
updateDataViewViewer = updateDataViewViewer,
|
||||
storeOfRelations = storeOfRelations,
|
||||
analytics = analytics
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerModal
|
||||
fun provideAddDataViewViewerSort(
|
||||
repo: BlockRepository
|
||||
): AddDataViewViewerSort = AddDataViewViewerSort(repo = repo)
|
||||
}
|
|
@ -67,8 +67,6 @@ import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
|||
import com.anytypeio.anytype.presentation.sets.ObjectSetCommand
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetViewModel
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetViewModelFactory
|
||||
import com.anytypeio.anytype.presentation.sets.model.FilterExpression
|
||||
import com.anytypeio.anytype.presentation.sets.model.SortingExpression
|
||||
import com.anytypeio.anytype.presentation.sets.model.Viewer
|
||||
import com.anytypeio.anytype.ui.base.NavigationFragment
|
||||
import com.anytypeio.anytype.ui.editor.cover.SelectCoverObjectSetFragment
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.anytypeio.anytype.core_utils.ext.drawable
|
|||
import com.anytypeio.anytype.core_utils.ext.gone
|
||||
import com.anytypeio.anytype.core_utils.ext.invisible
|
||||
import com.anytypeio.anytype.core_utils.ext.subscribe
|
||||
import com.anytypeio.anytype.core_utils.ext.toast
|
||||
import com.anytypeio.anytype.core_utils.ext.visible
|
||||
import com.anytypeio.anytype.core_utils.ext.withParent
|
||||
import com.anytypeio.anytype.core_utils.ui.BaseFragment
|
||||
|
@ -171,6 +172,9 @@ open class CreateFilterFromSelectedValueFragment :
|
|||
ctx = ctx
|
||||
)
|
||||
}
|
||||
is FilterViewModel.Commands.Toast -> {
|
||||
toast(commands.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -148,6 +148,9 @@ open class ModifyFilterFromSelectedValueFragment :
|
|||
ctx = ctx,
|
||||
)
|
||||
}
|
||||
is FilterViewModel.Commands.Toast -> {
|
||||
this.toast(commands.message)
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import javax.inject.Inject
|
|||
class ModifyViewerSortFragment : BaseBottomSheetFragment<FragmentModifyViewerSortBinding>() {
|
||||
|
||||
private val ctx: Id get() = arg(CTX_KEY)
|
||||
private val sortId: Id get() = arg(SORT_ID_KEY)
|
||||
private val relationKey: Key get() = arg(RELATION_KEY)
|
||||
|
||||
@Inject
|
||||
|
@ -37,8 +38,12 @@ class ModifyViewerSortFragment : BaseBottomSheetFragment<FragmentModifyViewerSor
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
with(lifecycleScope) {
|
||||
subscribe(binding.tvSortAsc.clicks()) { vm.onSortAscSelected(ctx, relationKey) }
|
||||
subscribe(binding.tvSortDesc.clicks()) { vm.onSortDescSelected(ctx, relationKey) }
|
||||
subscribe(binding.tvSortAsc.clicks()) {
|
||||
vm.onSortAscSelected(ctx = ctx, sortId = sortId)
|
||||
}
|
||||
subscribe(binding.tvSortDesc.clicks()) {
|
||||
vm.onSortDescSelected(ctx = ctx, sortId = sortId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +70,7 @@ class ModifyViewerSortFragment : BaseBottomSheetFragment<FragmentModifyViewerSor
|
|||
}
|
||||
}
|
||||
super.onStart()
|
||||
vm.onStart(relationKey)
|
||||
vm.onStart(sortId = sortId, relationKey = relationKey)
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
|
@ -89,12 +94,14 @@ class ModifyViewerSortFragment : BaseBottomSheetFragment<FragmentModifyViewerSor
|
|||
)
|
||||
|
||||
companion object {
|
||||
fun new(ctx: Id, relation: Id): ModifyViewerSortFragment =
|
||||
fun new(ctx: Id, sortId: Id, relation: Key): ModifyViewerSortFragment =
|
||||
ModifyViewerSortFragment().apply {
|
||||
arguments = bundleOf(CTX_KEY to ctx, RELATION_KEY to relation)
|
||||
arguments =
|
||||
bundleOf(CTX_KEY to ctx, SORT_ID_KEY to sortId, RELATION_KEY to relation)
|
||||
}
|
||||
|
||||
private const val CTX_KEY = "arg.modify-viewer-sort.ctx"
|
||||
private const val SORT_ID_KEY = "arg.modify-viewer-sort.sort-id"
|
||||
private const val RELATION_KEY = "arg.modify-viewer-sort.relation"
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Key
|
||||
import com.anytypeio.anytype.core_ui.extensions.drawable
|
||||
import com.anytypeio.anytype.core_ui.features.sets.ViewerSortAdapter
|
||||
import com.anytypeio.anytype.core_ui.layout.DividerVerticalItemDecoration
|
||||
|
@ -39,9 +40,16 @@ open class ViewerSortFragment : BaseBottomSheetFragment<FragmentViewerSortBindin
|
|||
private val viewerSortAdapter by lazy {
|
||||
ViewerSortAdapter(
|
||||
onViewerSortClicked = { view ->
|
||||
if (view.mode == ScreenState.READ) navigateToChangeSort(view.relation)
|
||||
if (view.mode == ScreenState.READ) navigateToChangeSort(
|
||||
sortId = view.sortId,
|
||||
relation = view.relation
|
||||
)
|
||||
},
|
||||
onRemoveViewerSortClicked = { vm.onRemoveViewerSortClicked(ctx, it) }
|
||||
onRemoveViewerSortClicked = {
|
||||
vm.onRemoveViewerSortClicked(
|
||||
ctx = ctx, view = it
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -53,8 +61,8 @@ open class ViewerSortFragment : BaseBottomSheetFragment<FragmentViewerSortBindin
|
|||
fr.show(parentFragmentManager, null)
|
||||
}
|
||||
|
||||
private fun navigateToChangeSort(relation: Id) {
|
||||
val fr = ModifyViewerSortFragment.new(ctx = ctx, relation = relation)
|
||||
private fun navigateToChangeSort(sortId: Id, relation: Key) {
|
||||
val fr = ModifyViewerSortFragment.new(ctx = ctx, sortId = sortId, relation = relation)
|
||||
fr.show(parentFragmentManager, null)
|
||||
}
|
||||
|
||||
|
|
|
@ -330,6 +330,7 @@ data class Block(
|
|||
enum class TimeFormat { H12, H24 }
|
||||
|
||||
data class Sort(
|
||||
val id: Id = "",
|
||||
val relationKey: String,
|
||||
val type: Type
|
||||
) {
|
||||
|
@ -340,7 +341,8 @@ data class Block(
|
|||
* [relationFormat] optional relation format, which should be specified for date-related filtering.
|
||||
*/
|
||||
data class Filter(
|
||||
val relationKey: String,
|
||||
val id: Id = "",
|
||||
val relation: Key,
|
||||
val relationFormat: RelationFormat? = null,
|
||||
val operator: Operator = Operator.AND,
|
||||
val condition: Condition,
|
||||
|
|
|
@ -384,4 +384,38 @@ sealed class Command {
|
|||
val blockId: String,
|
||||
val content: Block.Content.Link
|
||||
)
|
||||
|
||||
data class AddFilter(
|
||||
val ctx: Id,
|
||||
val dv: Id,
|
||||
val view: Id,
|
||||
val relationKey: String,
|
||||
val relationFormat: RelationFormat?,
|
||||
val operator: Block.Content.DataView.Filter.Operator,
|
||||
val condition: Block.Content.DataView.Filter.Condition,
|
||||
val quickOption: Block.Content.DataView.Filter.QuickOption,
|
||||
val value: Any? = null
|
||||
)
|
||||
|
||||
data class ReplaceFilter(val ctx: Id, val dv: Id, val view: Id, val id: Id, val filter: DVFilter)
|
||||
data class RemoveFilter(val ctx: Id, val dv: Id, val view: Id, val ids: List<Id>)
|
||||
|
||||
data class AddSort(
|
||||
val ctx: Id,
|
||||
val dv: Id,
|
||||
val view: Id,
|
||||
val relationKey: String,
|
||||
val relationFormat: RelationFormat? = null,
|
||||
val type: DVSortType,
|
||||
val customOrder: List<Any> = emptyList(),
|
||||
val includeTime: Boolean? = null
|
||||
)
|
||||
|
||||
data class ReplaceSort(val ctx: Id, val dv: Id, val view: Id, val sort: DVSort)
|
||||
data class RemoveSort(val ctx: Id, val dv: Id, val view: Id, val ids: List<Id>)
|
||||
|
||||
data class AddRelation(val ctx: Id, val dv: Id, val view: Id, val relation: DVViewerRelation)
|
||||
data class UpdateRelation(val ctx: Id, val dv: Id, val view: Id, val relation: DVViewerRelation)
|
||||
data class DeleteRelation(val ctx: Id, val dv: Id, val view: Id, val keys: List<Key>)
|
||||
data class SortRelations(val ctx: Id, val dv: Id, val view: Id, val keys: List<Key>)
|
||||
}
|
|
@ -266,7 +266,8 @@ sealed class Event {
|
|||
val viewerId: Id,
|
||||
val filterUpdates: List<DVFilterUpdate>,
|
||||
val sortUpdates: List<DVSortUpdate>,
|
||||
val relationUpdates: List<DVViewerRelationUpdate>
|
||||
val relationUpdates: List<DVViewerRelationUpdate>,
|
||||
val fields: DVViewerFields?
|
||||
) : DataView() {
|
||||
|
||||
sealed class DVFilterUpdate {
|
||||
|
@ -293,6 +294,15 @@ sealed class Event {
|
|||
data class Update(val id: Id, val relation: DVViewerRelation) :
|
||||
DVViewerRelationUpdate()
|
||||
}
|
||||
|
||||
data class DVViewerFields(
|
||||
val name: String,
|
||||
val type: DVViewerType,
|
||||
val coverRelationKey: String,
|
||||
val hideIcon: Boolean,
|
||||
val cardSize: DVViewerCardSize,
|
||||
val coverFit: Boolean
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -690,7 +690,7 @@ class BlockDataRepository(
|
|||
)
|
||||
}
|
||||
|
||||
override suspend fun addObjectToWorkspace(objects: List<Id>) : List<Id> {
|
||||
override suspend fun addObjectToWorkspace(objects: List<Id>): List<Id> {
|
||||
return remote.addObjectToWorkspace(
|
||||
objects = objects
|
||||
)
|
||||
|
@ -700,4 +700,44 @@ class BlockDataRepository(
|
|||
ctx = ctx,
|
||||
source = source
|
||||
)
|
||||
|
||||
override suspend fun addDataViewFilter(command: Command.AddFilter): Payload {
|
||||
return remote.addDataViewFilter(command = command)
|
||||
}
|
||||
|
||||
override suspend fun removeDataViewFilter(command: Command.RemoveFilter): Payload {
|
||||
return remote.removeDataViewFilter(command)
|
||||
}
|
||||
|
||||
override suspend fun replaceDataViewFilter(command: Command.ReplaceFilter): Payload {
|
||||
return remote.replaceDataViewFilter(command)
|
||||
}
|
||||
|
||||
override suspend fun addDataViewSort(command: Command.AddSort): Payload {
|
||||
return remote.addDataViewSort(command)
|
||||
}
|
||||
|
||||
override suspend fun removeDataViewSort(command: Command.RemoveSort): Payload {
|
||||
return remote.removeDataViewSort(command)
|
||||
}
|
||||
|
||||
override suspend fun replaceDataViewSort(command: Command.ReplaceSort): Payload {
|
||||
return remote.replaceDataViewSort(command)
|
||||
}
|
||||
|
||||
override suspend fun addDataViewViewRelation(command: Command.AddRelation): Payload {
|
||||
return remote.addDataViewViewRelation(command)
|
||||
}
|
||||
|
||||
override suspend fun removeDataViewViewRelation(command: Command.DeleteRelation): Payload {
|
||||
return remote.removeDataViewViewRelation(command)
|
||||
}
|
||||
|
||||
override suspend fun replaceDataViewViewRelation(command: Command.UpdateRelation): Payload {
|
||||
return remote.replaceDataViewViewRelation(command)
|
||||
}
|
||||
|
||||
override suspend fun sortDataViewViewRelation(command: Command.SortRelations): Payload {
|
||||
return remote.sortDataViewViewRelation(command)
|
||||
}
|
||||
}
|
|
@ -302,4 +302,17 @@ interface BlockDataStore {
|
|||
): CreateBlockLinkWithObjectResult
|
||||
|
||||
suspend fun createWidget(ctx: Id, source: Id): Payload
|
||||
|
||||
suspend fun addDataViewFilter(command: Command.AddFilter): Payload
|
||||
suspend fun removeDataViewFilter(command: Command.RemoveFilter): Payload
|
||||
suspend fun replaceDataViewFilter(command: Command.ReplaceFilter): Payload
|
||||
|
||||
suspend fun addDataViewSort(command: Command.AddSort): Payload
|
||||
suspend fun removeDataViewSort(command: Command.RemoveSort): Payload
|
||||
suspend fun replaceDataViewSort(command: Command.ReplaceSort): Payload
|
||||
|
||||
suspend fun addDataViewViewRelation(command: Command.AddRelation): Payload
|
||||
suspend fun removeDataViewViewRelation(command: Command.DeleteRelation): Payload
|
||||
suspend fun replaceDataViewViewRelation(command: Command.UpdateRelation): Payload
|
||||
suspend fun sortDataViewViewRelation(command: Command.SortRelations): Payload
|
||||
}
|
|
@ -49,7 +49,7 @@ interface BlockRemote {
|
|||
command: Command.CreateBlockLinkWithObject
|
||||
): CreateBlockLinkWithObjectResult
|
||||
|
||||
suspend fun openObject(id: Id) : ObjectView
|
||||
suspend fun openObject(id: Id): ObjectView
|
||||
suspend fun openPage(id: String): Payload
|
||||
suspend fun openProfile(id: String): Payload
|
||||
suspend fun openObjectSet(id: String): Payload
|
||||
|
@ -302,4 +302,17 @@ interface BlockRemote {
|
|||
suspend fun createObject(command: Command.CreateObject): CreateObjectResult
|
||||
|
||||
suspend fun createWidget(ctx: Id, source: Id): Payload
|
||||
|
||||
suspend fun addDataViewFilter(command: Command.AddFilter): Payload
|
||||
suspend fun removeDataViewFilter(command: Command.RemoveFilter): Payload
|
||||
suspend fun replaceDataViewFilter(command: Command.ReplaceFilter): Payload
|
||||
|
||||
suspend fun addDataViewSort(command: Command.AddSort): Payload
|
||||
suspend fun removeDataViewSort(command: Command.RemoveSort): Payload
|
||||
suspend fun replaceDataViewSort(command: Command.ReplaceSort): Payload
|
||||
|
||||
suspend fun addDataViewViewRelation(command: Command.AddRelation): Payload
|
||||
suspend fun removeDataViewViewRelation(command: Command.DeleteRelation): Payload
|
||||
suspend fun replaceDataViewViewRelation(command: Command.UpdateRelation): Payload
|
||||
suspend fun sortDataViewViewRelation(command: Command.SortRelations): Payload
|
||||
}
|
|
@ -631,4 +631,44 @@ class BlockRemoteDataStore(private val remote: BlockRemote) : BlockDataStore {
|
|||
ctx = ctx,
|
||||
source = source
|
||||
)
|
||||
|
||||
override suspend fun addDataViewFilter(command: Command.AddFilter): Payload {
|
||||
return remote.addDataViewFilter(command)
|
||||
}
|
||||
|
||||
override suspend fun removeDataViewFilter(command: Command.RemoveFilter): Payload {
|
||||
return remote.removeDataViewFilter(command)
|
||||
}
|
||||
|
||||
override suspend fun replaceDataViewFilter(command: Command.ReplaceFilter): Payload {
|
||||
return remote.replaceDataViewFilter(command)
|
||||
}
|
||||
|
||||
override suspend fun addDataViewSort(command: Command.AddSort): Payload {
|
||||
return remote.addDataViewSort(command)
|
||||
}
|
||||
|
||||
override suspend fun removeDataViewSort(command: Command.RemoveSort): Payload {
|
||||
return remote.removeDataViewSort(command)
|
||||
}
|
||||
|
||||
override suspend fun replaceDataViewSort(command: Command.ReplaceSort): Payload {
|
||||
return remote.replaceDataViewSort(command)
|
||||
}
|
||||
|
||||
override suspend fun addDataViewViewRelation(command: Command.AddRelation): Payload {
|
||||
return remote.addDataViewViewRelation(command)
|
||||
}
|
||||
|
||||
override suspend fun removeDataViewViewRelation(command: Command.DeleteRelation): Payload {
|
||||
return remote.removeDataViewViewRelation(command)
|
||||
}
|
||||
|
||||
override suspend fun replaceDataViewViewRelation(command: Command.UpdateRelation): Payload {
|
||||
return remote.replaceDataViewViewRelation(command)
|
||||
}
|
||||
|
||||
override suspend fun sortDataViewViewRelation(command: Command.SortRelations): Payload {
|
||||
return remote.sortDataViewViewRelation(command)
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ class GetLastOpenedObject(
|
|||
sorts = emptyList(),
|
||||
filters = listOf(
|
||||
Block.Content.DataView.Filter(
|
||||
relationKey = Relations.ID,
|
||||
relation = Relations.ID,
|
||||
condition = Block.Content.DataView.Filter.Condition.EQUAL,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
value = lastOpenObjectId
|
||||
|
|
|
@ -355,4 +355,17 @@ interface BlockRepository {
|
|||
ctx: Id,
|
||||
source: Id
|
||||
): Payload
|
||||
|
||||
suspend fun addDataViewFilter(command: Command.AddFilter): Payload
|
||||
suspend fun removeDataViewFilter(command: Command.RemoveFilter): Payload
|
||||
suspend fun replaceDataViewFilter(command: Command.ReplaceFilter): Payload
|
||||
|
||||
suspend fun addDataViewSort(command: Command.AddSort): Payload
|
||||
suspend fun removeDataViewSort(command: Command.RemoveSort): Payload
|
||||
suspend fun replaceDataViewSort(command: Command.ReplaceSort): Payload
|
||||
|
||||
suspend fun addDataViewViewRelation(command: Command.AddRelation): Payload
|
||||
suspend fun removeDataViewViewRelation(command: Command.DeleteRelation): Payload
|
||||
suspend fun replaceDataViewViewRelation(command: Command.UpdateRelation): Payload
|
||||
suspend fun sortDataViewViewRelation(command: Command.SortRelations): Payload
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package com.anytypeio.anytype.domain.dataview.interactor
|
||||
|
||||
import com.anytypeio.anytype.core_models.DVSort
|
||||
import com.anytypeio.anytype.core_models.DVViewer
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
|
||||
/**
|
||||
* Use-case for adding a sort to a dataview's view.
|
||||
*/
|
||||
class AddDataViewViewerSort(
|
||||
private val repo: BlockRepository
|
||||
) : BaseUseCase<Payload, AddDataViewViewerSort.Params>() {
|
||||
|
||||
override suspend fun run(params: Params) = safe {
|
||||
val update = params.viewer.sorts.toMutableList().apply { add(params.sort) }
|
||||
repo.updateDataViewViewer(
|
||||
context = params.ctx,
|
||||
target = params.dataview,
|
||||
viewer = params.viewer.copy(sorts = update),
|
||||
)
|
||||
}
|
||||
|
||||
data class Params(
|
||||
val ctx: Id,
|
||||
val dataview: Id,
|
||||
val viewer: DVViewer,
|
||||
val sort: DVSort
|
||||
)
|
||||
}
|
|
@ -63,10 +63,10 @@ class CreateDataViewObject(
|
|||
): Struct =
|
||||
buildMap {
|
||||
filters.forEach { filter ->
|
||||
val relation = storeOfRelations.getByKey(filter.relationKey)
|
||||
val relation = storeOfRelations.getByKey(filter.relation)
|
||||
if (relation != null && relation.isReadOnly == false) {
|
||||
if (filter.condition == DVFilterCondition.ALL_IN || filter.condition == DVFilterCondition.IN || filter.condition == DVFilterCondition.EQUAL) {
|
||||
filter.value?.let { put(filter.relationKey, it) }
|
||||
filter.value?.let { put(filter.relation, it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,12 +89,12 @@ class CreateDataViewObject(
|
|||
): Struct = try {
|
||||
buildMap {
|
||||
filters.forEach { filter ->
|
||||
val relation = storeOfRelations.getByKey(filter.relationKey)
|
||||
val relation = storeOfRelations.getByKey(filter.relation)
|
||||
if (relation != null && !relation.isReadonlyValue) {
|
||||
if (filter.condition == DVFilterCondition.ALL_IN || filter.condition == DVFilterCondition.IN || filter.condition == DVFilterCondition.EQUAL) {
|
||||
val value = filter.value
|
||||
if (value != null) {
|
||||
put(filter.relationKey, value)
|
||||
put(filter.relation, value)
|
||||
}
|
||||
} else {
|
||||
put(relation.key, resolveDefaultValueByFormat(relation.relationFormat))
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package com.anytypeio.anytype.domain.dataview.interactor
|
||||
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.core_models.DVViewer
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.ModifyDataViewViewerRelationOrder.Params
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
|
||||
/**
|
||||
* Use-case for modifying relation order for a data view's view.
|
||||
* @see [Params] for details.
|
||||
*/
|
||||
class ModifyDataViewViewerRelationOrder(
|
||||
private val repo: BlockRepository
|
||||
) : BaseUseCase<Payload, Params>() {
|
||||
|
||||
override suspend fun run(params: Params) = safe {
|
||||
repo.updateDataViewViewer(
|
||||
context = params.context,
|
||||
target = params.target,
|
||||
viewer = params.viewer
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @property [context] operation context (can be object-set's id or something else)
|
||||
* @property [target] id of the data-view block
|
||||
* @property [viewer] specific viewer of this [target], whose relation order is considered updated.
|
||||
*/
|
||||
data class Params(
|
||||
val context: Id,
|
||||
val target: Id,
|
||||
val viewer: DVViewer
|
||||
)
|
||||
}
|
|
@ -1,10 +1,17 @@
|
|||
package com.anytypeio.anytype.domain.dataview.interactor
|
||||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Command
|
||||
import com.anytypeio.anytype.core_models.DVFilter
|
||||
import com.anytypeio.anytype.core_models.DVSort
|
||||
import com.anytypeio.anytype.core_models.DVViewer
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.core_models.DVViewer
|
||||
import com.anytypeio.anytype.core_models.DVViewerRelation
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Key
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.RelationFormat
|
||||
|
||||
/**
|
||||
* Use-case for updating data view's viewer.
|
||||
|
@ -14,21 +21,168 @@ class UpdateDataViewViewer(
|
|||
) : BaseUseCase<Payload, UpdateDataViewViewer.Params>() {
|
||||
|
||||
override suspend fun run(params: Params) = safe {
|
||||
repo.updateDataViewViewer(
|
||||
context = params.context,
|
||||
target = params.target,
|
||||
viewer = params.viewer
|
||||
)
|
||||
when (params) {
|
||||
is Params.Filter.Add -> {
|
||||
val command = Command.AddFilter(
|
||||
ctx = params.ctx,
|
||||
dv = params.dv,
|
||||
view = params.view,
|
||||
relationKey = params.relationKey,
|
||||
relationFormat = params.relationFormat,
|
||||
operator = params.operator,
|
||||
condition = params.condition,
|
||||
quickOption = params.quickOption,
|
||||
value = params.value
|
||||
)
|
||||
repo.addDataViewFilter(command = command)
|
||||
}
|
||||
is Params.Filter.Remove -> {
|
||||
val command = Command.RemoveFilter(
|
||||
ctx = params.ctx,
|
||||
dv = params.dv,
|
||||
view = params.view,
|
||||
ids = params.ids
|
||||
)
|
||||
repo.removeDataViewFilter(command)
|
||||
}
|
||||
is Params.Filter.Replace -> {
|
||||
val command = Command.ReplaceFilter(
|
||||
ctx = params.ctx,
|
||||
dv = params.dv,
|
||||
view = params.view,
|
||||
id = params.filter.id,
|
||||
filter = params.filter
|
||||
)
|
||||
repo.replaceDataViewFilter(command)
|
||||
}
|
||||
is Params.Sort.Add -> {
|
||||
val command = Command.AddSort(
|
||||
ctx = params.ctx,
|
||||
dv = params.dv,
|
||||
view = params.view,
|
||||
relationKey = params.sort.relationKey,
|
||||
type = params.sort.type
|
||||
)
|
||||
repo.addDataViewSort(command)
|
||||
}
|
||||
is Params.Sort.Remove -> {
|
||||
val command = Command.RemoveSort(
|
||||
ctx = params.ctx,
|
||||
dv = params.dv,
|
||||
view = params.view,
|
||||
ids = params.ids
|
||||
)
|
||||
repo.removeDataViewSort(command)
|
||||
}
|
||||
is Params.Sort.Replace -> {
|
||||
val command = Command.ReplaceSort(
|
||||
ctx = params.ctx,
|
||||
dv = params.dv,
|
||||
view = params.view,
|
||||
sort = params.sort
|
||||
)
|
||||
repo.replaceDataViewSort(command)
|
||||
}
|
||||
is Params.ViewerRelation.Add -> {
|
||||
val command = Command.AddRelation(
|
||||
ctx = params.ctx,
|
||||
dv = params.dv,
|
||||
view = params.view,
|
||||
relation = params.relation
|
||||
)
|
||||
repo.addDataViewViewRelation(command)
|
||||
}
|
||||
is Params.ViewerRelation.Remove -> {
|
||||
val command = Command.DeleteRelation(
|
||||
ctx = params.ctx,
|
||||
dv = params.dv,
|
||||
view = params.view,
|
||||
keys = params.keys
|
||||
)
|
||||
repo.removeDataViewViewRelation(command)
|
||||
}
|
||||
is Params.ViewerRelation.Replace -> {
|
||||
val command = Command.UpdateRelation(
|
||||
ctx = params.ctx,
|
||||
dv = params.dv,
|
||||
view = params.view,
|
||||
relation = params.relation
|
||||
)
|
||||
repo.replaceDataViewViewRelation(command)
|
||||
}
|
||||
is Params.ViewerRelation.Sort -> {
|
||||
val command = Command.SortRelations(
|
||||
ctx = params.ctx,
|
||||
dv = params.dv,
|
||||
view = params.view,
|
||||
keys = params.keys
|
||||
)
|
||||
repo.sortDataViewViewRelation(command)
|
||||
}
|
||||
is Params.Fields -> {
|
||||
repo.updateDataViewViewer(
|
||||
context = params.context,
|
||||
target = params.target,
|
||||
viewer = params.viewer
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @property [context] operation context (can be object-set's id or something else)
|
||||
* @property [target] id of the data-view block
|
||||
* @property [target] specific viewer of this [target]
|
||||
*/
|
||||
data class Params(
|
||||
val context: Id,
|
||||
val target: Id,
|
||||
val viewer: DVViewer
|
||||
)
|
||||
sealed class Params {
|
||||
sealed class Filter : Params() {
|
||||
data class Add(
|
||||
val ctx: Id,
|
||||
val dv: Id,
|
||||
val view: Id,
|
||||
val relationKey: String,
|
||||
val relationFormat: RelationFormat? = null,
|
||||
val operator: Block.Content.DataView.Filter.Operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
val condition: Block.Content.DataView.Filter.Condition,
|
||||
val quickOption: Block.Content.DataView.Filter.QuickOption = Block.Content.DataView.Filter.QuickOption.EXACT_DATE,
|
||||
val value: Any? = null
|
||||
) : Filter()
|
||||
|
||||
data class Replace(val ctx: Id, val dv: Id, val view: Id, val filter: DVFilter) :
|
||||
Filter()
|
||||
|
||||
data class Remove(val ctx: Id, val dv: Id, val view: Id, val ids: List<Id>) : Filter()
|
||||
}
|
||||
|
||||
sealed class Sort : Params() {
|
||||
|
||||
data class Add(val ctx: Id, val dv: Id, val view: Id, val sort: DVSort) : Sort()
|
||||
data class Replace(
|
||||
val ctx: Id, val dv: Id, val view: Id, val sort: DVSort
|
||||
) : Sort()
|
||||
|
||||
data class Remove(val ctx: Id, val dv: Id, val view: Id, val ids: List<Id>) : Sort()
|
||||
}
|
||||
|
||||
sealed class ViewerRelation : Params() {
|
||||
|
||||
data class Add(val ctx: Id, val dv: Id, val view: Id, val relation: DVViewerRelation) :
|
||||
ViewerRelation()
|
||||
|
||||
data class Replace(
|
||||
val ctx: Id,
|
||||
val dv: Id,
|
||||
val view: Id,
|
||||
val key: Key,
|
||||
val relation: DVViewerRelation
|
||||
) : ViewerRelation()
|
||||
|
||||
data class Remove(val ctx: Id, val dv: Id, val view: Id, val keys: List<Key>) :
|
||||
ViewerRelation()
|
||||
|
||||
data class Sort(val ctx: Id, val dv: Id, val view: Id, val keys: List<Key>) :
|
||||
ViewerRelation()
|
||||
}
|
||||
|
||||
data class Fields(
|
||||
val context: Id,
|
||||
val target: Id,
|
||||
val viewer: DVViewer
|
||||
) : Params()
|
||||
}
|
||||
}
|
|
@ -17,28 +17,28 @@ class GetOptions(
|
|||
val filters = buildList {
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = ObjectTypeIds.RELATION_OPTION
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = false
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = false
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.RELATION_KEY,
|
||||
relation = Relations.RELATION_KEY,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = params.relation
|
||||
)
|
||||
|
|
|
@ -26,12 +26,12 @@ class ObjectTypesSubscriptionManager(
|
|||
subscription = ObjectTypesSubscriptionContainer.SUBSCRIPTION_ID,
|
||||
filters = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = ObjectTypeIds.OBJECT_TYPE
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceManager.getCurrentWorkspace()
|
||||
)
|
||||
|
|
|
@ -27,17 +27,17 @@ class RelationsSubscriptionManager(
|
|||
subscription = RelationsSubscriptionContainer.SUBSCRIPTION_ID,
|
||||
filters = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = ObjectTypeIds.RELATION
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = false
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceManager.getCurrentWorkspace()
|
||||
)
|
||||
|
|
|
@ -20,12 +20,12 @@ class FindObjectSetForType(
|
|||
limit = 1,
|
||||
filters = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = ObjectTypeIds.SET
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.SET_OF,
|
||||
relation = Relations.SET_OF,
|
||||
condition = DVFilterCondition.IN,
|
||||
value = listOf(params.type)
|
||||
)
|
||||
|
|
|
@ -26,22 +26,22 @@ class GetTemplates(
|
|||
repo.searchObjects(
|
||||
filters = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = false
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = false
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = ObjectTypeIds.TEMPLATE
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.TARGET_OBJECT_TYPE,
|
||||
relation = Relations.TARGET_OBJECT_TYPE,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = params.type
|
||||
)
|
||||
|
|
|
@ -668,4 +668,44 @@ class BlockMiddleware(
|
|||
ctx = ctx,
|
||||
source = source
|
||||
)
|
||||
|
||||
override suspend fun addDataViewFilter(command: Command.AddFilter): Payload {
|
||||
return middleware.addDataViewFilter(command)
|
||||
}
|
||||
|
||||
override suspend fun removeDataViewFilter(command: Command.RemoveFilter): Payload {
|
||||
return middleware.removeDataViewFilter(command)
|
||||
}
|
||||
|
||||
override suspend fun replaceDataViewFilter(command: Command.ReplaceFilter): Payload {
|
||||
return middleware.replaceDataViewFilter(command)
|
||||
}
|
||||
|
||||
override suspend fun addDataViewSort(command: Command.AddSort): Payload {
|
||||
return middleware.addDataViewSort(command)
|
||||
}
|
||||
|
||||
override suspend fun removeDataViewSort(command: Command.RemoveSort): Payload {
|
||||
return middleware.removeDataViewSort(command)
|
||||
}
|
||||
|
||||
override suspend fun replaceDataViewSort(command: Command.ReplaceSort): Payload {
|
||||
return middleware.replaceDataViewSort(command)
|
||||
}
|
||||
|
||||
override suspend fun addDataViewViewRelation(command: Command.AddRelation): Payload {
|
||||
return middleware.addDataViewViewRelation(command)
|
||||
}
|
||||
|
||||
override suspend fun removeDataViewViewRelation(command: Command.DeleteRelation): Payload {
|
||||
return middleware.removeDataViewViewRelation(command)
|
||||
}
|
||||
|
||||
override suspend fun replaceDataViewViewRelation(command: Command.UpdateRelation): Payload {
|
||||
return middleware.replaceDataViewViewRelation(command)
|
||||
}
|
||||
|
||||
override suspend fun sortDataViewViewRelation(command: Command.SortRelations): Payload {
|
||||
return middleware.sortDataViewViewRelation(command)
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@ import com.anytypeio.anytype.core_models.Url
|
|||
import com.anytypeio.anytype.middleware.BuildConfig
|
||||
import com.anytypeio.anytype.middleware.auth.toAccountSetup
|
||||
import com.anytypeio.anytype.middleware.const.Constants
|
||||
import com.anytypeio.anytype.middleware.mappers.MDVFilter
|
||||
import com.anytypeio.anytype.middleware.mappers.MRelationFormat
|
||||
import com.anytypeio.anytype.middleware.mappers.core
|
||||
import com.anytypeio.anytype.middleware.mappers.parse
|
||||
|
@ -1830,6 +1831,181 @@ class Middleware(
|
|||
return response.event.toPayload()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun addDataViewFilter(
|
||||
command: Command.AddFilter
|
||||
): Payload {
|
||||
val filter = MDVFilter(
|
||||
RelationKey = command.relationKey,
|
||||
operator_ = command.operator.toMiddlewareModel(),
|
||||
condition = command.condition.toMiddlewareModel(),
|
||||
quickOption = command.quickOption.toMiddlewareModel(),
|
||||
value_ = command.value,
|
||||
format = command.relationFormat?.toMiddlewareModel()
|
||||
?: anytype.model.RelationFormat.longtext
|
||||
)
|
||||
val request = Rpc.BlockDataview.Filter.Add.Request(
|
||||
contextId = command.ctx,
|
||||
blockId = command.dv,
|
||||
viewId = command.view,
|
||||
filter = filter
|
||||
)
|
||||
if (BuildConfig.DEBUG) logRequest(request)
|
||||
val response = service.blockDataViewAddFilter(request)
|
||||
if (BuildConfig.DEBUG) logResponse(response)
|
||||
return response.event.toPayload()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun replaceDataViewFilter(
|
||||
command: Command.ReplaceFilter
|
||||
): Payload {
|
||||
val request = Rpc.BlockDataview.Filter.Replace.Request(
|
||||
contextId = command.ctx,
|
||||
blockId = command.dv,
|
||||
viewId = command.view,
|
||||
id = command.id,
|
||||
filter = command.filter.toMiddlewareModel()
|
||||
)
|
||||
if (BuildConfig.DEBUG) logRequest(request)
|
||||
val response = service.blockDataViewReplaceFilter(request)
|
||||
if (BuildConfig.DEBUG) logResponse(response)
|
||||
return response.event.toPayload()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun removeDataViewFilter(
|
||||
command: Command.RemoveFilter
|
||||
): Payload {
|
||||
val request = Rpc.BlockDataview.Filter.Remove.Request(
|
||||
contextId = command.ctx,
|
||||
blockId = command.dv,
|
||||
viewId = command.view,
|
||||
ids = command.ids
|
||||
)
|
||||
if (BuildConfig.DEBUG) logRequest(request)
|
||||
val response = service.blockDataViewRemoveFilter(request)
|
||||
if (BuildConfig.DEBUG) logResponse(response)
|
||||
return response.event.toPayload()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun addDataViewSort(command: Command.AddSort): Payload {
|
||||
val request = Rpc.BlockDataview.Sort.Add.Request(
|
||||
contextId = command.ctx,
|
||||
blockId = command.dv,
|
||||
viewId = command.view,
|
||||
sort = Block.Content.Dataview.Sort(
|
||||
RelationKey = command.relationKey,
|
||||
type = command.type.toMiddlewareModel(),
|
||||
customOrder = command.customOrder,
|
||||
format = command.relationFormat?.toMiddlewareModel()
|
||||
?: anytype.model.RelationFormat.longtext,
|
||||
includeTime = command.includeTime ?: false
|
||||
)
|
||||
)
|
||||
if (BuildConfig.DEBUG) logRequest(request)
|
||||
val response = service.blockDataViewAddSort(request)
|
||||
if (BuildConfig.DEBUG) logResponse(response)
|
||||
return response.event.toPayload()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun replaceDataViewSort(command: Command.ReplaceSort): Payload {
|
||||
val request = Rpc.BlockDataview.Sort.Replace.Request(
|
||||
contextId = command.ctx,
|
||||
blockId = command.dv,
|
||||
viewId = command.view,
|
||||
id = command.sort.id,
|
||||
sort = command.sort.toMiddlewareModel()
|
||||
)
|
||||
if (BuildConfig.DEBUG) logRequest(request)
|
||||
val response = service.blockDataViewReplaceSort(request)
|
||||
if (BuildConfig.DEBUG) logResponse(response)
|
||||
return response.event.toPayload()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun removeDataViewSort(
|
||||
command: Command.RemoveSort
|
||||
): Payload {
|
||||
val request = Rpc.BlockDataview.Sort.Remove.Request(
|
||||
contextId = command.ctx,
|
||||
blockId = command.dv,
|
||||
viewId = command.view,
|
||||
ids = command.ids
|
||||
)
|
||||
if (BuildConfig.DEBUG) logRequest(request)
|
||||
val response = service.blockDataViewRemoveSort(request)
|
||||
if (BuildConfig.DEBUG) logResponse(response)
|
||||
return response.event.toPayload()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun addDataViewViewRelation(
|
||||
command: Command.AddRelation
|
||||
): Payload {
|
||||
val request = Rpc.BlockDataview.ViewRelation.Add.Request(
|
||||
contextId = command.ctx,
|
||||
blockId = command.dv,
|
||||
viewId = command.view,
|
||||
relation = command.relation.toMiddlewareModel()
|
||||
)
|
||||
if (BuildConfig.DEBUG) logRequest(request)
|
||||
val response = service.blockDataViewAddViewRelation(request)
|
||||
if (BuildConfig.DEBUG) logResponse(response)
|
||||
return response.event.toPayload()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun replaceDataViewViewRelation(
|
||||
command: Command.UpdateRelation
|
||||
): Payload {
|
||||
val request = Rpc.BlockDataview.ViewRelation.Replace.Request(
|
||||
contextId = command.ctx,
|
||||
blockId = command.dv,
|
||||
viewId = command.view,
|
||||
relationKey = command.relation.key,
|
||||
relation = command.relation.toMiddlewareModel()
|
||||
)
|
||||
if (BuildConfig.DEBUG) logRequest(request)
|
||||
val response = service.blockDataViewReplaceViewRelation(request)
|
||||
if (BuildConfig.DEBUG) logResponse(response)
|
||||
return response.event.toPayload()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun removeDataViewViewRelation(
|
||||
command: Command.DeleteRelation
|
||||
): Payload {
|
||||
val request = Rpc.BlockDataview.ViewRelation.Remove.Request(
|
||||
contextId = command.ctx,
|
||||
blockId = command.dv,
|
||||
viewId = command.view,
|
||||
relationKeys = command.keys
|
||||
)
|
||||
if (BuildConfig.DEBUG) logRequest(request)
|
||||
val response = service.blockDataViewRemoveViewRelation(request)
|
||||
if (BuildConfig.DEBUG) logResponse(response)
|
||||
return response.event.toPayload()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun sortDataViewViewRelation(
|
||||
command: Command.SortRelations
|
||||
): Payload {
|
||||
val request = Rpc.BlockDataview.ViewRelation.Sort.Request(
|
||||
contextId = command.ctx,
|
||||
blockId = command.dv,
|
||||
viewId = command.view,
|
||||
relationKeys = command.keys
|
||||
)
|
||||
if (BuildConfig.DEBUG) logRequest(request)
|
||||
val response = service.blockDataViewSortViewRelation(request)
|
||||
if (BuildConfig.DEBUG) logResponse(response)
|
||||
return response.event.toPayload()
|
||||
}
|
||||
|
||||
private fun logRequest(any: Any) {
|
||||
logger.logRequest(any)
|
||||
}
|
||||
|
|
|
@ -240,7 +240,8 @@ fun anytype.Event.Message.toCoreModels(
|
|||
},
|
||||
relationUpdates = event.relation.mapNotNull { relation ->
|
||||
relation.toCoreModels()
|
||||
}
|
||||
},
|
||||
fields = event.fields?.toCoreModels()
|
||||
)
|
||||
}
|
||||
else -> null
|
||||
|
|
|
@ -46,6 +46,7 @@ typealias MDVTimeFormat = anytype.model.Block.Content.Dataview.Relation.TimeForm
|
|||
typealias MDVFilterUpdate = anytype.Event.Block.Dataview.ViewUpdate.Filter
|
||||
typealias MDVSortUpdate = anytype.Event.Block.Dataview.ViewUpdate.Sort
|
||||
typealias MDVRelationUpdate = anytype.Event.Block.Dataview.ViewUpdate.Relation
|
||||
typealias MDVViewFields = anytype.Event.Block.Dataview.ViewUpdate.Fields
|
||||
|
||||
typealias MObjectType = anytype.model.ObjectType
|
||||
typealias MSmartBlockType = anytype.model.SmartBlockType
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.core_models.SearchResult
|
|||
import com.anytypeio.anytype.core_models.Event.Command.DataView.UpdateView.DVFilterUpdate
|
||||
import com.anytypeio.anytype.core_models.Event.Command.DataView.UpdateView.DVSortUpdate
|
||||
import com.anytypeio.anytype.core_models.Event.Command.DataView.UpdateView.DVViewerRelationUpdate
|
||||
import com.anytypeio.anytype.core_models.Event.Command.DataView.UpdateView.DVViewerFields
|
||||
|
||||
fun Event.Object.Subscription.Counters.parse(): SearchResult.Counter = SearchResult.Counter(
|
||||
total = total.toInt(),
|
||||
|
@ -127,4 +128,15 @@ fun MDVRelationUpdate.toCoreModels(): DVViewerRelationUpdate? {
|
|||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun MDVViewFields.toCoreModels(): DVViewerFields {
|
||||
return DVViewerFields(
|
||||
name = name,
|
||||
type = type.toCoreModels(),
|
||||
coverRelationKey = coverRelationKey,
|
||||
hideIcon = hideIcon,
|
||||
cardSize = cardSize.toCodeModels(),
|
||||
coverFit = coverFit
|
||||
)
|
||||
}
|
|
@ -518,7 +518,8 @@ fun MDVViewType.toCoreModels(): DVViewerType = when (this) {
|
|||
}
|
||||
|
||||
fun MDVFilter.toCoreModels(): DVFilter = DVFilter(
|
||||
relationKey = RelationKey,
|
||||
id = id,
|
||||
relation = RelationKey,
|
||||
operator = operator_.toCoreModels(),
|
||||
condition = condition.toCoreModels(),
|
||||
quickOption = quickOption.toCoreModels(),
|
||||
|
@ -566,6 +567,7 @@ fun MDVFilterOperator.toCoreModels(): DVFilterOperator = when (this) {
|
|||
}
|
||||
|
||||
fun MDVSort.toCoreModels(): Block.Content.DataView.Sort = DVSort(
|
||||
id = id,
|
||||
relationKey = RelationKey,
|
||||
type = type.toCoreModels()
|
||||
)
|
||||
|
@ -757,4 +759,10 @@ fun Rpc.BlockLink.CreateWithObject.Response.toCoreModel(): CreateBlockLinkWithOb
|
|||
objectId = targetId,
|
||||
event = event.toPayload()
|
||||
)
|
||||
}
|
||||
|
||||
fun MDVViewCardSize.toCodeModels(): DVViewerCardSize = when (this) {
|
||||
MDVViewCardSize.Small -> DVViewerCardSize.SMALL
|
||||
MDVViewCardSize.Medium -> DVViewerCardSize.MEDIUM
|
||||
MDVViewCardSize.Large -> DVViewerCardSize.LARGE
|
||||
}
|
|
@ -340,6 +340,7 @@ fun Block.Content.DataView.Viewer.Type.toMiddlewareModel(): MDVViewType = when (
|
|||
|
||||
fun Block.Content.DataView.Sort.toMiddlewareModel(): MDVSort =
|
||||
MDVSort(
|
||||
id = id,
|
||||
RelationKey = relationKey,
|
||||
type = type.toMiddlewareModel()
|
||||
)
|
||||
|
@ -352,7 +353,8 @@ fun Block.Content.DataView.Sort.Type.toMiddlewareModel(): MDVSortType = when (th
|
|||
|
||||
fun Block.Content.DataView.Filter.toMiddlewareModel(): MDVFilter =
|
||||
MDVFilter(
|
||||
RelationKey = relationKey,
|
||||
id = id,
|
||||
RelationKey = relation,
|
||||
operator_ = operator.toMiddlewareModel(),
|
||||
condition = condition.toMiddlewareModel(),
|
||||
quickOption = quickOption.toMiddlewareModel(),
|
||||
|
|
|
@ -283,6 +283,42 @@ interface MiddlewareService {
|
|||
@Throws(Exception::class)
|
||||
fun blockDataViewSetSource(request: Rpc.BlockDataview.SetSource.Request): Rpc.BlockDataview.SetSource.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewAddFilter(request: Rpc.BlockDataview.Filter.Add.Request): Rpc.BlockDataview.Filter.Add.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewRemoveFilter(request: Rpc.BlockDataview.Filter.Remove.Request): Rpc.BlockDataview.Filter.Remove.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewReplaceFilter(request: Rpc.BlockDataview.Filter.Replace.Request): Rpc.BlockDataview.Filter.Replace.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewSortFilter(request: Rpc.BlockDataview.Filter.Sort.Request): Rpc.BlockDataview.Filter.Sort.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewAddSort(request: Rpc.BlockDataview.Sort.Add.Request): Rpc.BlockDataview.Sort.Add.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewRemoveSort(request: Rpc.BlockDataview.Sort.Remove.Request): Rpc.BlockDataview.Sort.Remove.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewReplaceSort(request: Rpc.BlockDataview.Sort.Replace.Request): Rpc.BlockDataview.Sort.Replace.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewSortSort(request: Rpc.BlockDataview.Sort.SSort.Request): Rpc.BlockDataview.Sort.SSort.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewAddViewRelation(request: Rpc.BlockDataview.ViewRelation.Add.Request): Rpc.BlockDataview.ViewRelation.Add.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewRemoveViewRelation(request: Rpc.BlockDataview.ViewRelation.Remove.Request): Rpc.BlockDataview.ViewRelation.Remove.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewReplaceViewRelation(request: Rpc.BlockDataview.ViewRelation.Replace.Request): Rpc.BlockDataview.ViewRelation.Replace.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewSortViewRelation(request: Rpc.BlockDataview.ViewRelation.Sort.Request): Rpc.BlockDataview.ViewRelation.Sort.Response
|
||||
|
||||
//endregion
|
||||
|
||||
//region TEXT BLOCK commands
|
||||
|
|
|
@ -722,7 +722,8 @@ class MiddlewareServiceImplementation @Inject constructor(
|
|||
}
|
||||
|
||||
override fun objectCreateRelation(request: Rpc.Object.CreateRelation.Request): Rpc.Object.CreateRelation.Response {
|
||||
val encoded = Service.objectCreateRelation(Rpc.Object.CreateRelation.Request.ADAPTER.encode(request))
|
||||
val encoded =
|
||||
Service.objectCreateRelation(Rpc.Object.CreateRelation.Request.ADAPTER.encode(request))
|
||||
val response = Rpc.Object.CreateRelation.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.Object.CreateRelation.Response.Error.Code.NULL) {
|
||||
|
@ -733,7 +734,9 @@ class MiddlewareServiceImplementation @Inject constructor(
|
|||
}
|
||||
|
||||
override fun objectCreateRelationOption(request: Rpc.Object.CreateRelationOption.Request): Rpc.Object.CreateRelationOption.Response {
|
||||
val encoded = Service.objectCreateRelationOption(Rpc.Object.CreateRelationOption.Request.ADAPTER.encode(request))
|
||||
val encoded = Service.objectCreateRelationOption(
|
||||
Rpc.Object.CreateRelationOption.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.Object.CreateRelationOption.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.Object.CreateRelationOption.Response.Error.Code.NULL) {
|
||||
|
@ -1346,4 +1349,160 @@ class MiddlewareServiceImplementation @Inject constructor(
|
|||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun blockDataViewAddFilter(request: Rpc.BlockDataview.Filter.Add.Request): Rpc.BlockDataview.Filter.Add.Response {
|
||||
val encoded = Service.blockDataviewFilterAdd(
|
||||
Rpc.BlockDataview.Filter.Add.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.BlockDataview.Filter.Add.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.BlockDataview.Filter.Add.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun blockDataViewRemoveFilter(request: Rpc.BlockDataview.Filter.Remove.Request): Rpc.BlockDataview.Filter.Remove.Response {
|
||||
val encoded = Service.blockDataviewFilterRemove(
|
||||
Rpc.BlockDataview.Filter.Remove.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.BlockDataview.Filter.Remove.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.BlockDataview.Filter.Remove.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun blockDataViewReplaceFilter(request: Rpc.BlockDataview.Filter.Replace.Request): Rpc.BlockDataview.Filter.Replace.Response {
|
||||
val encoded = Service.blockDataviewFilterReplace(
|
||||
Rpc.BlockDataview.Filter.Replace.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.BlockDataview.Filter.Replace.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.BlockDataview.Filter.Replace.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun blockDataViewSortFilter(request: Rpc.BlockDataview.Filter.Sort.Request): Rpc.BlockDataview.Filter.Sort.Response {
|
||||
val encoded = Service.blockDataviewFilterSort(
|
||||
Rpc.BlockDataview.Filter.Sort.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.BlockDataview.Filter.Sort.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.BlockDataview.Filter.Sort.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun blockDataViewAddSort(request: Rpc.BlockDataview.Sort.Add.Request): Rpc.BlockDataview.Sort.Add.Response {
|
||||
val encoded = Service.blockDataviewSortAdd(
|
||||
Rpc.BlockDataview.Sort.Add.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.BlockDataview.Sort.Add.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.BlockDataview.Sort.Add.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun blockDataViewRemoveSort(request: Rpc.BlockDataview.Sort.Remove.Request): Rpc.BlockDataview.Sort.Remove.Response {
|
||||
val encoded = Service.blockDataviewSortRemove(
|
||||
Rpc.BlockDataview.Sort.Remove.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.BlockDataview.Sort.Remove.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.BlockDataview.Sort.Remove.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun blockDataViewReplaceSort(request: Rpc.BlockDataview.Sort.Replace.Request): Rpc.BlockDataview.Sort.Replace.Response {
|
||||
val encoded = Service.blockDataviewSortReplace(
|
||||
Rpc.BlockDataview.Sort.Replace.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.BlockDataview.Sort.Replace.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.BlockDataview.Sort.Replace.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun blockDataViewSortSort(request: Rpc.BlockDataview.Sort.SSort.Request): Rpc.BlockDataview.Sort.SSort.Response {
|
||||
val encoded = Service.blockDataviewSortSort(
|
||||
Rpc.BlockDataview.Sort.SSort.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.BlockDataview.Sort.SSort.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.BlockDataview.Sort.SSort.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun blockDataViewAddViewRelation(request: Rpc.BlockDataview.ViewRelation.Add.Request): Rpc.BlockDataview.ViewRelation.Add.Response {
|
||||
val encoded = Service.blockDataviewViewRelationAdd(
|
||||
Rpc.BlockDataview.ViewRelation.Add.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.BlockDataview.ViewRelation.Add.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.BlockDataview.ViewRelation.Add.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun blockDataViewRemoveViewRelation(request: Rpc.BlockDataview.ViewRelation.Remove.Request): Rpc.BlockDataview.ViewRelation.Remove.Response {
|
||||
val encoded = Service.blockDataviewViewRelationRemove(
|
||||
Rpc.BlockDataview.ViewRelation.Remove.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.BlockDataview.ViewRelation.Remove.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.BlockDataview.ViewRelation.Remove.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun blockDataViewReplaceViewRelation(request: Rpc.BlockDataview.ViewRelation.Replace.Request): Rpc.BlockDataview.ViewRelation.Replace.Response {
|
||||
val encoded = Service.blockDataviewViewRelationReplace(
|
||||
Rpc.BlockDataview.ViewRelation.Replace.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.BlockDataview.ViewRelation.Replace.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.BlockDataview.ViewRelation.Replace.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun blockDataViewSortViewRelation(request: Rpc.BlockDataview.ViewRelation.Sort.Request): Rpc.BlockDataview.ViewRelation.Sort.Response {
|
||||
val encoded = Service.blockDataviewViewRelationSort(
|
||||
Rpc.BlockDataview.ViewRelation.Sort.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.BlockDataview.ViewRelation.Sort.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.BlockDataview.ViewRelation.Sort.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@ import com.anytypeio.anytype.core_models.Id
|
|||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.presentation.mapper.toDomain
|
||||
import com.anytypeio.anytype.presentation.relations.toView
|
||||
import com.anytypeio.anytype.presentation.sets.filter.CreateFilterView
|
||||
import com.anytypeio.anytype.presentation.sets.filter.ViewerFilterViewModel
|
||||
|
@ -52,18 +51,10 @@ fun DVFilterCondition.isValueRequired(): Boolean = when (this) {
|
|||
else -> true
|
||||
}
|
||||
|
||||
fun List<CreateFilterView>.checkboxFilter(
|
||||
relationKey: Id,
|
||||
condition: Viewer.Filter.Condition
|
||||
): DVFilter {
|
||||
fun List<CreateFilterView>.checkboxFilterValue(): Boolean? {
|
||||
val checkboxes = filterIsInstance<CreateFilterView.Checkbox>()
|
||||
val selected = checkboxes.firstOrNull { it.isSelected }
|
||||
val value = selected?.isChecked
|
||||
return DVFilter(
|
||||
relationKey = relationKey,
|
||||
condition = condition.toDomain(),
|
||||
value = value
|
||||
)
|
||||
return selected?.isChecked
|
||||
}
|
||||
|
||||
suspend fun List<DVFilter>.toView(
|
||||
|
@ -73,7 +64,7 @@ suspend fun List<DVFilter>.toView(
|
|||
screenState: ViewerFilterViewModel.ScreenState,
|
||||
urlBuilder: UrlBuilder
|
||||
): List<FilterView.Expression> = mapNotNull { filter ->
|
||||
val relation = storeOfRelations.getByKey(filter.relationKey)
|
||||
val relation = storeOfRelations.getByKey(filter.relation)
|
||||
if (relation != null) {
|
||||
filter.toView(
|
||||
relation = relation,
|
||||
|
@ -83,7 +74,7 @@ suspend fun List<DVFilter>.toView(
|
|||
store = storeOfObjects
|
||||
)
|
||||
} else {
|
||||
Timber.w("Could not found relation: ${filter.relationKey} for filter: $filter")
|
||||
Timber.w("Could not found relation: ${filter.relation} for filter: $filter")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +86,7 @@ suspend fun List<DVSort>.toView(
|
|||
val relation = storeOfRelations.getByKey(sort.relationKey)
|
||||
if (relation != null) {
|
||||
ViewerSortViewModel.ViewerSortView(
|
||||
sortId = sort.id,
|
||||
relation = sort.relationKey,
|
||||
name = relation.name.orEmpty(),
|
||||
type = sort.type,
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
package com.anytypeio.anytype.presentation.mapper
|
||||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.DVFilter
|
||||
import com.anytypeio.anytype.core_models.DVFilterCondition
|
||||
import com.anytypeio.anytype.core_models.DVFilterOperator
|
||||
import com.anytypeio.anytype.core_models.DVSort
|
||||
import com.anytypeio.anytype.core_models.DocumentInfo
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.RelationFormat
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
|
@ -29,13 +26,9 @@ import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
|||
import com.anytypeio.anytype.presentation.objects.ObjectLayoutView
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectTypeView
|
||||
import com.anytypeio.anytype.presentation.objects.getProperName
|
||||
import com.anytypeio.anytype.presentation.relations.type
|
||||
import com.anytypeio.anytype.presentation.sets.buildGridRow
|
||||
import com.anytypeio.anytype.presentation.sets.model.ColumnView
|
||||
import com.anytypeio.anytype.presentation.sets.model.FilterExpression
|
||||
import com.anytypeio.anytype.presentation.sets.model.FilterValue
|
||||
import com.anytypeio.anytype.presentation.sets.model.SimpleRelationView
|
||||
import com.anytypeio.anytype.presentation.sets.model.SortingExpression
|
||||
import com.anytypeio.anytype.presentation.sets.model.Viewer
|
||||
import com.anytypeio.anytype.presentation.settings.EditorSettings
|
||||
import timber.log.Timber
|
||||
|
@ -591,35 +584,6 @@ fun DVFilterCondition.toCheckboxView(): Viewer.Filter.Condition.Checkbox = when
|
|||
else -> throw IllegalStateException("Unexpected filter condition $this for Checkbox relations")
|
||||
}
|
||||
|
||||
fun SortingExpression.toDomain(): DVSort = DVSort(
|
||||
relationKey = key,
|
||||
type = when (type) {
|
||||
Viewer.SortType.ASC -> Block.Content.DataView.Sort.Type.ASC
|
||||
Viewer.SortType.DESC -> Block.Content.DataView.Sort.Type.DESC
|
||||
Viewer.SortType.CUSTOM -> Block.Content.DataView.Sort.Type.CUSTOM
|
||||
}
|
||||
)
|
||||
|
||||
fun FilterExpression.toDomain(): DVFilter = DVFilter(
|
||||
relationKey = key,
|
||||
operator = operator.toDomain(),
|
||||
condition = condition.toDomain(),
|
||||
value = when (value) {
|
||||
is FilterValue.Number -> value.value
|
||||
is FilterValue.Status -> value.value
|
||||
is FilterValue.Tag -> value.value
|
||||
is FilterValue.Text -> value.value
|
||||
is FilterValue.Url -> value.value
|
||||
is FilterValue.Email -> value.value
|
||||
is FilterValue.Phone -> value.value
|
||||
is FilterValue.Date -> value.value
|
||||
is FilterValue.TextShort -> value.value
|
||||
is FilterValue.Check -> value.value
|
||||
is FilterValue.Object -> value.value
|
||||
null -> null
|
||||
}
|
||||
)
|
||||
|
||||
fun Viewer.FilterOperator.toDomain(): DVFilterOperator = when (this) {
|
||||
Viewer.FilterOperator.And -> DVFilterOperator.AND
|
||||
Viewer.FilterOperator.Or -> DVFilterOperator.OR
|
||||
|
|
|
@ -214,7 +214,7 @@ class ObjectTypeChangeViewModel(
|
|||
if (excludedMarketplaceTypes.isNotEmpty()) {
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.ID,
|
||||
relation = Relations.ID,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = excludedMarketplaceTypes
|
||||
)
|
||||
|
|
|
@ -36,17 +36,17 @@ class LimitObjectTypeViewModel(
|
|||
SearchObjects.Params(
|
||||
filters = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = ObjectTypeIds.OBJECT_TYPE
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = false
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
)
|
||||
|
|
|
@ -50,7 +50,6 @@ import com.anytypeio.anytype.presentation.sets.model.FilterValue
|
|||
import com.anytypeio.anytype.presentation.sets.model.FilterView
|
||||
import com.anytypeio.anytype.presentation.sets.model.ObjectView
|
||||
import com.anytypeio.anytype.presentation.sets.model.SimpleRelationView
|
||||
import com.anytypeio.anytype.presentation.sets.model.SortingExpression
|
||||
import com.anytypeio.anytype.presentation.sets.model.StatusView
|
||||
import com.anytypeio.anytype.presentation.sets.model.TagView
|
||||
import com.anytypeio.anytype.presentation.sets.model.Viewer
|
||||
|
@ -405,23 +404,6 @@ fun ObjectSet.columns(
|
|||
return ArrayList(columns)
|
||||
}
|
||||
|
||||
fun ObjectSet.sortingExpression(viewerId: Id): ArrayList<SortingExpression> {
|
||||
|
||||
val block = blocks.first { it.content is DV }
|
||||
|
||||
val dv = block.content as DV
|
||||
|
||||
val viewer = dv.viewers.first { it.id == viewerId }
|
||||
|
||||
val list = arrayListOf<SortingExpression>()
|
||||
viewer.sorts.forEach { sort ->
|
||||
list.add(
|
||||
SortingExpression(key = sort.relationKey, type = sort.type.toView())
|
||||
)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
fun ObjectSet.filterExpression(viewerId: Id?): List<DVFilter> {
|
||||
|
||||
val block = blocks.first { it.content is DV }
|
||||
|
@ -539,7 +521,8 @@ suspend fun DVFilter.toView(
|
|||
): FilterView.Expression = when (relation.format) {
|
||||
Relation.Format.SHORT_TEXT -> {
|
||||
FilterView.Expression.TextShort(
|
||||
key = relationKey,
|
||||
id = id,
|
||||
relation = this.relation,
|
||||
title = relation.name.orEmpty(),
|
||||
operator = operator.toView(),
|
||||
condition = condition.toTextView(),
|
||||
|
@ -551,7 +534,8 @@ suspend fun DVFilter.toView(
|
|||
}
|
||||
Relation.Format.LONG_TEXT -> {
|
||||
FilterView.Expression.Text(
|
||||
key = relationKey,
|
||||
id = id,
|
||||
relation = this.relation,
|
||||
title = relation.name.orEmpty(),
|
||||
operator = operator.toView(),
|
||||
condition = condition.toTextView(),
|
||||
|
@ -563,7 +547,8 @@ suspend fun DVFilter.toView(
|
|||
}
|
||||
Relation.Format.URL -> {
|
||||
FilterView.Expression.Url(
|
||||
key = relationKey,
|
||||
id = id,
|
||||
relation = this.relation,
|
||||
title = relation.name.orEmpty(),
|
||||
operator = operator.toView(),
|
||||
condition = condition.toTextView(),
|
||||
|
@ -575,7 +560,8 @@ suspend fun DVFilter.toView(
|
|||
}
|
||||
Relation.Format.EMAIL -> {
|
||||
FilterView.Expression.Email(
|
||||
key = relationKey,
|
||||
id = id,
|
||||
relation = this.relation,
|
||||
title = relation.name.orEmpty(),
|
||||
operator = operator.toView(),
|
||||
condition = condition.toTextView(),
|
||||
|
@ -587,7 +573,8 @@ suspend fun DVFilter.toView(
|
|||
}
|
||||
Relation.Format.PHONE -> {
|
||||
FilterView.Expression.Phone(
|
||||
key = relationKey,
|
||||
id = id,
|
||||
relation = this.relation,
|
||||
title = relation.name.orEmpty(),
|
||||
operator = operator.toView(),
|
||||
condition = condition.toTextView(),
|
||||
|
@ -599,7 +586,8 @@ suspend fun DVFilter.toView(
|
|||
}
|
||||
Relation.Format.NUMBER -> {
|
||||
FilterView.Expression.Number(
|
||||
key = relationKey,
|
||||
id = id,
|
||||
relation = this.relation,
|
||||
title = relation.name.orEmpty(),
|
||||
operator = operator.toView(),
|
||||
condition = condition.toNumberView(),
|
||||
|
@ -611,7 +599,8 @@ suspend fun DVFilter.toView(
|
|||
}
|
||||
Relation.Format.DATE -> {
|
||||
FilterView.Expression.Date(
|
||||
key = relationKey,
|
||||
id = id,
|
||||
relation = this.relation,
|
||||
title = relation.name.orEmpty(),
|
||||
operator = operator.toView(),
|
||||
condition = condition.toDateView(),
|
||||
|
@ -624,7 +613,8 @@ suspend fun DVFilter.toView(
|
|||
}
|
||||
Relation.Format.STATUS -> {
|
||||
FilterView.Expression.Status(
|
||||
key = relationKey,
|
||||
id = id,
|
||||
relation = this.relation,
|
||||
title = relation.name.orEmpty(),
|
||||
operator = operator.toView(),
|
||||
condition = condition.toSelectedView(),
|
||||
|
@ -641,7 +631,8 @@ suspend fun DVFilter.toView(
|
|||
}
|
||||
Relation.Format.TAG -> {
|
||||
FilterView.Expression.Tag(
|
||||
key = relationKey,
|
||||
id = id,
|
||||
relation = this.relation,
|
||||
title = relation.name.orEmpty(),
|
||||
operator = operator.toView(),
|
||||
condition = condition.toSelectedView(),
|
||||
|
@ -658,7 +649,8 @@ suspend fun DVFilter.toView(
|
|||
}
|
||||
Relation.Format.OBJECT -> {
|
||||
FilterView.Expression.Object(
|
||||
key = relationKey,
|
||||
id = id,
|
||||
relation = this.relation,
|
||||
title = relation.name.orEmpty(),
|
||||
operator = operator.toView(),
|
||||
condition = condition.toSelectedView(),
|
||||
|
@ -670,7 +662,8 @@ suspend fun DVFilter.toView(
|
|||
}
|
||||
Relation.Format.CHECKBOX -> {
|
||||
FilterView.Expression.Checkbox(
|
||||
key = relationKey,
|
||||
id = id,
|
||||
relation = this.relation,
|
||||
title = relation.name.orEmpty(),
|
||||
operator = operator.toView(),
|
||||
condition = condition.toCheckboxView(),
|
||||
|
|
|
@ -10,10 +10,8 @@ import com.anytypeio.anytype.core_models.Id
|
|||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.ext.content
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.ModifyDataViewViewerRelationOrder
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.relations.DeleteRelationFromDataView
|
||||
import com.anytypeio.anytype.presentation.common.BaseListViewModel
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsRelationDeleteEvent
|
||||
import com.anytypeio.anytype.presentation.mapper.toSimpleRelationView
|
||||
|
@ -34,9 +32,7 @@ class ObjectSetSettingsViewModel(
|
|||
private val objectSetState: StateFlow<ObjectSet>,
|
||||
private val session: ObjectSetSession,
|
||||
private val dispatcher: Dispatcher<Payload>,
|
||||
private val modifyViewerRelationOrder: ModifyDataViewViewerRelationOrder,
|
||||
private val updateDataViewViewer: UpdateDataViewViewer,
|
||||
private val deleteRelationFromDataView: DeleteRelationFromDataView,
|
||||
private val storeOfRelations: StoreOfRelations,
|
||||
private val analytics: Analytics
|
||||
) : BaseListViewModel<ViewerRelationListView>() {
|
||||
|
@ -159,7 +155,7 @@ class ObjectSetSettingsViewModel(
|
|||
}
|
||||
|
||||
updateDataViewViewer(
|
||||
UpdateDataViewViewer.Params(
|
||||
UpdateDataViewViewer.Params.Fields(
|
||||
context = ctx,
|
||||
target = block.id,
|
||||
viewer = updated
|
||||
|
@ -175,13 +171,13 @@ class ObjectSetSettingsViewModel(
|
|||
fun onDeleteClicked(ctx: Id, item: SimpleRelationView) {
|
||||
viewModelScope.launch {
|
||||
val state = objectSetState.value
|
||||
deleteRelationFromDataView(
|
||||
DeleteRelationFromDataView.Params(
|
||||
ctx = ctx,
|
||||
relation = item.key,
|
||||
dv = state.dataview.id
|
||||
)
|
||||
).process(
|
||||
val params = UpdateDataViewViewer.Params.ViewerRelation.Remove(
|
||||
ctx = ctx,
|
||||
dv = state.dataview.id,
|
||||
view = state.viewerById(session.currentViewerId.value).id,
|
||||
keys = listOf(item.key)
|
||||
)
|
||||
updateDataViewViewer(params).process(
|
||||
failure = { e -> Timber.e(e, "Error while deleting relation from dv") },
|
||||
success = { payload ->
|
||||
dispatcher.send(payload)
|
||||
|
@ -201,16 +197,15 @@ class ObjectSetSettingsViewModel(
|
|||
val block = objectSetState.value.blocks.first { it.content is DV }
|
||||
val updated = viewer.copy(
|
||||
viewerRelations = viewer.viewerRelations.filter { it.key != relation },
|
||||
filters = viewer.filters.filter { it.relationKey != relation },
|
||||
filters = viewer.filters.filter { it.relation != relation },
|
||||
sorts = viewer.sorts.filter { it.relationKey != relation }
|
||||
)
|
||||
updateDataViewViewer(
|
||||
UpdateDataViewViewer.Params(
|
||||
context = ctx,
|
||||
target = block.id,
|
||||
viewer = updated
|
||||
)
|
||||
).process(
|
||||
val params = UpdateDataViewViewer.Params.Fields(
|
||||
context = ctx,
|
||||
target = block.id,
|
||||
viewer = updated
|
||||
)
|
||||
updateDataViewViewer(params).process(
|
||||
success = { dispatcher.send(it) },
|
||||
failure = { Timber.e("Error while updating") }
|
||||
)
|
||||
|
@ -230,16 +225,13 @@ class ObjectSetSettingsViewModel(
|
|||
private fun proceedWithChangeOrderUpdate(ctx: Id, order: List<String>) {
|
||||
viewModelScope.launch {
|
||||
val viewer = objectSetState.value.viewerById(session.currentViewerId.value)
|
||||
val relations = viewer.viewerRelations.toMutableList().apply {
|
||||
sortBy { order.indexOf(it.key) }
|
||||
}
|
||||
modifyViewerRelationOrder(
|
||||
params = ModifyDataViewViewerRelationOrder.Params(
|
||||
context = ctx,
|
||||
target = objectSetState.value.dataview.id,
|
||||
viewer = viewer.copy(viewerRelations = relations)
|
||||
)
|
||||
).process(
|
||||
val params = UpdateDataViewViewer.Params.ViewerRelation.Sort(
|
||||
ctx = ctx,
|
||||
dv = objectSetState.value.dataview.id,
|
||||
view = viewer.id,
|
||||
keys = order
|
||||
)
|
||||
updateDataViewViewer(params).process(
|
||||
success = { dispatcher.send(it) },
|
||||
failure = {
|
||||
Timber.e(it, DND_ERROR_MSG)
|
||||
|
@ -252,23 +244,19 @@ class ObjectSetSettingsViewModel(
|
|||
private fun proceedWithVisibilityUpdate(ctx: Id, item: SimpleRelationView) {
|
||||
val viewer = objectSetState.value.viewerById(session.currentViewerId.value)
|
||||
val block = objectSetState.value.blocks.first { it.content is DV }
|
||||
val updated = viewer.copy(
|
||||
viewerRelations = viewer.viewerRelations.map {
|
||||
if (it.key == item.key) {
|
||||
it.copy(isVisible = item.isVisible)
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
val viewerRelation = viewer.viewerRelations
|
||||
.find { it.key == item.key }
|
||||
?.copy(isVisible = item.isVisible)
|
||||
?: return
|
||||
val params = UpdateDataViewViewer.Params.ViewerRelation.Replace(
|
||||
ctx = ctx,
|
||||
dv = block.id,
|
||||
view = viewer.id,
|
||||
key = item.key,
|
||||
relation = viewerRelation
|
||||
)
|
||||
viewModelScope.launch {
|
||||
updateDataViewViewer(
|
||||
UpdateDataViewViewer.Params(
|
||||
context = ctx,
|
||||
target = block.id,
|
||||
viewer = updated
|
||||
)
|
||||
).process(
|
||||
updateDataViewViewer(params).process(
|
||||
success = { dispatcher.send(it) },
|
||||
failure = { Timber.e("Error while updating") }
|
||||
)
|
||||
|
@ -279,9 +267,7 @@ class ObjectSetSettingsViewModel(
|
|||
private val state: StateFlow<ObjectSet>,
|
||||
private val session: ObjectSetSession,
|
||||
private val dispatcher: Dispatcher<Payload>,
|
||||
private val modifyViewerRelationOrder: ModifyDataViewViewerRelationOrder,
|
||||
private val updateDataViewViewer: UpdateDataViewViewer,
|
||||
private val deleteRelationFromDataView: DeleteRelationFromDataView,
|
||||
private val store: StoreOfRelations,
|
||||
private val analytics: Analytics
|
||||
) : ViewModelProvider.Factory {
|
||||
|
@ -291,9 +277,7 @@ class ObjectSetSettingsViewModel(
|
|||
objectSetState = state,
|
||||
session = session,
|
||||
dispatcher = dispatcher,
|
||||
modifyViewerRelationOrder = modifyViewerRelationOrder,
|
||||
updateDataViewViewer = updateDataViewViewer,
|
||||
deleteRelationFromDataView = deleteRelationFromDataView,
|
||||
storeOfRelations = store,
|
||||
analytics = analytics
|
||||
) as T
|
||||
|
|
|
@ -91,16 +91,13 @@ class RelationAddToDataViewViewModel(
|
|||
val viewer = dv.viewers.find { it.id == session.currentViewerId.value } ?: dv.viewers.first()
|
||||
|
||||
updateDataViewViewer(
|
||||
UpdateDataViewViewer.Params(
|
||||
context = ctx,
|
||||
target = block.id,
|
||||
viewer = viewer.copy(
|
||||
viewerRelations = viewer.viewerRelations + listOf(
|
||||
DVViewerRelation(
|
||||
key = relation,
|
||||
isVisible = true
|
||||
)
|
||||
)
|
||||
UpdateDataViewViewer.Params.ViewerRelation.Add(
|
||||
ctx = ctx,
|
||||
dv = block.id,
|
||||
view = viewer.id,
|
||||
relation = DVViewerRelation(
|
||||
key = relation,
|
||||
isVisible = true
|
||||
)
|
||||
)
|
||||
).process(
|
||||
|
|
|
@ -132,7 +132,7 @@ abstract class RelationAddViewModelBase(
|
|||
if (excluded.isNotEmpty()) {
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.ID,
|
||||
relation = Relations.ID,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = excluded
|
||||
)
|
||||
|
@ -140,21 +140,21 @@ abstract class RelationAddViewModelBase(
|
|||
}
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = false
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = MARKETPLACE_ID
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.RELATION_KEY,
|
||||
relation = Relations.RELATION_KEY,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = Relations.systemRelationKeys
|
||||
)
|
||||
|
@ -176,21 +176,21 @@ abstract class RelationAddViewModelBase(
|
|||
addAll(filterMyRelations())
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = false
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceManager.getCurrentWorkspace()
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.RELATION_KEY,
|
||||
relation = Relations.RELATION_KEY,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = Relations.systemRelationKeys
|
||||
)
|
||||
|
|
|
@ -330,16 +330,13 @@ class RelationCreateFromScratchForDataViewViewModel(
|
|||
val dv = block.content as DV
|
||||
val viewer = dv.viewers.find { it.id == session.currentViewerId.value } ?: dv.viewers.first()
|
||||
updateDataViewViewer(
|
||||
UpdateDataViewViewer.Params(
|
||||
context = ctx,
|
||||
target = block.id,
|
||||
viewer = viewer.copy(
|
||||
viewerRelations = viewer.viewerRelations + listOf(
|
||||
DVViewerRelation(
|
||||
key = relationKey,
|
||||
isVisible = true
|
||||
)
|
||||
)
|
||||
UpdateDataViewViewer.Params.ViewerRelation.Add(
|
||||
ctx = ctx,
|
||||
dv = block.id,
|
||||
view = viewer.id,
|
||||
relation = DVViewerRelation(
|
||||
key = relationKey,
|
||||
isVisible = true
|
||||
)
|
||||
)
|
||||
).process(
|
||||
|
|
|
@ -206,7 +206,7 @@ fun Relation.searchObjectsFilter(): List<DVFilter> {
|
|||
if (objectTypes.isNotEmpty()) {
|
||||
filter.add(
|
||||
DVFilter(
|
||||
relationKey = ObjectSetConfig.TYPE_KEY,
|
||||
relation = ObjectSetConfig.TYPE_KEY,
|
||||
operator = DVFilterOperator.AND,
|
||||
condition = DVFilterCondition.IN,
|
||||
value = objectTypes
|
||||
|
@ -221,7 +221,7 @@ fun ObjectWrapper.Relation.searchObjectsFilter(): List<DVFilter> {
|
|||
if (relationFormatObjectTypes.isNotEmpty()) {
|
||||
filter.add(
|
||||
DVFilter(
|
||||
relationKey = ObjectSetConfig.TYPE_KEY,
|
||||
relation = ObjectSetConfig.TYPE_KEY,
|
||||
operator = DVFilterOperator.AND,
|
||||
condition = DVFilterCondition.IN,
|
||||
value = relationFormatObjectTypes
|
||||
|
@ -235,7 +235,7 @@ fun List<DVFilter>.addIsHiddenFilter(): List<DVFilter> =
|
|||
this.toMutableList().apply {
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
)
|
||||
|
|
|
@ -163,7 +163,7 @@ class AddObjectRelationViewModel(
|
|||
if (targetTypes.isEmpty()) {
|
||||
filters.add(
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = listOf(
|
||||
ObjectTypeIds.OBJECT_TYPE,
|
||||
|
@ -175,7 +175,7 @@ class AddObjectRelationViewModel(
|
|||
} else {
|
||||
filters.add(
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.IN,
|
||||
value = targetTypes
|
||||
)
|
||||
|
|
|
@ -29,22 +29,22 @@ object ObjectSearchConstants {
|
|||
//region SEARCH OBJECTS
|
||||
fun filterSearchObjects(workspaceId: String) = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = listOf(
|
||||
OBJECT_TYPE,
|
||||
|
@ -60,7 +60,7 @@ object ObjectSearchConstants {
|
|||
)
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceId
|
||||
)
|
||||
|
@ -77,22 +77,22 @@ object ObjectSearchConstants {
|
|||
//region LINK TO
|
||||
fun getFilterLinkTo(ignore: Id?, workspaceId: String) = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = listOf(
|
||||
OBJECT_TYPE,
|
||||
|
@ -108,12 +108,12 @@ object ObjectSearchConstants {
|
|||
)
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.ID,
|
||||
relation = Relations.ID,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = ignore
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceId
|
||||
)
|
||||
|
@ -130,37 +130,37 @@ object ObjectSearchConstants {
|
|||
//region MOVE TO
|
||||
fun filterMoveTo(ctx: Id, types: List<String>, workspaceId: String) = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_READ_ONLY,
|
||||
relation = Relations.IS_READ_ONLY,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.IN,
|
||||
value = types
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.ID,
|
||||
relation = Relations.ID,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = listOf(ctx)
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceId
|
||||
)
|
||||
|
@ -177,22 +177,22 @@ object ObjectSearchConstants {
|
|||
//region ADD OBJECT TO RELATION VALUE
|
||||
fun filterAddObjectToRelation(workspaceId: String) = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceId
|
||||
)
|
||||
|
@ -209,22 +209,22 @@ object ObjectSearchConstants {
|
|||
//region ADD OBJECT TO FILTER
|
||||
fun filterAddObjectToFilter(workspaceId: String) = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = listOf(
|
||||
OBJECT_TYPE,
|
||||
|
@ -236,7 +236,7 @@ object ObjectSearchConstants {
|
|||
)
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceId
|
||||
)
|
||||
|
@ -253,22 +253,22 @@ object ObjectSearchConstants {
|
|||
//region TAB FAVORITES
|
||||
fun filterTabFavorites(workspaceId: String) = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.NOT_EQUAL ,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = listOf(
|
||||
OBJECT_TYPE,
|
||||
|
@ -285,12 +285,12 @@ object ObjectSearchConstants {
|
|||
)
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceId
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_FAVORITE,
|
||||
relation = Relations.IS_FAVORITE,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = true
|
||||
)
|
||||
|
@ -303,27 +303,27 @@ object ObjectSearchConstants {
|
|||
//region TAB RECENT
|
||||
fun filterTabRecent(workspaceId: String) = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.LAST_OPENED_DATE,
|
||||
relation = Relations.LAST_OPENED_DATE,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = null
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = listOf(
|
||||
OBJECT_TYPE,
|
||||
|
@ -340,7 +340,7 @@ object ObjectSearchConstants {
|
|||
)
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceId
|
||||
)
|
||||
|
@ -360,27 +360,27 @@ object ObjectSearchConstants {
|
|||
//region TAB SETS
|
||||
fun filterTabSets(workspaceId: String) = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = ObjectTypeIds.SET
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceId
|
||||
)
|
||||
|
@ -397,22 +397,22 @@ object ObjectSearchConstants {
|
|||
//region TAB ARCHIVE
|
||||
fun filterTabArchive(workspaceId: String) = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceId
|
||||
)
|
||||
|
@ -452,27 +452,27 @@ object ObjectSearchConstants {
|
|||
//region OBJECT TYPES
|
||||
fun filterObjectTypeLibrary(workspaceId: String) = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = OBJECT_TYPE
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceId
|
||||
)
|
||||
|
@ -480,17 +480,17 @@ object ObjectSearchConstants {
|
|||
|
||||
fun defaultDataViewFilters() = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = Condition.NOT_EQUAL,
|
||||
value = true,
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = Condition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = Condition.NOT_EQUAL,
|
||||
value = true
|
||||
)
|
||||
|
@ -498,27 +498,27 @@ object ObjectSearchConstants {
|
|||
|
||||
val filterObjectTypeMarketplace = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = MarketplaceObjectTypeIds.OBJECT_TYPE
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = MARKETPLACE_ID
|
||||
)
|
||||
|
@ -549,22 +549,22 @@ object ObjectSearchConstants {
|
|||
|
||||
fun filterMyRelations() : List<DVFilter> = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = RELATION
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
)
|
||||
|
@ -572,22 +572,22 @@ object ObjectSearchConstants {
|
|||
|
||||
fun filterMarketplaceRelations() : List<DVFilter> = listOf(
|
||||
DVFilter(
|
||||
relationKey = Relations.TYPE,
|
||||
relation = Relations.TYPE,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = MarketplaceObjectTypeIds.RELATION
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_ARCHIVED,
|
||||
relation = Relations.IS_ARCHIVED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_DELETED,
|
||||
relation = Relations.IS_DELETED,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = true
|
||||
)
|
||||
|
|
|
@ -184,7 +184,7 @@ class EditDataViewViewerViewModel(
|
|||
viewModelScope.launch {
|
||||
isLoading.value = true
|
||||
updateDataViewViewer(
|
||||
UpdateDataViewViewer.Params(
|
||||
UpdateDataViewViewer.Params.Fields(
|
||||
context = ctx,
|
||||
target = state.dataview.id,
|
||||
viewer = viewer.copy(type = type, name = name)
|
||||
|
|
|
@ -20,9 +20,7 @@ sealed class ObjectSetCommand {
|
|||
|
||||
data class EditDataViewViewer(
|
||||
val ctx: Id,
|
||||
val dataview: Id,
|
||||
val viewer: Id,
|
||||
val name: String
|
||||
val viewer: Id
|
||||
) : Modal()
|
||||
|
||||
data class ManageViewer(val ctx: Id, val dataview: Id) : Modal()
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.core_models.DV
|
|||
import com.anytypeio.anytype.core_models.DVFilter
|
||||
import com.anytypeio.anytype.core_models.DVRecord
|
||||
import com.anytypeio.anytype.core_models.DVSort
|
||||
import com.anytypeio.anytype.core_models.DVViewer
|
||||
import com.anytypeio.anytype.core_models.DVViewerRelation
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectTypeIds
|
||||
|
@ -12,7 +13,6 @@ import com.anytypeio.anytype.core_models.ObjectWrapper
|
|||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_utils.ext.addAfterIndexInLine
|
||||
import com.anytypeio.anytype.core_utils.ext.replace
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
|
@ -27,6 +27,7 @@ import com.anytypeio.anytype.presentation.sets.model.SimpleRelationView
|
|||
import com.anytypeio.anytype.core_models.Event.Command.DataView.UpdateView.DVSortUpdate
|
||||
import com.anytypeio.anytype.core_models.Event.Command.DataView.UpdateView.DVFilterUpdate
|
||||
import com.anytypeio.anytype.core_models.Event.Command.DataView.UpdateView.DVViewerRelationUpdate
|
||||
import com.anytypeio.anytype.core_models.Event.Command.DataView.UpdateView.DVViewerFields
|
||||
import com.anytypeio.anytype.core_utils.ext.mapInPlace
|
||||
import com.anytypeio.anytype.core_utils.ext.moveAfterIndexInLine
|
||||
|
||||
|
@ -197,24 +198,24 @@ fun List<DVFilter>.updateFilters(updates: List<DVFilterUpdate>): List<DVFilter>
|
|||
when (update) {
|
||||
is DVFilterUpdate.Add -> {
|
||||
filters.addAfterIndexInLine(
|
||||
predicateIndex = { it.relationKey == update.afterId },
|
||||
predicateIndex = { it.id == update.afterId },
|
||||
items = update.filters
|
||||
)
|
||||
}
|
||||
is DVFilterUpdate.Move -> {
|
||||
filters.moveAfterIndexInLine(
|
||||
predicateIndex = { filter -> filter.relationKey == update.afterId },
|
||||
predicateMove = { filter -> update.ids.contains(filter.relationKey) }
|
||||
predicateIndex = { filter -> filter.id == update.afterId },
|
||||
predicateMove = { filter -> update.ids.contains(filter.id) }
|
||||
)
|
||||
}
|
||||
is DVFilterUpdate.Remove -> {
|
||||
filters.retainAll {
|
||||
!update.ids.contains(it.relationKey)
|
||||
!update.ids.contains(it.id)
|
||||
}
|
||||
}
|
||||
is DVFilterUpdate.Update -> {
|
||||
filters.mapInPlace { filter ->
|
||||
if (filter.relationKey == update.id) update.filter else filter
|
||||
if (filter.id == update.id) update.filter else filter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -228,24 +229,24 @@ fun List<DVSort>.updateSorts(updates: List<DVSortUpdate>): List<DVSort> {
|
|||
when (update) {
|
||||
is DVSortUpdate.Add -> {
|
||||
sorts.addAfterIndexInLine(
|
||||
predicateIndex = { it.relationKey == update.afterId },
|
||||
predicateIndex = { it.id == update.afterId },
|
||||
items = update.sorts
|
||||
)
|
||||
}
|
||||
is DVSortUpdate.Move -> {
|
||||
sorts.moveAfterIndexInLine(
|
||||
predicateIndex = { sort -> sort.relationKey == update.afterId },
|
||||
predicateMove = { sort -> update.ids.contains(sort.relationKey) }
|
||||
predicateIndex = { sort -> sort.id == update.afterId },
|
||||
predicateMove = { sort -> update.ids.contains(sort.id) }
|
||||
)
|
||||
}
|
||||
is DVSortUpdate.Remove -> {
|
||||
sorts.retainAll {
|
||||
!update.ids.contains(it.relationKey)
|
||||
!update.ids.contains(it.id)
|
||||
}
|
||||
}
|
||||
is DVSortUpdate.Update -> {
|
||||
sorts.mapInPlace { sort ->
|
||||
if (sort.relationKey == update.id) update.sort else sort
|
||||
if (sort.id == update.id) update.sort else sort
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -286,4 +287,15 @@ fun List<DVViewerRelation>.updateViewerRelations(updates: List<DVViewerRelationU
|
|||
|
||||
fun ObjectSet.getSetOf(ctx: Id): List<Id> {
|
||||
return ObjectWrapper.Basic(details[ctx]?.map.orEmpty()).setOf
|
||||
}
|
||||
|
||||
fun DVViewer.updateFields(fields: DVViewerFields): DVViewer {
|
||||
return copy(
|
||||
name = fields.name,
|
||||
type = fields.type,
|
||||
coverRelationKey = fields.coverRelationKey,
|
||||
hideIcon = fields.hideIcon,
|
||||
cardSize = fields.cardSize,
|
||||
coverFit = fields.coverFit
|
||||
)
|
||||
}
|
|
@ -178,11 +178,20 @@ class ObjectSetReducer {
|
|||
} else {
|
||||
viewer.viewerRelations
|
||||
}
|
||||
viewer.copy(
|
||||
filters = filters,
|
||||
sorts = sorts,
|
||||
viewerRelations = viewerRelations
|
||||
)
|
||||
val fields = event.fields
|
||||
if (fields != null) {
|
||||
viewer.updateFields(fields).copy(
|
||||
filters = filters,
|
||||
sorts = sorts,
|
||||
viewerRelations = viewerRelations
|
||||
)
|
||||
} else {
|
||||
viewer.copy(
|
||||
filters = filters,
|
||||
sorts = sorts,
|
||||
viewerRelations = viewerRelations
|
||||
)
|
||||
}
|
||||
} else {
|
||||
viewer
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
|
|||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.editor.model.TextUpdate
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsShowSetEvent
|
||||
import com.anytypeio.anytype.presentation.mapper.toDomain
|
||||
import com.anytypeio.anytype.presentation.navigation.AppNavigation
|
||||
import com.anytypeio.anytype.presentation.navigation.SupportNavigation
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig.DEFAULT_LIMIT
|
||||
|
@ -61,8 +60,6 @@ import com.anytypeio.anytype.presentation.relations.tabs
|
|||
import com.anytypeio.anytype.presentation.relations.title
|
||||
import com.anytypeio.anytype.presentation.search.ObjectSearchConstants
|
||||
import com.anytypeio.anytype.presentation.sets.model.CellView
|
||||
import com.anytypeio.anytype.presentation.sets.model.FilterExpression
|
||||
import com.anytypeio.anytype.presentation.sets.model.SortingExpression
|
||||
import com.anytypeio.anytype.presentation.sets.model.Viewer
|
||||
import com.anytypeio.anytype.presentation.sets.model.ViewerTabView
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -202,7 +199,7 @@ class ObjectSetViewModel(
|
|||
filters = buildList {
|
||||
addAll(
|
||||
view.filters.map { f: DVFilter ->
|
||||
val r = storeOfRelations.getByKey(f.relationKey)
|
||||
val r = storeOfRelations.getByKey(f.relation)
|
||||
if (r != null && r.relationFormat == RelationFormat.DATE) {
|
||||
f.copy(
|
||||
relationFormat = r.relationFormat
|
||||
|
@ -456,21 +453,6 @@ class ObjectSetViewModel(
|
|||
)
|
||||
}
|
||||
|
||||
fun onCreateNewViewerClicked() {
|
||||
Timber.d("onCreateNewViewerClicked, ")
|
||||
dispatch(
|
||||
ObjectSetCommand.Modal.CreateViewer(
|
||||
ctx = context,
|
||||
target = reducer.state.value.dataview.id
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun onViewerTabClicked(viewer: Id) {
|
||||
Timber.d("onViewerTabClicked, viewer:[$viewer]")
|
||||
session.currentViewerId.value = viewer
|
||||
}
|
||||
|
||||
fun onTitleChanged(txt: String) {
|
||||
Timber.d("onTitleChanged, txt:[$txt]")
|
||||
val target = header.value?.id
|
||||
|
@ -812,9 +794,7 @@ class ObjectSetViewModel(
|
|||
dispatch(
|
||||
ObjectSetCommand.Modal.EditDataViewViewer(
|
||||
ctx = context,
|
||||
dataview = block.id,
|
||||
viewer = viewer.id,
|
||||
name = viewer.name
|
||||
viewer = viewer.id
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.anytypeio.anytype.core_models.DVSort
|
|||
import com.anytypeio.anytype.core_models.DVSortType
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewViewerSort
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsAddSortEvent
|
||||
import com.anytypeio.anytype.presentation.relations.simpleRelations
|
||||
|
@ -23,7 +23,7 @@ class SelectSortRelationViewModel(
|
|||
private val objectSetState: StateFlow<ObjectSet>,
|
||||
private val session: ObjectSetSession,
|
||||
private val dispatcher: Dispatcher<Payload>,
|
||||
private val addDataViewViewerSort: AddDataViewViewerSort,
|
||||
private val updateDataViewViewer: UpdateDataViewViewer,
|
||||
private val storeOfRelations: StoreOfRelations,
|
||||
private val analytics: Analytics
|
||||
) : SearchRelationViewModel(
|
||||
|
@ -34,17 +34,16 @@ class SelectSortRelationViewModel(
|
|||
|
||||
fun onRelationClicked(ctx: Id, relation: SimpleRelationView) {
|
||||
viewModelScope.launch {
|
||||
addDataViewViewerSort(
|
||||
AddDataViewViewerSort.Params(
|
||||
ctx = ctx,
|
||||
sort = DVSort(
|
||||
relationKey = relation.key,
|
||||
type = DVSortType.ASC
|
||||
),
|
||||
dataview = objectSetState.value.dataview.id,
|
||||
viewer = objectSetState.value.viewerById(session.currentViewerId.value)
|
||||
val params = UpdateDataViewViewer.Params.Sort.Add(
|
||||
ctx = ctx,
|
||||
dv = objectSetState.value.dataview.id,
|
||||
view = objectSetState.value.viewerById(session.currentViewerId.value).id,
|
||||
sort = DVSort(
|
||||
relationKey = relation.key,
|
||||
type = DVSortType.ASC
|
||||
)
|
||||
).process(
|
||||
)
|
||||
updateDataViewViewer(params).process(
|
||||
success = {
|
||||
dispatcher.send(it).also {
|
||||
sendAnalyticsAddSortEvent(analytics)
|
||||
|
@ -64,7 +63,7 @@ class SelectSortRelationViewModel(
|
|||
private val state: StateFlow<ObjectSet>,
|
||||
private val session: ObjectSetSession,
|
||||
private val dispatcher: Dispatcher<Payload>,
|
||||
private val addDataViewViewerSort: AddDataViewViewerSort,
|
||||
private val updateDataViewViewer: UpdateDataViewViewer,
|
||||
private val storeOfRelations: StoreOfRelations,
|
||||
private val analytics: Analytics
|
||||
) : ViewModelProvider.Factory {
|
||||
|
@ -74,7 +73,7 @@ class SelectSortRelationViewModel(
|
|||
objectSetState = state,
|
||||
session = session,
|
||||
dispatcher = dispatcher,
|
||||
addDataViewViewerSort = addDataViewViewerSort,
|
||||
updateDataViewViewer = updateDataViewViewer,
|
||||
storeOfRelations = storeOfRelations,
|
||||
analytics = analytics
|
||||
) as T
|
||||
|
|
|
@ -5,6 +5,8 @@ import androidx.lifecycle.ViewModelProvider
|
|||
import androidx.lifecycle.viewModelScope
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.DVFilter
|
||||
import com.anytypeio.anytype.core_models.DVFilterCondition
|
||||
import com.anytypeio.anytype.core_models.DVFilterOperator
|
||||
import com.anytypeio.anytype.core_models.DVFilterQuickOption
|
||||
import com.anytypeio.anytype.core_models.DVViewer
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
|
@ -21,7 +23,7 @@ import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
|||
import com.anytypeio.anytype.domain.objects.options.GetOptions
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.domain.workspace.WorkspaceManager
|
||||
import com.anytypeio.anytype.presentation.extension.checkboxFilter
|
||||
import com.anytypeio.anytype.presentation.extension.checkboxFilterValue
|
||||
import com.anytypeio.anytype.presentation.extension.hasValue
|
||||
import com.anytypeio.anytype.presentation.extension.index
|
||||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsAddFilterEvent
|
||||
|
@ -206,7 +208,7 @@ open class FilterViewModel(
|
|||
relation.toConditionView(condition = null)
|
||||
} else {
|
||||
val filter = viewer.filters[index]
|
||||
check(filter.relationKey == relation.key) { "Incorrect filter state" }
|
||||
check(filter.relation == relation.key) { "Incorrect filter state" }
|
||||
relation.toConditionView(condition = filter.condition)
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +242,7 @@ open class FilterViewModel(
|
|||
)
|
||||
} else {
|
||||
val filter = viewer.filters[index]
|
||||
check(filter.relationKey == relation.key) { "Incorrect filter state" }
|
||||
check(filter.relation == relation.key) { "Incorrect filter state" }
|
||||
filterValueState.value = relation.toFilterValue(
|
||||
value = filter.value,
|
||||
details = objectSet.details,
|
||||
|
@ -260,7 +262,7 @@ open class FilterViewModel(
|
|||
relation: ObjectWrapper.Relation,
|
||||
filter: DVFilter?,
|
||||
condition: Viewer.Filter.Condition
|
||||
) : Unit = when (relation.format) {
|
||||
): Unit = when (relation.format) {
|
||||
Relation.Format.DATE -> {
|
||||
val value = (filter?.value as? Double)?.toLong() ?: 0L
|
||||
filterValueListState.value = relation.toCreateFilterDateView(
|
||||
|
@ -459,18 +461,17 @@ open class FilterViewModel(
|
|||
condition = condition,
|
||||
format = format
|
||||
)
|
||||
|
||||
viewModelScope.launch {
|
||||
proceedWithCreatingFilter(
|
||||
ctx = ctx,
|
||||
filter = DVFilter(
|
||||
relationKey = relation,
|
||||
value = value,
|
||||
condition = condition.toDomain(),
|
||||
relationFormat = if (format == ColumnView.Format.DATE)
|
||||
RelationFormat.DATE
|
||||
else
|
||||
null
|
||||
)
|
||||
relationKey = relation,
|
||||
value = value,
|
||||
condition = condition.toDomain(),
|
||||
relationFormat = if (format == ColumnView.Format.DATE)
|
||||
RelationFormat.DATE
|
||||
else
|
||||
null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -513,11 +514,9 @@ open class FilterViewModel(
|
|||
val selected = tags.filter { it.isSelected }.map { tag -> tag.id }
|
||||
proceedWithCreatingFilter(
|
||||
ctx = ctx,
|
||||
filter = DVFilter(
|
||||
relationKey = relation,
|
||||
value = selected,
|
||||
condition = condition.toDomain()
|
||||
)
|
||||
relationKey = relation,
|
||||
value = selected,
|
||||
condition = condition.toDomain(),
|
||||
)
|
||||
}
|
||||
ColumnView.Format.STATUS -> {
|
||||
|
@ -526,11 +525,9 @@ open class FilterViewModel(
|
|||
val selected = statuses.filter { it.isSelected }.map { status -> status.id }
|
||||
proceedWithCreatingFilter(
|
||||
ctx = ctx,
|
||||
filter = DVFilter(
|
||||
relationKey = relation,
|
||||
value = selected,
|
||||
condition = condition.toDomain()
|
||||
)
|
||||
relationKey = relation,
|
||||
value = selected,
|
||||
condition = condition.toDomain()
|
||||
)
|
||||
}
|
||||
ColumnView.Format.DATE -> {
|
||||
|
@ -539,12 +536,10 @@ open class FilterViewModel(
|
|||
val selected = dates.firstOrNull { it.isSelected }
|
||||
proceedWithCreatingFilter(
|
||||
ctx = ctx,
|
||||
filter = DVFilter(
|
||||
relationKey = relation,
|
||||
value = selected?.value?.toDouble(),
|
||||
quickOption = selected?.type ?: DVFilterQuickOption.EXACT_DATE,
|
||||
condition = condition.toDomain()
|
||||
)
|
||||
relationKey = relation,
|
||||
value = selected?.value?.toDouble(),
|
||||
quickOption = selected?.type ?: DVFilterQuickOption.EXACT_DATE,
|
||||
condition = condition.toDomain()
|
||||
)
|
||||
}
|
||||
ColumnView.Format.OBJECT -> {
|
||||
|
@ -555,21 +550,18 @@ open class FilterViewModel(
|
|||
.map { obj -> obj.id }
|
||||
proceedWithCreatingFilter(
|
||||
ctx = ctx,
|
||||
filter = DVFilter(
|
||||
relationKey = relation,
|
||||
value = selected,
|
||||
condition = condition.toDomain()
|
||||
)
|
||||
relationKey = relation,
|
||||
value = selected,
|
||||
condition = condition.toDomain(),
|
||||
)
|
||||
}
|
||||
ColumnView.Format.CHECKBOX -> {
|
||||
val filter = filterValueListState.value.checkboxFilter(
|
||||
relationKey = relation,
|
||||
condition = condition
|
||||
)
|
||||
val value = filterValueListState.value.checkboxFilterValue()
|
||||
proceedWithCreatingFilter(
|
||||
ctx = ctx,
|
||||
filter = filter
|
||||
relationKey = relation,
|
||||
value = value,
|
||||
condition = condition.toDomain()
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
|
@ -597,13 +589,19 @@ open class FilterViewModel(
|
|||
viewModelScope.launch {
|
||||
val block = objectSetState.value.dataview
|
||||
val viewer = objectSetState.value.viewerById(session.currentViewerId.value)
|
||||
val filterId = viewer.filters.getOrNull(idx)?.id
|
||||
if (filterId == null) {
|
||||
commands.emit(Commands.Toast("Filter with index $idx not found"))
|
||||
Timber.e("Filter with index $idx not found")
|
||||
return@launch
|
||||
}
|
||||
proceedWithUpdatingFilter(
|
||||
ctx = ctx,
|
||||
target = block.id,
|
||||
idx = idx,
|
||||
viewer = viewer,
|
||||
updatedFilter = DVFilter(
|
||||
relationKey = relation,
|
||||
id = filterId,
|
||||
relation = relation,
|
||||
condition = condition.toDomain(),
|
||||
value = value
|
||||
)
|
||||
|
@ -625,6 +623,12 @@ open class FilterViewModel(
|
|||
viewModelScope.launch {
|
||||
val block = objectSetState.value.dataview
|
||||
val viewer = objectSetState.value.viewerById(session.currentViewerId.value)
|
||||
val filterId = viewer.filters.getOrNull(idx)?.id
|
||||
if (filterId == null) {
|
||||
commands.emit(Commands.Toast("Filter with index $idx not found"))
|
||||
Timber.e("Filter with index $idx not found")
|
||||
return@launch
|
||||
}
|
||||
val format = relationState.value?.format
|
||||
if (format != null) {
|
||||
when (format) {
|
||||
|
@ -638,10 +642,10 @@ open class FilterViewModel(
|
|||
proceedWithUpdatingFilter(
|
||||
ctx = ctx,
|
||||
target = block.id,
|
||||
idx = idx,
|
||||
viewer = viewer,
|
||||
updatedFilter = DVFilter(
|
||||
relationKey = relation,
|
||||
id = filterId,
|
||||
relation = relation,
|
||||
condition = condition.toDomain(),
|
||||
value = value
|
||||
)
|
||||
|
@ -661,10 +665,10 @@ open class FilterViewModel(
|
|||
proceedWithUpdatingFilter(
|
||||
ctx = ctx,
|
||||
target = block.id,
|
||||
idx = idx,
|
||||
viewer = viewer,
|
||||
updatedFilter = DVFilter(
|
||||
relationKey = relation,
|
||||
id = filterId,
|
||||
relation = relation,
|
||||
condition = condition.toDomain(),
|
||||
value = value
|
||||
)
|
||||
|
@ -681,10 +685,10 @@ open class FilterViewModel(
|
|||
proceedWithUpdatingFilter(
|
||||
ctx = ctx,
|
||||
target = block.id,
|
||||
idx = idx,
|
||||
viewer = viewer,
|
||||
updatedFilter = DVFilter(
|
||||
relationKey = relation,
|
||||
id = filterId,
|
||||
relation = relation,
|
||||
condition = condition.toDomain(),
|
||||
quickOption = date?.type ?: DVFilterQuickOption.EXACT_DATE,
|
||||
value = date?.value?.toDouble()
|
||||
|
@ -705,10 +709,10 @@ open class FilterViewModel(
|
|||
proceedWithUpdatingFilter(
|
||||
ctx = ctx,
|
||||
target = block.id,
|
||||
idx = idx,
|
||||
viewer = viewer,
|
||||
updatedFilter = DVFilter(
|
||||
relationKey = relation,
|
||||
id = filterId,
|
||||
relation = relation,
|
||||
condition = condition.toDomain(),
|
||||
value = value
|
||||
)
|
||||
|
@ -719,16 +723,17 @@ open class FilterViewModel(
|
|||
)
|
||||
}
|
||||
ColumnView.Format.CHECKBOX -> {
|
||||
val filter = filterValueListState.value.checkboxFilter(
|
||||
relationKey = relation,
|
||||
condition = condition
|
||||
)
|
||||
val value = filterValueListState.value.checkboxFilterValue()
|
||||
proceedWithUpdatingFilter(
|
||||
ctx = ctx,
|
||||
target = block.id,
|
||||
idx = idx,
|
||||
viewer = viewer,
|
||||
updatedFilter = filter
|
||||
updatedFilter = DVFilter(
|
||||
id = filterId,
|
||||
relation = relation,
|
||||
condition = condition.toDomain(),
|
||||
value = value
|
||||
)
|
||||
)
|
||||
sendAnalyticsChangeFilterValueEvent(
|
||||
analytics = analytics,
|
||||
|
@ -746,45 +751,50 @@ open class FilterViewModel(
|
|||
private suspend fun proceedWithUpdatingFilter(
|
||||
ctx: Id,
|
||||
target: Id,
|
||||
idx: Int,
|
||||
viewer: DVViewer,
|
||||
updatedFilter: DVFilter
|
||||
) {
|
||||
updateDataViewViewer(
|
||||
UpdateDataViewViewer.Params(
|
||||
context = ctx,
|
||||
target = target,
|
||||
viewer = viewer.copy(
|
||||
filters = viewer.filters.mapIndexed { index, filter ->
|
||||
if (index == idx)
|
||||
updatedFilter
|
||||
else
|
||||
filter
|
||||
}
|
||||
)
|
||||
)
|
||||
).process(
|
||||
val params = UpdateDataViewViewer.Params.Filter.Replace(
|
||||
ctx = ctx,
|
||||
dv = target,
|
||||
view = viewer.id,
|
||||
filter = updatedFilter
|
||||
)
|
||||
updateDataViewViewer(params).process(
|
||||
failure = { Timber.e(it, "Error while creating filter") },
|
||||
success = { dispatcher.send(it).also { isCompleted.emit(true) } }
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun proceedWithCreatingFilter(ctx: Id, filter: DVFilter) {
|
||||
private suspend fun proceedWithCreatingFilter(
|
||||
ctx: Id,
|
||||
relationKey: String,
|
||||
relationFormat: RelationFormat? = null,
|
||||
operator: DVFilterOperator = DVFilterOperator.AND,
|
||||
condition: DVFilterCondition,
|
||||
quickOption: DVFilterQuickOption = DVFilterQuickOption.EXACT_DATE,
|
||||
value: Any? = null
|
||||
) {
|
||||
val block = objectSetState.value.dataview
|
||||
val viewer = objectSetState.value.viewerById(session.currentViewerId.value)
|
||||
updateDataViewViewer(
|
||||
UpdateDataViewViewer.Params(
|
||||
context = ctx,
|
||||
target = block.id,
|
||||
viewer = viewer.copy(filters = viewer.filters + listOf(filter))
|
||||
)
|
||||
).process(
|
||||
val params = UpdateDataViewViewer.Params.Filter.Add(
|
||||
ctx = ctx,
|
||||
dv = block.id,
|
||||
view = viewer.id,
|
||||
relationKey = relationKey,
|
||||
relationFormat = relationFormat,
|
||||
operator = operator,
|
||||
condition = condition,
|
||||
quickOption = quickOption,
|
||||
value = value
|
||||
)
|
||||
updateDataViewViewer(params).process(
|
||||
failure = { Timber.e(it, "Error while creating filter") },
|
||||
success = {
|
||||
dispatcher.send(it).also {
|
||||
viewModelScope.sendAnalyticsAddFilterEvent(
|
||||
analytics = analytics,
|
||||
condition = filter.condition
|
||||
condition = condition
|
||||
)
|
||||
isCompleted.emit(true)
|
||||
}
|
||||
|
@ -887,5 +897,6 @@ open class FilterViewModel(
|
|||
object TagDivider : Commands()
|
||||
object ObjectDivider : Commands()
|
||||
object DateDivider : Commands()
|
||||
data class Toast(val message: String) : Commands()
|
||||
}
|
||||
}
|
|
@ -16,7 +16,6 @@ import com.anytypeio.anytype.presentation.sets.ObjectSet
|
|||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.sets.filter.ViewerFilterCommand.Modal
|
||||
import com.anytypeio.anytype.presentation.sets.model.FilterScreenData
|
||||
import com.anytypeio.anytype.presentation.sets.model.FilterView
|
||||
import com.anytypeio.anytype.presentation.sets.viewerById
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -37,7 +36,6 @@ class ViewerFilterViewModel(
|
|||
|
||||
val screenState = MutableStateFlow(ScreenState.LIST)
|
||||
|
||||
val data: MutableStateFlow<FilterScreenData> = MutableStateFlow(FilterScreenData.empty())
|
||||
val commands = MutableSharedFlow<ViewerFilterCommand>()
|
||||
|
||||
init {
|
||||
|
@ -123,37 +121,37 @@ class ViewerFilterViewModel(
|
|||
private fun proceedToFilterValueScreen(filterIndex: Int) {
|
||||
when (val filter = _views.value[filterIndex]) {
|
||||
is FilterView.Expression.Text -> {
|
||||
emitCommand(Modal.UpdateInputValueFilter(filter.key, filterIndex))
|
||||
emitCommand(Modal.UpdateInputValueFilter(filter.relation, filterIndex))
|
||||
}
|
||||
is FilterView.Expression.Number -> {
|
||||
emitCommand(Modal.UpdateInputValueFilter(filter.key, filterIndex))
|
||||
emitCommand(Modal.UpdateInputValueFilter(filter.relation, filterIndex))
|
||||
}
|
||||
is FilterView.Expression.Tag -> {
|
||||
emitCommand(Modal.UpdateSelectValueFilter(filter.key, filterIndex))
|
||||
emitCommand(Modal.UpdateSelectValueFilter(filter.relation, filterIndex))
|
||||
}
|
||||
is FilterView.Expression.Status -> {
|
||||
emitCommand(Modal.UpdateSelectValueFilter(filter.key, filterIndex))
|
||||
emitCommand(Modal.UpdateSelectValueFilter(filter.relation, filterIndex))
|
||||
}
|
||||
is FilterView.Expression.Date -> {
|
||||
emitCommand(Modal.UpdateSelectValueFilter(filter.key, filterIndex))
|
||||
emitCommand(Modal.UpdateSelectValueFilter(filter.relation, filterIndex))
|
||||
}
|
||||
is FilterView.Expression.Email -> {
|
||||
emitCommand(Modal.UpdateInputValueFilter(filter.key, filterIndex))
|
||||
emitCommand(Modal.UpdateInputValueFilter(filter.relation, filterIndex))
|
||||
}
|
||||
is FilterView.Expression.Object -> {
|
||||
emitCommand(Modal.UpdateSelectValueFilter(filter.key, filterIndex))
|
||||
emitCommand(Modal.UpdateSelectValueFilter(filter.relation, filterIndex))
|
||||
}
|
||||
is FilterView.Expression.Phone -> {
|
||||
emitCommand(Modal.UpdateInputValueFilter(filter.key, filterIndex))
|
||||
emitCommand(Modal.UpdateInputValueFilter(filter.relation, filterIndex))
|
||||
}
|
||||
is FilterView.Expression.TextShort -> {
|
||||
emitCommand(Modal.UpdateInputValueFilter(filter.key, filterIndex))
|
||||
emitCommand(Modal.UpdateInputValueFilter(filter.relation, filterIndex))
|
||||
}
|
||||
is FilterView.Expression.Url -> {
|
||||
emitCommand(Modal.UpdateInputValueFilter(filter.key, filterIndex))
|
||||
emitCommand(Modal.UpdateInputValueFilter(filter.relation, filterIndex))
|
||||
}
|
||||
is FilterView.Expression.Checkbox -> {
|
||||
emitCommand(Modal.UpdateSelectValueFilter(filter.key, filterIndex))
|
||||
emitCommand(Modal.UpdateSelectValueFilter(filter.relation, filterIndex))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,24 +159,19 @@ class ViewerFilterViewModel(
|
|||
private fun onRemoveFilterClicked(ctx: Id, filterIndex: Int) {
|
||||
val viewer = objectSetState.value.viewerById(session.currentViewerId.value)
|
||||
val block = objectSetState.value.blocks.first { it.content is DV }
|
||||
val filters = viewer.filters.mapIndexedNotNull { index, filter ->
|
||||
if (index != filterIndex) {
|
||||
filter
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val filter = viewer.filters.getOrNull(filterIndex)
|
||||
if (filter == null) {
|
||||
Timber.e("Filter with index $filterIndex not found")
|
||||
return
|
||||
}
|
||||
val updated = viewer.copy(
|
||||
filters = filters
|
||||
)
|
||||
viewModelScope.launch {
|
||||
updateDataViewViewer(
|
||||
UpdateDataViewViewer.Params(
|
||||
context = ctx,
|
||||
target = block.id,
|
||||
viewer = updated
|
||||
)
|
||||
).process(
|
||||
val params = UpdateDataViewViewer.Params.Filter.Remove(
|
||||
ctx = ctx,
|
||||
dv = block.id,
|
||||
view = viewer.id,
|
||||
ids = listOf(filter.id),
|
||||
)
|
||||
updateDataViewViewer(params).process(
|
||||
success = { dispatcher.send(it) },
|
||||
failure = { Timber.e("Error while reset all filters") }
|
||||
)
|
||||
|
|
|
@ -94,21 +94,5 @@ sealed class FilterValue {
|
|||
}
|
||||
}
|
||||
|
||||
data class FilterExpression(
|
||||
val key: String,
|
||||
val operator: Viewer.FilterOperator,
|
||||
val condition: Viewer.Filter.Condition,
|
||||
val value: FilterValue?
|
||||
)
|
||||
|
||||
data class FilterScreenData(
|
||||
val relations: List<SimpleRelationView>,
|
||||
val filters: List<FilterExpression>
|
||||
) {
|
||||
companion object {
|
||||
fun empty() = FilterScreenData(emptyList(), emptyList())
|
||||
}
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
data class TagValue(val id: String, val text: String, val color: String): Parcelable
|
|
@ -1,12 +1,15 @@
|
|||
package com.anytypeio.anytype.presentation.sets.model
|
||||
|
||||
import com.anytypeio.anytype.core_models.DVFilterQuickOption
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.Key
|
||||
import com.anytypeio.anytype.core_utils.ui.ViewType
|
||||
|
||||
sealed class FilterView : ViewType {
|
||||
|
||||
sealed class Expression : FilterView() {
|
||||
abstract val key: String
|
||||
abstract val id: Id
|
||||
abstract val relation: Key
|
||||
abstract val title: String
|
||||
abstract val operator: Viewer.FilterOperator
|
||||
abstract val condition: Viewer.Filter.Condition
|
||||
|
@ -17,7 +20,8 @@ sealed class FilterView : ViewType {
|
|||
abstract val isInEditMode:Boolean
|
||||
|
||||
data class Text(
|
||||
override val key: String,
|
||||
override val id: Id,
|
||||
override val relation: Key,
|
||||
override val title: String,
|
||||
override val operator: Viewer.FilterOperator,
|
||||
override val condition: Viewer.Filter.Condition.Text,
|
||||
|
@ -30,7 +34,8 @@ sealed class FilterView : ViewType {
|
|||
}
|
||||
|
||||
data class TextShort(
|
||||
override val key: String,
|
||||
override val id: Id,
|
||||
override val relation: Key,
|
||||
override val title: String,
|
||||
override val operator: Viewer.FilterOperator,
|
||||
override val condition: Viewer.Filter.Condition.Text,
|
||||
|
@ -43,7 +48,8 @@ sealed class FilterView : ViewType {
|
|||
}
|
||||
|
||||
data class Url(
|
||||
override val key: String,
|
||||
override val id: Id,
|
||||
override val relation: Key,
|
||||
override val title: String,
|
||||
override val operator: Viewer.FilterOperator,
|
||||
override val condition: Viewer.Filter.Condition.Text,
|
||||
|
@ -56,7 +62,8 @@ sealed class FilterView : ViewType {
|
|||
}
|
||||
|
||||
data class Email(
|
||||
override val key: String,
|
||||
override val id: Id,
|
||||
override val relation: Key,
|
||||
override val title: String,
|
||||
override val operator: Viewer.FilterOperator,
|
||||
override val condition: Viewer.Filter.Condition.Text,
|
||||
|
@ -69,7 +76,8 @@ sealed class FilterView : ViewType {
|
|||
}
|
||||
|
||||
data class Phone(
|
||||
override val key: String,
|
||||
override val id: Id,
|
||||
override val relation: Key,
|
||||
override val title: String,
|
||||
override val operator: Viewer.FilterOperator,
|
||||
override val condition: Viewer.Filter.Condition.Text,
|
||||
|
@ -82,7 +90,8 @@ sealed class FilterView : ViewType {
|
|||
}
|
||||
|
||||
data class Number(
|
||||
override val key: String,
|
||||
override val id: Id,
|
||||
override val relation: Key,
|
||||
override val title: String,
|
||||
override val operator: Viewer.FilterOperator,
|
||||
override val condition: Viewer.Filter.Condition.Number,
|
||||
|
@ -95,7 +104,8 @@ sealed class FilterView : ViewType {
|
|||
}
|
||||
|
||||
data class Status(
|
||||
override val key: String,
|
||||
override val id: Id,
|
||||
override val relation: Key,
|
||||
override val title: String,
|
||||
override val operator: Viewer.FilterOperator,
|
||||
override val condition: Viewer.Filter.Condition.Selected,
|
||||
|
@ -108,7 +118,8 @@ sealed class FilterView : ViewType {
|
|||
}
|
||||
|
||||
data class Tag(
|
||||
override val key: String,
|
||||
override val id: Id,
|
||||
override val relation: Key,
|
||||
override val title: String,
|
||||
override val operator: Viewer.FilterOperator,
|
||||
override val condition: Viewer.Filter.Condition.Selected,
|
||||
|
@ -121,7 +132,8 @@ sealed class FilterView : ViewType {
|
|||
}
|
||||
|
||||
data class Date(
|
||||
override val key: String,
|
||||
override val id: Id,
|
||||
override val relation: Key,
|
||||
override val title: String,
|
||||
override val operator: Viewer.FilterOperator,
|
||||
override val condition: Viewer.Filter.Condition.Date,
|
||||
|
@ -135,7 +147,8 @@ sealed class FilterView : ViewType {
|
|||
}
|
||||
|
||||
data class Object(
|
||||
override val key: String,
|
||||
override val id: Id,
|
||||
override val relation: Key,
|
||||
override val title: String,
|
||||
override val operator: Viewer.FilterOperator,
|
||||
override val condition: Viewer.Filter.Condition.Selected,
|
||||
|
@ -148,7 +161,8 @@ sealed class FilterView : ViewType {
|
|||
}
|
||||
|
||||
data class Checkbox(
|
||||
override val key: String,
|
||||
override val id: Id,
|
||||
override val relation: Key,
|
||||
override val title: String,
|
||||
override val operator: Viewer.FilterOperator,
|
||||
override val condition: Viewer.Filter.Condition.Checkbox,
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
package com.anytypeio.anytype.presentation.sets.model
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class SortingExpression(
|
||||
val key: String,
|
||||
val type: Viewer.SortType = Viewer.SortType.ASC
|
||||
) : Parcelable
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
package com.anytypeio.anytype.presentation.sets.model
|
||||
|
||||
import com.anytypeio.anytype.core_utils.ui.ViewType
|
||||
|
||||
sealed class SortingView : ViewType {
|
||||
|
||||
data class Set(
|
||||
val key: String,
|
||||
val type: Viewer.SortType,
|
||||
val title: String,
|
||||
val isWithPrefix: Boolean = false,
|
||||
val format: ColumnView.Format
|
||||
) : SortingView(), ViewType {
|
||||
override fun getViewType(): Int = HOLDER_SET
|
||||
}
|
||||
|
||||
object Add : SortingView(), ViewType {
|
||||
override fun getViewType(): Int = HOLDER_ADD
|
||||
}
|
||||
|
||||
object Apply : SortingView(), ViewType {
|
||||
override fun getViewType(): Int = HOLDER_APPLY
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val HOLDER_SET = 1
|
||||
const val HOLDER_ADD = 2
|
||||
const val HOLDER_APPLY = 3
|
||||
}
|
||||
}
|
|
@ -32,12 +32,12 @@ class ModifyViewerSortViewModel(
|
|||
val viewState = MutableStateFlow<ViewState?>(null)
|
||||
private val jobs = mutableListOf<Job>()
|
||||
|
||||
fun onStart(relationKey: Key) {
|
||||
Timber.d("onStart, relationKey:[$relationKey]")
|
||||
fun onStart(sortId: Id, relationKey: Key) {
|
||||
Timber.d("onStart, sortId: [$sortId], relationKey:[$relationKey]")
|
||||
jobs += viewModelScope.launch {
|
||||
objectSetState.filter { it.isInitialized }.collect { state ->
|
||||
val viewer = state.viewerById(session.currentViewerId.value)
|
||||
val sort = viewer.sorts.find { it.relationKey == relationKey }
|
||||
val sort = viewer.sorts.find { it.id == sortId }
|
||||
if (sort != null) {
|
||||
val relation = storeOfRelations.getByKey(relationKey)
|
||||
if (relation != null) {
|
||||
|
@ -61,39 +61,44 @@ class ModifyViewerSortViewModel(
|
|||
jobs.clear()
|
||||
}
|
||||
|
||||
fun onSortDescSelected(ctx: Id, relation: Id) {
|
||||
Timber.d("onSortDescSelected, ctx:[$ctx], relationKek")
|
||||
proceedWithUpdatingSortType(ctx, relation, DVSortType.DESC)
|
||||
fun onSortDescSelected(ctx: Id, sortId: Id) {
|
||||
Timber.d("onSortDescSelected, ctx:[$ctx], sortId:[$sortId]")
|
||||
proceedWithUpdatingSortType(
|
||||
ctx = ctx,
|
||||
sortId = sortId,
|
||||
type = DVSortType.DESC
|
||||
)
|
||||
}
|
||||
|
||||
fun onSortAscSelected(ctx: Id, relation: Id) {
|
||||
proceedWithUpdatingSortType(ctx, relation, DVSortType.ASC)
|
||||
fun onSortAscSelected(ctx: Id, sortId: Id) {
|
||||
Timber.d("onSortDescSelected, ctx:[$ctx], sortId:[$sortId]")
|
||||
proceedWithUpdatingSortType(
|
||||
ctx = ctx,
|
||||
sortId = sortId,
|
||||
type = DVSortType.ASC
|
||||
)
|
||||
}
|
||||
|
||||
private fun proceedWithUpdatingSortType(
|
||||
ctx: Id,
|
||||
relation: Key,
|
||||
sortId: Id,
|
||||
type: Block.Content.DataView.Sort.Type
|
||||
) {
|
||||
val state = objectSetState.value
|
||||
val viewer = state.viewerById(session.currentViewerId.value)
|
||||
val sort = viewer.sorts.find { it.id == sortId }
|
||||
if (sort == null) {
|
||||
Timber.e("Couldn't find sort in view:[$viewer] by sortId:[$sortId]")
|
||||
return
|
||||
}
|
||||
viewModelScope.launch {
|
||||
updateDataViewViewer(
|
||||
UpdateDataViewViewer.Params(
|
||||
context = ctx,
|
||||
target = state.dataview.id,
|
||||
viewer = viewer.copy(
|
||||
sorts = viewer.sorts.map { sort ->
|
||||
if (sort.relationKey == relation)
|
||||
sort.copy(
|
||||
type = type
|
||||
)
|
||||
else
|
||||
sort
|
||||
}
|
||||
)
|
||||
)
|
||||
).process(
|
||||
val params = UpdateDataViewViewer.Params.Sort.Replace(
|
||||
ctx = ctx,
|
||||
dv = state.dataview.id,
|
||||
view = viewer.id,
|
||||
sort = sort.copy(type = type)
|
||||
)
|
||||
updateDataViewViewer(params).process(
|
||||
success = {
|
||||
dispatcher.send(it).also {
|
||||
sendAnalyticsChangeSortValueEvent(analytics)
|
||||
|
|
|
@ -87,14 +87,13 @@ class ViewerSortViewModel(
|
|||
viewModelScope.launch {
|
||||
val state = objectSetState.value
|
||||
val viewer = state.viewerById(session.currentViewerId.value)
|
||||
val sorts = viewer.sorts.filter { it.relationKey != view.relation }
|
||||
updateDataViewViewer(
|
||||
UpdateDataViewViewer.Params(
|
||||
context = ctx,
|
||||
target = state.dataview.id,
|
||||
viewer = viewer.copy(sorts = sorts)
|
||||
)
|
||||
).process(
|
||||
val params = UpdateDataViewViewer.Params.Sort.Remove(
|
||||
ctx = ctx,
|
||||
dv = state.dataview.id,
|
||||
view = viewer.id,
|
||||
ids = listOf(view.sortId)
|
||||
)
|
||||
updateDataViewViewer(params).process(
|
||||
failure = { Timber.e(it, "Error while removing a sort") },
|
||||
success = { dispatcher.send(it) }
|
||||
)
|
||||
|
@ -115,13 +114,15 @@ class ViewerSortViewModel(
|
|||
}
|
||||
|
||||
/**
|
||||
* @property [relation] id of the relation, to which this sort is applied.
|
||||
* @property [sortId] sort id
|
||||
* @property [relation] key of the relation, to which this sort is applied.
|
||||
* @property [name] relation name
|
||||
* @property [format] relation format
|
||||
* @property [type] sort type
|
||||
*/
|
||||
data class ViewerSortView(
|
||||
val relation: Id,
|
||||
val sortId: Id,
|
||||
val relation: Key,
|
||||
val name: String,
|
||||
val format: Relation.Format,
|
||||
val type: DVSortType,
|
||||
|
|
|
@ -75,7 +75,7 @@ class ViewerCardSizeSelectViewModel(
|
|||
val currObjectSetState = objectSetState.value
|
||||
if (currObjectSetState.isInitialized) {
|
||||
updateDataViewViewer(
|
||||
UpdateDataViewViewer.Params(
|
||||
UpdateDataViewViewer.Params.Fields(
|
||||
context = ctx,
|
||||
target = currObjectSetState.dataview.id,
|
||||
viewer = currObjectSetState.viewerById(session.currentViewerId.value).copy(
|
||||
|
|
|
@ -61,7 +61,7 @@ class ViewerImagePreviewSelectViewModel(
|
|||
val currObjectSetState = objectSetState.value
|
||||
if (currObjectSetState.isInitialized) {
|
||||
updateDataViewViewer(
|
||||
UpdateDataViewViewer.Params(
|
||||
UpdateDataViewViewer.Params.Fields(
|
||||
context = ctx,
|
||||
target = currObjectSetState.dataview.id,
|
||||
viewer = currObjectSetState.viewerById(session.currentViewerId.value).copy(
|
||||
|
|
|
@ -79,21 +79,21 @@ class RelationAddViewModelBaseTest {
|
|||
addAll(ObjectSearchConstants.filterMyRelations())
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = false
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceId
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.RELATION_KEY,
|
||||
relation = Relations.RELATION_KEY,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = Relations.systemRelationKeys
|
||||
)
|
||||
|
@ -114,28 +114,28 @@ class RelationAddViewModelBaseTest {
|
|||
addAll(ObjectSearchConstants.filterMarketplaceRelations())
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.ID,
|
||||
relation = Relations.ID,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = listOf(relation.sourceObject)
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = false
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = MARKETPLACE_ID
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.RELATION_KEY,
|
||||
relation = Relations.RELATION_KEY,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = Relations.systemRelationKeys
|
||||
)
|
||||
|
@ -218,21 +218,21 @@ class RelationAddViewModelBaseTest {
|
|||
addAll(ObjectSearchConstants.filterMyRelations())
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = false
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = workspaceId
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.RELATION_KEY,
|
||||
relation = Relations.RELATION_KEY,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = Relations.systemRelationKeys
|
||||
)
|
||||
|
@ -253,28 +253,28 @@ class RelationAddViewModelBaseTest {
|
|||
addAll(ObjectSearchConstants.filterMarketplaceRelations())
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.ID,
|
||||
relation = Relations.ID,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = library.mapNotNull { it.sourceObject }
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = false
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.WORKSPACE_ID,
|
||||
relation = Relations.WORKSPACE_ID,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = MARKETPLACE_ID
|
||||
)
|
||||
)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.RELATION_KEY,
|
||||
relation = Relations.RELATION_KEY,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = Relations.systemRelationKeys
|
||||
)
|
||||
|
|
|
@ -49,7 +49,7 @@ class RelationExtensionsTest {
|
|||
|
||||
val expected = listOf(
|
||||
DVFilter(
|
||||
relationKey = ObjectSetConfig.TYPE_KEY,
|
||||
relation = ObjectSetConfig.TYPE_KEY,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.IN,
|
||||
value = listOf("_image", "_video", "_file")
|
||||
|
@ -80,13 +80,13 @@ class RelationExtensionsTest {
|
|||
|
||||
val expected = listOf(
|
||||
DVFilter(
|
||||
relationKey = ObjectSetConfig.TYPE_KEY,
|
||||
relation = ObjectSetConfig.TYPE_KEY,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.IN,
|
||||
value = listOf("_image", "_video", "_file")
|
||||
),
|
||||
DVFilter(
|
||||
relationKey = Relations.IS_HIDDEN,
|
||||
relation = Relations.IS_HIDDEN,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.NOT_EQUAL,
|
||||
value = true
|
||||
|
|
|
@ -377,11 +377,16 @@ class ObjectSetReducerTest {
|
|||
val relationKey3 = MockDataFactory.randomUuid()
|
||||
val relationKey4 = MockDataFactory.randomUuid()
|
||||
val relationKey5 = MockDataFactory.randomUuid()
|
||||
val sort1 = StubSort(relationKey = relationKey1)
|
||||
val sort2 = StubSort(relationKey = relationKey2)
|
||||
val sort3 = StubSort(relationKey = relationKey3)
|
||||
val sort4 = StubSort(relationKey = relationKey4)
|
||||
val sort5 = StubSort(relationKey = relationKey5)
|
||||
val sortId1 = MockDataFactory.randomUuid()
|
||||
val sortId2 = MockDataFactory.randomUuid()
|
||||
val sortId3 = MockDataFactory.randomUuid()
|
||||
val sortId4 = MockDataFactory.randomUuid()
|
||||
val sortId5 = MockDataFactory.randomUuid()
|
||||
val sort1 = StubSort(relationKey = relationKey1, id = sortId1)
|
||||
val sort2 = StubSort(relationKey = relationKey2, id = sortId2)
|
||||
val sort3 = StubSort(relationKey = relationKey3, id = sortId3)
|
||||
val sort4 = StubSort(relationKey = relationKey4, id = sortId4)
|
||||
val sort5 = StubSort(relationKey = relationKey5, id = sortId5)
|
||||
|
||||
val viewer1 = StubDataViewView(
|
||||
type = Block.Content.DataView.Viewer.Type.BOARD,
|
||||
|
@ -408,41 +413,46 @@ class ObjectSetReducerTest {
|
|||
viewerId = viewer1.id,
|
||||
sortUpdates = listOf(
|
||||
Event.Command.DataView.UpdateView.DVSortUpdate.Move(
|
||||
afterId = relationKey3,
|
||||
ids = listOf(relationKey1, relationKey2)
|
||||
afterId = sortId3,
|
||||
ids = listOf(sortId1, sortId2)
|
||||
),
|
||||
Event.Command.DataView.UpdateView.DVSortUpdate.Add(
|
||||
afterId = relationKey3,
|
||||
afterId = sortId3,
|
||||
sorts = listOf(sort5)
|
||||
),
|
||||
Event.Command.DataView.UpdateView.DVSortUpdate.Update(
|
||||
id = relationKey2,
|
||||
sort = DVSort(relationKey2, Block.Content.DataView.Sort.Type.DESC)
|
||||
id = sortId2,
|
||||
sort = DVSort(sort2.id, relationKey2, Block.Content.DataView.Sort.Type.DESC)
|
||||
),
|
||||
Event.Command.DataView.UpdateView.DVSortUpdate.Remove(
|
||||
ids = listOf(relationKey1)
|
||||
ids = listOf(sortId1)
|
||||
)
|
||||
),
|
||||
filterUpdates = listOf(),
|
||||
relationUpdates = listOf()
|
||||
relationUpdates = listOf(),
|
||||
fields = null
|
||||
)
|
||||
|
||||
val result = reducer.reduce(state = objectSet, events = listOf(event))
|
||||
|
||||
val expectedSorts = listOf(
|
||||
DVSort(
|
||||
id = sortId3,
|
||||
relationKey = relationKey3,
|
||||
type = Block.Content.DataView.Sort.Type.ASC
|
||||
),
|
||||
DVSort(
|
||||
id = sortId5,
|
||||
relationKey = relationKey5,
|
||||
type = Block.Content.DataView.Sort.Type.ASC
|
||||
),
|
||||
DVSort(
|
||||
id = sortId2,
|
||||
relationKey = relationKey2,
|
||||
type = Block.Content.DataView.Sort.Type.DESC
|
||||
),
|
||||
DVSort(
|
||||
id = sortId4,
|
||||
relationKey = relationKey4,
|
||||
type = Block.Content.DataView.Sort.Type.ASC
|
||||
)
|
||||
|
@ -489,16 +499,21 @@ class ObjectSetReducerTest {
|
|||
val context = MockDataFactory.randomUuid()
|
||||
val title = StubTitle()
|
||||
|
||||
val filterId1 = MockDataFactory.randomUuid()
|
||||
val filterId2 = MockDataFactory.randomUuid()
|
||||
val filterId3 = MockDataFactory.randomUuid()
|
||||
val filterId4 = MockDataFactory.randomUuid()
|
||||
val filterId5 = MockDataFactory.randomUuid()
|
||||
val relationKey1 = MockDataFactory.randomUuid()
|
||||
val relationKey2 = MockDataFactory.randomUuid()
|
||||
val relationKey3 = MockDataFactory.randomUuid()
|
||||
val relationKey4 = MockDataFactory.randomUuid()
|
||||
val relationKey5 = MockDataFactory.randomUuid()
|
||||
val filter1 = StubFilter(relationKey = relationKey1)
|
||||
val filter2 = StubFilter(relationKey = relationKey2)
|
||||
val filter3 = StubFilter(relationKey = relationKey3)
|
||||
val filter4 = StubFilter(relationKey = relationKey4)
|
||||
val filter5 = StubFilter(relationKey = relationKey5)
|
||||
val filter1 = StubFilter(relationKey = relationKey1, id = filterId1)
|
||||
val filter2 = StubFilter(relationKey = relationKey2, id = filterId2)
|
||||
val filter3 = StubFilter(relationKey = relationKey3, id = filterId3)
|
||||
val filter4 = StubFilter(relationKey = relationKey4, id = filterId4)
|
||||
val filter5 = StubFilter(relationKey = relationKey5, id = filterId5)
|
||||
|
||||
val viewer1 = StubDataViewView(
|
||||
type = Block.Content.DataView.Viewer.Type.BOARD,
|
||||
|
@ -523,24 +538,25 @@ class ObjectSetReducerTest {
|
|||
sortUpdates = listOf(),
|
||||
filterUpdates = listOf(
|
||||
Event.Command.DataView.UpdateView.DVFilterUpdate.Move(
|
||||
afterId = relationKey3,
|
||||
ids = listOf(relationKey1, relationKey2)
|
||||
afterId = filterId3,
|
||||
ids = listOf(filterId1, filterId2)
|
||||
),
|
||||
Event.Command.DataView.UpdateView.DVFilterUpdate.Add(
|
||||
afterId = relationKey3,
|
||||
afterId = filterId3,
|
||||
filters = listOf(filter5)
|
||||
),
|
||||
Event.Command.DataView.UpdateView.DVFilterUpdate.Update(
|
||||
id = relationKey2,
|
||||
id = filterId2,
|
||||
filter = filter2.copy(
|
||||
value = filter2Value
|
||||
)
|
||||
),
|
||||
Event.Command.DataView.UpdateView.DVFilterUpdate.Remove(
|
||||
ids = listOf(relationKey1)
|
||||
ids = listOf(filterId1)
|
||||
)
|
||||
),
|
||||
relationUpdates = listOf()
|
||||
relationUpdates = listOf(),
|
||||
fields = null
|
||||
)
|
||||
|
||||
val result = reducer.reduce(state = objectSet, events = listOf(event))
|
||||
|
@ -639,7 +655,8 @@ class ObjectSetReducerTest {
|
|||
Event.Command.DataView.UpdateView.DVViewerRelationUpdate.Remove(
|
||||
ids = listOf(relationKey1)
|
||||
)
|
||||
)
|
||||
),
|
||||
fields = null
|
||||
)
|
||||
|
||||
val result = reducer.reduce(state = objectSet, events = listOf(event))
|
||||
|
@ -680,4 +697,95 @@ class ObjectSetReducerTest {
|
|||
|
||||
assertEquals(expected, result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should update fields for viewer, with new fields`() {
|
||||
val context = MockDataFactory.randomUuid()
|
||||
val title = StubTitle()
|
||||
|
||||
val relationKey1 = MockDataFactory.randomUuid()
|
||||
val relationKey2 = MockDataFactory.randomUuid()
|
||||
val relation1 = StubDataViewViewRelation(key = relationKey1)
|
||||
val relation2 = StubDataViewViewRelation(key = relationKey2)
|
||||
val filter1 = StubFilter(relationKey = relationKey1)
|
||||
val filter2 = StubFilter(relationKey = relationKey2)
|
||||
val sort1 = StubSort(relationKey = relationKey1)
|
||||
val sort2 = StubSort(relationKey = relationKey2)
|
||||
|
||||
val viewer = StubDataViewView(
|
||||
type = Block.Content.DataView.Viewer.Type.GRID,
|
||||
viewerRelations = listOf(relation1, relation2),
|
||||
filters = listOf(filter1, filter2),
|
||||
sorts = listOf(sort1, sort2),
|
||||
name = MockDataFactory.randomString(),
|
||||
cardSize = Block.Content.DataView.Viewer.Size.MEDIUM,
|
||||
coverFit = true,
|
||||
coverRelationKey = relationKey1,
|
||||
hideIcon = false
|
||||
)
|
||||
|
||||
val dataView = StubDataView(
|
||||
id = MockDataFactory.randomUuid(),
|
||||
views = listOf(viewer),
|
||||
)
|
||||
|
||||
val blocks = listOf(title, dataView)
|
||||
|
||||
val objectSet = ObjectSet(blocks = blocks)
|
||||
|
||||
// TESTING
|
||||
|
||||
val newViewerName = MockDataFactory.randomString()
|
||||
val newCardSize = Block.Content.DataView.Viewer.Size.SMALL
|
||||
val newCoverFit = false
|
||||
|
||||
val event = Event.Command.DataView.UpdateView(
|
||||
context = context,
|
||||
block = dataView.id,
|
||||
viewerId = viewer.id,
|
||||
sortUpdates = listOf(),
|
||||
filterUpdates = listOf(),
|
||||
relationUpdates = listOf(),
|
||||
fields = Event.Command.DataView.UpdateView.DVViewerFields(
|
||||
name = newViewerName,
|
||||
cardSize = newCardSize,
|
||||
coverFit = newCoverFit,
|
||||
coverRelationKey = relationKey1,
|
||||
hideIcon = false,
|
||||
type = Block.Content.DataView.Viewer.Type.GRID
|
||||
)
|
||||
)
|
||||
|
||||
val result = reducer.reduce(state = objectSet, events = listOf(event))
|
||||
|
||||
val expectedDataView = Block(
|
||||
id = dataView.id,
|
||||
content = Block.Content.DataView(
|
||||
viewers = listOf(
|
||||
Block.Content.DataView.Viewer(
|
||||
id = viewer.id,
|
||||
type = viewer.type,
|
||||
viewerRelations = viewer.viewerRelations,
|
||||
sorts = viewer.sorts,
|
||||
filters = viewer.filters,
|
||||
name = newViewerName,
|
||||
cardSize = newCardSize,
|
||||
coverFit = newCoverFit,
|
||||
coverRelationKey = relationKey1
|
||||
)
|
||||
),
|
||||
relations = listOf(),
|
||||
targetObjectId = (dataView.content as Block.Content.DataView).targetObjectId
|
||||
),
|
||||
fields = Block.Fields.empty(),
|
||||
children = listOf()
|
||||
)
|
||||
|
||||
val expected = ObjectSetReducer.Transformation(
|
||||
state = ObjectSet(blocks = listOf(title, expectedDataView)),
|
||||
effects = emptyList()
|
||||
)
|
||||
|
||||
assertEquals(expected, result)
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import app.cash.turbine.test
|
|||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.DVViewerRelation
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewViewerSort
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.presentation.MockRelationFactory
|
||||
|
@ -47,7 +47,7 @@ class SearchRelationViewModelTest {
|
|||
private val session = ObjectSetSession()
|
||||
|
||||
@Mock
|
||||
lateinit var addDataViewViewerSort: AddDataViewViewerSort
|
||||
lateinit var updateDataViewViewer: UpdateDataViewViewer
|
||||
|
||||
@Mock
|
||||
lateinit var analytics: Analytics
|
||||
|
@ -273,7 +273,7 @@ class SearchRelationViewModelTest {
|
|||
return SelectSortRelationViewModel(
|
||||
objectSetState = state,
|
||||
session = session,
|
||||
addDataViewViewerSort = addDataViewViewerSort,
|
||||
updateDataViewViewer = updateDataViewViewer,
|
||||
dispatcher = dispatcher,
|
||||
analytics = analytics,
|
||||
storeOfRelations = storeOfRelations
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
package com.anytypeio.anytype.presentation.sets.filter
|
||||
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.DVFilter
|
||||
import com.anytypeio.anytype.core_models.DVFilterCondition
|
||||
import com.anytypeio.anytype.presentation.extension.checkboxFilter
|
||||
import com.anytypeio.anytype.presentation.sets.model.Viewer
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.presentation.extension.checkboxFilterValue
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
|
@ -14,9 +9,6 @@ class FilterExtensionsTest {
|
|||
@Test
|
||||
fun shouldReturnCheckedTrue() {
|
||||
|
||||
val relationKey = MockDataFactory.randomUuid()
|
||||
val condition = Viewer.Filter.Condition.Checkbox.Equal()
|
||||
|
||||
val views = listOf(
|
||||
CreateFilterView.Checkbox(
|
||||
isChecked = true,
|
||||
|
@ -28,14 +20,9 @@ class FilterExtensionsTest {
|
|||
)
|
||||
)
|
||||
|
||||
val result = views.checkboxFilter(relationKey, condition)
|
||||
val result = views.checkboxFilterValue()
|
||||
|
||||
val expected = DVFilter(
|
||||
relationKey = relationKey,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = true
|
||||
)
|
||||
val expected = true
|
||||
|
||||
Assert.assertEquals(expected, result)
|
||||
}
|
||||
|
@ -43,19 +30,11 @@ class FilterExtensionsTest {
|
|||
@Test
|
||||
fun shouldReturnNullValueOnCheckboxNoneCondition() {
|
||||
|
||||
val relationKey = MockDataFactory.randomUuid()
|
||||
val condition = Viewer.Filter.Condition.Checkbox.None()
|
||||
|
||||
val views = listOf<CreateFilterView>()
|
||||
|
||||
val result = views.checkboxFilter(relationKey, condition)
|
||||
val result = views.checkboxFilterValue()
|
||||
|
||||
val expected = DVFilter(
|
||||
relationKey = relationKey,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = DVFilterCondition.NONE,
|
||||
value = null
|
||||
)
|
||||
val expected = null
|
||||
|
||||
Assert.assertEquals(expected, result)
|
||||
}
|
||||
|
@ -63,9 +42,6 @@ class FilterExtensionsTest {
|
|||
@Test
|
||||
fun shouldReturnNotCheckedTrue() {
|
||||
|
||||
val relationKey = MockDataFactory.randomUuid()
|
||||
val condition = Viewer.Filter.Condition.Checkbox.Equal()
|
||||
|
||||
val views = listOf(
|
||||
CreateFilterView.Checkbox(
|
||||
isChecked = true,
|
||||
|
@ -77,14 +53,9 @@ class FilterExtensionsTest {
|
|||
)
|
||||
)
|
||||
|
||||
val result = views.checkboxFilter(relationKey, condition)
|
||||
val result = views.checkboxFilterValue()
|
||||
|
||||
val expected = DVFilter(
|
||||
relationKey = relationKey,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = DVFilterCondition.EQUAL,
|
||||
value = false
|
||||
)
|
||||
val expected = false
|
||||
|
||||
Assert.assertEquals(expected, result)
|
||||
}
|
||||
|
@ -92,9 +63,6 @@ class FilterExtensionsTest {
|
|||
@Test
|
||||
fun shouldReturnNotEqualNotCheckedTrue() {
|
||||
|
||||
val relationKey = MockDataFactory.randomUuid()
|
||||
val condition = Viewer.Filter.Condition.Checkbox.NotEqual()
|
||||
|
||||
val views = listOf(
|
||||
CreateFilterView.Checkbox(
|
||||
isChecked = true,
|
||||
|
@ -106,14 +74,9 @@ class FilterExtensionsTest {
|
|||
)
|
||||
)
|
||||
|
||||
val result = views.checkboxFilter(relationKey, condition)
|
||||
val result = views.checkboxFilterValue()
|
||||
|
||||
val expected = DVFilter(
|
||||
relationKey = relationKey,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = DVFilterCondition.NOT_EQUAL,
|
||||
value = false
|
||||
)
|
||||
val expected = false
|
||||
|
||||
Assert.assertEquals(expected, result)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.anytypeio.anytype.presentation.sets.filter
|
|||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.DVFilter
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
|
@ -203,7 +202,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
|
||||
//region LONG TEXT
|
||||
@Test
|
||||
fun `should null string value, long text 1`() = runTest{
|
||||
fun `should null string value, long text 1`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -216,7 +215,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, long text 2`() = runTest{
|
||||
fun `should null string value, long text 2`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -229,7 +228,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, long text 3`() = runTest{
|
||||
fun `should null string value, long text 3`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -242,7 +241,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, long text 4`() = runTest{
|
||||
fun `should null string value, long text 4`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -255,7 +254,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, long text 1`() = runTest{
|
||||
fun `should not empty string value, long text 1`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -268,7 +267,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, long text 2`() = runTest{
|
||||
fun `should not empty string value, long text 2`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -281,7 +280,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, long text 3`() = runTest{
|
||||
fun `should not empty string value, long text 3`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -294,7 +293,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, long text 4`() = runTest{
|
||||
fun `should not empty string value, long text 4`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -310,7 +309,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
|
||||
//region SHORT TEXT
|
||||
@Test
|
||||
fun `should null string value, short text 1`() = runTest{
|
||||
fun `should null string value, short text 1`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -323,7 +322,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, short text 2`() = runTest{
|
||||
fun `should null string value, short text 2`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -336,7 +335,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, short text 3`() = runTest{
|
||||
fun `should null string value, short text 3`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -349,7 +348,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, short text 4`() = runTest{
|
||||
fun `should null string value, short text 4`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -362,7 +361,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, short text 1`() = runTest{
|
||||
fun `should not empty string value, short text 1`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -375,7 +374,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, short text 2`() = runTest{
|
||||
fun `should not empty string value, short text 2`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -388,7 +387,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, short text 3`() = runTest{
|
||||
fun `should not empty string value, short text 3`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -401,7 +400,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, short text 4`() = runTest{
|
||||
fun `should not empty string value, short text 4`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -416,7 +415,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
|
||||
//region NUMBER
|
||||
@Test
|
||||
fun `should null string value, number 1`() = runTest{
|
||||
fun `should null string value, number 1`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -429,7 +428,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, number 2`() = runTest{
|
||||
fun `should null string value, number 2`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -442,7 +441,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, number 3`() = runTest{
|
||||
fun `should null string value, number 3`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -455,7 +454,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, number 4`() = runTest{
|
||||
fun `should null string value, number 4`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -468,7 +467,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should send default number value, number 1`() = runTest{
|
||||
fun `should send default number value, number 1`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -484,11 +483,12 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
condition = condition,
|
||||
textInput = textInput,
|
||||
value = value,
|
||||
filterIndex = filterIndex)
|
||||
filterIndex = filterIndex
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should send default number value, number 2`() = runTest{
|
||||
fun `should send default number value, number 2`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -504,11 +504,12 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
condition = condition,
|
||||
textInput = textInput,
|
||||
value = value,
|
||||
filterIndex = filterIndex)
|
||||
filterIndex = filterIndex
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should send double, number 2`() = runTest{
|
||||
fun `should send double, number 2`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -524,11 +525,12 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
condition = condition,
|
||||
textInput = textInput,
|
||||
value = value,
|
||||
filterIndex = filterIndex)
|
||||
filterIndex = filterIndex
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should send negative double, number 3`() = runTest{
|
||||
fun `should send negative double, number 3`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -544,11 +546,12 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
condition = condition,
|
||||
textInput = textInput,
|
||||
value = value,
|
||||
filterIndex = filterIndex)
|
||||
filterIndex = filterIndex
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should send negative double, number 4`() = runTest{
|
||||
fun `should send negative double, number 4`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -564,11 +567,12 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
condition = condition,
|
||||
textInput = textInput,
|
||||
value = value,
|
||||
filterIndex = filterIndex)
|
||||
filterIndex = filterIndex
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should send default number value, number 3`() = runTest{
|
||||
fun `should send default number value, number 3`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -584,7 +588,8 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
condition = condition,
|
||||
textInput = textInput,
|
||||
value = value,
|
||||
filterIndex = filterIndex)
|
||||
filterIndex = filterIndex
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
@ -592,7 +597,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
|
||||
//region URL
|
||||
@Test
|
||||
fun `should null string value, url 1`() = runTest{
|
||||
fun `should null string value, url 1`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -605,7 +610,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, url 2`() = runTest{
|
||||
fun `should null string value, url 2`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -618,7 +623,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, url 3`() = runTest{
|
||||
fun `should null string value, url 3`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -631,7 +636,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, url 4`() = runTest{
|
||||
fun `should null string value, url 4`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -644,7 +649,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, url 1`() = runTest{
|
||||
fun `should not empty string value, url 1`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -657,7 +662,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, url 2`() = runTest{
|
||||
fun `should not empty string value, url 2`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -670,7 +675,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, url 3`() = runTest{
|
||||
fun `should not empty string value, url 3`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -683,7 +688,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, url 4`() = runTest{
|
||||
fun `should not empty string value, url 4`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -698,7 +703,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
|
||||
//region EMAIL
|
||||
@Test
|
||||
fun `should null string value, email 1`() = runTest{
|
||||
fun `should null string value, email 1`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -711,7 +716,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, email 2`() = runTest{
|
||||
fun `should null string value, email 2`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -724,7 +729,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, email 3`() = runTest{
|
||||
fun `should null string value, email 3`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -737,7 +742,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, email 4`() = runTest{
|
||||
fun `should null string value, email 4`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -750,7 +755,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, email 1`() = runTest{
|
||||
fun `should not empty string value, email 1`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -763,7 +768,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, email 2`() = runTest{
|
||||
fun `should not empty string value, email 2`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -776,7 +781,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, email 3`() = runTest{
|
||||
fun `should not empty string value, email 3`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -789,7 +794,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, email 4`() = runTest{
|
||||
fun `should not empty string value, email 4`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -804,7 +809,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
|
||||
//region PHONE
|
||||
@Test
|
||||
fun `should null string value, phone 1`() = runTest{
|
||||
fun `should null string value, phone 1`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -817,7 +822,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, phone 2`() = runTest{
|
||||
fun `should null string value, phone 2`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -830,7 +835,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, phone 3`() = runTest{
|
||||
fun `should null string value, phone 3`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -843,7 +848,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should null string value, phone 4`() = runTest{
|
||||
fun `should null string value, phone 4`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -856,7 +861,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, phone 1`() = runTest{
|
||||
fun `should not empty string value, phone 1`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -869,7 +874,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, phone 2`() = runTest{
|
||||
fun `should not empty string value, phone 2`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -882,7 +887,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, phone 3`() = runTest{
|
||||
fun `should not empty string value, phone 3`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -895,7 +900,7 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should not empty string value, phone 4`() = runTest{
|
||||
fun `should not empty string value, phone 4`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -933,19 +938,14 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
|
||||
verifyBlocking(updateDataViewViewer, times(1)) {
|
||||
invoke(
|
||||
UpdateDataViewViewer.Params(
|
||||
context = root,
|
||||
target = dataViewId,
|
||||
viewer = viewer.copy(
|
||||
filters = listOf(
|
||||
DVFilter(
|
||||
relationKey = relationKey,
|
||||
operator = DEFAULT_OPERATOR,
|
||||
condition = condition.toDomain(),
|
||||
value = null
|
||||
)
|
||||
)
|
||||
)
|
||||
UpdateDataViewViewer.Params.Filter.Add(
|
||||
ctx = root,
|
||||
dv = dataViewId,
|
||||
view = viewer.id,
|
||||
relationKey = relationKey,
|
||||
operator = DEFAULT_OPERATOR,
|
||||
condition = condition.toDomain(),
|
||||
value = null
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -976,19 +976,14 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
|
||||
verifyBlocking(updateDataViewViewer, times(1)) {
|
||||
invoke(
|
||||
UpdateDataViewViewer.Params(
|
||||
context = root,
|
||||
target = dataViewId,
|
||||
viewer = viewer.copy(
|
||||
filters = listOf(
|
||||
DVFilter(
|
||||
relationKey = relationKey,
|
||||
operator = DEFAULT_OPERATOR,
|
||||
condition = condition.toDomain(),
|
||||
value = textInput
|
||||
)
|
||||
)
|
||||
)
|
||||
UpdateDataViewViewer.Params.Filter.Add(
|
||||
ctx = root,
|
||||
dv = dataViewId,
|
||||
view = viewer.id,
|
||||
relationKey = relationKey,
|
||||
operator = DEFAULT_OPERATOR,
|
||||
condition = condition.toDomain(),
|
||||
value = textInput
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -1020,19 +1015,14 @@ class FilterViewModelInputFieldValueCreateTest {
|
|||
|
||||
verifyBlocking(updateDataViewViewer, times(1)) {
|
||||
invoke(
|
||||
UpdateDataViewViewer.Params(
|
||||
context = root,
|
||||
target = dataViewId,
|
||||
viewer = viewer.copy(
|
||||
filters = listOf(
|
||||
DVFilter(
|
||||
relationKey = relationKey,
|
||||
operator = DEFAULT_OPERATOR,
|
||||
condition = condition.toDomain(),
|
||||
value = value
|
||||
)
|
||||
)
|
||||
)
|
||||
UpdateDataViewViewer.Params.Filter.Add(
|
||||
ctx = root,
|
||||
dv = dataViewId,
|
||||
view = viewer.id,
|
||||
relationKey = relationKey,
|
||||
operator = DEFAULT_OPERATOR,
|
||||
condition = condition.toDomain(),
|
||||
value = value
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ class FilterViewModelInputFieldValueModifyTest {
|
|||
),
|
||||
filters = listOf(
|
||||
Block.Content.DataView.Filter(
|
||||
relationKey = relation1.key,
|
||||
relation = relation1.key,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.LIKE,
|
||||
value = MockDataFactory.randomString()
|
||||
|
@ -210,7 +210,7 @@ class FilterViewModelInputFieldValueModifyTest {
|
|||
|
||||
//region LONG TEXT
|
||||
@Test
|
||||
fun `should empty string value, long text 1`() = runTest{
|
||||
fun `should empty string value, long text 1`() = runTest {
|
||||
|
||||
storeOfRelations.merge(relations)
|
||||
|
||||
|
@ -339,18 +339,15 @@ class FilterViewModelInputFieldValueModifyTest {
|
|||
|
||||
verifyBlocking(updateDataViewViewer, times(1)) {
|
||||
invoke(
|
||||
UpdateDataViewViewer.Params(
|
||||
context = root,
|
||||
target = dataViewId,
|
||||
viewer = viewer.copy(
|
||||
filters = listOf(
|
||||
DVFilter(
|
||||
relationKey = relationKey,
|
||||
operator = DEFAULT_OPERATOR,
|
||||
condition = condition.toDomain(),
|
||||
value = null
|
||||
)
|
||||
)
|
||||
UpdateDataViewViewer.Params.Filter.Replace(
|
||||
ctx = root,
|
||||
dv = dataViewId,
|
||||
view = viewer.id,
|
||||
filter = DVFilter(
|
||||
relation = relationKey,
|
||||
operator = DEFAULT_OPERATOR,
|
||||
condition = condition.toDomain(),
|
||||
value = null
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -382,18 +379,15 @@ class FilterViewModelInputFieldValueModifyTest {
|
|||
|
||||
verifyBlocking(updateDataViewViewer, times(1)) {
|
||||
invoke(
|
||||
UpdateDataViewViewer.Params(
|
||||
context = root,
|
||||
target = dataViewId,
|
||||
viewer = viewer.copy(
|
||||
filters = listOf(
|
||||
DVFilter(
|
||||
relationKey = relationKey,
|
||||
operator = DEFAULT_OPERATOR,
|
||||
condition = condition.toDomain(),
|
||||
value = textInput
|
||||
)
|
||||
)
|
||||
UpdateDataViewViewer.Params.Filter.Replace(
|
||||
ctx = root,
|
||||
dv = dataViewId,
|
||||
view = viewer.id,
|
||||
filter = DVFilter(
|
||||
relation = relationKey,
|
||||
operator = DEFAULT_OPERATOR,
|
||||
condition = condition.toDomain(),
|
||||
value = textInput
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -277,7 +277,7 @@ class ObjectSetDataViewObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
val givenType = MockDataFactory.randomString()
|
||||
|
||||
val filter = DVFilter(
|
||||
relationKey = relationStakeholderKey,
|
||||
relation = relationStakeholderKey,
|
||||
operator = DVFilterOperator.AND,
|
||||
condition = condition,
|
||||
value = relationStakeholderValue,
|
||||
|
|
|
@ -1,275 +0,0 @@
|
|||
package com.anytypeio.anytype.presentation.sets.main
|
||||
|
||||
import app.cash.turbine.test
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.DV
|
||||
import com.anytypeio.anytype.core_models.SearchResult
|
||||
import com.anytypeio.anytype.core_models.SubscriptionEvent
|
||||
import com.anytypeio.anytype.core_models.ext.content
|
||||
import com.anytypeio.anytype.presentation.TypicalTwoRecordObjectSet
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||
import com.anytypeio.anytype.presentation.search.ObjectSearchConstants
|
||||
import com.anytypeio.anytype.presentation.search.ObjectSearchConstants.defaultDataViewFilters
|
||||
import com.anytypeio.anytype.presentation.sets.model.CellView
|
||||
import com.anytypeio.anytype.presentation.sets.model.ColumnView
|
||||
import com.anytypeio.anytype.presentation.sets.model.Viewer
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.MockitoAnnotations
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertIs
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class ObjectSetSettingActiveViewerTest : ObjectSetViewModelTestSetup() {
|
||||
|
||||
val doc = TypicalTwoRecordObjectSet()
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
initDataViewSubscriptionContainer()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should set active viewer and update row order and column count`() = runTest {
|
||||
|
||||
// SETUP
|
||||
|
||||
val delayBeforeChangingOrder = 3000L
|
||||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSubscriptionEventChannel(
|
||||
flow = flow {
|
||||
delay(delayBeforeChangingOrder)
|
||||
emit(
|
||||
listOf(
|
||||
SubscriptionEvent.Position(
|
||||
target = doc.firstRecordId,
|
||||
afterId = doc.secondRecordId
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
val setOf = listOf(MockDataFactory.randomString())
|
||||
val keys = (ObjectSearchConstants.defaultDataViewKeys + doc.dv.content<DV>().relationsIndex.map { it.key }).distinct()
|
||||
|
||||
stubSearchWithSubscription(
|
||||
subscription = root,
|
||||
filters = doc.dv.content<DV>().viewers.first().filters + defaultDataViewFilters(),
|
||||
sorts = doc.dv.content<DV>().viewers.first().sorts,
|
||||
afterId = null,
|
||||
beforeId = null,
|
||||
sources = setOf,
|
||||
keys = keys,
|
||||
limit = ObjectSetConfig.DEFAULT_LIMIT,
|
||||
offset = 0,
|
||||
result = SearchResult(
|
||||
results = doc.initialObjects,
|
||||
dependencies = emptyList(),
|
||||
counter = SearchResult.Counter(
|
||||
total = doc.initialObjects.size,
|
||||
prev = 0,
|
||||
next = 0
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val details = Block.Details(
|
||||
details = mapOf(
|
||||
root to Block.Fields(
|
||||
mapOf("setOf" to setOf)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
stubOpenObjectSet(
|
||||
doc = listOf(
|
||||
doc.header,
|
||||
doc.title,
|
||||
doc.dv
|
||||
),
|
||||
details = details
|
||||
)
|
||||
|
||||
println(storeOfRelations.getAll().toString())
|
||||
|
||||
println(doc.relationsObjects)
|
||||
|
||||
runBlocking {
|
||||
storeOfRelations.merge(
|
||||
relations = doc.relationsObjects
|
||||
)
|
||||
}
|
||||
|
||||
println(storeOfRelations.getAll().toString())
|
||||
|
||||
val vm = givenViewModel()
|
||||
|
||||
// TESTING
|
||||
|
||||
vm.onStart(root)
|
||||
|
||||
vm.currentViewer.test {
|
||||
val valueBeforeLoading = awaitItem()
|
||||
|
||||
assertIs<Viewer.GridView>(valueBeforeLoading)
|
||||
|
||||
assertEquals(
|
||||
expected = 0,
|
||||
actual = valueBeforeLoading.rows.size
|
||||
)
|
||||
|
||||
val valueBeforeChangingViewer = awaitItem()
|
||||
|
||||
// Expecting that all columns are visibile (number of columns == number of relations)
|
||||
|
||||
val expectedColumnsBefore = listOf(
|
||||
ColumnView(
|
||||
key = doc.relationsObjects[0].key,
|
||||
text = doc.relationsObjects[0].name.orEmpty(),
|
||||
format = ColumnView.Format.LONG_TEXT,
|
||||
width = 0,
|
||||
isVisible = true,
|
||||
isHidden = false,
|
||||
isReadOnly = false
|
||||
),
|
||||
ColumnView(
|
||||
key = doc.relationsObjects[1].key,
|
||||
text = doc.relationsObjects[1].name.orEmpty(),
|
||||
format = ColumnView.Format.LONG_TEXT,
|
||||
width = 0,
|
||||
isVisible = true,
|
||||
isHidden = false,
|
||||
isReadOnly = false
|
||||
)
|
||||
)
|
||||
|
||||
// Expecting that cells corresponding to both the first and the second relation are visible.
|
||||
|
||||
val expectedRowsBefore = listOf(
|
||||
Viewer.GridView.Row(
|
||||
id = doc.firstRecordId,
|
||||
name = doc.firstRecordName,
|
||||
emoji = null,
|
||||
image = null,
|
||||
type = doc.firstRecordType,
|
||||
showIcon = true,
|
||||
cells = listOf(
|
||||
CellView.Description(
|
||||
id = doc.firstRecordId,
|
||||
text = doc.firstRecord[doc.relationsObjects[0].key] as String,
|
||||
relationKey = doc.relationsObjects[0].key
|
||||
),
|
||||
CellView.Description(
|
||||
id = doc.firstRecordId,
|
||||
text = doc.firstRecord[doc.relationsObjects[1].key] as String,
|
||||
relationKey = doc.relationsObjects[1].key
|
||||
)
|
||||
)
|
||||
),
|
||||
Viewer.GridView.Row(
|
||||
id = doc.secondRecordId,
|
||||
name = doc.secondRecordName,
|
||||
emoji = null,
|
||||
image = null,
|
||||
type = doc.secondRecordType,
|
||||
showIcon = true,
|
||||
cells = listOf(
|
||||
CellView.Description(
|
||||
id = doc.secondRecordId,
|
||||
text = doc.secondRecord[doc.relationsObjects[0].key] as String,
|
||||
relationKey = doc.relationsObjects[0].key
|
||||
),
|
||||
CellView.Description(
|
||||
id = doc.secondRecordId,
|
||||
text = doc.secondRecord[doc.relationsObjects[1].key] as String,
|
||||
relationKey = doc.relationsObjects[1].key
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
assertIs<Viewer.GridView>(valueBeforeChangingViewer)
|
||||
|
||||
assertEquals(
|
||||
expected = expectedColumnsBefore,
|
||||
actual = valueBeforeChangingViewer.columns
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
expected = expectedRowsBefore,
|
||||
actual = valueBeforeChangingViewer.rows
|
||||
)
|
||||
|
||||
// Selecting second viewer
|
||||
|
||||
vm.onViewerTabClicked(doc.viewer2.id)
|
||||
|
||||
coroutineTestRule.advanceTime(delayBeforeChangingOrder)
|
||||
|
||||
val valueAfterSelectingSecondViewerAndLoading = awaitItem()
|
||||
|
||||
val valueAfterSelectingSecondViewer = awaitItem()
|
||||
|
||||
val expectedColumnsAfter = listOf(expectedColumnsBefore[1])
|
||||
|
||||
// Expecting that cells corresponding to the first relations are not visible
|
||||
// Expecting that row order is reversed, because record order was reversed.
|
||||
|
||||
val expectedRowsAfter = listOf(
|
||||
Viewer.GridView.Row(
|
||||
id = doc.secondRecordId,
|
||||
name = doc.secondRecordName,
|
||||
emoji = null,
|
||||
image = null,
|
||||
type = doc.secondRecordType,
|
||||
showIcon = true,
|
||||
cells = listOf(
|
||||
CellView.Description(
|
||||
id = doc.secondRecordId,
|
||||
text = doc.secondRecord[doc.relationsObjects[1].key] as String,
|
||||
relationKey = doc.relationsObjects[1].key
|
||||
)
|
||||
)
|
||||
),
|
||||
Viewer.GridView.Row(
|
||||
id = doc.firstRecordId,
|
||||
name = doc.firstRecordName,
|
||||
emoji = null,
|
||||
image = null,
|
||||
type = doc.firstRecordType,
|
||||
showIcon = true,
|
||||
cells = listOf(
|
||||
CellView.Description(
|
||||
id = doc.firstRecordId,
|
||||
text = doc.firstRecord[doc.relationsObjects[1].key] as String,
|
||||
relationKey = doc.relationsObjects[1].key
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
assertTrue { valueAfterSelectingSecondViewer is Viewer.GridView }
|
||||
|
||||
check(valueAfterSelectingSecondViewer is Viewer.GridView)
|
||||
|
||||
assertEquals(
|
||||
expected = expectedColumnsAfter,
|
||||
actual = valueAfterSelectingSecondViewer.columns
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
expected = expectedRowsAfter,
|
||||
actual = valueAfterSelectingSecondViewer.rows
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -144,7 +144,7 @@ class ObjectTypeChangeViewModelTest {
|
|||
addAll(ObjectSearchConstants.filterObjectTypeMarketplace)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.ID,
|
||||
relation = Relations.ID,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = listOf(
|
||||
marketplaceType1.id,
|
||||
|
@ -229,7 +229,7 @@ class ObjectTypeChangeViewModelTest {
|
|||
addAll(ObjectSearchConstants.filterObjectTypeMarketplace)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.ID,
|
||||
relation = Relations.ID,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = listOf(
|
||||
marketplaceType1.id,
|
||||
|
@ -390,7 +390,7 @@ class ObjectTypeChangeViewModelTest {
|
|||
addAll(ObjectSearchConstants.filterObjectTypeMarketplace)
|
||||
add(
|
||||
DVFilter(
|
||||
relationKey = Relations.ID,
|
||||
relation = Relations.ID,
|
||||
condition = DVFilterCondition.NOT_IN,
|
||||
value = listOf(
|
||||
marketplaceType1.id,
|
||||
|
|
|
@ -3,15 +3,15 @@ package com.anytypeio.anytype.core_models
|
|||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
|
||||
fun StubDataView(
|
||||
id : Id = MockDataFactory.randomUuid(),
|
||||
id: Id = MockDataFactory.randomUuid(),
|
||||
views: List<DVViewer> = emptyList(),
|
||||
relations: List<RelationLink> = emptyList(),
|
||||
targetObjectId: Id = MockDataFactory.randomUuid()
|
||||
) : Block = Block(
|
||||
): Block = Block(
|
||||
id = id,
|
||||
content = DV(
|
||||
relations = emptyList(),
|
||||
relationsIndex= relations,
|
||||
relationsIndex = relations,
|
||||
viewers = views,
|
||||
targetObjectId = targetObjectId
|
||||
),
|
||||
|
@ -20,25 +20,33 @@ fun StubDataView(
|
|||
)
|
||||
|
||||
fun StubDataViewView(
|
||||
id : Id = MockDataFactory.randomUuid(),
|
||||
id: Id = MockDataFactory.randomUuid(),
|
||||
filters: List<DVFilter> = emptyList(),
|
||||
sorts: List<DVSort> = emptyList(),
|
||||
type: DVViewerType = DVViewerType.GRID,
|
||||
name: String = MockDataFactory.randomString(),
|
||||
viewerRelations: List<DVViewerRelation> = emptyList()
|
||||
) : DVViewer = DVViewer(
|
||||
viewerRelations: List<DVViewerRelation> = emptyList(),
|
||||
cardSize: DVViewerCardSize = DVViewerCardSize.SMALL,
|
||||
hideIcon: Boolean = false,
|
||||
coverFit: Boolean = false,
|
||||
coverRelationKey: String? = null
|
||||
): DVViewer = DVViewer(
|
||||
id = id,
|
||||
filters = filters,
|
||||
sorts = sorts,
|
||||
type = type,
|
||||
name = name,
|
||||
viewerRelations = viewerRelations
|
||||
viewerRelations = viewerRelations,
|
||||
cardSize = cardSize,
|
||||
hideIcon = hideIcon,
|
||||
coverFit = coverFit,
|
||||
coverRelationKey = coverRelationKey
|
||||
)
|
||||
|
||||
fun StubDataViewViewRelation(
|
||||
key: Key = MockDataFactory.randomUuid(),
|
||||
isVisible: Boolean = MockDataFactory.randomBoolean()
|
||||
) : DVViewerRelation = DVViewerRelation(
|
||||
): DVViewerRelation = DVViewerRelation(
|
||||
key = key,
|
||||
isVisible = isVisible
|
||||
)
|
||||
|
@ -52,23 +60,26 @@ fun StubRelationLink(
|
|||
)
|
||||
|
||||
fun StubSort(
|
||||
id: Id = MockDataFactory.randomUuid(),
|
||||
relationKey: Key = MockDataFactory.randomUuid(),
|
||||
type: DVSortType = DVSortType.ASC
|
||||
): DVSort = DVSort(
|
||||
id = id,
|
||||
relationKey = relationKey,
|
||||
type = type
|
||||
)
|
||||
|
||||
fun StubFilter(
|
||||
id: Id = MockDataFactory.randomUuid(),
|
||||
relationKey: Key = MockDataFactory.randomUuid(),
|
||||
relationFormat: RelationFormat = RelationFormat.LONG_TEXT,
|
||||
operator: DVFilterOperator = DVFilterOperator.AND,
|
||||
condition: DVFilterCondition = DVFilterCondition.EQUAL,
|
||||
quickOption: DVFilterQuickOption = DVFilterQuickOption.EXACT_DATE,
|
||||
value: Any? = null
|
||||
|
||||
): DVFilter = DVFilter(
|
||||
relationKey = relationKey,
|
||||
id = id,
|
||||
relation = relationKey,
|
||||
relationFormat = relationFormat,
|
||||
operator = operator,
|
||||
condition = condition,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue