Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #?delimiters [%, %], [%=, %]
- <wr:LayoutParameter label="Use Empty Unit Message" name="use-empty-unit-message" type="boolean" default="false">
- Defines the usage of a message for empty units.
- Allowed values are: true(default) or false.
- </wr:LayoutParameter>
- <wr:LayoutParameter label="Empty Unit Message" name="empty-unit-message" type="string" default="emptyUnitMessage">
- Defines the key of the message to use if the unit is empty.
- Default value: emptyUnitMessage
- </wr:LayoutParameter>
- [%
- import org.apache.commons.lang.StringUtils
- setHTMLOutput()
- def useEmptyUnitMessage = params["use-empty-unit-message"]
- def emptyUnitMessage = params["empty-unit-message"]
- def position = "index"
- def atts = unit.selectNodes("layout:Attribute")
- def rootFirstLink = unit.selectSingleNode("layout:Link[string(@sort) != 'true' and string(@scroll) != 'true']")
- def rootFirstLinkId = rootFirstLink?.valueOf("@link")
- def isScrollable = unit["blockFactor"] != "" ? "true": "false"
- def blockFactor = unit["blockFactor"]
- def firstLink = unit.selectSingleNode("layout:Link[contains(@link,'First')]")
- def previousLink = unit.selectSingleNode("layout:Link[contains(@link,'Previous')]")
- def blockLink = unit.selectSingleNode("layout:Link[contains(@link,'Block')]")
- def nextLink = unit.selectSingleNode("layout:Link[contains(@link,'Next')]")
- def lastLink = unit.selectSingleNode("layout:Link[contains(@link,'Last')]")
- def getIconPath(linkLayout) {
- folder = linkLayout.parameters["icon-folder"]
- name = StringUtils.defaultIfEmpty(linkLayout.parameters["icon-name"], linkLayout.contextElement?.attributeValue("name"))
- extension = linkLayout.parameters["icon-extension"]
- return getFilePath(folder, name, extension)
- }
- // OUR FUNCTION iterates recursively on the hierarchicalLevels
- def getSubLevelsLayoutOur(hLevel, position, levelCount ) {
- def levelId = hLevel["id"]
- def currentLevel = "level" + levelCount + "current"
- position = position + ",level" + levelCount
- def atts = hLevel.selectNodes("layout:Attribute")
- def links = hLevel.selectNodes("layout:Link")
- def levelFirstLink = hLevel.selectSingleNode("layout:Link[1]")
- %]
- <c:forEach items="${level[%=levelCount -1 %]current.[%=levelId%]data}" var="level[%=levelCount%]current"
- varStatus="level[%=levelCount%]status">
- [%/*GET VALUE */%]
- <wr:Iterate var="attr" context="hLevel" select="layout:Attribute">
- <wr:Visible>
- <wr:Value item="currentLevel"/>
- </wr:Visible>
- </wr:Iterate>
- [%/*GET VALUES RECURSIVE*/%]
- <wr:Iterate var="subLevel" context="hLevel" select="HierarchicalIndexLevel">
- <c:out value=", "/>[% getSubLevelsLayoutOur(subLevel, position, levelCount + 1) %]
- </wr:Iterate>
- </c:forEach>
- [% }
- if (useEmptyUnitMessage != "true") { %]
- <c:if test="${not(empty <wr:UnitId/>) and (<wr:UnitId/>.dataSize gt 0)}">
- [% } else { %]
- <c:choose>
- <c:when test="${not(empty <wr:UnitId/>) and (<wr:UnitId/>.dataSize gt 0)}">
- [% } %]
- <wr:Frame>
- [%/*SHOW OBJECTS*/%]
- <table class="table table-striped <wr:StyleClass/>">
- <thead>
- <tr>
- <th><bean:message key="Offer"/></th>
- <th><bean:message key="Desired price"/></th>
- <th><bean:message key="Current price"/></th>
- <th><bean:message key="offer.links"/></th>
- </tr>
- </thead>
- <tbody>
- <c:forEach var="level1current" varStatus="level1status" items="${<wr:UnitId/>.data}">
- <c:set var="index" value="${level1status.index}"/>
- <c:set var="currency" value="${level1current.currencySymbol}"/>
- <wr:Iterate var="attr" context="unit" select="layout:Attribute[@name='add']">
- [% def attrName = attr.attribute("name").getValue().replaceAll(/(?m)_\w/,{ ((it.size() > 1) ? it[1].toUpperCase() : '') }) %]
- <c:if test="${not(empty(level1current['[%= attrName%]']))}">
- <c:set var="currency" value="${currency}/${level1current['[%= attrName%]']}"/>
- </c:if>
- </wr:Iterate>
- <tr>
- [%/* Offer */%]
- <td>
- <wr:Iterate var="attr" context="unit" select="layout:Attribute[@label='offer']">
- <a rel="popover" data-original-title="[% getSubLevelsLayoutOur(unit.selectSingleNode("HierarchicalIndexLevel[@name='Type']"), "level1", 2) %]" data-load="<c:out value="${pageContext.response.locale.language}"/>/offer-popover/<c:out value="${level1current.[%=getFieldName(attr["attribute"])%]}"/>" href="<c:out value="${pageContext.response.locale.language}"/>/offer/<c:out value="${level1current.[%=getFieldName(attr["attribute"])%]}"/>" target="blank"><bean:message key="Ref."/> <wr:Value item="'level1current'"/></a>.
- </wr:Iterate>
- <wr:Iterate var="hLevel" context="unit" select="HierarchicalIndexLevel[@name='Type']">
- [% getSubLevelsLayoutOur(hLevel, "level1", 2) %].
- </wr:Iterate>
- <wr:Iterate var="attr" context="unit" select="layout:Attribute[@name='aliasPublic']">
- <wr:Value item="'level1current'"/>
- </wr:Iterate>
- </td>
- <td>
- [%/* price */%]
- <wr:Iterate var="attr" context="unit" select="layout:Attribute[@name='price']">
- <span class="nowrap"><a href="#" class="editable" id="price-<c:out value="${level1current.oid}"/>" data-type="text" data-pk="<c:out value="${level1current.oid}"/>" data-name="price" data-url="<c:out value="${pageContext.response.locale.language}"/>/alertprice-edit" data-original-title="<wr:LocalizationString key="price"/>"><wr:Value item="'level1current'"/></a> <c:out value="${currency}"/></span>
- </wr:Iterate>
- </td>
- <td>
- <wr:Iterate var="attr" context="unit" select="layout:Attribute[@name='offerprice']">
- <span class="nowrap"><wr:Value item="'level1current'"/> <c:out value="${currency}"/></span>
- </wr:Iterate>
- </td>
- <td>
- [%/* LINKS */%]
- <div class="btn-group">
- <wr:Iterate var="link" context="unit" select="layout:Link[string(@sort) != 'true' and string(@scroll) != 'true']">
- <wr:Visible>
- <wr:Link class="link" position="position"/>
- </wr:Visible>
- </wr:Iterate>
- </div>
- [%/* END LINKS*/%]
- </td>
- </tr>
- </c:forEach>
- [%/*END SHOW OBJECT*/%]
- </tbody>
- </table>
- [%/*PAGINATION*/%]
- [% if (isScrollable == "true") { %]
- <c:if test="${<wr:UnitId/>.scroller.of gt [%= blockFactor %]}">
- <div class="pagination pagination-centered">
- <ul>
- [% if (firstLink) { %]
- <wr:Visible context="firstLink">
- <c:if test="${<wr:UnitId/>.scroller.current ne <wr:UnitId/>.scroller.first}">
- <li><wr:Link context="firstLink"/></li>
- </c:if>
- </wr:Visible>
- [% } %]
- [% if (previousLink) { %]
- <wr:Visible context="previousLink">
- <c:if test="${<wr:UnitId/>.scroller.current ne <wr:UnitId/>.scroller.previous}">
- <li><wr:Link context="previousLink"/></li>
- </c:if>
- </wr:Visible>
- [% } %]
- [% if (blockLink) {%]
- <wr:Visible context="blockLink">
- <c:forEach var="current" varStatus="status" items="${<wr:UnitId/>.scroller.blocks}">
- <c:set var="index" value="${status.index}"/>
- <c:choose>
- <c:when test="${current ne <wr:UnitId/>.scroller.current}">
- <li>
- <a href="<wr:URL context="blockLink"/>" onclick="<wr:AjaxURL context="blockLink" />">${current}</a>
- </li>
- </c:when>
- <c:otherwise>
- <li class="active"><a>${current}</a></span>
- </c:otherwise>
- </c:choose>
- </c:forEach>
- </wr:Visible>
- [% } %]
- [% if (nextLink) { %]
- <wr:Visible context="nextLink">
- <c:if test="${<wr:UnitId/>.scroller.current ne <wr:UnitId/>.scroller.next}">
- <li><wr:Link context="nextLink"/></li>
- </c:if>
- </wr:Visible>
- [% } %]
- [% if (lastLink) { %]
- <wr:Visible context="lastLink">
- <c:if test="${<wr:UnitId/>.scroller.current ne <wr:UnitId/>.scroller.last}">
- <li><wr:Link context="lastLink"/></li>
- </c:if>
- </wr:Visible>
- [% } %]
- </ul>
- </div>
- </c:if>
- [%}%]
- [%/*END PAGINATION*/%]
- <script type="text/javascript">
- (function($) { jQuery(document).on('ready', function() {
- $('a.editable').editable({
- validate:function(value) {
- var value = unlocalizeNumber($.trim(value));
- if(value == '') {
- return '<wr:LocalizationString key="MandatoryValidationRule.error"/>';
- }
- },
- getInputValue:function(value) {
- return localizeNumber($.trim(this.$input.val()));
- },
- success:function(data) {
- if (typeof data == 'object' && typeof data.value !== 'undefined') return;
- else return messages["Error"];
- },
- error:function(data) {
- return messages["Error"];
- }
- });
- $('a[rel="popover"]').on('hover',function(){
- var el=$(this).off('hover');
- $.get(el.attr('data-load'),function(d){
- el.popover({content: d}).popover('show');
- });
- });
- })})(jQuery);
- </script>
- </wr:Frame>
- [% if (useEmptyUnitMessage != "true") { %]
- </c:if>
- [% } else { %]
- </c:when>
- <c:otherwise>
- <wr:Frame>
- <div class="<wr:StyleClass/>"><bean:message key="[%printJSPTagValue(emptyUnitMessage)%]"/></div>
- </wr:Frame>
- </c:otherwise>
- </c:choose>
- [% } %]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement