-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from picortex/master-dev
Master dev
- Loading branch information
Showing
85 changed files
with
847 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
bitframe-presenters/src/commonMain/kotlin/bitframe/presenters/fields/BooleanInputField.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@file:JsExport | ||
|
||
package bitframe.presenters.fields | ||
|
||
import kotlinx.serialization.Serializable | ||
import kotlin.js.JsExport | ||
|
||
@Serializable | ||
data class BooleanInputField( | ||
val label: String, | ||
var value: Boolean? = null | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...nitor-client/browser/react/src/jsMain/kotlin/pimonitor/evaluation/business/AddBusiness.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package pimonitor.evaluation.business | ||
|
||
import pimonitor.PiMonitorService | ||
import pimonitor.evaluation.business.exports.CreateBusinessScope | ||
import pimonitor.evaluation.business.forms.CreateBusinessState.* | ||
import react.Props | ||
import react.RBuilder | ||
import react.fc | ||
import react.useEffectOnce | ||
import reakt.ErrorBox | ||
import reakt.LoadingBox | ||
import reakt.SuccessBox | ||
import useViewModelState | ||
import pimonitor.evaluation.business.forms.CreateBusinessIntent as Intent | ||
|
||
private external interface AddBusinessProps : Props { | ||
var uid: String? | ||
var scope: CreateBusinessScope | ||
} | ||
|
||
private val AddBusiness = fc<AddBusinessProps> { props -> | ||
val scope = props.scope | ||
val vm = scope.viewModel | ||
useEffectOnce { scope.showForm(props.uid) } | ||
when (val state = useViewModelState(vm)) { | ||
is Loading -> LoadingBox(state.message) | ||
is Form -> CreateBusinessForm( | ||
state = state, | ||
onSubmit = { vm.post(Intent.SubmitForm(it)) } | ||
) | ||
is Success -> SuccessBox(state.message) | ||
is Failure -> ErrorBox(state.cause) | ||
} | ||
} | ||
|
||
internal fun RBuilder.AddBusiness(service: PiMonitorService, uid: String? = null) = child(AddBusiness) { | ||
attrs.scope = CreateBusinessScope(service) | ||
attrs.uid = uid | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...lient/browser/react/src/jsMain/kotlin/pimonitor/evaluation/business/CreateBusinessForm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package pimonitor.evaluation.business | ||
|
||
import bitframe.components.TextInput | ||
import kotlinx.css.* | ||
import kotlinx.extensions.onDesktop | ||
import kotlinx.extensions.onMobile | ||
import kotlinx.extensions.text | ||
import pimonitor.evaluation.business.forms.CreateBusinessState | ||
import pimonitor.monitored.CreateMonitoredBusinessParams | ||
import react.RBuilder | ||
import reakt.ContainedButton | ||
import reakt.FlexBox | ||
import reakt.Form | ||
import reakt.centerContent | ||
import styled.css | ||
import styled.styledDiv | ||
import styled.styledH2 | ||
import theme.clazz | ||
|
||
internal fun RBuilder.CreateBusinessForm( | ||
state: CreateBusinessState.Form, | ||
onSubmit: (params: CreateMonitoredBusinessParams) -> Unit | ||
) = FlexBox { theme -> | ||
css { | ||
centerContent() | ||
onMobile { padding(horizontal = 1.em) } | ||
onDesktop { padding(horizontal = 20.pct) } | ||
} | ||
|
||
val fields = state.fields | ||
Form { | ||
fields.inviterIntroduction?.let { | ||
styledDiv { +it } | ||
} | ||
styledH2 { | ||
css { +theme.text.h2.clazz } | ||
+fields.title | ||
} | ||
TextInput("businessName", fields.businessName) | ||
TextInput("contactName", fields.contactName) | ||
TextInput("contactEmail", fields.contactEmail) | ||
ContainedButton(fields.submitButton.text) | ||
} onSubmit { | ||
val businessName by text() | ||
val contactName by text() | ||
val contactEmail by text() | ||
|
||
val params = CreateMonitoredBusinessParams(businessName, contactName, contactEmail) | ||
onSubmit(params) | ||
} | ||
} |
Oops, something went wrong.