temporal unworkable progress
This commit is contained in:
client
features
common
client
common
src
commonMain
kotlin
dev
inmo
postssystem
features
common
common
content
client
src
jsMain
kotlin
dev
inmo
postssystem
features
content
client
text
client
gradle
server/src/main/resources/web
services/posts
client
src
commonMain
kotlin
dev
inmo
postssystem
services
posts
server
src
jvmMain
kotlin
dev
inmo
postssystem
services
posts
targets/telegram
content
polls
client
build.gradle
src
common
server
loader
client
server
template
@ -10,6 +10,12 @@ apply from: "$mppProjectWithSerializationPresetPath"
|
||||
kotlin {
|
||||
js(IR) {
|
||||
binaries.executable()
|
||||
|
||||
compileKotlinJs {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs += "-Xir-property-lazy-initialization"
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
commonMain {
|
||||
|
@ -23,8 +23,7 @@ import dev.inmo.postssystem.client.settings.DefaultSettings
|
||||
import dev.inmo.postssystem.client.settings.Settings
|
||||
import dev.inmo.postssystem.client.settings.auth.AuthSettings
|
||||
import dev.inmo.postssystem.client.settings.auth.DefaultAuthSettings
|
||||
import dev.inmo.postssystem.features.common.common.SerializersModuleConfigurator
|
||||
import dev.inmo.postssystem.features.common.common.singleWithRandomQualifier
|
||||
import dev.inmo.postssystem.features.common.common.*
|
||||
import dev.inmo.postssystem.features.content.common.ContentSerializersModuleConfigurator
|
||||
import dev.inmo.postssystem.features.content.common.OtherContentSerializerModuleConfigurator
|
||||
import dev.inmo.postssystem.features.content.text.common.TextContentSerializerModuleConfigurator
|
||||
@ -95,6 +94,10 @@ fun baseKoin(
|
||||
)) } }
|
||||
single<AuthSettings> { DefaultAuthSettings(get(SettingsQualifier), get(), koin, get()) }
|
||||
single<Settings> { DefaultSettings(get()) }
|
||||
|
||||
AdditionalModules.modules.forEach {
|
||||
it.apply { load() }
|
||||
}
|
||||
}
|
||||
)
|
||||
}.koin.apply {
|
||||
|
@ -13,6 +13,7 @@ import dev.inmo.micro_utils.fsm.common.StatesMachine
|
||||
import dev.inmo.micro_utils.repos.mappers.withMapper
|
||||
import dev.inmo.micro_utils.serialization.typed_serializer.TypedSerializer
|
||||
import dev.inmo.postssystem.client.settings.auth.AuthSettings
|
||||
import dev.inmo.postssystem.features.common.common.getAllDistinct
|
||||
import dev.inmo.postssystem.services.posts.client.ui.create.*
|
||||
import kotlinx.browser.*
|
||||
import kotlinx.coroutines.*
|
||||
@ -92,7 +93,7 @@ fun baseKoin(): Koin {
|
||||
|
||||
factory<PostCreateUIModel> { DefaultPostCreateUIModel(get(), get()) }
|
||||
factory { PostCreateUIViewModel(get()) }
|
||||
factory { PostCreateView(get(), get(UIScopeQualifier)) }
|
||||
factory { PostCreateView(get(), getAllDistinct(), get(UIScopeQualifier)) }
|
||||
}
|
||||
)
|
||||
strictlyOn<AuthUIFSMState>(get<AuthView>())
|
||||
|
@ -1,24 +1,25 @@
|
||||
package dev.inmo.postssystem.client.fsm.ui
|
||||
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.runtime.*
|
||||
import dev.inmo.jsuikit.elements.*
|
||||
import dev.inmo.jsuikit.modifiers.*
|
||||
import dev.inmo.micro_utils.common.*
|
||||
import dev.inmo.jsuikit.utils.Attrs
|
||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.fsm.common.StatesMachine
|
||||
import dev.inmo.postssystem.client.ui.fsm.CreatePostUIFSMState
|
||||
import dev.inmo.postssystem.client.ui.fsm.UIFSMState
|
||||
import dev.inmo.postssystem.client.utils.renderComposableAndLinkToContext
|
||||
import dev.inmo.postssystem.features.content.common.*
|
||||
import dev.inmo.postssystem.features.content.text.common.TextContent
|
||||
import dev.inmo.postssystem.features.content.client.ContentClientProvider
|
||||
import dev.inmo.postssystem.services.posts.client.ui.create.PostCreateUIViewModel
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.jetbrains.compose.web.dom.*
|
||||
import org.jetbrains.compose.web.dom.Div
|
||||
import org.w3c.dom.HTMLElement
|
||||
import org.w3c.dom.Text
|
||||
|
||||
class PostCreateView(
|
||||
private val createPostCreateUIModel: PostCreateUIViewModel,
|
||||
private val contentClientProviders: List<ContentClientProvider>,
|
||||
private val uiScope: CoroutineScope
|
||||
) : JSView<CreatePostUIFSMState>() {
|
||||
override suspend fun StatesMachine<in UIFSMState>.safeHandleState(
|
||||
@ -27,68 +28,46 @@ class PostCreateView(
|
||||
): UIFSMState? {
|
||||
val result = CompletableDeferred<UIFSMState?>()
|
||||
|
||||
val contentStatesList = mutableStateListOf<Content>()
|
||||
val contentProvidersList = mutableStateListOf<ContentClientProvider.ContentRenderer>()
|
||||
|
||||
renderComposableAndLinkToContext(htmlElement) {
|
||||
Flex(
|
||||
UIKitFlex.Alignment.Horizontal.Center
|
||||
) {
|
||||
Div({ include(UIKitWidth.Fixed.XLarge) }) {
|
||||
contentStatesList.forEachIndexed { i, it ->
|
||||
Div ({ include(UIKitWidth.Fixed.XLarge) }) {
|
||||
contentProvidersList.forEachIndexed { i, it ->
|
||||
Flex(UIKitWidth.Expand) {
|
||||
when (it) {
|
||||
is TextContent -> {
|
||||
TextArea(it.text) {
|
||||
include(UIKitWidth.Expand)
|
||||
onInput { contentStatesList[i] = TextContent(it.value) }
|
||||
}
|
||||
}
|
||||
is BinaryContent -> {
|
||||
DefaultButton(it.filename.name, UIKitWidth.Expand) {
|
||||
selectFile {
|
||||
contentStatesList[i] = it.binaryContent()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
it.render()
|
||||
|
||||
DefaultButton("Remove") {
|
||||
contentStatesList.removeAt(i)
|
||||
contentProvidersList.removeAt(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
DefaultButton("Add content")
|
||||
Label("Add content", Attrs.empty())
|
||||
Dropdown {
|
||||
DefaultNav {
|
||||
NavItemElement(
|
||||
attributesCustomizer = {
|
||||
onClick {
|
||||
contentStatesList.add(TextContent(""))
|
||||
}
|
||||
}
|
||||
) {
|
||||
Text("Text")
|
||||
}
|
||||
NavItemElement(
|
||||
attributesCustomizer = {
|
||||
onClick {
|
||||
selectFile {
|
||||
contentStatesList.add(it.binaryContent())
|
||||
contentClientProviders.forEach {
|
||||
NavItemElement(
|
||||
attributesCustomizer = {
|
||||
onClick { _ ->
|
||||
contentProvidersList.add(it.createNewContentRenderer())
|
||||
}
|
||||
}
|
||||
) {
|
||||
Text(it.contentTypeNameForUser())
|
||||
}
|
||||
) {
|
||||
Text("File")
|
||||
}
|
||||
}
|
||||
}
|
||||
DefaultButton(
|
||||
"Upload",
|
||||
disabled = contentStatesList.isEmpty()
|
||||
disabled = contentProvidersList.isEmpty()
|
||||
) {
|
||||
it.preventDefault()
|
||||
uiScope.launchSafelyWithoutExceptions {
|
||||
createPostCreateUIModel.create(
|
||||
contentStatesList.toList()
|
||||
contentProvidersList.mapNotNull { it.state.value }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user