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

Revision 5122, 2.5 KB checked in by viani, 12 years ago (diff)

Ticket #2304 - Incluído parâmetro useCCParams no plugin wf_select_ldap_users

  • 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, opt_complement, useCCParams)
12
13        // o parâmetro opt_complement foi acrescentado posteriormente a esta função, devido alguns métodos não utilizá-lo é
14        // necessário fazer o tratamento do mesmo caso não seja passado.
15        if(opt_complement == undefined)
16                opt_complement = '';
17
18/* Método que trata o retorno da chamada Ajax. Atribui os valores retornados à combobox */
19        function result_search_ldap_users_by_cn(data)
20        {
21                if (data['error'])
22                {
23                        alert(data['error'].replace(/<br \/>/gi, "\n"));
24                        if (data['url'])
25                                if (handleExpiredSessions)
26                                        window.location = data['url'].replace(/\.\./gi, ".");
27
28                        return;
29                }
30
31                if (data['msg'] != "")
32                {
33                        document.getElementById(data["target"] + "_span").hide();
34                        document.getElementById(data['target'] + "_img").hide();
35                        alert(data['msg']);
36                        return false;
37                }
38                else
39                {
40                        var container = document.getElementById(data["target"]);
41                        container.innerHTML = "";
42                        if(data['values'].length >= 1){
43                                container.disabled = true;
44                                fill_combo_employee(data["target"], data["values"]);
45                                container.disabled = false;
46                                document.getElementById(data["target"] + "_span").show();
47                                document.getElementById(data['target'] + "_img").hide();
48                                return true;
49                        }
50                }
51
52                return false;
53        }
54
55        var url = '$this.bo_utils.search_ldap_users_by_cn';
56        var param = "cn=" + cn + "&target=" + target + "&id=" + opt_id + "&name=" + opt_name + "&complement=" + opt_complement + "&useCCParams=" + useCCParams;
57
58        document.getElementById(target + "_img").show();
59
60        cExecute(url, result_search_ldap_users_by_cn, param);
61}
62
63/* Preenche a combo com os registros recuperados na chamada Ajax */
64function fill_combo_employee(target, values)
65{
66        var container = document.getElementById(target);
67
68        for (var i = 0; i < values.length; i++)
69        {
70                var option = document.createElement("option");
71                option.innerHTML = values[i].name;
72                option.value = values[i].id;
73                container.appendChild(option);
74        }
75}
Note: See TracBrowser for help on using the repository browser.