Ignore:
Timestamp:
06/22/12 18:01:36 (12 years ago)
Author:
gustavo
Message:

Ticket #2766 - Arrumado a configuracao de limite de contatos dinamicos

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/js/draw_api.js

    r6580 r6592  
    99 */ 
    1010onceOpenedHeadersMessages = {}; 
    11  
     11var cache = new Array(); 
    1212var openTab = { 
    1313        'type' : [], // 8 types of tabs, further info. see expressolivre.org/dev/wiki/mail/Documentacao 
     
    35513551 
    35523552//DESENHO DAS CAIXA DE EMAIL 
    3553 function draw_email_box(input_data, location, personal){ 
     3553function draw_email_box(input_data, location, personal, shared){ 
    35543554        if($.trim(input_data) != ""){ 
    35553555                var box_data = valid_emails(input_data); 
     
    35593559                        if((preferences.expressoMail_ldap_identifier_recipient || personal)&& $(newBox).hasClass("invalid-email-box")){ 
    35603560                                //$(newBox).find(".loading").css("background-image", "../prototype/modules/mail/img/ajax-loader.gif"); 
    3561                                 show_detais(newBox, input_data, personal); 
     3561                                show_detais(newBox, input_data, personal, shared); 
    35623562                        }else{ 
    35633563                                $(newBox).find(".box-loading").remove(); 
     
    38553855 
    38563856//MOSTRA OS DETALHES DAS CAIXA DE EMAIL NOS CAMPOS PARA - CC - CCO 
    3857 function show_detais(box, value, personal){ 
     3857function show_detais(box, value, personal, shared){ 
    38583858        var ldap_id = preferences.expressoMail_ldap_identifier_recipient; 
    38593859        var group = (personal != undefined ? (personal == "G" ? true : false) : false); 
    3860          
     3860        shared = shared ? shared : false; 
    38613861        if(group){ 
    3862                 REST.get("/group/"+value, {}, function(data){ 
     3862                REST.get("/"+ (shared ? "shared" : "") +"group/"+value, {}, function(data){ 
    38633863                        if(!data.error){ 
    38643864                                if(data.collection.error) 
     
    38863886         
    38873887        if(personal){ 
    3888                 REST.get("/contact/"+value, {}, function(data){ 
     3888                REST.get("/"+ (shared ? "shared" : "") +"contact/"+value, {}, function(data){ 
    38893889                        if(!data.error){ 
    38903890                                if(data.collection.error) 
     
    39893989                                currentType = ""; 
    39903990                                $.each( items, function( index, item ) { 
    3991                                         if ( item.type != currentType) { 
    3992                                                 if(item.type == "G" && $(ul).find(".dynamic-recent").length) 
     3991                                        if ( item.typel != currentType) { 
     3992                                                if(item.typel == "/groups" && $(ul).find(".dynamic-recent").length) 
    39933993                                                        self._renderItem( ul, {name:"", value:"", type:"linha"} ); 
    3994                                                 if(item.type == "P" && ($(ul).find(".dynamic-group").length || $(ul).find(".dynamic-recent").length)) 
     3994                                                if(item.typel == "/contacts" && ($(ul).find(".dynamic-group").length || $(ul).find(".dynamic-recent").length)) 
    39953995                                                        self._renderItem( ul, {name:"", value:"", type:"linha"} );       
    3996                                                 currentType = item.type; 
     3996                                                currentType = item.typel; 
    39973997                                        } 
    39983998                                        self._renderItem( ul, item ); 
     
    40014001                                                half : true, 
    40024002                                                hints : ['','','','',''], 
    4003                                                 score    : ((parseInt(item.qtd)*5)/topContact), 
     4003                                                score    : ((item.number_of_messages*5)/topContact), 
    40044004                                                starOn  : '../../prototype/plugins/jq-raty/img/star-on.png', 
    40054005                                                starOff : '../../prototype/plugins/jq-raty/img/star-off.png', 
     
    40074007                                        }); 
    40084008                                }); 
     4009                                if($(ul).find("li:last").hasClass("dynamic-separator")){ 
     4010                                        $(ul).find("li:last").remove(); 
     4011                                } 
    40094012                        } 
    40104013                }); 
     
    40134016                        minLength: 1,                    
    40144017                        source: function(request, response){ 
    4015                                 response( $.ui.autocomplete.filter(dynamicContactList, request.term ) ); 
     4018                                if ( request.term in cache ) { 
     4019                                        response( cache[ request.term ] ); 
     4020                                        return; 
     4021                                } 
     4022                                dynamicContacts = new Array(); 
     4023                                REST.get("/usercontacts", false, function(data){ 
     4024                                        dynamicData = data.collection.itens; 
     4025                                        if(dynamicData){ 
     4026                                                $.each(dynamicData, function(index, value){ 
     4027                                                        dynamic = {}; 
     4028                                                        $.each(value.data, function(index, value){ 
     4029                                                                dynamic[value.name] = value.value; 
     4030                                                        }); 
     4031                                                        dynamic['value'] = (dynamic.name ? dynamic.name +' - ': '') + dynamic.mail; 
     4032                                                        dynamic['type'] = value.dataType; 
     4033                                                        dynamic['typel'] = (value.dataType.substring(0,7) == "/shared" ? "/"+value.dataType.substring(7,value.dataType.length)+"s" : value.dataType) ; 
     4034                                                        dynamicContacts.push(dynamic); 
     4035                                                }); 
     4036                                        } 
     4037                                        var data = $.ui.autocomplete.filter(dynamicContacts, request.term ); 
     4038                                        cache[ request.term ] = data; 
     4039                                        response( data ); 
     4040                                }); 
    40164041                        }, 
    40174042                        focus: function() { 
     
    40234048                                event.preventDefault(); 
    40244049                                $(this).val(""); 
    4025                                 if(ui.item.type == "P") 
    4026                                         draw_email_box(""+ui.item.id, $(this), true); 
    4027                                 else if(ui.item.type == "G") 
    4028                                         draw_email_box(""+ui.item.id, $(this), "G"); 
     4050                                if(ui.item.typel == "/contacts") 
     4051                                        draw_email_box(""+ui.item.id, $(this), true, (ui.item.type.substring(0,7) == "/shared" ? true : false)); 
     4052                                else if(ui.item.typel == "/groups") 
     4053                                        draw_email_box(""+ui.item.id, $(this), "G", (ui.item.type.substring(0,7) == "/shared" ? true : false)); 
    40294054                                else 
    4030                                         draw_email_box(ui.item.name ? "\""+ui.item.name+"\" <"+ui.item.email+">" : ui.item.email, $(this)); 
     4055                                        draw_email_box(ui.item.name ? "\""+ui.item.name+"\" <"+ui.item.mail+">" : ui.item.mail, $(this)); 
    40314056                                return false; 
    40324057                        }, 
     
    40414066                //MONTAGEM DA LISTA DE CONTATOS DINÂMICOS DO AUTO COMPLETE 
    40424067                .data( "catcomplete" )._renderItem = function( ul, item ) { 
    4043                         var autocomplete = $(this)[0].element; 
    4044                         ul.css({"min-width":"400px", "width":"50%", "max-height" : "180px", "overflow-y" : "auto", "min-height": "30px"}); 
    4045                         var listContacts = DataLayer.render("../prototype/modules/mail/templates/listContacts.ejs", item); 
    4046                         return $(listContacts).data( "item.autocomplete", item ).appendTo( ul ).find("span:last").button({ 
    4047                                         icons : { 
    4048                                         primary : "ui-icon-close" 
    4049                                 }, 
    4050                                 text: false 
    4051                         }).click(function(event){ 
    4052                                 var removeLi = $(this).parents("li:first"); 
    4053                                 if(!event.keyCode) 
    4054                                         autocomplete.catcomplete( "close" ); 
    4055                                 $.Zebra_Dialog('Deseja remover <b>'+(item.name ? item.name+" - " : "")+ item.email+'</b>?', { 
    4056                                                 'type':     'question', 
    4057                                                 'custom_class': (is_ie ? 'configure-zebra-dialog' : ''), 
    4058                                                 'title':    'Atenção', 
    4059                                                 'buttons': ['Sim','Não'],                
    4060                                                 'overlay_opacity': '0.5', 
    4061                                                 'onClose':  function(caption) { 
    4062                                                         if(caption == 'Sim'){ 
    4063                                                                 $(removeLi).remove(); 
    4064                                                                 REST.delete("/dynamiccontact/"+item.id); 
    4065                                                                 updateDynamicContact(); 
    4066                                                                 updateDynamicContactList(); 
     4068                        if($(ul).find("li").length < 50){ 
     4069                                var autocomplete = $(this)[0].element; 
     4070                                ul.css({"min-width":"500px", "width":"50%", "max-height" : "180px", "overflow-y" : "auto", "min-height": "30px"}); 
     4071                                var listContacts = DataLayer.render("../prototype/modules/mail/templates/listContacts.ejs", item); 
     4072                                return $(listContacts).data( "item.autocomplete", item ).appendTo( ul ).find("span:last").button({ 
     4073                                                icons : { 
     4074                                                primary : "ui-icon-close" 
     4075                                        }, 
     4076                                        text: false 
     4077                                }).click(function(event){ 
     4078                                        var removeLi = $(this).parents("li:first"); 
     4079                                        if(!event.keyCode) 
     4080                                                autocomplete.catcomplete( "close" ); 
     4081                                        $.Zebra_Dialog('Deseja remover <b>'+(item.name ? item.name+" - " : "")+ item.email+'</b>?', { 
     4082                                                        'type':     'question', 
     4083                                                        'custom_class': (is_ie ? 'configure-zebra-dialog' : ''), 
     4084                                                        'title':    'Atenção', 
     4085                                                        'buttons': ['Sim','Não'],                
     4086                                                        'overlay_opacity': '0.5', 
     4087                                                        'onClose':  function(caption) { 
     4088                                                                if(caption == 'Sim'){ 
     4089                                                                        $(removeLi).remove(); 
     4090                                                                        REST.delete("/dynamiccontact/"+item.id); 
     4091                                                                        updateDynamicContact(); 
     4092                                                                        updateDynamicContactList(); 
     4093                                                                        cache = new Array(); 
     4094                                                                } 
    40674095                                                        } 
    4068                                                 } 
     4096                                        }); 
    40694097                                }); 
    4070                         }); 
     4098                        } 
     4099                        return; 
    40714100                }; 
    40724101        } 
Note: See TracChangeset for help on using the changeset viewer.