Skip to content

Commit

Permalink
For #6518: improve layout, validation, titles
Browse files Browse the repository at this point in the history
  • Loading branch information
ebruchez committed Sep 30, 2024
1 parent cfa96b6 commit 4dcfa02
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -713,19 +713,19 @@ body.orbeon {
display: flex;
flex-wrap: wrap;
gap: 1em;
min-height: 190px;
max-height: 390px;
min-height: 234px; // empirically fit one line
max-height: 482px; // empirically fit two lines
overflow-y: scroll;
padding: 5px; // so that selection outline/shadow is not clipped
justify-content: space-evenly;
justify-content: space-around;

& > span {
display: none;
}

.fb-template-card {
width: 150px;
height: 170px;
width: 190px; // empirically fit 4 cards in a row
height: 220px;
display: flex;
flex-direction: column;
white-space: nowrap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<xf:action ev:event="DOMActivate">
<!-- Open the dialog in "edit" mode -->
<xxf:show dialog="dialog-form-settings">
<xf:property name="for-action" value="event('for-action')"/>
<xf:property name="lang" value="$fb-lang"/>
<xf:property name="langs" value="$resources/resource/@xml:lang/string()"/>
<xf:property name="mode" value="(event('mode'), 'edit')[1]"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@

<!-- Save event context information in local instance -->
<xf:setvalue
iterate="'app', 'form', 'title', 'description', 'screenshot', 'allow-template-use', 'singleton', 'mode', 'created-with-version'"
iterate="
'for-action', 'app', 'form', 'title', 'description', 'screenshot', 'allow-template-use',
'singleton', 'mode', 'created-with-version'"
ref="$i/*[name() = context()]"
value="event(context())"/>

Expand Down Expand Up @@ -270,19 +272,6 @@
<xf:property name="metadata-instance" value="frf:metadataInstanceRootOpt($form)"/>
</xf:dispatch>

<!-- If there are invalid initial app/form values, mark them as visited and focus on first -->
<xf:action>
<xf:var
name="invalid-app-form"
value="$i/(app, form)[xxf:non-blank() and not(valid())]"/>

<xxf:setvisited
iterate="$invalid-app-form"
control="fb-{name()}-name-input"/>
<xf:setfocus
control="fb-general-settings-grid"/>
</xf:action>

<!-- Load form templates -->
<xf:send
if="$is-new-form"
Expand All @@ -293,14 +282,26 @@
value="if ($app-chooser = 'select1') then string-join($allowed-apps-if-has-roles, ' ') else ()"
xxf:tunnel="true"/>
</xf:send>
<!-- Explicit focus is necessary or the tab might not consistently open -->
<xf:setfocus
if="$is-new-form"
control="fb-templates-grid"/>

<!-- Necessary or the tab will not open -->
<xf:setfocus
if="$is-app-form or $is-form-settings"
control="fb-general-settings-grid"/>
<!-- If there are invalid initial app/form values, mark them as visited and focus on first -->
<xf:action if="$is-app-form or $is-form-settings">
<xf:var
name="invalid-app-form"
value="$i/(app, form)[not(valid())]"/>
<xf:action if="exists($invalid-app-form)">
<xf:setfocus
iterate="$invalid-app-form[1]"
control="fb-{name()}-name-input"/>
</xf:action>
<!-- Explicit focus is necessary or the tab might not consistently open -->
<xf:setfocus
if="empty($invalid-app-form)"
control="fb-general-settings-grid"/>
</xf:action>

</xbl:handler>

Expand Down Expand Up @@ -455,6 +456,7 @@
<xf:model id="model">
<xf:instance id="local">
<_ valid="true">
<for-action/>
<lang/>
<app/>
<form/>
Expand Down Expand Up @@ -525,7 +527,7 @@

<xf:bind
ref="app | form"
required="../mode = 'app-form'"
required="../mode != 'new'"
constraint="xxf:is-blank() or matches(., '^[A-Za-z0-9\-_]+$') and xxf:max-length(255)"
xxf:whitespace="trim"
readonly="false()"/>
Expand Down Expand Up @@ -800,8 +802,18 @@
<xf:label
value="
if ($is-new-form) then
(: No title in this case :)
()
else if (xxf:non-blank($i/for-action)) then
(: The action must match a process button and we use the associated text label if present :)
let $r := xxf:r(concat('buttons.', $i/for-action), '|fr-fr-resources|')
return
if (exists($r)) then
string(xf:parse(concat('&lt;span>', $r, '&lt;/span>')))
else
$resources/dialog-form-settings/label
else
(: Case of form settings :)
$resources/dialog-form-settings/label"/>

<!-- Expose mode to CSS -->
Expand Down
18 changes: 9 additions & 9 deletions src/main/resources/config/properties-form-builder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
return
xxf:is-blank($metadata/application-name) or xxf:is-blank($metadata/form-name)
") then (
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form") then
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form", for-action = "excel-export") then
suspend then
xf:dispatch(name = "fb-excel-export")
) else
Expand All @@ -158,7 +158,7 @@
return
xxf:is-blank($metadata/application-name) or xxf:is-blank($metadata/form-name)
") then (
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form") then
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form", for-action = "xml-export") then
suspend then
xf:dispatch(name = "fb-xml-export")
) else
Expand All @@ -171,7 +171,7 @@
return
xxf:is-blank($metadata/application-name) or xxf:is-blank($metadata/form-name)
") then (
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form") then
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form", for-action = "form-definition-xhtml-export") then
suspend then
xf:show(
dialog = "fb-publish-dialog",
Expand All @@ -188,7 +188,7 @@
return
xxf:is-blank($metadata/application-name) or xxf:is-blank($metadata/form-name)
") then (
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form") then
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form", for-action = "test") then
suspend then
xf:dispatch(name = "fb-test-form")
) else
Expand All @@ -201,7 +201,7 @@
return
xxf:is-blank($metadata/application-name) or xxf:is-blank($metadata/form-name)
") then (
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form") then
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form", for-action = "test-formulas") then
suspend then
xf:dispatch(name = "fb-test-formulas")
) else
Expand All @@ -214,7 +214,7 @@
return
xxf:is-blank($metadata/application-name) or xxf:is-blank($metadata/form-name)
") then (
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form") then
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form", for-action = "test-offline") then
suspend then
xf:dispatch(name = "fb-test-offline")
) else
Expand All @@ -227,7 +227,7 @@
return
xxf:is-blank($metadata/application-name) or xxf:is-blank($metadata/form-name)
") then (
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form") then
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form", for-action = "test-pdf") then
suspend then
xf:dispatch(name = "fb-test-pdf-show-dialog")
) else
Expand All @@ -240,7 +240,7 @@
return
xxf:is-blank($metadata/application-name) or xxf:is-blank($metadata/form-name)
") then (
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form") then
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form", for-action = "publish") then
suspend then
xf:show(
dialog = "fb-publish-dialog",
Expand All @@ -261,7 +261,7 @@
return
xxf:is-blank($metadata/application-name) or xxf:is-blank($metadata/form-name)
") then (
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form") then
xf:dispatch(name = "DOMActivate", targetid="open-form-settings-trigger", mode = "app-form", for-action = "save") then
suspend then
save-final
) else
Expand Down

0 comments on commit 4dcfa02

Please sign in to comment.