Commit a289d28acfb57936634f441727eedb3d1e7ca60f

Authored by Fabio Teixeira
1 parent b15b9498

Link_List_Block_Improvements: Merge request corrections

(ActionItem2582)

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
app/controllers/box_organizer_controller.rb
@@ -84,7 +84,7 @@ class BoxOrganizerController &lt; ApplicationController @@ -84,7 +84,7 @@ class BoxOrganizerController &lt; ApplicationController
84 if request.xhr? and params[:query] 84 if request.xhr? and params[:query]
85 search = params[:query] 85 search = params[:query]
86 articles = @profile.articles.find(:all, :conditions=>"name ILIKE '%#{search}%' or path ILIKE '%#{search}%'", :limit=>20) 86 articles = @profile.articles.find(:all, :conditions=>"name ILIKE '%#{search}%' or path ILIKE '%#{search}%'", :limit=>20)
87 - path_list = articles.map { |content| content.path } 87 + path_list = articles.map { |content| "/{profile}/"+content.path }
88 88
89 render :json => path_list.to_json 89 render :json => path_list.to_json
90 else 90 else
app/views/box_organizer/_link_list_block.rhtml
@@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
25 <%= select_tag('block[links][][target]', options_for_select(LinkListBlock::TARGET_OPTIONS, link[:target])) %> 25 <%= select_tag('block[links][][target]', options_for_select(LinkListBlock::TARGET_OPTIONS, link[:target])) %>
26 </li> 26 </li>
27 <li> 27 <li>
28 - <%= button_without_text("", _('Delete'), "#" , :class=>"icon-delete delete-link-list-row") %> 28 + <%= button_without_text(:delete, _('Delete'), "#" , :class=>"delete-link-list-row") %>
29 </li> 29 </li>
30 </ul> 30 </ul>
31 </li> 31 </li>
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
42 content_tag('li', text_field_tag('block[links][][address]', nil, :class => 'link-address')) + 42 content_tag('li', text_field_tag('block[links][][address]', nil, :class => 'link-address')) +
43 content_tag('li', select_tag('block[links][][target]', 43 content_tag('li', select_tag('block[links][][target]',
44 options_for_select(LinkListBlock::TARGET_OPTIONS, '_self'))) + 44 options_for_select(LinkListBlock::TARGET_OPTIONS, '_self'))) +
45 - content_tag('li', button_without_text("", _('Delete'), "#" , :class=>"icon-delete delete-link-list-row")), 45 + content_tag('li', button_without_text(:delete, _('Delete'), "#" , :class=>"delete-link-list-row")),
46 :class=>"link-list-row new_link_row") 46 :class=>"link-list-row new_link_row")
47 ) + 47 ) +
48 javascript_tag("new_link_action()") 48 javascript_tag("new_link_action()")
public/javascripts/edit-link-list.js
@@ -23,16 +23,7 @@ function new_link_action(){ @@ -23,16 +23,7 @@ function new_link_action(){
23 23
24 jQuery(".delete-link-list-row").click(function(){ 24 jQuery(".delete-link-list-row").click(function(){
25 jQuery(this).parent().parent().remove(); 25 jQuery(this).parent().parent().remove();
26 - });  
27 -  
28 - jQuery(".link-address").blur(function(){  
29 - var value = jQuery(this).val();  
30 - var search = /(^$)|(^\/$)|(http|www).*|.*\{profile\}.*|.*(\.com|\.org|\.net|\.edu|\.gov|\.info|\.eu)/;  
31 -  
32 - if( !search.test(value) ) {  
33 - value = "/{profile}/"+value;  
34 - jQuery(this).val(value);  
35 - } 26 + return false;
36 }); 27 });
37 28
38 jQuery(document).scrollTop(jQuery('#dropable-link-list').scrollTop()); 29 jQuery(document).scrollTop(jQuery('#dropable-link-list').scrollTop());
public/stylesheets/application.css
@@ -1864,7 +1864,6 @@ a.button.disabled, input.disabled { @@ -1864,7 +1864,6 @@ a.button.disabled, input.disabled {
1864 position: relative; 1864 position: relative;
1865 left: -24px; 1865 left: -24px;
1866 } 1866 }
1867 -  
1868 .link-list-header { 1867 .link-list-header {
1869 width: 98%; 1868 width: 98%;
1870 height: 25px; 1869 height: 25px;
@@ -1872,16 +1871,20 @@ a.button.disabled, input.disabled { @@ -1872,16 +1871,20 @@ a.button.disabled, input.disabled {
1872 margin-bottom: 5px; 1871 margin-bottom: 5px;
1873 cursor: pointer; 1872 cursor: pointer;
1874 } 1873 }
1875 - 1874 +.link-list-header li {
  1875 + list-style-type: none;
  1876 + display: inline;
  1877 + font-weight: bold;
  1878 + font-size: 14px;
  1879 + text-align: center;
  1880 +}
1876 #dropable-link-list { 1881 #dropable-link-list {
1877 padding-left: 23px; 1882 padding-left: 23px;
1878 margin-top: -12px; 1883 margin-top: -12px;
1879 } 1884 }
1880 -  
1881 #dropable-link-list li { 1885 #dropable-link-list li {
1882 list-style-type: none; 1886 list-style-type: none;
1883 } 1887 }
1884 -  
1885 .link-list-row { 1888 .link-list-row {
1886 line-height: 25px; 1889 line-height: 25px;
1887 margin-bottom: 5px; 1890 margin-bottom: 5px;
@@ -1890,54 +1893,37 @@ a.button.disabled, input.disabled { @@ -1890,54 +1893,37 @@ a.button.disabled, input.disabled {
1890 width: 90%; 1893 width: 90%;
1891 } 1894 }
1892 .link-list-row:hover { 1895 .link-list-row:hover {
1893 - background: #aaa url(/images/drag-and-drop.png) no-repeat; 1896 + background: #ddd url(/images/drag-and-drop.png) no-repeat;
1894 background-position: 98% 15px; 1897 background-position: 98% 15px;
1895 } 1898 }
1896 -  
1897 .link-list-row li { 1899 .link-list-row li {
1898 list-style-type: none; 1900 list-style-type: none;
1899 display: inline; 1901 display: inline;
1900 margin-left: 5px; 1902 margin-left: 5px;
1901 } 1903 }
1902 -  
1903 .link-list-row li div { 1904 .link-list-row li div {
1904 float: left; 1905 float: left;
1905 margin-top: 4px; 1906 margin-top: 4px;
1906 } 1907 }
1907 -  
1908 .link-list-row li a { 1908 .link-list-row li a {
1909 line-height: 27px !important; 1909 line-height: 27px !important;
1910 padding-right: 5px; 1910 padding-right: 5px;
1911 } 1911 }
1912 -  
1913 -.link-list-header li {  
1914 - list-style-type: none;  
1915 - display: inline;  
1916 - font-weight: bold;  
1917 - font-size: 14px;  
1918 - text-align: center;  
1919 -}  
1920 -  
1921 .link-list-icon { 1912 .link-list-icon {
1922 margin-left: 14px; 1913 margin-left: 14px;
1923 } 1914 }
1924 -  
1925 .link-list-name { 1915 .link-list-name {
1926 margin-left: 40px; 1916 margin-left: 40px;
1927 } 1917 }
1928 -  
1929 .link-list-address { 1918 .link-list-address {
1930 margin-left: 90px; 1919 margin-left: 90px;
1931 } 1920 }
1932 -  
1933 .link-list-target { 1921 .link-list-target {
1934 margin-left: 77px; 1922 margin-left: 77px;
1935 } 1923 }
1936 -  
1937 .new_link_row li { 1924 .new_link_row li {
1938 margin-left: 7px; 1925 margin-left: 7px;
1939 } 1926 }
1940 -  
1941 #content .link-list-block { 1927 #content .link-list-block {
1942 padding: 10px 0px 10px 10px; 1928 padding: 10px 0px 10px 10px;
1943 } 1929 }
test/functional/profile_design_controller_test.rb
@@ -326,10 +326,13 @@ class ProfileDesignControllerTest &lt; ActionController::TestCase @@ -326,10 +326,13 @@ class ProfileDesignControllerTest &lt; ActionController::TestCase
326 article3 = fast_create(Article, :profile_id => @profile.id, :name => "Not an article") 326 article3 = fast_create(Article, :profile_id => @profile.id, :name => "Not an article")
327 327
328 xhr :get, :search_autocomplete, :profile => 'designtestuser' , :query => 'Some' 328 xhr :get, :search_autocomplete, :profile => 'designtestuser' , :query => 'Some'
  329 +
  330 + json_response = ActiveSupport::JSON.decode(@response.body)
  331 +
329 assert_response :success 332 assert_response :success
330 - assert_equal @response.body.include?(article1.path), true  
331 - assert_equal @response.body.include?(article2.path), true  
332 - assert_equal @response.body.include?(article3.path), false 333 + assert_equal json_response.include?("/{profile}/"+article1.path), true
  334 + assert_equal json_response.include?("/{profile}/"+article2.path), true
  335 + assert_equal json_response.include?("/{profile}/"+article3.path), false
333 end 336 end
334 337
335 ###################################################### 338 ######################################################