Skip to content

Commit

Permalink
Fix #6347: support fr:mode() outside of Form Runner
Browse files Browse the repository at this point in the history
  • Loading branch information
avernet committed Jun 1, 2024
1 parent 86a6e17 commit 6032ecb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 0 additions & 6 deletions form-runner/jvm/src/main/resources/xbl/orbeon/date/date.xbl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@
name="binding"
value="xxf:binding('fr-date')"/>
<xf:var
xxbl:keep-if-function-available="fr:mode"
name="view"
value="
(: Q: Do we need to test for `xxf:is-control-readonly('fr-number')` like `fr:number`? :)
Expand All @@ -168,11 +167,6 @@
) or
fr:mode() = 'pdf'
"/>
<xf:var
xxbl:keep-if-function-unavailable="fr:mode"
name="view"
value="false()"/>

<xf:var name="class-field-width" value="concat('fr-field-width-' , fr:component-param-value('field-width'))"/>
<xf:var name="class-native-picker" value="concat('fr-native-picker-', fr:component-param-value('native-picker'))"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ object FormRunnerFunctionLibrary extends OrbeonFunctionLibrary {
private object FormRunnerFunctions {

val StringGettersByName: Seq[(String, () => Option[String])] = List(
"mode" -> (() => Some(FormRunnerParams().mode)),
"mode" -> (() => FormRunnerParamsOpt().map(_.mode)),
"app-name" -> (() => Some(FormRunnerParams().app)),
"form-name" -> (() => Some(FormRunnerParams().form)),
"document-id" -> (() => FormRunnerParams().document),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ object FormRunnerParams {
type AppFormVersion = (AppForm, Int)
}

// Like `FormRunnerParams`, but for cases where we want to support a potentially missing `fr-parameters-instance`,
// because we want that code to also be able to run outside of Form Runner.
object FormRunnerParamsOpt {

def apply(): Option[FormRunnerParams] =
frc.parametersInstance.map(_.rootElement).map(FormRunnerParams.apply)

}

case class AppForm(app: String, form: String) {

val toList: List[String] = List(app, form)
Expand Down

0 comments on commit 6032ecb

Please sign in to comment.