dashboard.jsp 2.34 KB
<%--
  ADOBE CONFIDENTIAL

  Copyright 2015 Adobe Systems Incorporated
  All Rights Reserved.

  NOTICE:  All information contained herein is, and remains
  the property of Adobe Systems Incorporated and its suppliers,
  if any.  The intellectual and technical concepts contained
  herein are proprietary to Adobe Systems Incorporated and its
  suppliers and may be covered by U.S. and Foreign Patents,
  patents in process, and are protected by trade secret or copyright law.
  Dissemination of this information or reproduction of this material
  is strictly forbidden unless prior written permission is obtained
  from Adobe Systems Incorporated.
--%><%
%><%@include file="/libs/granite/ui/global.jsp" %><%
%><%@page session="false"
          import="java.util.Iterator,
                  com.adobe.granite.ui.components.AttrBuilder,
                  com.adobe.granite.ui.components.Config,
                  com.adobe.granite.ui.components.Tag" %>
<%@ page import="org.apache.sling.api.resource.Resource" %>
<%@ page import="org.apache.sling.api.resource.ValueMap" %>
<%--###
Dashboard
=====

.. granite:servercomponent:: /libs/screens/dcc/components/granite/dashboard



   It has the following content structure:

   .. gnd:gnd::

      [granite:Dashboard] > granite:commonAttrs, granite:renderCondition


      /**
       *
       */
      + items

   Example::

      + mytile
        - sling:resourceType = "screens/dcc/components/granite/dashboard"
        + items
###--%><%

    if (!cmp.getRenderCondition(resource, false).check()) {
        return;
    }

    Config cfg = cmp.getConfig();

    Tag tag = cmp.consumeTag();

    AttrBuilder attrs = tag.getAttrs();
    cmp.populateCommonAttrs(attrs);

    attrs.add("layout", "dashboard");
    attrs.add("columnwidth", cfg.get("columnWidth", "500"));
    attrs.add("spacing", cfg.get("spacing", "20"));

%><coral-masonry <%= attrs.build() %>>
    <%
        Resource items = resource.getChild("items");
        if (items != null) {
            for (Iterator<Resource> it = items.listChildren(); it.hasNext();) {
                Resource item = it.next();

                ValueMap itemProp = item.adaptTo(ValueMap.class);
                int colspan = itemProp.get("colspan", 1);
    %><coral-masonry-item colspan="<%= colspan %>"><sling:include resource="<%= item %>" /></coral-masonry-item><%
        }
    }
    %>
</coral-masonry>