Created
November 20, 2015 22:30
-
-
Save ebruchez/fd1c8d88f7966a9f0707 to your computer and use it in GitHub Desktop.
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
<xh:html | |
xmlns:xh="http://www.w3.org/1999/xhtml" | |
xmlns:xf="http://www.w3.org/2002/xforms"> | |
<xh:head> | |
<xh:style> | |
.outer-group { display: block; border: 1px solid blue } | |
.outer-iteration { border: 1px solid red; margin-bottom: 1em } | |
.inner-iteration { border: 1px solid green } | |
</xh:style> | |
<xf:model> | |
<xf:instance id="scheme1"> | |
<json object="true"> | |
<g array="true"> | |
<_ name="" array="true" type="string">a</_> | |
<_ name="" array="true" type="string">b</_> | |
<_ name="" array="true" type="string">c</_> | |
</g> | |
<g array="true"> | |
<_ name="" array="true" type="string">d</_> | |
<_ name="" array="true" type="string">e</_> | |
</g> | |
</json> | |
</xf:instance> | |
<xf:instance id="scheme2"> | |
<json type="object"> | |
<g type="array"> | |
<_ type="array"> | |
<_ type="string">a</_> | |
<_ type="string">b</_> | |
<_ type="string">c</_> | |
</_> | |
<_ type="array"> | |
<_ type="string">d</_> | |
<_ type="string">e</_> | |
</_> | |
</g> | |
</json> | |
</xf:instance> | |
</xf:model> | |
</xh:head> | |
<xh:body> | |
<h2>Scheme 1</h2> | |
<xf:group ref="instance('scheme1')" class="outer-group"> | |
<xf:repeat ref=".[exists(g/(@type, @object, *))]/g"> | |
<xh:div class="outer-iteration"> | |
<xf:repeat ref=".[exists(_/(@type, @object, *))]/_"> | |
<xh:div class="inner-iteration"> | |
<xf:input ref="."/> | |
<xf:trigger> | |
<xf:label>Remove</xf:label> | |
<xf:action event="DOMActivate"> | |
<xf:delete | |
if="count(../_) gt 1" | |
ref="."/> | |
<xf:setvalue | |
if="count(../_) = 1" | |
ref="."/> | |
<xf:delete | |
if="count(../_) = 1" | |
ref="./@type"/> | |
</xf:action> | |
</xf:trigger> | |
</xh:div> | |
</xf:repeat> | |
<xf:trigger> | |
<xf:label>Add</xf:label> | |
<xf:action event="DOMActivate"> | |
<xf:insert | |
if="exists(_/(@type, @object, *))" | |
ref="_" | |
origin="xf:element('_', (xf:attribute('array', 'true'), xf:attribute('type', 'string')))"/> | |
<xf:insert | |
if="empty(_/(@type, @object, *))" | |
context="_" | |
origin="xf:attribute('type', 'string')"/> | |
</xf:action> | |
</xf:trigger> | |
</xh:div> | |
</xf:repeat> | |
</xf:group> | |
<h2>Scheme 2</h2> | |
<xf:group ref="instance('scheme2')" class="outer-group"> | |
<xf:repeat ref="g/_"> | |
<xh:div class="outer-iteration"> | |
<xf:repeat ref="_"> | |
<xh:div class="inner-iteration"> | |
<xf:input ref="."/> | |
<xf:trigger> | |
<xf:label>Remove</xf:label> | |
<xf:delete event="DOMActivate" ref="."/> | |
</xf:trigger> | |
</xh:div> | |
</xf:repeat> | |
<xf:trigger> | |
<xf:label>Add</xf:label> | |
<xf:insert | |
event="DOMActivate" | |
context="." | |
ref="_" | |
origin="xf:element('_', (xf:attribute('array', 'true'), xf:attribute('type', 'string')))"/> | |
</xf:trigger> | |
</xh:div> | |
</xf:repeat> | |
</xf:group> | |
</xh:body> | |
</xh:html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment