1. Zhang Huangbin
  2. iredadmin-ose

Commits

Zhang Huangbin  committed a32c35b

Use standalone js to implement check/uncheck all checkboxes.

  • Participants
  • Parent commits f0af87f
  • Branches default

Comments (0)

Files changed (7)

File controllers/ldap/domain.py

View file
  • Ignore whitespace
         domainName = i.get('domainName', None)
         if i.has_key('delete'):
             result = domainLib.delete(domains=domainName)
-            msg = 'DOMAIN_DELETED_SUCCESS'
+            msg = 'DELETED_SUCCESS'
         elif i.has_key('disable'):
             result = domainLib.enableOrDisableAccount(domains=domainName, value='disabled',)
-            msg = 'DOMAIN_DISABLED_SUCCESS'
+            msg = 'DISABLED_SUCCESS'
         elif i.has_key('enable'):
             result = domainLib.enableOrDisableAccount(domains=domainName, value='active',)
-            msg = 'DOMAIN_ENABLED_SUCCESS'
+            msg = 'ENABLED_SUCCESS'
         else:
             msg = i.get('msg', None)
 
                 data=i,
                 )
         if result[0] is True:
-            web.seeother('/profile/domain/%s/%s?msg=DOMAIN_PROFILE_UPDATED_SUCCESS' % (self.profile_type, self.domain) )
+            web.seeother('/profile/domain/%s/%s?msg=PROFILE_UPDATED_SUCCESS' % (self.profile_type, self.domain) )
         elif result[0] is False:
             web.seeother('/profile/domain/%s/%s?' % (self.profile_type, self.domain) + result[1])
 
     def POST(self):
         result = domainLib.add(data=i)
         if result[0] is True:
-            web.seeother('/domains?msg=DOMAIN_CREATED_SUCCESS')
+            web.seeother('/domains?msg=CREATED_SUCCESS')
         else:
             web.seeother('/create/domain?' + result[1])

File i18n/translation.sh

View file
  • Ignore whitespace
-#!/bin/sh
+#!/usr/bin/env bash
 
 # =========================================================
 # Author:    Zhang Huangbin (michaelbibby@gmail.com)
 # =========================================================
 
-ACTION="$1"
+# Available actions: [all, LANG].
+ACTIONORLANG="$1"
+
+if [ -z "${ACTIONORLANG}" ]; then
+    cat <<EOF
+
+Usage: $0 [all, LANGUAGE]
+
+Example:
+
+    $ $0 all
+    $ $0 zh_CN
+    $ $0 fr_Fr
+
+EOF
+    exit 255
+fi
 
 DOMAIN="iredadmin"
 POFILE="${DOMAIN}.po"
 AVAILABLE_LANGS="$(ls -d *_*)"
 
-if [ X"${ACTION}" == X"extract" ]; then
-    # Extract.
+extractLastest()
+{
+    # Extract strings from template files.
     echo "* Extract localizable messages from template files to ${POFILE}..."
     pybabel -v extract -F babel.cfg \
         --charset=utf-8 \
         --msgid-bugs-address=michaelbibby@gmail.com \
         -o ${POFILE} \
         .. >/dev/null
+}
 
-elif [ X"${ACTION}" == X"update" ]; then
-    # Update.
+updatePO()
+{
+    # Update PO files.
     echo "* Update existing new translations catalog based on ${POFILE}..."
-    for lang in ${AVAILABLE_LANGS}
+    for lang in ${LANGUAGES}
     do
+        [ -d ${lang}/LC_MESSAGES/ ] || mkdir -p ${lang}/LC_MESSAGES/
         pybabel update -i ${POFILE} \
             -D ${DOMAIN} \
             -d . \
             -l ${lang}
     done
+}
 
-elif [ X"${ACTION}" == X"convert" ]; then
+convertPO2MO()
+{
     echo "* Convert translation catalogs into binary MO files..."
-    for lang in ${AVAILABLE_LANGS}
+    for lang in ${LANGUAGES}
     do
         echo "  + Converting ${lang}..."
         python ./msgfmt.py ${lang}/LC_MESSAGES/${DOMAIN}.po
     done
-elif [ X"${ACTION}" == X"all" ]; then
-    bash $0 extract && \
-    bash $0 update && \
-    bash $0 convert
+}
+
+if [ X"${ACTIONORLANG}" == X"all" -o X"${ACTIONORLANG}" == X"" ]; then
+    export LANGUAGES="${AVAILABLE_LANGS}"
 else
-    :
+    export LANGUAGES="${ACTIONORLANG}"
 fi
+
+extractLastest && \
+updatePO && \
+convertPO2MO

File templates/default/ldap/admins.html

View file
  • Ignore whitespace
 
         <div class="frm-buttons">
             <span class="submit">
-                <input type="checkbox" id="checkall" />{{ _('Select/Unselect all') }}
+                <input type="checkbox" id="checkall" onClick="checkAll(list_table);" />{{ _('Select/Unselect all') }}
                 <input type="submit" name="delete" value="{{ _('Delete') }}" onclick="return confirm('{{ _('Are you sure want to delete selected account(s)?') }}');" }}" />
                 <input type="submit" name="disable" value="{{ _('Disable') }}" onclick="return confirm('{{ _('Are you sure want to disable selected account(s)?') }}');" }}" />
                 <input type="submit" name="enable" value="{{ _('Enable') }}" onclick="return confirm('{{ _('Are you sure want to enable selected account(s)?') }}');" }}" />

File templates/default/ldap/domains.html

View file
  • Ignore whitespace
     {% if session.get('domainGlobalAdmin') == 'yes' %}
         <div class="frm-buttons">
             <span class="submit">
