Advertisement
Guest User

Untitled

a guest
Aug 29th, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 11.69 KB | None | 0 0
  1. #?delimiters [%, %], [%=, %]
  2. <wr:LayoutParameter label="Use Empty Unit Message" name="use-empty-unit-message" type="boolean" default="false">
  3. Defines the usage of a message for empty units.
  4. Allowed values are: true(default) or false.
  5. </wr:LayoutParameter>
  6. <wr:LayoutParameter label="Empty Unit Message" name="empty-unit-message" type="string" default="emptyUnitMessage">
  7. Defines the key of the message to use if the unit is empty.
  8. Default value: emptyUnitMessage
  9. </wr:LayoutParameter>
  10. [%
  11. import org.apache.commons.lang.StringUtils
  12.  
  13. setHTMLOutput()
  14.  
  15. def useEmptyUnitMessage = params["use-empty-unit-message"]
  16. def emptyUnitMessage = params["empty-unit-message"]  
  17. def position = "index"
  18. def atts = unit.selectNodes("layout:Attribute")
  19. def rootFirstLink = unit.selectSingleNode("layout:Link[string(@sort) != 'true' and string(@scroll) != 'true']")
  20. def rootFirstLinkId = rootFirstLink?.valueOf("@link")
  21. def isScrollable = unit["blockFactor"] != "" ? "true": "false"
  22. def blockFactor = unit["blockFactor"]
  23. def firstLink = unit.selectSingleNode("layout:Link[contains(@link,'First')]")
  24. def previousLink = unit.selectSingleNode("layout:Link[contains(@link,'Previous')]")
  25. def blockLink = unit.selectSingleNode("layout:Link[contains(@link,'Block')]")
  26. def nextLink = unit.selectSingleNode("layout:Link[contains(@link,'Next')]")
  27. def lastLink = unit.selectSingleNode("layout:Link[contains(@link,'Last')]")
  28.  
  29. def getIconPath(linkLayout) {
  30.     folder = linkLayout.parameters["icon-folder"]
  31.     name = StringUtils.defaultIfEmpty(linkLayout.parameters["icon-name"], linkLayout.contextElement?.attributeValue("name"))
  32.     extension = linkLayout.parameters["icon-extension"]
  33.     return getFilePath(folder, name, extension)
  34. }
  35. // OUR FUNCTION iterates recursively on the hierarchicalLevels
  36.    def getSubLevelsLayoutOur(hLevel, position, levelCount ) {
  37.      
  38.       def levelId = hLevel["id"]
  39.       def currentLevel = "level" + levelCount + "current"
  40.       position = position + ",level" + levelCount
  41.       def atts = hLevel.selectNodes("layout:Attribute")
  42.       def links = hLevel.selectNodes("layout:Link")
  43.       def levelFirstLink = hLevel.selectSingleNode("layout:Link[1]")
  44. %]
  45.  
  46.      <c:forEach items="${level[%=levelCount -1 %]current.[%=levelId%]data}" var="level[%=levelCount%]current"
  47.         varStatus="level[%=levelCount%]status">
  48.               [%/*GET VALUE */%]
  49.               <wr:Iterate var="attr" context="hLevel" select="layout:Attribute">
  50.                 <wr:Visible>
  51.                     <wr:Value item="currentLevel"/>
  52.                 </wr:Visible>    
  53.               </wr:Iterate>
  54.                 [%/*GET VALUES RECURSIVE*/%]
  55.                 <wr:Iterate var="subLevel" context="hLevel" select="HierarchicalIndexLevel">
  56.                         <c:out value=", "/>[% getSubLevelsLayoutOur(subLevel, position, levelCount + 1) %]
  57.                 </wr:Iterate>
  58.             </c:forEach>
  59.  
  60. [% }
  61.  if (useEmptyUnitMessage != "true") { %]
  62. <c:if test="${not(empty <wr:UnitId/>) and (<wr:UnitId/>.dataSize gt 0)}">
  63. [% } else { %]
  64. <c:choose>
  65. <c:when test="${not(empty <wr:UnitId/>) and (<wr:UnitId/>.dataSize gt 0)}">
  66. [% } %]
  67.    
  68.     <wr:Frame>
  69.                 [%/*SHOW OBJECTS*/%]
  70.                 <table class="table table-striped <wr:StyleClass/>">
  71.                 <thead>
  72.                     <tr>
  73.                     <th><bean:message key="Offer"/></th>
  74.                     <th><bean:message key="Desired price"/></th>
  75.                     <th><bean:message key="Current price"/></th>
  76.                     <th><bean:message key="offer.links"/></th>
  77.                 </tr>
  78.                 </thead>
  79.                 <tbody>
  80.                 <c:forEach var="level1current" varStatus="level1status" items="${<wr:UnitId/>.data}">
  81.                     <c:set var="index" value="${level1status.index}"/>
  82.                     <c:set var="currency" value="${level1current.currencySymbol}"/>
  83.                     <wr:Iterate var="attr" context="unit" select="layout:Attribute[@name='add']">
  84.                     [% def attrName = attr.attribute("name").getValue().replaceAll(/(?m)_\w/,{ ((it.size() > 1) ? it[1].toUpperCase() : '') }) %]
  85.                     <c:if test="${not(empty(level1current['[%= attrName%]']))}">
  86.                                                 <c:set var="currency" value="${currency}/${level1current['[%= attrName%]']}"/>
  87.                     </c:if>
  88.                     </wr:Iterate>
  89.                     <tr>
  90.                     [%/* Offer */%]      
  91.                     <td>
  92.                         <wr:Iterate var="attr" context="unit" select="layout:Attribute[@label='offer']">
  93.                         <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."/>&nbsp;<wr:Value item="'level1current'"/></a>.
  94.                         </wr:Iterate>
  95.                         <wr:Iterate var="hLevel" context="unit" select="HierarchicalIndexLevel[@name='Type']">
  96.                                 &nbsp;[% getSubLevelsLayoutOur(hLevel, "level1", 2) %].
  97.                             </wr:Iterate>
  98.                             <wr:Iterate var="attr" context="unit" select="layout:Attribute[@name='aliasPublic']">
  99.                                     <wr:Value item="'level1current'"/>
  100.                             </wr:Iterate>
  101.                     </td>
  102.                     <td>
  103.                         [%/* price */%]    
  104.                         <wr:Iterate var="attr" context="unit" select="layout:Attribute[@name='price']">
  105.                                             <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>&nbsp;
  106.                         </wr:Iterate>  
  107.                        
  108.                     </td>
  109.                     <td>
  110.                     <wr:Iterate var="attr" context="unit" select="layout:Attribute[@name='offerprice']">
  111.                                             <span class="nowrap"><wr:Value item="'level1current'"/> <c:out value="${currency}"/></span>&nbsp;
  112.                         </wr:Iterate>
  113.                     </td>
  114.                    
  115.                     <td>
  116.                     [%/* LINKS */%]
  117.                     <div class="btn-group">
  118.                             <wr:Iterate var="link" context="unit" select="layout:Link[string(@sort) != 'true' and string(@scroll) != 'true']">
  119.                                 <wr:Visible>
  120.                                         <wr:Link class="link" position="position"/>
  121.                                 </wr:Visible>
  122.                             </wr:Iterate>
  123.                     </div>
  124.                     [%/* END LINKS*/%]
  125.                     </td>
  126.                    
  127.                 </tr>
  128.                
  129.                
  130.                 </c:forEach>
  131.                 [%/*END SHOW OBJECT*/%]
  132.                 </tbody>
  133.                 </table>
  134.                
  135.                 [%/*PAGINATION*/%]
  136.                  [% if (isScrollable == "true") { %]
  137.                     <c:if test="${<wr:UnitId/>.scroller.of gt [%= blockFactor %]}">
  138.                         <div class="pagination pagination-centered">
  139.                              <ul>
  140.                                 [% if (firstLink) { %]
  141.                                         <wr:Visible context="firstLink">
  142.                                             <c:if test="${<wr:UnitId/>.scroller.current ne <wr:UnitId/>.scroller.first}">
  143.                                                     <li><wr:Link  context="firstLink"/></li>
  144.                                             </c:if>
  145.                                         </wr:Visible>
  146.                                 [% } %]
  147.                                 [% if (previousLink) { %]
  148.                                         <wr:Visible context="previousLink">
  149.                                             <c:if test="${<wr:UnitId/>.scroller.current ne <wr:UnitId/>.scroller.previous}">
  150.                                                     <li><wr:Link  context="previousLink"/></li>
  151.                                             </c:if>
  152.                                         </wr:Visible>
  153.                                 [% } %]        
  154.                                 [% if (blockLink) {%]
  155.                                         <wr:Visible context="blockLink">
  156.                                             <c:forEach var="current" varStatus="status" items="${<wr:UnitId/>.scroller.blocks}">
  157.                                                 <c:set var="index" value="${status.index}"/>
  158.                                                     <c:choose>
  159.                                                         <c:when test="${current ne <wr:UnitId/>.scroller.current}">
  160.                                                            <li>
  161.                                                                 <a  href="<wr:URL context="blockLink"/>" onclick="<wr:AjaxURL context="blockLink" />">${current}</a>
  162.                                                             </li>
  163.                                                         </c:when>
  164.                                                         <c:otherwise>
  165.                                                             <li class="active"><a>${current}</a></span>
  166.                                                         </c:otherwise>
  167.                                                     </c:choose>
  168.                                             </c:forEach>
  169.                                         </wr:Visible>
  170.                                 [% } %]
  171.                                [% if (nextLink) { %]
  172.                                         <wr:Visible context="nextLink">
  173.                                             <c:if test="${<wr:UnitId/>.scroller.current ne <wr:UnitId/>.scroller.next}">
  174.                                                     <li><wr:Link  context="nextLink"/></li>
  175.                                             </c:if>
  176.                                         </wr:Visible>
  177.                                 [% } %]
  178.                                 [% if (lastLink) { %]
  179.                                         <wr:Visible context="lastLink">
  180.                                             <c:if test="${<wr:UnitId/>.scroller.current ne <wr:UnitId/>.scroller.last}">
  181.                                                 <li><wr:Link context="lastLink"/></li>
  182.                                             </c:if>
  183.                                         </wr:Visible>
  184.                                 [% } %]
  185.                                 </ul>
  186.                         </div>
  187.                     </c:if>
  188.                 [%}%]
  189.                 [%/*END PAGINATION*/%]
  190. <script type="text/javascript">
  191. (function($) { jQuery(document).on('ready', function() {
  192. $('a.editable').editable({
  193.     validate:function(value) {
  194.         var value =  unlocalizeNumber($.trim(value));
  195.         if(value == '') {
  196.             return '<wr:LocalizationString key="MandatoryValidationRule.error"/>';
  197.         }
  198.     },
  199.     getInputValue:function(value) {
  200.         return localizeNumber($.trim(this.$input.val()));
  201.     },
  202.     success:function(data) {
  203.        if (typeof data == 'object' && typeof data.value !== 'undefined') return;
  204.        else return messages["Error"];
  205.     },
  206.     error:function(data) {
  207.        return messages["Error"];
  208.     }
  209. });
  210. $('a[rel="popover"]').on('hover',function(){
  211.         var el=$(this).off('hover');
  212.         $.get(el.attr('data-load'),function(d){
  213.             el.popover({content: d}).popover('show');
  214.         });
  215. });
  216. })})(jQuery);
  217. </script>
  218.     </wr:Frame>
  219. [% if (useEmptyUnitMessage != "true") { %]
  220. </c:if>
  221. [% } else { %]
  222. </c:when>
  223. <c:otherwise>
  224.     <wr:Frame>
  225.         <div class="<wr:StyleClass/>"><bean:message key="[%printJSPTagValue(emptyUnitMessage)%]"/></div>
  226.     </wr:Frame>
  227. </c:otherwise>
  228. </c:choose>
  229. [% } %]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement