source: trunk/workflow/js/jscode/wf_select_ldap_users.js @ 795

Revision 795, 2.2 KB checked in by viani, 15 years ago (diff)

Ticket #488 - Inclusão do módulo workflow no ramo trunk do repositório Expresso.

  • Property svn:executable set to *
Line 
1/************************************************************
2 * Métodos utilizados pelo componente wf_select_ldap_users. *
3 ************************************************************/
4
5/* Método que faz a chamada Ajax para buscar os registros
6 * @param String cn Parte do nome a ser procurado no LDAP
7 * @param String target id da combo onde os registros serão inseridos
8 * @param String opt_id Atributo que será atribuído ao id (value) das options da combo, por padrão é o 'dn'
9 * @param String opt_name Atributo que será atribuído ao name (innerHTML) das options da combo, por padrão é o 'cn'
10 */
11function search_ldap_users_by_cn(cn, target, opt_id, opt_name, handleExpiredSessions)
12{
13/* Método que trata o retorno da chamada Ajax. Atribui os valores retornados à combobox */
14        function result_search_ldap_users_by_cn(data)
15        {
16                if (data['error'])
17                {
18                        alert(data['error'].replace(/<br \/>/gi, "\n"));
19                        if (data['url'])
20                                if (handleExpiredSessions)
21                                        window.location = data['url'].replace(/\.\./gi, ".");
22
23                        return;
24                }
25
26                if (data['msg'] != "")
27                {
28                        document.getElementById(data["target"] + "_span").hide();
29                        document.getElementById(data['target'] + "_img").hide();
30                        alert(data['msg']);
31                        return false;
32                }
33                else
34                {
35                        var container = document.getElementById(data["target"]);
36                        container.innerHTML = "";
37                        if(data['values'].length > 1){
38                                container.disabled = true;
39                                fill_combo_employee(data["target"], data["values"]);
40                                container.disabled = false;
41                                document.getElementById(data["target"] + "_span").show();
42                                document.getElementById(data['target'] + "_img").hide();
43                                return true;
44                        }
45                }
46        }
47
48        var url = '$this.bo_utils.search_ldap_users_by_cn';
49        var param = "cn=" + cn + "&target=" + target + "&id=" + opt_id + "&name=" + opt_name;
50
51        document.getElementById(target + "_img").show();
52
53        cExecute(url, result_search_ldap_users_by_cn, param);
54}
55
56/* Preenche a combo com os registros recuperados na chamada Ajax */
57function fill_combo_employee(target, values)
58{
59        var container = document.getElementById(target);
60
61        for (var i = 0; i < values.length; i++)
62        {
63                var option = document.createElement("option");
64                option.innerHTML = values[i].name;
65                option.value = values[i].id;
66                container.appendChild(option);
67        }
68}
Note: See TracBrowser for help on using the repository browser.