<metal:macro define-macro="portlet-edit">
    <li tal:define="hash request/portlethash;
                     html python:request.get('portlethtml-%s' % hash);"
        tal:attributes="id string:portleteditwrapper-${hash};
                         hash hash;">

        <div tal:attributes="id string:portletbody-${hash};">
            <div id="iframe-spinner">
                <img tal:attributes="src string:${portal_url}/spinner.gif" alt="" />
                <br/>
                <br/>
            </div>
            <iframe class="portlet_edit_iframe" 
                    style="display: none"
                    scrolling="NO"
                    frameborder="0"
                    tal:attributes="src request/iframe_url;
                                    id string:iframe-$hash;
                                    ">
            </iframe>
        </div>
    </li>
</metal:macro>

<metal:macro define-macro="current-portlets-list">
    <ul class="portlets-manager column"
         tal:attributes="id view/manager_name;">

    <tal:block repeat="portlet options/portlets">
    <li class="draggable dp-portlet" 
         tal:define=" hash portlet/hash;"
         tal:attributes="id string:portletwrapper-${hash};
                         hash hash;">

        <div class="portlet-controls"  
              tal:attributes="id string:portlet-controls-${hash}" style="display:None">
            <span style="cursor:pointer"
                 class="toggle-dashboard-portlet
                        min-dashboard-portlet"
                 tal:attributes="
                    id string:portlet-toggle-${hash}; 
                    onclick string:togglePortlet(this, '${hash}');">
                    &nbsp;
            </span>
            <br clear="all"/>
        </div>

        <div tal:attributes="id string:portletbody-${hash};">
            <tal:body replace="structure python:view.safe_render(portlet['renderer'])" />
        </div>
    </li>
    </tal:block>
    </ul>
</metal:macro>

<metal:macro define-macro="current-editable-portlets-list">
    <ul class="portlets-manager column"
        tal:attributes="id view/manager_name;
                        class string:kssattr-manager-${view/manager_name} 
                                     portlets-manager droppable column"> 

    <tal:block repeat="portlet options/portlets">
    <metal:macro define-macro="portlet-manage-view">
    <li class="draggable dp-portlet" 
         tal:define="
            hash portlet/hash|request/portlethash;
            phtml python:request.form.get('portlethtml-%s' % hash);
            html python: phtml or view.safe_render(portlet['renderer']);
            editable portlet/editview|python:phtml and True or False"
         tal:attributes="id string:portletwrapper-${hash};
                         hash hash;">

        <div class="portlet-controls"  
              tal:attributes="id string:portlet-controls-${hash}" style="display:None">
            <span style="cursor:pointer"
                 class="toggle-dashboard-portlet
                        min-dashboard-portlet"
                 tal:attributes="
                    id string:portlet-toggle-${hash}; 
                    onclick string:togglePortlet(this, '${hash}');">
                    &nbsp;
            </span>
            <span class="remove-dashboard-portlet"
                 tal:attributes="onclick string:removePortlet(this);"
                 confirm_title="Confirm Deletion"
                 confirm_message="Are you sure you want to remove this portlet?"
                 i18n:domain="collective.idashboard"
                 i18n:attributes="confirm_title portlet-remove-confirm-title;
                                  confirm_message portlet-remove-confirm-message">
                    &nbsp;
            </span>
            <span tal:condition="editable"   
                 class="edit-dashboard-portlet"
                 tal:attributes="onclick string:configurePortlet(this);">
                    &nbsp;
            </span>
            <br clear="all"/>
        </div>
        <div class="dp-portletbody"
            tal:attributes="id string:portletbody-${hash};">
            <tal:body replace="structure html" />
        </div>
    </li>
    </metal:macro>
    </tal:block>
    </ul>
</metal:macro>