-                <input type="checkbox" id="checkall" />{{ _('Select/Unselect all') }}
+                <input type="checkbox" id="checkall" onClick="checkAll(list_table);" />{{ _('Select/Unselect all') }}
                 <input type="submit" name="delete" value="{{ _('Delete') }}" onclick="return confirm('{{ _('Are you sure want to delete selected domain(s) and accounts under it?') }}');" }}" />
                 <input type="submit" name="disable" value="{{ _('Disable') }}" onclick="return confirm('{{ _('Are you sure want to disable selected domain(s)?') }}');" }}" />
                 <input type="submit" name="enable" value="{{ _('Enable') }}" onclick="return confirm('{{ _('Are you sure want to enable selected domain(s)?') }}');" }}" />

File templates/default/ldap/layout.html

View file
  • Ignore whitespace
     {% block jquery_docoment_ready %}
     <script type="text/javascript">
         $(document).ready(function() {
-            $("#list_table :checkbox").change(function() {
-                var chkAll = this;
-                if (chkAll.id == "checkall") {
-                    $("#list_table :checkbox").each(function() {
-                        this.checked = chkAll.checked;
-                    });
-                } else {
-                    $("#checkall")[0].checked = false;
-                }
-            });
-
             $("a,input,img").ToolTipDemo('#8dbdd8');
             {% block jquery_snippet_sorter %}
                 $("#account_list").tablesorter( {sortList: [[0,0]]} );
     {% endblock jquery_docoment_ready %}
 
     <script type="text/javascript">
+        checked=false;
+        function checkAll(list_table) {
+            var aa= document.getElementById('list_table');
+            if (checked == false) {
+                checked = true
+            } else {
+                checked = false
+            }
+            for (var i =0; i < aa.elements.length; i++) {
+                aa.elements[i].checked = checked;
+            }
+        }
+
         function changeDomain(domain, baseurl) {
             if ( domain.options[domain.selectedIndex].value != 'none' ) {
                 location.href = baseurl + domain.options[domain.selectedIndex].value;

File templates/default/ldap/msgHandlers.html

View file
  • Ignore whitespace
 {%- endmacro %}
 
 {% macro loginMsgHandler(msg) -%}
-{% if msg is not sameas none and msg|string != '' %}
+{% if msg is defined and msg is not sameas none and msg|string != '' %}
     {% if msg == 'INVALID_CREDENTIALS' %}
         {{ _errorInfo( _('Username or password is incorrect.') ) }}
     {% elif msg == 'INVALID_USERNAME' %}
 {%- endmacro %}
 
 {% macro domainMsgHandler(msg=none) -%}
-{% if msg is not sameas none and msg|string != '' %}
-    {% if msg == 'DOMAIN_CREATED_SUCCESS' %}
+{% if msg is defined and msg is not sameas none and msg|string != '' %}
+    {% if msg == 'CREATED_SUCCESS' %}
         {{ _successInfo( _('Domain was created.') ) }}
-    {% elif msg == 'DOMAIN_PROFILE_UPDATED_SUCCESS' %}
+    {% elif msg == 'PROFILE_UPDATED_SUCCESS' %}
         {{ _successInfo( _('Profile update success.') ) }}
-    {% elif msg == 'DOMAIN_DELETED_SUCCESS' %}
+    {% elif msg == 'DELETED_SUCCESS' %}
         {{ _successInfo( _('Selected domains were deleted.') ) }}
-    {% elif msg == 'DOMAIN_DISABLED_SUCCESS' %}
+    {% elif msg == 'DISABLED_SUCCESS' %}
         {{ _successInfo( _('Selected domains were diabled.') ) }}
-    {% elif msg == 'DOMAIN_ENABLED_SUCCESS' %}
+    {% elif msg == 'ENABLED_SUCCESS' %}
         {{ _successInfo( _('Selected domains were enabled.') ) }}
 
     {# Error handler #}
 {%- endmacro %}
 
 {% macro userMsgHandler(msg) -%}
-{% if msg is not sameas none and msg|string != '' %}
+{% if msg is defined and msg is not sameas none and msg|string != '' %}
     {% if msg == 'PROFILE_UPDATED_SUCCESS' %}
         {{ _successInfo( _('Profile updated success.') ) }}
     {% elif msg == 'UPDATED_FAILED' %}
 {%- endmacro %}
 
 {% macro adminMsgHandler(msg) -%}
-{% if msg is not sameas none and msg|string != '' %}
+{% if msg is defined and msg is not sameas none and msg|string != '' %}
     {% if msg == 'CREATED_SUCCESS' %}
         {{ _successInfo( _('Account created success. Would you like to <a href="%s/create/admin">add one more</a>?') |format(ctx.homepath) ) }}
     {% elif msg == 'PROFILE_UPDATED_SUCCESS' %}

File templates/default/ldap/users.html

View file
  • Ignore whitespace
 
     <div class="frm-buttons">
         <span class="submit">
-            <input type="checkbox" id="checkall" />{{ _('Select/Unselect all') }}
+            <input type="checkbox" id="checkall" onClick="checkAll(list_table);" />{{ _('Select/Unselect all') }}
             <input type="submit" name="delete" value="{{ _('Delete') }}" onclick="return confirm('{{ _('Are you sure want to delete selected account(s)?') }}');" }}" />
             <input type="submit" name="disable" value="{{ _('Disable') }}" onclick="return confirm('{{ _('Are you sure want to disable selected account(s)?') }}');" }}" />
             <input type="submit" name="enable" value="{{ _('Enable') }}" onclick="return confirm('{{ _('Are you sure want to enable selected account(s)?') }}');" }}" />