DROID-1865 Object create | Prefilled relations, refactoring (#794)
This commit is contained in:
parent
a73e54a69a
commit
9384477659
|
@ -56,6 +56,7 @@ import com.anytypeio.anytype.domain.unsplash.DownloadUnsplashImage
|
|||
import com.anytypeio.anytype.domain.unsplash.UnsplashRepository
|
||||
import com.anytypeio.anytype.domain.workspace.SpaceManager
|
||||
import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider
|
||||
import com.anytypeio.anytype.ext.DefaultDateHelper
|
||||
import com.anytypeio.anytype.presentation.common.Action
|
||||
import com.anytypeio.anytype.presentation.common.Delegator
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
|
@ -68,6 +69,7 @@ import com.anytypeio.anytype.presentation.sets.subscription.DefaultDataViewSubsc
|
|||
import com.anytypeio.anytype.presentation.sets.viewer.ViewerDelegate
|
||||
import com.anytypeio.anytype.presentation.templates.ObjectTypeTemplatesContainer
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
import com.anytypeio.anytype.presentation.widgets.collection.DateProviderImpl
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.emptyFlow
|
||||
|
@ -169,9 +171,6 @@ abstract class TestObjectSetSetup {
|
|||
@Mock
|
||||
lateinit var getNetworkMode: GetNetworkMode
|
||||
|
||||
@Mock
|
||||
lateinit var dateProvider: DateProvider
|
||||
|
||||
private lateinit var getTemplates: GetTemplates
|
||||
private lateinit var getDefaultObjectType: GetDefaultObjectType
|
||||
|
||||
|
@ -211,6 +210,8 @@ abstract class TestObjectSetSetup {
|
|||
|
||||
private val delegator = Delegator.Default<Action>()
|
||||
|
||||
private val dateProvider = DateProviderImpl()
|
||||
|
||||
open fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
||||
|
@ -232,10 +233,8 @@ abstract class TestObjectSetSetup {
|
|||
)
|
||||
createDataViewObject = CreateDataViewObject(
|
||||
repo = repo,
|
||||
storeOfRelations = storeOfRelations,
|
||||
dispatchers = dispatchers,
|
||||
spaceManager = spaceManager,
|
||||
dateProvider = dateProvider
|
||||
spaceManager = spaceManager
|
||||
)
|
||||
setObjectDetails = UpdateDetail(repo)
|
||||
updateDataViewViewer = UpdateDataViewViewer(repo, dispatchers)
|
||||
|
@ -295,6 +294,7 @@ abstract class TestObjectSetSetup {
|
|||
storelessSubscriptionContainer = storelessSubscriptionContainer,
|
||||
dispatchers = appCoroutineDispatchers,
|
||||
getNetworkMode = getNetworkMode,
|
||||
dateProvider = dateProvider
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
|||
import com.anytypeio.anytype.domain.icon.SetDocumentImageIcon
|
||||
import com.anytypeio.anytype.domain.launch.GetDefaultObjectType
|
||||
import com.anytypeio.anytype.domain.library.StorelessSubscriptionContainer
|
||||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.networkmode.GetNetworkMode
|
||||
import com.anytypeio.anytype.domain.`object`.ConvertObjectToCollection
|
||||
|
@ -240,7 +241,8 @@ object ObjectSetModule {
|
|||
spaceManager: SpaceManager,
|
||||
storelessSubscriptionContainer: StorelessSubscriptionContainer,
|
||||
dispatchers: AppCoroutineDispatchers,
|
||||
getNetworkMode: GetNetworkMode
|
||||
getNetworkMode: GetNetworkMode,
|
||||
dateProvider: DateProvider
|
||||
): ObjectSetViewModelFactory = ObjectSetViewModelFactory(
|
||||
openObjectSet = openObjectSet,
|
||||
closeBlock = closeBlock,
|
||||
|
@ -279,7 +281,8 @@ object ObjectSetModule {
|
|||
createTemplate = createTemplate,
|
||||
storelessSubscriptionContainer = storelessSubscriptionContainer,
|
||||
dispatchers = dispatchers,
|
||||
getNetworkMode = getNetworkMode
|
||||
getNetworkMode = getNetworkMode,
|
||||
dateProvider = dateProvider
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package com.anytypeio.anytype.core_models
|
||||
|
||||
val PermittedConditions = listOf(
|
||||
Block.Content.DataView.Filter.Condition.ALL_IN,
|
||||
Block.Content.DataView.Filter.Condition.IN,
|
||||
Block.Content.DataView.Filter.Condition.EQUAL,
|
||||
Block.Content.DataView.Filter.Condition.GREATER_OR_EQUAL,
|
||||
Block.Content.DataView.Filter.Condition.LESS_OR_EQUAL
|
||||
)
|
|
@ -27,4 +27,9 @@ object DateParser {
|
|||
else
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const val SECONDS_IN_DAY = 86400
|
||||
const val DAYS_IN_MONTH = 30
|
||||
const val DAYS_IN_WEEK = 7
|
||||
const val EMPTY_STRING_VALUE = ""
|
|
@ -2,23 +2,14 @@ package com.anytypeio.anytype.domain.dataview.interactor
|
|||
|
||||
import com.anytypeio.anytype.core_models.Command
|
||||
import com.anytypeio.anytype.core_models.DVFilter
|
||||
import com.anytypeio.anytype.core_models.DVFilterCondition
|
||||
import com.anytypeio.anytype.core_models.DVFilterQuickOption
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.InternalFlags
|
||||
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.RelationLink
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
import com.anytypeio.anytype.core_models.ext.DateParser
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeKey
|
||||
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||
import com.anytypeio.anytype.domain.base.ResultInteractor
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.workspace.SpaceManager
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -27,9 +18,7 @@ import javax.inject.Inject
|
|||
*/
|
||||
class CreateDataViewObject @Inject constructor(
|
||||
private val repo: BlockRepository,
|
||||
private val storeOfRelations: StoreOfRelations,
|
||||
private val spaceManager: SpaceManager,
|
||||
private val dateProvider: DateProvider,
|
||||
dispatchers: AppCoroutineDispatchers
|
||||
) : ResultInteractor<CreateDataViewObject.Params, CreateDataViewObject.Result>(dispatchers.io) {
|
||||
|
||||
|
@ -39,10 +28,7 @@ class CreateDataViewObject @Inject constructor(
|
|||
is Params.SetByType -> {
|
||||
val command = Command.CreateObject(
|
||||
template = params.template,
|
||||
prefilled = prefillObjectDetails(
|
||||
filters = params.filters,
|
||||
dataViewRelationLinks = params.dvRelationLinks
|
||||
),
|
||||
prefilled = params.prefilled,
|
||||
internalFlags = listOf(InternalFlags.ShouldSelectTemplate),
|
||||
space = space,
|
||||
typeKey = params.type
|
||||
|
@ -55,14 +41,9 @@ class CreateDataViewObject @Inject constructor(
|
|||
)
|
||||
}
|
||||
is Params.SetByRelation -> {
|
||||
val prefilled = resolveSetByRelationPrefilledObjectData(
|
||||
viewerFilters = params.filters,
|
||||
objSetByRelation = params.objSetByRelation,
|
||||
dataViewRelationLinks = params.dvRelationLinks
|
||||
)
|
||||
val command = Command.CreateObject(
|
||||
template = params.template,
|
||||
prefilled = prefilled,
|
||||
prefilled = params.prefilled,
|
||||
internalFlags = listOf(InternalFlags.ShouldSelectTemplate),
|
||||
space = space,
|
||||
typeKey = params.type
|
||||
|
@ -77,10 +58,7 @@ class CreateDataViewObject @Inject constructor(
|
|||
is Params.Collection -> {
|
||||
val command = Command.CreateObject(
|
||||
template = params.template,
|
||||
prefilled = prefillObjectDetails(
|
||||
filters = params.filters,
|
||||
dataViewRelationLinks = params.dvRelationLinks
|
||||
),
|
||||
prefilled = params.prefilled,
|
||||
internalFlags = listOf(InternalFlags.ShouldSelectTemplate),
|
||||
space = space,
|
||||
typeKey = params.type
|
||||
|
@ -95,90 +73,26 @@ class CreateDataViewObject @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun resolveSetByRelationPrefilledObjectData(
|
||||
objSetByRelation: ObjectWrapper.Relation,
|
||||
viewerFilters: List<DVFilter>,
|
||||
dataViewRelationLinks: List<RelationLink>
|
||||
): Struct {
|
||||
val prefillWithSetOf = buildMap {
|
||||
val relationFormat = objSetByRelation.relationFormat
|
||||
val defaultValue = resolveDefaultValueByFormat(relationFormat)
|
||||
put(objSetByRelation.key, defaultValue)
|
||||
}
|
||||
return prefillWithSetOf + prefillObjectDetails(viewerFilters, dataViewRelationLinks)
|
||||
}
|
||||
|
||||
private suspend fun prefillObjectDetails(
|
||||
filters: List<DVFilter>,
|
||||
dataViewRelationLinks: List<RelationLink>
|
||||
): Struct = buildMap {
|
||||
filters.forEach { filter ->
|
||||
val relationObject = storeOfRelations.getByKey(filter.relation) ?: return@forEach
|
||||
if (!relationObject.isReadonlyValue && permittedConditions.contains(filter.condition)) {
|
||||
//Relation format should be taken from DataView relation links
|
||||
val filterRelationFormat = dataViewRelationLinks.firstOrNull { it.key == filter.relation }?.format
|
||||
when (filterRelationFormat) {
|
||||
Relation.Format.DATE -> {
|
||||
val value = DateParser.parse(filter.value)
|
||||
val updatedValue = filter.quickOption.getTimestampForQuickOption(
|
||||
value = value,
|
||||
dateProvider = dateProvider
|
||||
)
|
||||
if (updatedValue != null) {
|
||||
put(filter.relation, updatedValue.toDouble())
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
filter.value?.let { put(filter.relation, it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun resolveDefaultValueByFormat(format: RelationFormat): Any? {
|
||||
when (format) {
|
||||
Relation.Format.LONG_TEXT,
|
||||
Relation.Format.SHORT_TEXT,
|
||||
Relation.Format.URL,
|
||||
Relation.Format.EMAIL,
|
||||
Relation.Format.PHONE,
|
||||
Relation.Format.EMOJI -> {
|
||||
return EMPTY_STRING_VALUE
|
||||
}
|
||||
Relation.Format.NUMBER -> {
|
||||
return null
|
||||
}
|
||||
Relation.Format.CHECKBOX -> {
|
||||
return false
|
||||
}
|
||||
else -> {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sealed class Params {
|
||||
data class SetByType(
|
||||
val type: TypeKey,
|
||||
val filters: List<DVFilter>,
|
||||
val template: Id?,
|
||||
val dvRelationLinks: List<RelationLink>
|
||||
val prefilled: Struct
|
||||
) : Params()
|
||||
|
||||
data class SetByRelation(
|
||||
val type: TypeKey,
|
||||
val filters: List<DVFilter>,
|
||||
val template: Id?,
|
||||
val dvRelationLinks: List<RelationLink>,
|
||||
val objSetByRelation: ObjectWrapper.Relation
|
||||
val prefilled: Struct
|
||||
) : Params()
|
||||
|
||||
data class Collection(
|
||||
val type: TypeKey,
|
||||
val filters: List<DVFilter>,
|
||||
val template: Id?,
|
||||
val dvRelationLinks: List<RelationLink>
|
||||
val prefilled: Struct
|
||||
) : Params()
|
||||
}
|
||||
|
||||
|
@ -187,45 +101,5 @@ class CreateDataViewObject @Inject constructor(
|
|||
val objectType: TypeKey,
|
||||
val struct: Struct? = null
|
||||
)
|
||||
|
||||
companion object {
|
||||
const val EMPTY_STRING_VALUE = ""
|
||||
|
||||
val permittedConditions = listOf(
|
||||
DVFilterCondition.ALL_IN,
|
||||
DVFilterCondition.IN,
|
||||
DVFilterCondition.EQUAL,
|
||||
DVFilterCondition.GREATER_OR_EQUAL,
|
||||
DVFilterCondition.LESS_OR_EQUAL
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun DVFilterQuickOption.getTimestampForQuickOption(value: Long?, dateProvider: DateProvider): Long? {
|
||||
val option = this
|
||||
val time = dateProvider.getCurrentTimestampInSeconds()
|
||||
return when (option) {
|
||||
DVFilterQuickOption.DAYS_AGO -> {
|
||||
if (value == null) return null
|
||||
time - SECONDS_IN_DAY * value
|
||||
}
|
||||
DVFilterQuickOption.LAST_MONTH -> time - SECONDS_IN_DAY * DAYS_IN_MONTH
|
||||
DVFilterQuickOption.LAST_WEEK -> time - SECONDS_IN_DAY * DAYS_IN_WEEK
|
||||
DVFilterQuickOption.YESTERDAY -> time - SECONDS_IN_DAY
|
||||
DVFilterQuickOption.CURRENT_WEEK,
|
||||
DVFilterQuickOption.CURRENT_MONTH,
|
||||
DVFilterQuickOption.TODAY -> time
|
||||
DVFilterQuickOption.TOMORROW -> time + SECONDS_IN_DAY
|
||||
DVFilterQuickOption.NEXT_WEEK -> time + SECONDS_IN_DAY * DAYS_IN_WEEK
|
||||
DVFilterQuickOption.NEXT_MONTH -> time + SECONDS_IN_DAY * DAYS_IN_MONTH
|
||||
DVFilterQuickOption.DAYS_AHEAD -> {
|
||||
if (value == null) return null
|
||||
time + SECONDS_IN_DAY * value
|
||||
}
|
||||
DVFilterQuickOption.EXACT_DATE -> value
|
||||
}
|
||||
}
|
||||
|
||||
const val SECONDS_IN_DAY = 86400
|
||||
const val DAYS_IN_MONTH = 30
|
||||
const val DAYS_IN_WEEK = 7
|
|
@ -1,695 +0,0 @@
|
|||
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.DVFilterCondition
|
||||
import com.anytypeio.anytype.core_models.DVFilterQuickOption
|
||||
import com.anytypeio.anytype.core_models.InternalFlags
|
||||
import com.anytypeio.anytype.core_models.RelationFormat
|
||||
import com.anytypeio.anytype.core_models.RelationLink
|
||||
import com.anytypeio.anytype.core_models.StubRelationObject
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeKey
|
||||
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.common.DefaultCoroutineTestRule
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.workspace.SpaceManager
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mockito.Mock
|
||||
import org.mockito.kotlin.doReturn
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.stub
|
||||
import org.mockito.kotlin.times
|
||||
import org.mockito.kotlin.verifyBlocking
|
||||
|
||||
class CreateDataViewObjectUseCaseTest {
|
||||
|
||||
@get:Rule
|
||||
val rule = DefaultCoroutineTestRule()
|
||||
|
||||
@Mock
|
||||
lateinit var repo: BlockRepository
|
||||
|
||||
@Mock
|
||||
lateinit var dateProvider: DateProvider
|
||||
|
||||
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||
lateinit var spaceManager: SpaceManager
|
||||
|
||||
lateinit var dispatchers: AppCoroutineDispatchers
|
||||
lateinit var createDataViewObject: CreateDataViewObject
|
||||
|
||||
private val SECONDS_IN_DAY = 86400L
|
||||
|
||||
private val timestamp = 1703775402L
|
||||
private val spaceId = "spaceId-${MockDataFactory.randomString()}"
|
||||
private val type = "type-${MockDataFactory.randomString()}"
|
||||
private val template = "template-${MockDataFactory.randomString()}"
|
||||
private val filterDate = StubRelationObject(
|
||||
id = "dueDateId-${MockDataFactory.randomString()}",
|
||||
key = "dueDateKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.DATE,
|
||||
isReadOnlyValue = false,
|
||||
spaceId = spaceId
|
||||
)
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@Before
|
||||
fun setup() = runTest {
|
||||
repo = mock(verboseLogging = true)
|
||||
dateProvider = mock(verboseLogging = true)
|
||||
dispatchers = AppCoroutineDispatchers(
|
||||
io = rule.dispatcher,
|
||||
computation = rule.dispatcher,
|
||||
main = rule.dispatcher
|
||||
)
|
||||
spaceManager = SpaceManager.Impl(
|
||||
repo = repo,
|
||||
dispatchers = dispatchers,
|
||||
configStorage = ConfigStorage.CacheStorage(),
|
||||
logger = mock()
|
||||
)
|
||||
createDataViewObject = CreateDataViewObject(
|
||||
repo = repo,
|
||||
storeOfRelations = storeOfRelations,
|
||||
spaceManager = spaceManager,
|
||||
dispatchers = dispatchers,
|
||||
dateProvider = dateProvider
|
||||
)
|
||||
storeOfRelations.merge(listOf(filterDate))
|
||||
spaceManager.set(spaceId)
|
||||
dateProvider.stub {
|
||||
on { getCurrentTimestampInSeconds() } doReturn timestamp
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@Test
|
||||
fun `should create object with prefilled details from filters in set by relation`() = runTest {
|
||||
|
||||
val spaceId = "spaceId-${MockDataFactory.randomString()}"
|
||||
val type = "type-${MockDataFactory.randomString()}"
|
||||
val template = "template-${MockDataFactory.randomString()}"
|
||||
val prefilledRelation = StubRelationObject(
|
||||
id = "prefilledRelationId-${MockDataFactory.randomString()}",
|
||||
key = "prefilledRelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.OBJECT
|
||||
)
|
||||
val filter1Relation = StubRelationObject(
|
||||
id = "filter1RelationId-${MockDataFactory.randomString()}",
|
||||
key = "filter1RelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.SHORT_TEXT,
|
||||
isReadOnlyValue = false,
|
||||
spaceId = spaceId
|
||||
)
|
||||
val filter2Relation = StubRelationObject(
|
||||
id = "filter2RelationId-${MockDataFactory.randomString()}",
|
||||
key = "filter2RelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.CHECKBOX,
|
||||
isReadOnlyValue = false,
|
||||
spaceId = spaceId
|
||||
)
|
||||
val filter3Relation = StubRelationObject(
|
||||
id = "filter3RelationId-${MockDataFactory.randomString()}",
|
||||
key = "filter3RelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.SHORT_TEXT,
|
||||
isReadOnlyValue = true,
|
||||
spaceId = spaceId
|
||||
)
|
||||
val filter4Relation = StubRelationObject(
|
||||
id = "filter4RelationId-${MockDataFactory.randomString()}",
|
||||
key = "filter4RelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.SHORT_TEXT,
|
||||
isReadOnlyValue = false,
|
||||
spaceId = spaceId
|
||||
)
|
||||
|
||||
val dvRelationLinks = listOf(
|
||||
RelationLink(filter1Relation.key, RelationFormat.SHORT_TEXT),
|
||||
RelationLink(filter2Relation.key, RelationFormat.CHECKBOX),
|
||||
RelationLink(filter3Relation.key, RelationFormat.SHORT_TEXT),
|
||||
RelationLink(filter4Relation.key, RelationFormat.SHORT_TEXT)
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
listOf(
|
||||
prefilledRelation,
|
||||
filter1Relation,
|
||||
filter2Relation,
|
||||
filter3Relation,
|
||||
filter4Relation
|
||||
)
|
||||
)
|
||||
spaceManager.set(spaceId)
|
||||
|
||||
val notPermittedConditions =
|
||||
DVFilterCondition.values().filterNot { it in CreateDataViewObject.permittedConditions }
|
||||
|
||||
val filters = listOf(
|
||||
DVFilter(
|
||||
relation = filter1Relation.key,
|
||||
relationFormat = RelationFormat.SHORT_TEXT,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.EQUAL,
|
||||
value = "321"
|
||||
),
|
||||
DVFilter(
|
||||
relation = filter2Relation.key,
|
||||
relationFormat = RelationFormat.CHECKBOX,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relation = filter3Relation.key,
|
||||
relationFormat = RelationFormat.SHORT_TEXT,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.EQUAL,
|
||||
value = "456"
|
||||
),
|
||||
DVFilter(
|
||||
relation = filter4Relation.key,
|
||||
relationFormat = RelationFormat.SHORT_TEXT,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = notPermittedConditions.random(),
|
||||
value = "456"
|
||||
)
|
||||
)
|
||||
|
||||
val params = CreateDataViewObject.Params.SetByRelation(
|
||||
template = template,
|
||||
type = TypeKey(type),
|
||||
objSetByRelation = prefilledRelation,
|
||||
filters = filters,
|
||||
dvRelationLinks = dvRelationLinks
|
||||
)
|
||||
|
||||
createDataViewObject.async(params)
|
||||
|
||||
val expected = Command.CreateObject(
|
||||
template = template,
|
||||
prefilled = mapOf(
|
||||
prefilledRelation.key to null,
|
||||
filter1Relation.key to "321",
|
||||
filter2Relation.key to true
|
||||
),
|
||||
internalFlags = listOf(InternalFlags.ShouldSelectTemplate),
|
||||
space = SpaceId(spaceId),
|
||||
typeKey = TypeKey(type)
|
||||
)
|
||||
|
||||
verifyBlocking(repo, times(1)) {
|
||||
createObject(command = expected)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@Test
|
||||
fun `should update value prefilled setof relation by filter value`() = runTest {
|
||||
|
||||
val spaceId = "spaceId-${MockDataFactory.randomString()}"
|
||||
val type = "type-${MockDataFactory.randomString()}"
|
||||
val template = "template-${MockDataFactory.randomString()}"
|
||||
val prefilledRelation = StubRelationObject(
|
||||
id = "prefilledRelationId-${MockDataFactory.randomString()}",
|
||||
key = "prefilledRelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.SHORT_TEXT
|
||||
)
|
||||
|
||||
val dvRelationLinks = listOf(
|
||||
RelationLink(prefilledRelation.key, RelationFormat.SHORT_TEXT),
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
listOf(
|
||||
prefilledRelation
|
||||
)
|
||||
)
|
||||
spaceManager.set(spaceId)
|
||||
|
||||
val filters = listOf(
|
||||
DVFilter(
|
||||
relation = prefilledRelation.key,
|
||||
relationFormat = prefilledRelation.relationFormat,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.EQUAL,
|
||||
value = "456"
|
||||
)
|
||||
)
|
||||
|
||||
val params = CreateDataViewObject.Params.SetByRelation(
|
||||
template = template,
|
||||
type = TypeKey(type),
|
||||
filters = filters,
|
||||
dvRelationLinks = dvRelationLinks,
|
||||
objSetByRelation = prefilledRelation
|
||||
)
|
||||
|
||||
createDataViewObject.async(params)
|
||||
|
||||
val expected = Command.CreateObject(
|
||||
template = template,
|
||||
prefilled = mapOf(
|
||||
prefilledRelation.key to "456"
|
||||
),
|
||||
internalFlags = listOf(InternalFlags.ShouldSelectTemplate),
|
||||
space = SpaceId(spaceId),
|
||||
typeKey = TypeKey(type)
|
||||
)
|
||||
|
||||
verifyBlocking(repo, times(1)) {
|
||||
createObject(command = expected)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@Test
|
||||
fun `should create object with prefilled details from filters in set by type`() = runTest {
|
||||
|
||||
val spaceId = "spaceId-${MockDataFactory.randomString()}"
|
||||
val type = "type-${MockDataFactory.randomString()}"
|
||||
val template = "template-${MockDataFactory.randomString()}"
|
||||
val filter1Relation = StubRelationObject(
|
||||
id = "filter1RelationId-${MockDataFactory.randomString()}",
|
||||
key = "filter1RelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.SHORT_TEXT,
|
||||
isReadOnlyValue = false,
|
||||
spaceId = spaceId
|
||||
)
|
||||
val filter2Relation = StubRelationObject(
|
||||
id = "filter2RelationId-${MockDataFactory.randomString()}",
|
||||
key = "filter2RelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.CHECKBOX,
|
||||
isReadOnlyValue = false,
|
||||
spaceId = spaceId
|
||||
)
|
||||
val filter3Relation = StubRelationObject(
|
||||
id = "filter3RelationId-${MockDataFactory.randomString()}",
|
||||
key = "filter3RelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.SHORT_TEXT,
|
||||
isReadOnlyValue = true,
|
||||
spaceId = spaceId
|
||||
)
|
||||
val filter4Relation = StubRelationObject(
|
||||
id = "filter4RelationId-${MockDataFactory.randomString()}",
|
||||
key = "filter4RelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.SHORT_TEXT,
|
||||
isReadOnlyValue = false,
|
||||
spaceId = spaceId
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
listOf(
|
||||
filter1Relation,
|
||||
filter2Relation,
|
||||
filter3Relation,
|
||||
filter4Relation
|
||||
)
|
||||
)
|
||||
spaceManager.set(spaceId)
|
||||
|
||||
val notPermittedConditions =
|
||||
DVFilterCondition.values().filterNot { it in CreateDataViewObject.permittedConditions }
|
||||
|
||||
val filters = listOf(
|
||||
DVFilter(
|
||||
relation = filter1Relation.key,
|
||||
relationFormat = RelationFormat.SHORT_TEXT,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.EQUAL,
|
||||
value = "321"
|
||||
),
|
||||
DVFilter(
|
||||
relation = filter2Relation.key,
|
||||
relationFormat = RelationFormat.CHECKBOX,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relation = filter3Relation.key,
|
||||
relationFormat = RelationFormat.SHORT_TEXT,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.EQUAL,
|
||||
value = "456"
|
||||
),
|
||||
DVFilter(
|
||||
relation = filter4Relation.key,
|
||||
relationFormat = RelationFormat.SHORT_TEXT,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = notPermittedConditions.random(),
|
||||
value = "456"
|
||||
)
|
||||
)
|
||||
|
||||
val dvRelationLinks = listOf(
|
||||
RelationLink(filter1Relation.key, RelationFormat.SHORT_TEXT),
|
||||
RelationLink(filter2Relation.key, RelationFormat.CHECKBOX),
|
||||
RelationLink(filter3Relation.key, RelationFormat.SHORT_TEXT),
|
||||
RelationLink(filter4Relation.key, RelationFormat.SHORT_TEXT)
|
||||
)
|
||||
|
||||
val params = CreateDataViewObject.Params.SetByType(
|
||||
template = template,
|
||||
type = TypeKey(type),
|
||||
filters = filters,
|
||||
dvRelationLinks = dvRelationLinks
|
||||
)
|
||||
|
||||
createDataViewObject.async(params)
|
||||
|
||||
val expected = Command.CreateObject(
|
||||
template = template,
|
||||
prefilled = mapOf(
|
||||
filter1Relation.key to "321",
|
||||
filter2Relation.key to true
|
||||
),
|
||||
internalFlags = listOf(InternalFlags.ShouldSelectTemplate),
|
||||
space = SpaceId(spaceId),
|
||||
typeKey = TypeKey(type)
|
||||
)
|
||||
|
||||
verifyBlocking(repo, times(1)) {
|
||||
createObject(command = expected)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@Test
|
||||
fun `should create object with prefilled details from filters in collection`() = runTest {
|
||||
|
||||
val spaceId = "spaceId-${MockDataFactory.randomString()}"
|
||||
val type = "type-${MockDataFactory.randomString()}"
|
||||
val template = "template-${MockDataFactory.randomString()}"
|
||||
val filter1Relation = StubRelationObject(
|
||||
id = "filter1RelationId-${MockDataFactory.randomString()}",
|
||||
key = "filter1RelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.SHORT_TEXT,
|
||||
isReadOnlyValue = false,
|
||||
spaceId = spaceId
|
||||
)
|
||||
val filter2Relation = StubRelationObject(
|
||||
id = "filter2RelationId-${MockDataFactory.randomString()}",
|
||||
key = "filter2RelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.CHECKBOX,
|
||||
isReadOnlyValue = false,
|
||||
spaceId = spaceId
|
||||
)
|
||||
val filter3Relation = StubRelationObject(
|
||||
id = "filter3RelationId-${MockDataFactory.randomString()}",
|
||||
key = "filter3RelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.SHORT_TEXT,
|
||||
isReadOnlyValue = true,
|
||||
spaceId = spaceId
|
||||
)
|
||||
val filter4Relation = StubRelationObject(
|
||||
id = "filter4RelationId-${MockDataFactory.randomString()}",
|
||||
key = "filter4RelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.SHORT_TEXT,
|
||||
isReadOnlyValue = false,
|
||||
spaceId = spaceId
|
||||
)
|
||||
|
||||
val dvRelationLinks = listOf(
|
||||
RelationLink(filter1Relation.id, RelationFormat.SHORT_TEXT),
|
||||
RelationLink(filter2Relation.id, RelationFormat.CHECKBOX),
|
||||
RelationLink(filter3Relation.id, RelationFormat.SHORT_TEXT),
|
||||
RelationLink(filter4Relation.id, RelationFormat.SHORT_TEXT)
|
||||
)
|
||||
|
||||
storeOfRelations.merge(
|
||||
listOf(
|
||||
filter1Relation,
|
||||
filter2Relation,
|
||||
filter3Relation,
|
||||
filter4Relation
|
||||
)
|
||||
)
|
||||
spaceManager.set(spaceId)
|
||||
|
||||
val notPermittedConditions =
|
||||
DVFilterCondition.values().filterNot { it in CreateDataViewObject.permittedConditions }
|
||||
|
||||
val filters = listOf(
|
||||
DVFilter(
|
||||
relation = filter1Relation.key,
|
||||
relationFormat = RelationFormat.SHORT_TEXT,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.EQUAL,
|
||||
value = "321"
|
||||
),
|
||||
DVFilter(
|
||||
relation = filter2Relation.key,
|
||||
relationFormat = RelationFormat.CHECKBOX,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.EQUAL,
|
||||
value = true
|
||||
),
|
||||
DVFilter(
|
||||
relation = filter3Relation.key,
|
||||
relationFormat = RelationFormat.SHORT_TEXT,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.EQUAL,
|
||||
value = "456"
|
||||
),
|
||||
DVFilter(
|
||||
relation = filter4Relation.key,
|
||||
relationFormat = RelationFormat.SHORT_TEXT,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = notPermittedConditions.random(),
|
||||
value = "456"
|
||||
)
|
||||
)
|
||||
|
||||
val params = CreateDataViewObject.Params.Collection(
|
||||
template = template,
|
||||
type = TypeKey(type),
|
||||
filters = filters,
|
||||
dvRelationLinks = dvRelationLinks
|
||||
)
|
||||
|
||||
createDataViewObject.async(params)
|
||||
|
||||
val expected = Command.CreateObject(
|
||||
template = template,
|
||||
prefilled = mapOf(
|
||||
filter1Relation.key to "321",
|
||||
filter2Relation.key to true
|
||||
),
|
||||
internalFlags = listOf(InternalFlags.ShouldSelectTemplate),
|
||||
space = SpaceId(spaceId),
|
||||
typeKey = TypeKey(type)
|
||||
)
|
||||
|
||||
verifyBlocking(repo, times(1)) {
|
||||
createObject(command = expected)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
private fun createObjectWithQuickOption(
|
||||
quickOption: DVFilterQuickOption,
|
||||
filterValue: Long? = null,
|
||||
expectedValue: Long?
|
||||
) = runTest {
|
||||
val filters = listOf(
|
||||
DVFilter(
|
||||
relation = filterDate.key,
|
||||
relationFormat = RelationFormat.DATE,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.EQUAL,
|
||||
quickOption = quickOption,
|
||||
value = filterValue
|
||||
)
|
||||
)
|
||||
|
||||
val dvRelationLinks = listOf(
|
||||
RelationLink(filterDate.key, RelationFormat.DATE)
|
||||
)
|
||||
|
||||
val params = CreateDataViewObject.Params.SetByType(
|
||||
template = template,
|
||||
type = TypeKey(type),
|
||||
filters = filters,
|
||||
dvRelationLinks = dvRelationLinks
|
||||
)
|
||||
|
||||
createDataViewObject.async(params)
|
||||
|
||||
val expected = Command.CreateObject(
|
||||
template = template,
|
||||
prefilled = mapOf(
|
||||
filterDate.key to (expectedValue?.toDouble() ?: timestamp.toDouble()),
|
||||
),
|
||||
internalFlags = listOf(InternalFlags.ShouldSelectTemplate),
|
||||
space = SpaceId(spaceId),
|
||||
typeKey = TypeKey(type)
|
||||
)
|
||||
|
||||
verifyBlocking(repo, times(1)) {
|
||||
createObject(command = expected)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should create object with proper today timestamp on quick option Today`() {
|
||||
createObjectWithQuickOption(
|
||||
quickOption = DVFilterQuickOption.TODAY,
|
||||
expectedValue = timestamp
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should create object with proper today timestamp on quick option Days Ago`() {
|
||||
createObjectWithQuickOption(
|
||||
quickOption = DVFilterQuickOption.DAYS_AGO,
|
||||
filterValue = 99L,
|
||||
expectedValue = timestamp - SECONDS_IN_DAY * 99
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should create object with proper today timestamp on quick option Last Month`() {
|
||||
createObjectWithQuickOption(
|
||||
quickOption = DVFilterQuickOption.LAST_MONTH,
|
||||
expectedValue = timestamp - SECONDS_IN_DAY * DAYS_IN_MONTH
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should create object with proper today timestamp on quick option Last Week`() {
|
||||
createObjectWithQuickOption(
|
||||
quickOption = DVFilterQuickOption.LAST_WEEK,
|
||||
expectedValue = timestamp - SECONDS_IN_DAY * DAYS_IN_WEEK
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should create object with proper today timestamp on quick option Yesterday`() {
|
||||
createObjectWithQuickOption(
|
||||
quickOption = DVFilterQuickOption.YESTERDAY,
|
||||
expectedValue = timestamp - SECONDS_IN_DAY
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should create object with proper today timestamp on quick option Current Week`() {
|
||||
createObjectWithQuickOption(
|
||||
quickOption = DVFilterQuickOption.CURRENT_WEEK,
|
||||
expectedValue = timestamp
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should create object with proper today timestamp on quick option Current Month`() {
|
||||
createObjectWithQuickOption(
|
||||
quickOption = DVFilterQuickOption.CURRENT_MONTH,
|
||||
expectedValue = timestamp
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should create object with proper today timestamp on quick option Next Week`() {
|
||||
createObjectWithQuickOption(
|
||||
quickOption = DVFilterQuickOption.NEXT_WEEK,
|
||||
expectedValue = timestamp + SECONDS_IN_DAY * DAYS_IN_WEEK
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should create object with proper today timestamp on quick option Next Month`() {
|
||||
createObjectWithQuickOption(
|
||||
quickOption = DVFilterQuickOption.NEXT_MONTH,
|
||||
expectedValue = timestamp + SECONDS_IN_DAY * DAYS_IN_MONTH
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should create object with proper today timestamp on quick option Tomorrow`() {
|
||||
createObjectWithQuickOption(
|
||||
quickOption = DVFilterQuickOption.TOMORROW,
|
||||
expectedValue = timestamp + SECONDS_IN_DAY
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should create object with proper today timestamp on quick option Days Ahead`() {
|
||||
createObjectWithQuickOption(
|
||||
quickOption = DVFilterQuickOption.DAYS_AHEAD,
|
||||
filterValue = 99L,
|
||||
expectedValue = timestamp + SECONDS_IN_DAY * 99
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should create object with proper today timestamp on quick option Exact Day`() {
|
||||
createObjectWithQuickOption(
|
||||
quickOption = DVFilterQuickOption.EXACT_DATE,
|
||||
filterValue = timestamp,
|
||||
expectedValue = timestamp
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@Test
|
||||
fun `should take relation format from relation link`() = runTest {
|
||||
|
||||
val spaceId = "spaceId-${MockDataFactory.randomString()}"
|
||||
val type = "type-${MockDataFactory.randomString()}"
|
||||
val template = "template-${MockDataFactory.randomString()}"
|
||||
val filter1Relation = StubRelationObject(
|
||||
id = "filter1RelationId-${MockDataFactory.randomString()}",
|
||||
key = "filter1RelationKey-${MockDataFactory.randomString()}",
|
||||
format = RelationFormat.DATE,
|
||||
isReadOnlyValue = false,
|
||||
spaceId = spaceId
|
||||
)
|
||||
|
||||
storeOfRelations.merge(listOf(filter1Relation))
|
||||
spaceManager.set(spaceId)
|
||||
|
||||
val filters = listOf(
|
||||
DVFilter(
|
||||
relation = filter1Relation.key,
|
||||
operator = Block.Content.DataView.Filter.Operator.AND,
|
||||
condition = Block.Content.DataView.Filter.Condition.EQUAL,
|
||||
value = true
|
||||
)
|
||||
)
|
||||
|
||||
val dvRelationLinks = listOf(
|
||||
RelationLink(filter1Relation.key, RelationFormat.CHECKBOX),
|
||||
)
|
||||
|
||||
val params = CreateDataViewObject.Params.SetByType(
|
||||
template = template,
|
||||
type = TypeKey(type),
|
||||
filters = filters,
|
||||
dvRelationLinks = dvRelationLinks
|
||||
)
|
||||
|
||||
createDataViewObject.async(params)
|
||||
|
||||
val expected = Command.CreateObject(
|
||||
template = template,
|
||||
prefilled = mapOf(filter1Relation.key to true),
|
||||
internalFlags = listOf(InternalFlags.ShouldSelectTemplate),
|
||||
space = SpaceId(spaceId),
|
||||
typeKey = TypeKey(type)
|
||||
)
|
||||
|
||||
verifyBlocking(repo, times(1)) {
|
||||
createObject(command = expected)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.anytypeio.anytype.core_models.Block
|
|||
import com.anytypeio.anytype.core_models.CoverType
|
||||
import com.anytypeio.anytype.core_models.DVFilter
|
||||
import com.anytypeio.anytype.core_models.DVFilterCondition
|
||||
import com.anytypeio.anytype.core_models.DVFilterQuickOption
|
||||
import com.anytypeio.anytype.core_models.DVRecord
|
||||
import com.anytypeio.anytype.core_models.DVSort
|
||||
import com.anytypeio.anytype.core_models.DVViewer
|
||||
|
@ -15,9 +16,12 @@ import com.anytypeio.anytype.core_models.Event.Command.DataView.UpdateView.DVVie
|
|||
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.RelationLink
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
import com.anytypeio.anytype.core_models.ext.DateParser
|
||||
import com.anytypeio.anytype.core_models.ext.mapToObjectWrapperType
|
||||
import com.anytypeio.anytype.core_models.ext.title
|
||||
import com.anytypeio.anytype.core_models.primitives.TypeId
|
||||
|
@ -26,6 +30,7 @@ import com.anytypeio.anytype.core_utils.ext.addAfterIndexInLine
|
|||
import com.anytypeio.anytype.core_utils.ext.mapInPlace
|
||||
import com.anytypeio.anytype.core_utils.ext.moveAfterIndexInLine
|
||||
import com.anytypeio.anytype.core_utils.ext.moveOnTop
|
||||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
|
@ -41,6 +46,11 @@ import com.anytypeio.anytype.presentation.relations.isSystemKey
|
|||
import com.anytypeio.anytype.presentation.relations.linksFeaturedRelation
|
||||
import com.anytypeio.anytype.presentation.relations.title
|
||||
import com.anytypeio.anytype.presentation.relations.view
|
||||
import com.anytypeio.anytype.core_models.PermittedConditions
|
||||
import com.anytypeio.anytype.core_models.ext.DAYS_IN_MONTH
|
||||
import com.anytypeio.anytype.core_models.ext.DAYS_IN_WEEK
|
||||
import com.anytypeio.anytype.core_models.ext.EMPTY_STRING_VALUE
|
||||
import com.anytypeio.anytype.core_models.ext.SECONDS_IN_DAY
|
||||
import com.anytypeio.anytype.presentation.sets.model.ObjectView
|
||||
import com.anytypeio.anytype.presentation.sets.model.SimpleRelationView
|
||||
import com.anytypeio.anytype.presentation.sets.model.Viewer
|
||||
|
@ -602,3 +612,89 @@ fun ObjectState.DataView.isChangingDefaultTypeAvailable(): Boolean {
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun DVViewer.prefillNewObjectDetails(
|
||||
storeOfRelations: StoreOfRelations,
|
||||
dateProvider: DateProvider,
|
||||
dataViewRelationLinks: List<RelationLink>
|
||||
): Struct =
|
||||
buildMap {
|
||||
filters.forEach { filter ->
|
||||
val relationObject = storeOfRelations.getByKey(filter.relation) ?: return@forEach
|
||||
if (!relationObject.isReadonlyValue && PermittedConditions.contains(
|
||||
filter.condition
|
||||
)
|
||||
) {
|
||||
//Relation format should be taken from DataView relation links
|
||||
val filterRelationFormat =
|
||||
dataViewRelationLinks.firstOrNull { it.key == filter.relation }?.format
|
||||
when (filterRelationFormat) {
|
||||
Relation.Format.DATE -> {
|
||||
val value = DateParser.parse(filter.value)
|
||||
val updatedValue = filter.quickOption.getTimestampForQuickOption(
|
||||
value = value,
|
||||
dateProvider = dateProvider
|
||||
)
|
||||
if (updatedValue != null) {
|
||||
put(filter.relation, updatedValue.toDouble())
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
filter.value?.let { put(filter.relation, it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun DVViewer.resolveSetByRelationPrefilledObjectData(
|
||||
storeOfRelations: StoreOfRelations,
|
||||
dateProvider: DateProvider,
|
||||
objSetByRelation: ObjectWrapper.Relation,
|
||||
dataViewRelationLinks: List<RelationLink>
|
||||
): Struct {
|
||||
val prefillWithSetOf = buildMap {
|
||||
val relationFormat = objSetByRelation.relationFormat
|
||||
val defaultValue = resolveDefaultValueByFormat(relationFormat)
|
||||
put(objSetByRelation.key, defaultValue)
|
||||
}
|
||||
val prefillNewObjectDetails = prefillNewObjectDetails(storeOfRelations, dateProvider, dataViewRelationLinks)
|
||||
return prefillWithSetOf + prefillNewObjectDetails
|
||||
}
|
||||
|
||||
private fun resolveDefaultValueByFormat(format: RelationFormat): Any? = when (format) {
|
||||
Relation.Format.LONG_TEXT,
|
||||
Relation.Format.SHORT_TEXT,
|
||||
Relation.Format.URL,
|
||||
Relation.Format.EMAIL,
|
||||
Relation.Format.PHONE,
|
||||
Relation.Format.EMOJI -> EMPTY_STRING_VALUE
|
||||
Relation.Format.CHECKBOX -> false
|
||||
Relation.Format.NUMBER -> null
|
||||
else -> null
|
||||
}
|
||||
|
||||
fun DVFilterQuickOption.getTimestampForQuickOption(value: Long?, dateProvider: DateProvider): Long? {
|
||||
val option = this
|
||||
val time = dateProvider.getCurrentTimestampInSeconds()
|
||||
return when (option) {
|
||||
DVFilterQuickOption.DAYS_AGO -> {
|
||||
if (value == null) return null
|
||||
time - SECONDS_IN_DAY * value
|
||||
}
|
||||
DVFilterQuickOption.LAST_MONTH -> time - SECONDS_IN_DAY * DAYS_IN_MONTH
|
||||
DVFilterQuickOption.LAST_WEEK -> time - SECONDS_IN_DAY * DAYS_IN_WEEK
|
||||
DVFilterQuickOption.YESTERDAY -> time - SECONDS_IN_DAY
|
||||
DVFilterQuickOption.CURRENT_WEEK,
|
||||
DVFilterQuickOption.CURRENT_MONTH,
|
||||
DVFilterQuickOption.TODAY -> time
|
||||
DVFilterQuickOption.TOMORROW -> time + SECONDS_IN_DAY
|
||||
DVFilterQuickOption.NEXT_WEEK -> time + SECONDS_IN_DAY * DAYS_IN_WEEK
|
||||
DVFilterQuickOption.NEXT_MONTH -> time + SECONDS_IN_DAY * DAYS_IN_MONTH
|
||||
DVFilterQuickOption.DAYS_AHEAD -> {
|
||||
if (value == null) return null
|
||||
time + SECONDS_IN_DAY * value
|
||||
}
|
||||
DVFilterQuickOption.EXACT_DATE -> value
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import com.anytypeio.anytype.domain.error.Error
|
|||
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
||||
import com.anytypeio.anytype.domain.library.StoreSearchByIdsParams
|
||||
import com.anytypeio.anytype.domain.library.StorelessSubscriptionContainer
|
||||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.networkmode.GetNetworkMode
|
||||
import com.anytypeio.anytype.domain.`object`.ConvertObjectToCollection
|
||||
|
@ -168,7 +169,8 @@ class ObjectSetViewModel(
|
|||
private val createTemplate: CreateTemplate,
|
||||
private val storelessSubscriptionContainer: StorelessSubscriptionContainer,
|
||||
private val dispatchers: AppCoroutineDispatchers,
|
||||
private val getNetworkMode: GetNetworkMode
|
||||
private val getNetworkMode: GetNetworkMode,
|
||||
private val dateProvider: DateProvider
|
||||
) : ViewModel(), SupportNavigation<EventWrapper<AppNavigation.Command>>, ViewerDelegate by viewerDelegate {
|
||||
|
||||
val icon = MutableStateFlow<ProfileIconView>(ProfileIconView.Loading)
|
||||
|
@ -1048,25 +1050,35 @@ class ObjectSetViewModel(
|
|||
} else {
|
||||
val validTemplateId = templateChosenBy ?: defaultTemplate
|
||||
val dvRelationLinks = currentState.dataViewContent.relationLinks
|
||||
val prefilled = viewer.prefillNewObjectDetails(
|
||||
storeOfRelations = storeOfRelations,
|
||||
dateProvider = dateProvider,
|
||||
dataViewRelationLinks = dvRelationLinks
|
||||
)
|
||||
proceedWithCreatingDataViewObject(
|
||||
CreateDataViewObject.Params.SetByType(
|
||||
type = TypeKey(uniqueKey),
|
||||
filters = viewer.filters,
|
||||
template = validTemplateId,
|
||||
dvRelationLinks = dvRelationLinks
|
||||
prefilled = prefilled
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
ObjectType.Layout.RELATION -> {
|
||||
val validTemplateId = templateChosenBy ?: defaultTemplate
|
||||
val prefilled = viewer.resolveSetByRelationPrefilledObjectData(
|
||||
storeOfRelations = storeOfRelations,
|
||||
dateProvider = dateProvider,
|
||||
dataViewRelationLinks = currentState.dataViewContent.relationLinks,
|
||||
objSetByRelation = ObjectWrapper.Relation(sourceDetails.map)
|
||||
)
|
||||
proceedWithCreatingDataViewObject(
|
||||
CreateDataViewObject.Params.SetByRelation(
|
||||
filters = viewer.filters,
|
||||
template = validTemplateId,
|
||||
type = TypeKey(objectTypeUniqueKey),
|
||||
objSetByRelation = ObjectWrapper.Relation(sourceDetails.map),
|
||||
dvRelationLinks = currentState.dataViewContent.relationLinks
|
||||
prefilled = prefilled
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -1106,11 +1118,16 @@ class ObjectSetViewModel(
|
|||
}
|
||||
|
||||
val validTemplateId = templateChosenBy ?: defaultTemplate
|
||||
val prefilled = viewer.prefillNewObjectDetails(
|
||||
storeOfRelations = storeOfRelations,
|
||||
dateProvider = dateProvider,
|
||||
dataViewRelationLinks = state.dataViewContent.relationLinks
|
||||
)
|
||||
val createObjectParams = CreateDataViewObject.Params.Collection(
|
||||
template = validTemplateId,
|
||||
type = typeChosenByUser ?: defaultObjectTypeUniqueKey!!,
|
||||
filters = viewer.filters,
|
||||
dvRelationLinks = state.dataViewContent.relationLinks
|
||||
prefilled = prefilled
|
||||
)
|
||||
proceedWithCreatingDataViewObject(createObjectParams) { result ->
|
||||
val params = AddObjectToCollection.Params(
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.anytypeio.anytype.domain.cover.SetDocCoverImage
|
|||
import com.anytypeio.anytype.domain.dataview.interactor.CreateDataViewObject
|
||||
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
||||
import com.anytypeio.anytype.domain.library.StorelessSubscriptionContainer
|
||||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.networkmode.GetNetworkMode
|
||||
import com.anytypeio.anytype.domain.`object`.ConvertObjectToCollection
|
||||
|
@ -78,7 +79,8 @@ class ObjectSetViewModelFactory(
|
|||
private val spaceManager: SpaceManager,
|
||||
private val storelessSubscriptionContainer: StorelessSubscriptionContainer,
|
||||
private val dispatchers: AppCoroutineDispatchers,
|
||||
private val getNetworkMode: GetNetworkMode
|
||||
private val getNetworkMode: GetNetworkMode,
|
||||
private val dateProvider: DateProvider
|
||||
) : ViewModelProvider.Factory {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
|
@ -120,7 +122,8 @@ class ObjectSetViewModelFactory(
|
|||
createTemplate = createTemplate,
|
||||
dispatchers = dispatchers,
|
||||
storelessSubscriptionContainer = storelessSubscriptionContainer,
|
||||
getNetworkMode = getNetworkMode
|
||||
getNetworkMode = getNetworkMode,
|
||||
dateProvider = dateProvider
|
||||
) as T
|
||||
}
|
||||
}
|
|
@ -85,9 +85,7 @@ class CollectionCreateAndAddObjectTest: ObjectSetViewModelTestSetup() {
|
|||
createDataViewObject = CreateDataViewObject(
|
||||
repo = repo,
|
||||
spaceManager = spaceManager,
|
||||
dispatchers = dispatchers,
|
||||
storeOfRelations = storeOfRelations,
|
||||
dateProvider = dateProvider
|
||||
dispatchers = dispatchers
|
||||
),
|
||||
dispatcher = dispatcher,
|
||||
delegator = delegator,
|
||||
|
@ -120,7 +118,8 @@ class CollectionCreateAndAddObjectTest: ObjectSetViewModelTestSetup() {
|
|||
getObjectTypes = getObjectTypes,
|
||||
storelessSubscriptionContainer = storelessSubscriptionContainer,
|
||||
dispatchers = dispatchers,
|
||||
getNetworkMode = getNetworkMode
|
||||
getNetworkMode = getNetworkMode,
|
||||
dateProvider = dateProvider
|
||||
)
|
||||
stubNetworkMode()
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
type = TypeKey(setOfKey),
|
||||
filters = mockObjectSet.filters,
|
||||
template = null,
|
||||
dvRelationLinks = mockObjectSet.relationLinks
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
)
|
||||
doReturn(Resultat.success(Unit)).`when`(closeBlock).async(mockObjectSet.root)
|
||||
|
@ -111,7 +111,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
type = TypeKey(setOfKey),
|
||||
filters = mockObjectSet.filters,
|
||||
template = null,
|
||||
dvRelationLinks = mockObjectSet.relationLinks
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
type = TypeKey(setOfKey),
|
||||
filters = mockObjectSet.filters,
|
||||
template = null,
|
||||
dvRelationLinks = emptyList()
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
)
|
||||
doReturn(Resultat.success(Unit)).`when`(closeBlock).async(mockObjectSet.root)
|
||||
|
@ -180,7 +180,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
type = TypeKey(setOfKey),
|
||||
filters = mockObjectSet.filters,
|
||||
template = null,
|
||||
dvRelationLinks = mockObjectSet.relationLinks
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -245,8 +245,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = mockObjectSet.filters,
|
||||
template = null,
|
||||
type = TypeKey(pageTypeId),
|
||||
objSetByRelation = relationSetBy,
|
||||
dvRelationLinks = mockObjectSet.relationLinks
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
)
|
||||
doReturn(Resultat.success(Unit)).`when`(closeBlock).async(mockObjectSet.root)
|
||||
|
@ -266,8 +265,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = mockObjectSet.filters,
|
||||
template = null,
|
||||
type = TypeKey(pageTypeId),
|
||||
objSetByRelation = relationSetBy,
|
||||
dvRelationLinks = mockObjectSet.relationLinks
|
||||
prefilled = mapOf(relationKey to null)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -328,7 +326,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
template = null,
|
||||
type = TypeKey(pageTypeId),
|
||||
filters = emptyList(),
|
||||
dvRelationLinks = objectCollection.relationLinks
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
)
|
||||
doReturn(Resultat.success(Unit)).`when`(closeBlock).async(objectCollection.root)
|
||||
|
@ -348,7 +346,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
type = TypeKey(pageTypeId),
|
||||
template = null,
|
||||
filters = emptyList(),
|
||||
dvRelationLinks = objectCollection.relationLinks
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class ObjectSetDataViewObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
type = TypeKey(setOfKey),
|
||||
filters = mockObjectSet.filters,
|
||||
template = null,
|
||||
dvRelationLinks = listOf()
|
||||
prefilled = mapOf(),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -100,7 +100,7 @@ class ObjectSetDataViewObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
type = TypeKey(setOfKey),
|
||||
filters = mockObjectSet.filters,
|
||||
template = null,
|
||||
dvRelationLinks = mockObjectSet.relationLinks
|
||||
prefilled = mapOf(),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ import com.anytypeio.anytype.presentation.sets.viewer.ViewerDelegate
|
|||
import com.anytypeio.anytype.presentation.templates.ObjectTypeTemplatesContainer
|
||||
import com.anytypeio.anytype.presentation.util.DefaultCoroutineTestRule
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
import com.anytypeio.anytype.presentation.widgets.collection.DateProviderImpl
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
@ -274,7 +275,8 @@ open class ObjectSetViewModelTestSetup {
|
|||
getObjectTypes = getObjectTypes,
|
||||
storelessSubscriptionContainer = storelessSubscriptionContainer,
|
||||
dispatchers = dispatchers,
|
||||
getNetworkMode = getNetworkMode
|
||||
getNetworkMode = getNetworkMode,
|
||||
dateProvider = DateProviderImpl()
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ class SetByRelationTest : ObjectSetViewModelTestSetup() {
|
|||
closable = MockitoAnnotations.openMocks(this)
|
||||
viewModel = givenViewModel()
|
||||
mockObjectSet = MockSet(context = root, setOfValue = setOfId, setOfKey = setOfKey)
|
||||
stubNetworkMode()
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -66,7 +67,7 @@ class SetByRelationTest : ObjectSetViewModelTestSetup() {
|
|||
type = TypeKey(setOfKey),
|
||||
filters = mockObjectSet.filters,
|
||||
template = null,
|
||||
dvRelationLinks = mockObjectSet.relationLinks
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -90,7 +91,10 @@ class SetByRelationTest : ObjectSetViewModelTestSetup() {
|
|||
type = TypeKey(setOfKey),
|
||||
filters = mockObjectSet.filters,
|
||||
template = null,
|
||||
dvRelationLinks = mockObjectSet.relationLinks
|
||||
prefilled = mapOf(
|
||||
mockObjectSet.filters[0].relation to mockObjectSet.filters[0].value,
|
||||
mockObjectSet.filters[1].relation to mockObjectSet.filters[1].value
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ class CollectionViewerTypeAndTemplateTest: ObjectSetViewModelTestSetup() {
|
|||
type = pageTypeKey,
|
||||
template = null,
|
||||
filters = emptyList(),
|
||||
dvRelationLinks = listOf(relationLink1)
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ class CollectionViewerTypeAndTemplateTest: ObjectSetViewModelTestSetup() {
|
|||
type = pageTypeKey,
|
||||
template = null,
|
||||
filters = emptyList(),
|
||||
dvRelationLinks = listOf(relationLink1)
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ class CollectionViewerTypeAndTemplateTest: ObjectSetViewModelTestSetup() {
|
|||
type = pageTypeKey,
|
||||
template = pageTemplate2.id,
|
||||
filters = emptyList(),
|
||||
dvRelationLinks = listOf(relationLink1)
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ class CollectionViewerTypeAndTemplateTest: ObjectSetViewModelTestSetup() {
|
|||
type = TypeKey(customType1Key.key),
|
||||
template = template1.id,
|
||||
filters = emptyList(),
|
||||
dvRelationLinks = listOf(relationLink1)
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ class CollectionViewerTypeAndTemplateTest: ObjectSetViewModelTestSetup() {
|
|||
type = TypeKey(customType1Key.key),
|
||||
template = DEFAULT_TEMPLATE_ID_BLANK,
|
||||
filters = emptyList(),
|
||||
dvRelationLinks = listOf(relationLink1)
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -630,7 +630,7 @@ class CollectionViewerTypeAndTemplateTest: ObjectSetViewModelTestSetup() {
|
|||
type = TypeKey(customType1Key.key),
|
||||
template = template2.id,
|
||||
filters = emptyList(),
|
||||
dvRelationLinks = listOf(relationLink1)
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
|
|
@ -177,8 +177,7 @@ class SetByRelationViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = listOf(),
|
||||
type = pageTypeKey,
|
||||
template = null,
|
||||
dvRelationLinks = listOf(relationLink1),
|
||||
objSetByRelation = relationObject1
|
||||
prefilled = mapOf(relationLink1.key to null)
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -268,8 +267,7 @@ class SetByRelationViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = listOf(),
|
||||
type = pageTypeKey,
|
||||
template = DEFAULT_TEMPLATE_ID_BLANK,
|
||||
dvRelationLinks = listOf(relationLink1),
|
||||
objSetByRelation = relationObject1
|
||||
prefilled = mapOf(relationLink1.key to null)
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -359,8 +357,7 @@ class SetByRelationViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = listOf(),
|
||||
type = pageTypeKey,
|
||||
template = pageTemplate2.id,
|
||||
dvRelationLinks = listOf(relationLink1),
|
||||
objSetByRelation = relationObject1
|
||||
prefilled = mapOf(relationLink1.key to null)
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -461,8 +458,7 @@ class SetByRelationViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = listOf(),
|
||||
type = customType1Key,
|
||||
template = template1.id,
|
||||
dvRelationLinks = listOf(relationLink1),
|
||||
objSetByRelation = relationObject1
|
||||
prefilled = mapOf(relationLink1.key to null)
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -563,8 +559,7 @@ class SetByRelationViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = listOf(),
|
||||
type = customType1Key,
|
||||
template = null,
|
||||
dvRelationLinks = listOf(relationLink1),
|
||||
objSetByRelation = relationObject1
|
||||
prefilled = mapOf(relationLink1.key to null)
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -665,8 +660,7 @@ class SetByRelationViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = listOf(),
|
||||
type = customType1Key,
|
||||
template = DEFAULT_TEMPLATE_ID_BLANK,
|
||||
dvRelationLinks = listOf(relationLink1),
|
||||
objSetByRelation = relationObject1
|
||||
prefilled = mapOf(relationLink1.key to null)
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -767,8 +761,7 @@ class SetByRelationViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = listOf(),
|
||||
type = customType1Key,
|
||||
template = DEFAULT_TEMPLATE_ID_BLANK,
|
||||
dvRelationLinks = listOf(relationLink1),
|
||||
objSetByRelation = relationObject1
|
||||
prefilled = mapOf(relationLink1.key to null)
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -869,8 +862,7 @@ class SetByRelationViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = listOf(),
|
||||
type = customType1Key,
|
||||
template = template2.id,
|
||||
dvRelationLinks = listOf(relationLink1),
|
||||
objSetByRelation = relationObject1
|
||||
prefilled = mapOf(relationLink1.key to null)
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ class SetByTypeViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = listOf(),
|
||||
type = customType1Key,
|
||||
template = null,
|
||||
dvRelationLinks = listOf(relationLink1)
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ class SetByTypeViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = listOf(),
|
||||
type = customType1Key,
|
||||
template = DEFAULT_TEMPLATE_ID_BLANK,
|
||||
dvRelationLinks = listOf(relationLink1)
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ class SetByTypeViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = listOf(),
|
||||
type = customType1Key,
|
||||
template = template2.id,
|
||||
dvRelationLinks = listOf(relationLink1)
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ class SetByTypeViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = listOf(),
|
||||
type = customType1Key,
|
||||
template = template1.id,
|
||||
dvRelationLinks = listOf(relationLink1)
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ class SetByTypeViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = listOf(),
|
||||
type = customType1Key,
|
||||
template = template1.id,
|
||||
dvRelationLinks = listOf(relationLink1)
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
@ -610,7 +610,7 @@ class SetByTypeViewerTypeAndTemplateTest : ObjectSetViewModelTestSetup() {
|
|||
filters = listOf(),
|
||||
type = customType1Key,
|
||||
template = DEFAULT_TEMPLATE_ID_BLANK,
|
||||
dvRelationLinks = listOf(relationLink1)
|
||||
prefilled = emptyMap()
|
||||
)
|
||||
async(params)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue