Changeset 1219 in main


Ignore:
Timestamp:
06/14/12 13:10:14 (7 years ago)
Author:
zali
Message:

Templates : search from left panel is performed asynchronously except in pages for link creation

Location:
trunk/openPLM
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/media/js/async_search.js

    r1215 r1219  
    11 
     2//update the results block 
    23function update_results(msg){ 
    34    var response = $(msg); 
    4     var hr_element = response.find("hr")[0]; 
     5     
     6    // get the results block 
    57    var res_div = response.find("div.Result")[0]; 
    68    $.each($(res_div).find("div.reference"), function(i,v){ 
     
    911        $(link).append(span_link); 
    1012    }); 
    11     var searchBox=$(res_div).parent()[0]; 
     13    /*var searchBox=$(res_div).parent()[0]; 
    1214    var searchBox_class = $(searchBox).attr("class"); 
    13     $("#SearchBox").attr("class",searchBox_class); 
     15    $("#SearchBox").attr("class",searchBox_class);*/ 
    1416    $("#SearchBox > div.Result").replaceWith(res_div); 
    15     $("#SearchBox hr").replaceWith(hr_element); 
    16     init(); 
    17  
     17    if($(res_div).attr("navigate")=="true"){ 
     18        init(); 
     19    } 
    1820} 
    1921 
     22//launch the search request asynchronously 
    2023function perform_search(){ 
    21     var url = location.href; 
    22     url = url.split("navigate")[0]; 
    23     url = url+"navigate/perform_search/"; 
    24     var data = "type=" + $("#search_id_type").val(); 
     24    var data ="navigate=" + $("div.Result").attr("navigate"); 
     25    data = data + "&type=" + $("#search_id_type").val(); 
    2526    data = data +"&q=" + $("#search_id_q").val(); 
    2627    $.ajax({ 
    2728        type : "GET", 
    28         url : url, 
     29        url : "/perform_search/", 
    2930        data : data, 
    3031        success : function(msg){ 
    3132            update_results(msg); 
    3233        }  
    33     }) 
     34    }); 
    3435} 
    3536 
    3637$(function(){ 
    37     $("#search_button").click(function(e){ 
    38         e.preventDefault(); 
    39         perform_search(); 
     38    $("#SearchBox #search_button").click(function(e){ 
     39        if($("div.Result").attr("link_creation")!="true"){ 
     40            e.preventDefault(); 
     41            perform_search(); 
     42        } 
    4043    }); 
    4144}) 
  • trunk/openPLM/plmapp/views/main.py

    r1216 r1219  
    21542154 
    21552155@handle_errors 
    2156 def async_search(request, obj_type, obj_ref, obj_revi): 
     2156def async_search(request): 
    21572157    """Perform search_request asynchronously""" 
    21582158    obj,ctx = get_generic_data(request) 
    2159     ctx["navigate_bool"]=True 
     2159    if request.GET["navigate"]=="true" : 
     2160        ctx["navigate_bool"]=True 
    21602161    return r2r("render_search.html",ctx,request) 
  • trunk/openPLM/templates/base.html

    r1184 r1219  
    3030        <script type="text/javascript" src="/media/js/panels.js"></script> 
    3131        <script type="text/javascript" src="/media/js/confirm.js"></script> 
     32        <script type="text/javascript" src="/media/js/async_search.js"></script> 
    3233 
    3334 
  • trunk/openPLM/templates/blocks/search.html

    r995 r1219  
    1414    {% trans "Results for link creation:" %} 
    1515{% endif %} 
    16 <div class="Result"> 
     16<div class="Result" link_creation= 
     17    {% if link_creation %} 
     18    "true"  
     19    {% else %} 
     20    "false"  
     21    {% endif %}  
     22     navigate= 
     23    {% if navigate_bool %} 
     24    "true" 
     25    {% else %} 
     26    "false" 
     27    {% endif %} > 
    1728    {% for result in results %} 
    1829 
  • trunk/openPLM/urls.py

    r1215 r1219  
    9191    # browse 
    9292    (r'^browse/(?P<type>object|part|document|user|group)?/', 'openPLM.plmapp.views.main.browse'), 
     93    (r'^perform_search/$',async_search), 
    9394    ) 
    9495 
     
    132133    (r'management/delete/$', delete_management), 
    133134    (r'navigate/$', navigate), 
    134     (r'navigate/perform_search/$', async_search), 
    135135    (r'(?:files/|doc-cad/)?archive/$', download_archive), 
    136136    (r'public/$', public), 
     
    152152    (r'password/$', change_user_password), 
    153153    (r'navigate/$', navigate, user_dict), 
    154     (r'navigate/perform_search/$', async_search, user_dict), 
    155154    (r'groups/$', display_groups), 
    156155) 
     
    162161    (r'objects/$', display_plmobjects), 
    163162    (r'navigate/$', navigate, group_dict), 
    164     (r'navigate/perform_search/$', async_search,group_dict), 
    165163    (r'users/$', display_users), 
    166164    (r'users/add/$', group_add_user), 
Note: See TracChangeset for help on using the changeset viewer.