summaryrefslogtreecommitdiffstats
path: root/ipa-server/ipa-gui/ipagui/templates/dynamiceditsearch.kid
blob: 2407f66539879d36fe6ab311b2f2a3baf38834c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!-- 
 Copyright (C) 2007  Red Hat
 see file 'COPYING' for use and warranty information

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as
 published by the Free Software Foundation; version 2 only

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-->
<div xmlns:py="http://purl.org/kid/ns#">

<?python
from ipagui.helpers import ipahelper
#
# This file is used to render the results from an AJAX search onto a page.
# It has many expectations of the page being rendered into:
#   - Source page must have included dynamicedit.js and followed all of its
#     requirements
#
?>
    <div id="search-results-count">
    </div>
    <?python
    criteria_esc = ipahelper.javascript_string_escape(criteria)
    ?>
    <script type="text/javascript">
      search_string = "${criteria_esc}";
      results_counter = 0;
    </script>
    <?python search_div_counter = 1 ?>
    <div py:for="entities in (users, groups)">
      <div py:if='(entities != None) and (len(entities) > 0)'>
          <div py:for="entity in entities" id="search-${search_div_counter}">
            <?python
            ent_dn_esc = ipahelper.javascript_string_escape(entity.dn)
            ent_uid = entity.uid
            if ent_uid:
                ent_name = "%s %s" % (entity.getValue('givenName', ''),
                                      entity.getValue('sn', ''))
                ent_descr = "(%s)" % entity.uid
                ent_type = "user"
            else:
                ent_name = entity.cn
                ent_descr = "[group]"
                ent_type = "group"
            ent_name_esc = ipahelper.javascript_string_escape(ent_name)
            ent_descr_esc = ipahelper.javascript_string_escape(ent_descr)
            ent_type_esc = ipahelper.javascript_string_escape(ent_type)
            ?>
            <span id="search-info-${search_div_counter}"></span>
            <script type="text/javascript">
              if ((added_hash["${ent_dn_esc}"] == 1) ||
                  (member_hash["${ent_dn_esc}"] == 1)) {
                $("search-${search_div_counter}").style.display = 'none';
              } else {
                results_counter = results_counter + 1;
              }

              renderMemberInfo($('search-info-${search_div_counter}'),
                           new MemberDisplayInfo('${ent_name_esc}',
                                                 '${ent_descr_esc}',
                                                 '${ent_type_esc}'));
            </script>
            <a href=""
              onclick="addmemberHandler(this, '${ent_dn_esc}',
                           new MemberDisplayInfo('${ent_name_esc}',
                                                 '${ent_descr_esc}',
                                                 '${ent_type_esc}'));
                      return false;"
            >add</a>
            <?python
            search_div_counter = search_div_counter + 1
            ?>
          </div>
      </div>
    </div>
    <script type="text/javascript">
      if (results_counter == 0) {
        var message = "No results found for '" + search_string + "'";
      } else {
        var message =  results_counter + " results found:";
      }
      $('search-results-count').appendChild(document.createTextNode(message));
    </script>
    <script py:if="counter &lt; 0">
      $('search-results-count').appendChild(document.createTextNode(
        " (truncated)"));
    </script>
</div>