Changeset 5881


Ignore:
Timestamp:
04/04/12 15:36:26 (12 years ago)
Author:
marcieli
Message:

Ticket #2593 - Solução para impedir marcadores duplicados, entretanto preve melhorias.

Location:
trunk/prototype
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/config/label.ini

    r5533 r5881  
    88clearAllLabeledsOfLabel = modules/mail/interceptors/Helpers.php 
    99 
     10[before.create] 
     11verifyNameLabel = modules/mail/interceptors/Helpers.php 
     12 
    1013[PostgreSQL.mapping] 
    1114id = id 
  • trunk/prototype/modules/mail/interceptors/Helpers.php

    r5817 r5881  
    298298                //$result = Controller::update($imap_uri, $params, $criteria); 
    299299        } 
     300         
     301                 
     302        //label:before.create 
     303        public function verifyNameLabel(&$uri , &$params , &$criteria , $original){ 
     304                $nameLabel = $params['name']; 
     305                $Labels = Controller::find(array('concept' => 'label'), false, array('filter' => array('=', 'name', $nameLabel) )); 
     306                if($Labels){ 
     307                        //Throw new Exception('Marcador existe'); 
     308                        //$params['id'] = 'Marcador existe'; 
     309                        return false; 
     310                } 
     311        } 
    300312 
    301313} 
  • trunk/prototype/modules/mail/js/label.js

    r5824 r5881  
    134134                        }); 
    135135                        DataLayer.put('label', labelEdited.id, labelEdited); 
    136                         DataLayer.commit(false, false, function(){ 
    137                                  
    138                                 winElement.find(".insert-label").val(""); 
    139                                 $.Watermark.ShowAll(); 
    140                                  
    141                                 $(".label-list-container .label-list li").find('.button').button() 
    142                                         .filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end() 
    143                                         .filter('.close').button({icons:{primary:'ui-icon-close'}, text:false}); 
    144                                          
    145                                 winElement.find('.edit').unbind("click").click(editLabel);                               
    146                                 winElement.find('.close').click(deleteLabel); 
    147                                  
    148                                 draw_tree_labels(); 
    149                                 updateMessageLabels(labelEdited.id); 
    150                                  
    151                                 /** 
    152                                 * Atualiza menu remove o menu presente em cada mensagem listada em uma pasta  
    153                                 * e carrega novamente para que os dados sejam atualizados 
    154                                 */ 
    155                                 $.contextMenu( 'destroy', ".table_box tbody tr"); 
    156                                 loadMenu(); 
     136                        DataLayer.commit(false, false, function(data){ 
     137                                var hasLabel = true; 
     138                                        for(var i in data){ 
     139                                                if(parseInt(data[i].id)) 
     140                                                        hasLabel = false; 
     141                                        } 
     142                                        if(!hasLabel){ 
     143                                                winElement.find(".insert-label").val(""); 
     144                                                $.Watermark.ShowAll(); 
     145                                                 
     146                                                $(".label-list-container .label-list li").find('.button').button() 
     147                                                        .filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end() 
     148                                                        .filter('.close').button({icons:{primary:'ui-icon-close'}, text:false}); 
     149                                                         
     150                                                winElement.find('.edit').unbind("click").click(editLabel);                               
     151                                                winElement.find('.close').click(deleteLabel); 
     152                                                 
     153                                                draw_tree_labels(); 
     154                                                updateMessageLabels(labelEdited.id); 
     155                                                 
     156                                                /** 
     157                                                * Atualiza menu remove o menu presente em cada mensagem listada em uma pasta  
     158                                                * e carrega novamente para que os dados sejam atualizados 
     159                                                */ 
     160                                                $.contextMenu( 'destroy', ".table_box tbody tr"); 
     161                                                loadMenu(); 
     162                                        }else{ 
     163                                                $(".add-label-button").empty() 
     164                                                .addClass("ui-icon ui-icon-plus"); 
     165                                                alert('Problema ao salvar marcador.'); 
     166                                        } 
    157167                        }); 
    158168                // criar marcador 
     
    231241        .html('<img alt="Carregando" title="Carregando" style="margin-left:10px;" src="../prototype/modules/mail/img/loader.gif" />'); 
    232242         
    233         DataLayer.commit(false, false, function(){ 
    234  
    235                 labels = DataLayer.get('label',{criteria:{order: 'id'}}, true); 
    236                 newLabel = { 
    237                         id: labels[labels.length - 1].id,  
    238                         name : labels[labels.length- 1].name, 
    239                         uid: User.me.id, 
    240                         bgColor : !!isNew ? '#ebebeb' : winElement.find("input[name='backgroundColor']").val(), 
    241                         fontColor : !!isNew ? '#000000' : winElement.find("input[name='fontColor']").val(), 
    242                         borderColor : !!isNew ? '#000000' : winElement.find("input[name='borderColor']").val() 
    243                 }; 
    244                  
    245                 /** Marca as mensagens selecionadas com o marcador criado*/ 
    246                 if(apply){ 
    247                         labeledMessages(newLabel.id) 
    248                 } 
    249                  
    250                 $(".label-list-container ul").find(".empty-item").css("display","none"); 
    251                 $(".label-list-container ul") 
    252                 .prepend(DataLayer.render("../prototype/modules/mail/templates/label_listitem.ejs", newLabel)) 
    253                 .find("li:first") 
    254                 .fadeIn("slow").click(configureLabel); 
    255                  
    256                 draw_tree_labels(); 
    257  
    258                 $(".label-list-container .label-list li").not(".empty-item").click(function(){ 
    259                         $(".label-list-container .label-list li").find("img").remove(); 
    260                         $(".label-list-container .label-list li.label-item").removeClass("selected"); 
    261                         $(this).prepend("<img src='../prototype/modules/mail/img/triangle.png' style='margin: 0 5px 0 -5px;'>"); 
    262                         $(this).addClass("selected"); 
    263                 }); 
    264                  
    265                 $(".label-list-container .label-list li").find('.button').button() 
    266                 .filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end() 
    267                 .filter('.close').button({icons:{primary:'ui-icon-close'}, text:false}); 
    268                  
    269                 //posiciona para edição o label inserido                         
    270                 winElement.find("ul.label-list li:first").trigger("click");                      
    271                 winElement.find(".buttons .save-label .ui-button-text").text('Salvar'); 
    272                 $(".delete-label").button("enable"); 
    273                  
    274                 winElement.find('.edit').unbind("click").click(editLabel);                               
    275                 winElement.find('.close').click(deleteLabel); 
    276                  
    277                 $(".my-labels").show(); 
    278                  
    279                 $.contextMenu( 'destroy', ".table_box tbody tr"); 
    280                 loadMenu(); 
    281                  
    282                 $(".add-label-button").empty() 
    283                 .addClass("ui-icon ui-icon-plus"); 
     243        DataLayer.commit(false, false, function(data){ 
     244        var hasLabel = true; 
     245                for(var i in data){ 
     246                        if(parseInt(data[i].id)) 
     247                                hasLabel = false; 
     248                } 
     249                if(!hasLabel){ 
     250                        labels = DataLayer.get('label',{criteria:{order: 'id'}}, true); 
     251                        newLabel = { 
     252                                id: labels[labels.length - 1].id,  
     253                                name : labels[labels.length- 1].name, 
     254                                uid: User.me.id, 
     255                                bgColor : !!isNew ? '#ebebeb' : winElement.find("input[name='backgroundColor']").val(), 
     256                                fontColor : !!isNew ? '#000000' : winElement.find("input[name='fontColor']").val(), 
     257                                borderColor : !!isNew ? '#000000' : winElement.find("input[name='borderColor']").val() 
     258                                 
     259                        }; 
     260                 
     261                        /** Marca as mensagens selecionadas com o marcador criado*/ 
     262                        if(apply){ 
     263                                labeledMessages(newLabel.id) 
     264                        } 
     265                         
     266                        $(".label-list-container ul").find(".empty-item").css("display","none"); 
     267                        $(".label-list-container ul") 
     268                        .prepend(DataLayer.render("../prototype/modules/mail/templates/label_listitem.ejs", newLabel)) 
     269                        .find("li:first") 
     270                        .fadeIn("slow").click(configureLabel); 
     271                         
     272                        draw_tree_labels(); 
     273 
     274                        $(".label-list-container .label-list li").not(".empty-item").click(function(){ 
     275                                $(".label-list-container .label-list li").find("img").remove(); 
     276                                $(".label-list-container .label-list li.label-item").removeClass("selected"); 
     277                                $(this).prepend("<img src='../prototype/modules/mail/img/triangle.png' style='margin: 0 5px 0 -5px;'>"); 
     278                                $(this).addClass("selected"); 
     279                        }); 
     280                         
     281                        $(".label-list-container .label-list li").find('.button').button() 
     282                        .filter('.edit').button({icons:{primary:'ui-icon-pencil'}, text:false}).end() 
     283                        .filter('.close').button({icons:{primary:'ui-icon-close'}, text:false}); 
     284                         
     285                        //posiciona para edição o label inserido                         
     286                        winElement.find("ul.label-list li:first").trigger("click");                      
     287                        winElement.find(".buttons .save-label .ui-button-text").text('Salvar'); 
     288                        $(".delete-label").button("enable"); 
     289                         
     290                        winElement.find('.edit').unbind("click").click(editLabel);                               
     291                        winElement.find('.close').click(deleteLabel); 
     292                         
     293                        $(".my-labels").show(); 
     294                         
     295                        $.contextMenu( 'destroy', ".table_box tbody tr"); 
     296                        loadMenu(); 
     297                         
     298                        $(".add-label-button").empty() 
     299                        .addClass("ui-icon ui-icon-plus"); 
     300                }else{ 
     301                        $(".add-label-button").empty() 
     302                        .addClass("ui-icon ui-icon-plus"); 
     303                        alert('Problema ao salvar marcador.'); 
     304                } 
    284305        }); 
    285306} 
Note: See TracChangeset for help on using the changeset viewer.