<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      lang="en"
      metal:use-macro="context/prefs_main_template/macros/master"
      i18n:domain="plone">

<body>

<metal:main fill-slot="prefs_configlet_content"
     tal:define="errors python:request.get('errors', {});
                 portal_roles python:context.portal_membership.getPortalRoles();
                 mq python:modules['ZTUtils'].make_query;
                 groupname request/groupname | nothing;
                 groupquery python:mq(groupname=groupname);
                 groupkeyquery python:mq(key=groupname);
                 grouproles python:request.set('grouproles', []);
                 gtool context/portal_groups;
                 group python:gtool.getGroupById(groupname);
                 grouptitle group/getGroupTitleOrName | nothing;
                 portal_url context/portal_url;">

    <tal:conditional condition="group">
        <tal:defines define="dummy python:request.set('grouproles', group.getRoles())" />
    </tal:conditional>

    <div class="documentEditable">
        <!-- simulating views on the groups/user pages until we have real objects. -->
        <div id="edit-bar">
            <ul class="contentViews" id="content-views">
              <li>
                <a href=""
                   tal:attributes="href string:$portal_url/@@usergroup-groupmembership?${groupquery}"
                   i18n:translate="label_group_members">Group Members</a>
              </li>
              <li class="selected">
                <a href=""
                   tal:attributes="href string:$portal_url/${template/getId}?${groupquery}"
                   i18n:translate="label_group_properties">Group Properties</a>
              </li>
              <li>
                <a href=""
                   tal:attributes="href string:${portal_url}/@@manage-group-portlets?${groupkeyquery}"
                   i18n:translate="label_group_portlets">Group Portlets</a>
              </li>
              <li>
                <a href=""
                   tal:attributes="href string:${portal_url}/@@manage-group-dashboard?${groupkeyquery}"
                   i18n:translate="label_group_dashboard">Group Dashboard</a>
              </li>

            </ul>

            <div class="contentActions">&nbsp;</div>
        </div>

        <div metal:use-macro="context/global_statusmessage/macros/portal_message">
          Portal status message
        </div>

        <!-- When no group is specified, this gets used as the add group page page -->
        <div id="content" tal:condition="not:group | nothing">
            <metal:block metal:use-macro="template/macros/props">
                <metal:title metal:fill-slot="content-title">
                    <h1 class="documentFirstHeading"
                        i18n:translate="heading_create_group">Create a Group</h1>
                </metal:title>

                <metal:name metal:fill-slot="name">
                    <div class="field">
                        <label for="addname" i18n:translate="label_name">Name</label>

                        <span class="fieldRequired" title="Required"
                              i18n:attributes="title title_required;"
                              i18n:translate="label_required">(Required)</span>

                         <div class="formHelp" i18n:translate="help_groupname">
                         A unique identifier for the group. Can not be changed after creation.
                         </div>

                        <input type="text" name="addname" value="groupname"
                               id="addname"
                               tal:attributes="value group/getGroupName | string:"/>
                    </div>
                </metal:name>
            </metal:block>
        </div>

        <div id="content" tal:condition="group | nothing">
            <metal:block define-macro="props">

                <h1 class="documentFirstHeading"
                    i18n:translate="heading_edit_groupproperties"
                    metal:define-slot="content-title">
                    Edit Group Properties for <span tal:content="grouptitle | default" tal:omit-tag="" i18n:name="groupname">unavailable</span>
                </h1>

                <div class="documentDescription" i18n:translate="description_edit_groupproperties">
                Groups are logical collections of users, like departments and business units.
                They are not directly related to permissions on a global level, you normally
                use Roles for that - and let certain Groups have a particular role.
                </div>

                <div id="content-core">
                    <a href=""
                       class="link-parent"
                       tal:attributes="href string:$portal_url/@@usergroup-groupprefs"
                       i18n:translate="label_up_to_groups_overview">
                       Up to Groups Overview
                    </a>

                    <form action=""
                          id="createGroup"
                          name="groups"
                          method="post"
                          class="enableUnloadProtection enableAutoFocus"
                          tal:attributes="action string:${gtool/absolute_url}"
                          tal:define="targetobject context/portal_groupdata;
                                      targetGetProperty nocall:group/getProperty | nocall:context/returnNone;">

                        <fieldset>
                            <legend i18n:translate="link_group_properties">Group Properties</legend>

                            <div class="field" metal:define-slot="name">
                               <label for="groupname" i18n:translate="label_name">Name</label>

                               <div tal:content="group/getGroupName | string:" />
                               <input type="hidden" name="groupname" value="groupname" id="groupname"
                                             tal:attributes="value group/getGroupName | string:"/>
                            </div>

                             <tal:set tal:condition="targetobject/management_page_charset|nothing"
                                      tal:define="dummy python:request.set('management_page_charset_tag','')" />

                             <tal:set tal:condition="not:targetobject/management_page_charset|nothing">
                                <tal:defines define="dummy python:request.set('management_page_charset','UTF-8');
                                                     dummy python:request.set('management_page_charset_tag','UTF-8:');" />
                             </tal:set>

                            <tal:properties repeat="property targetobject/propertyMap">
                                <div class="field"
                                     tal:define="id property/id;
                                                 type property/type;
                                                 propertyvalue python:targetGetProperty(id, None);">

                                <label for="value"
                                        tal:attributes="for id"
                                        i18n:translate=""
                                        tal:content="python:targetobject.propertyLabel(id).capitalize()">Property Value</label>

                                <div tal:define="propertyitem python:targetobject.getProperty(id);
                                                 disabled python:(not group or group.canWriteProperty(id)) and default or 'disabled';"
                                tal:condition="python:'w' in property.get('mode', 'awd')">

                                <input type="text" name="id" size="35"
                                        tal:condition="python:type in ('int', 'long')"
                                        tal:attributes="name string:$id:$type;
                                                        id id;
                                                        value python:test(propertyvalue, propertyvalue, '');
                                                        disabled disabled;" />

                                <input type="text" name="id" size="35"
                                        tal:condition="python:type in ('float','date')"
                                        tal:attributes="name string:$id:${request/management_page_charset_tag}$type;
                                                        id id;
                                                        value python:test(propertyvalue, propertyvalue, '');
                                                        disabled disabled;" />

                                <input type="text" name="string and ustring" size="35"
                                        tal:condition="python:type in ('string','ustring')"
                                        tal:attributes="name string:$id:${request/management_page_charset_tag}$type;
                                                        id id;
                                                        value python:test(propertyvalue, propertyvalue, '');
                                                        disabled disabled;" />

                                <input type="checkbox"
                                        class="noborder"
                                        name="id"
                                        id="cb-checkbox"
                                        tal:condition="python: type in ('boolean',)"
                                        tal:attributes="name string:$id:$type;
                                                        id id;
                                                        checked python:test(propertyvalue, 'checked', '');
                                                        disabled disabled;" />

                                <input name="tokens and utokens" value="" type="text" size="35"
                                        tal:condition="python:type in ('tokens', 'utokens')"
                                        tal:attributes="name string:$id:${request/management_page_charset_tag}$type;
                                                        value python:test(propertyvalue, propertyvalue, '');
                                                        disabled disabled;" />

                                <textarea name="text and utext"
                                        rows="6"
                                        cols="35"
                                        tal:condition="python: type in ('text', 'utext')"
                                        tal:attributes="name string:$id:${request/management_page_charset_tag}$type;
                                                        disabled disabled;"
                                        tal:content="propertyvalue">some data</textarea>

                                <textarea name="lines and ulines"
                                        rows="6"
                                        cols="35"
                                        tal:condition="python: type in ('lines', 'ulines')"
                                        tal:attributes="name string:$id:${request/management_page_charset_tag}$type;
                                                        disabled disabled;"
                                        tal:content="python: propertyvalue and '\n'.join(propertyvalue) or ''">
                                </textarea>


                                <tal:selections tal:condition="python:type in ('selection', 'multiple selection')"
                                                tal:define="select_variable python:property.get('select_variable','');
                                                select_value python:select_variable and path('context/%s' %select_variable) or [];">

                                <select name="selection" tal:condition="python:type in ('selection',)"
                                    tal:attributes="name string:$id:${request/management_page_charset_tag}text;
                                                    disabled disabled;">
                                    <tal:values repeat="option select_value">
                                        <option tal:attributes="SELECTED python:test(propertyvalue==option,'SELECTED','')"
                                            tal:content="option">value</option>
                                    </tal:values>
                                </select>

                                <select name="multiple selection" multiple="multiple" tal:condition="python:type in ('multiple selection',)"
                                        tal:attributes="name string:$id:${request/management_page_charset_tag}list:string;
                                                        size python:min(7, len(select_value));
                                                        disabled disabled;">
                                    <tal:values repeat="option select_value">
                                        <option tal:attributes="SELECTED python:test(propertyvalue and option in propertyvalue,
                                                                                    'selected', '')"
                                                tal:content="option">value</option>
                                    </tal:values>
                                </select>

                                </tal:selections>

                                </div>

                                </div>
                            </tal:properties>

                            <div class="formControls">
                                <input class="context"
                                       type="submit"
                                       name="prefs_group_edit:method"
                                       value="Save"
                                       i18n:attributes="value label_save;" />
                            </div>
                        </fieldset>
                    </form>
                </div>
            </metal:block>
        </div>


    </div>

</metal:main>

</body>
</html>

