@@ -642,7 +642,7 @@ LIMIT 10
642642 </xsl : template >
643643
644644 <xsl : template name =" ldh:ReconcileForm" >
645- <xsl : param name =" id" select =" 'reconcile'" as =" xs:string?" />
645+ <xsl : param name =" id" select =" 'form- reconcile'" as =" xs:string?" />
646646 <xsl : param name =" button-class" select =" 'btn btn-primary btn-save'" as =" xs:string?" />
647647 <xsl : param name =" accept-charset" select =" 'UTF-8'" as =" xs:string?" />
648648 <xsl : param name =" action" select =" ac:absolute-path(ldh:base-uri(.))" as =" xs:anyURI" />
@@ -738,6 +738,7 @@ LIMIT 10
738738 </xsl : template >
739739
740740 <xsl : template match =" button[contains-token(@class, 'btn-app-settings')]" mode =" ixsl:onclick" >
741+ <xsl : param name =" id" select =" 'app-settings'" as =" xs:string?" />
741742 <xsl : param name =" method" select =" 'patch'" as =" xs:string" />
742743 <xsl : variable name =" content-body" select =" id('content-body', ixsl:page())" as =" element()" />
743744
@@ -746,6 +747,10 @@ LIMIT 10
746747 <xsl : for-each select =" $content-body" >
747748 <xsl : result-document href =" ?." method =" ixsl:append-content" >
748749 <div class =" modal modal-constructor fade in" about =" {$lapp:application}" >
750+ <xsl : if test =" $id" >
751+ <xsl : attribute name =" id" select =" $id" />
752+ </xsl : if >
753+
749754 <div class =" modal-header" >
750755 <button type =" button" class =" close" >× </button >
751756
@@ -786,6 +791,14 @@ LIMIT 10
786791 " on-failure =" ldh:promise-failure#1" />
787792 </xsl : template >
788793
794+ <!-- submit application settings modal form using PATCH with custom callback -->
795+
796+ <xsl : template match =" div[@id = 'app-settings']//form[upper-case(@method) = 'PATCH']" mode =" ixsl:onsubmit" priority =" 3" >
797+ <xsl : next-match >
798+ <xsl : with-param name =" callback" select =" ldh:settings-form-response#1" />
799+ </xsl : next-match >
800+ </xsl : template >
801+
789802 <xsl : template match =" button[contains-token(@class, 'btn-access-form')]" mode =" ixsl:onclick" >
790803 <!-- TO-DO: fix for admin apps -->
791804 <xsl : param name =" this" select =" ac:absolute-path(ldh:base-uri(.))" as =" xs:anyURI" />
@@ -1303,5 +1316,34 @@ LIMIT 10
13031316 </xsl : otherwise >
13041317 </xsl : choose >
13051318 </xsl : template >
1306-
1319+
1320+ <xsl : function name =" ldh:settings-form-response" ixsl : updating =" yes" >
1321+ <xsl : param name =" context" as =" map(*)" />
1322+ <xsl : variable name =" response" select =" $context('response')" as =" map(*)" />
1323+ <xsl : variable name =" status" select =" $response?status" as =" xs:double" />
1324+ <xsl : variable name =" media-type" select =" $response?media-type" as =" xs:string?" />
1325+ <xsl : variable name =" form" select =" $context('form')" as =" element()?" />
1326+
1327+ <xsl : message >ldh:settings-form-response</xsl : message >
1328+
1329+ <xsl : choose >
1330+ <!-- 200/204: settings saved successfully, close the modal -->
1331+ <xsl : when test =" $status = (200, 204)" >
1332+ <ixsl : set-style name =" cursor" select =" 'default'" object =" ixsl:page()//body" />
1333+ <!-- close the modal -->
1334+ <xsl : if test =" $form" >
1335+ <xsl : sequence select =" ixsl:call($form/ancestor::div[contains-token(@class, 'modal')], 'remove', [])[current-date() lt xs:date('2000-01-01')]" />
1336+ </xsl : if >
1337+ </xsl : when >
1338+ <!-- validation errors -->
1339+ <xsl : when test =" $status = (400, 422) and starts-with($media-type, 'application/rdf+xml')" >
1340+ <xsl : sequence select =" ldh:modal-form-submit-violation($context)" />
1341+ </xsl : when >
1342+ <!-- other errors -->
1343+ <xsl : otherwise >
1344+ <xsl : sequence select =" ldh:error-response-alert($context)" />
1345+ </xsl : otherwise >
1346+ </xsl : choose >
1347+ </xsl : function >
1348+
13071349</xsl : stylesheet >
0 commit comments