Commit cac9b82e6a90d4c0cd954cd37ffb2ed9ad47b056
Committed by
Antonio Terceiro
1 parent
99a5c48c
Exists in
master
and in
22 other branches
ActionItem928: enhancing media listing
Showing
5 changed files
with
46 additions
and
39 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -212,12 +212,12 @@ class CmsController < MyProfileController | @@ -212,12 +212,12 @@ class CmsController < MyProfileController | ||
212 | def media_listing | 212 | def media_listing |
213 | if params[:image_folder_id] | 213 | if params[:image_folder_id] |
214 | folder = profile.articles.find(params[:image_folder_id]) if !params[:image_folder_id].blank? | 214 | folder = profile.articles.find(params[:image_folder_id]) if !params[:image_folder_id].blank? |
215 | - @images = (folder ? folder.children : UploadedFile.find(:all, :conditions => ["profile_id = ? AND parent_id is NULL", profile ])).select { |c| c.image? } | 215 | + @images = (folder ? folder.children : UploadedFile.find(:all, :order => 'created_at desc', :conditions => ["profile_id = ? AND parent_id is NULL", profile ])).select { |c| c.image? } |
216 | elsif params[:document_folder_id] | 216 | elsif params[:document_folder_id] |
217 | folder = profile.articles.find(params[:document_folder_id]) if !params[:document_folder_id].blank? | 217 | folder = profile.articles.find(params[:document_folder_id]) if !params[:document_folder_id].blank? |
218 | - @documents = (folder ? folder.children : UploadedFile.find(:all, :conditions => ["profile_id = ? AND parent_id is NULL", profile ])).select { |c| c.kind_of?(UploadedFile) && !c.image? } | 218 | + @documents = (folder ? folder.children : UploadedFile.find(:all, :order => 'created_at desc', :conditions => ["profile_id = ? AND parent_id is NULL", profile ])).select { |c| c.kind_of?(UploadedFile) && !c.image? } |
219 | else | 219 | else |
220 | - @documents = UploadedFile.find(:all, :conditions => ["profile_id = ? AND parent_id is NULL", profile ]) | 220 | + @documents = UploadedFile.find(:all, :order => 'created_at desc', :conditions => ["profile_id = ? AND parent_id is NULL", profile ]) |
221 | @images = @documents.select(&:image?) | 221 | @images = @documents.select(&:image?) |
222 | @documents -= @images | 222 | @documents -= @images |
223 | end | 223 | end |
app/helpers/application_helper.rb
@@ -519,8 +519,8 @@ module ApplicationHelper | @@ -519,8 +519,8 @@ module ApplicationHelper | ||
519 | content_tag('div', result) | 519 | content_tag('div', result) |
520 | end | 520 | end |
521 | 521 | ||
522 | - def select_folder(object, method, collection, html_options = {}, js_options = {}) | ||
523 | - labelled_form_field(_('Folder'), select(object, method, collection.map {|f| [ profile.identifier + '/' + f.full_name, f.id ] }, html_options.merge({:include_blank => "#{profile.identifier}"}), js_options)) | 522 | + def select_folder(label, object, method, collection, html_options = {}, js_options = {}) |
523 | + labelled_form_field(label, select(object, method, collection.map {|f| [ profile.identifier + '/' + f.full_name, f.id ] }, html_options.merge({:include_blank => "#{profile.identifier}"}), js_options)) | ||
524 | end | 524 | end |
525 | 525 | ||
526 | def theme_option(opt = nil) | 526 | def theme_option(opt = nil) |
app/views/cms/media_listing.rhtml
@@ -30,22 +30,9 @@ | @@ -30,22 +30,9 @@ | ||
30 | } | 30 | } |
31 | registerDocumentSize(); | 31 | registerDocumentSize(); |
32 | </script> | 32 | </script> |
33 | - <div id='media-listing'> | ||
34 | - <div id='media-listing-images'> | ||
35 | - <h3><%= _('Images') %></h3> | ||
36 | - <%= select_folder('folder', 'image_folder_id', @image_folders, {}, :onchange => remote_function(:with => "'image_folder_id=' + value + '&ipage=1'", :url => { :action => :media_listing, :format => 'js' }) ) %> | ||
37 | - <%= render :partial => 'image_thumb', :locals => { :images => @images } %> | ||
38 | - </div><!-- id='media-listing-images' --> | ||
39 | - <div id='media-listing-documents'> | ||
40 | - <h3><%= _('Documents') %></h3> | ||
41 | - <%= select_folder('folder', 'document_folder_id', @document_folders, {}, :onchange => remote_function(:with => "'document_folder_id=' + value + '&dpage=1'", :url => { :action => :media_listing }) ) %> | ||
42 | - <%= render :partial => 'document_link', :locals => { :documents => @documents } %> | ||
43 | - </div><!-- id='media-listing-documents' --> | ||
44 | - <br style="clear:both" /> | ||
45 | - <p><big><%= _('Drag images and documents to add them to the text.') %></big></p> | ||
46 | - <br style="clear:both" /> | ||
47 | - </div><!-- id='media-listing' --> | ||
48 | <div id='media-listing-upload'> | 33 | <div id='media-listing-upload'> |
34 | + <p><%= _("Include files in some folder or select from the list below to add images and documents to the text editor beside (max size %s)") % UploadedFile.max_size.to_humanreadable %></p> | ||
35 | + | ||
49 | <div id="notice" onclick="Element.hide('notice');" style="display:none"> | 36 | <div id="notice" onclick="Element.hide('notice');" style="display:none"> |
50 | <% unless flash[:notice].nil? %> | 37 | <% unless flash[:notice].nil? %> |
51 | <%= flash[:notice] unless flash[:notice].nil? %> | 38 | <%= flash[:notice] unless flash[:notice].nil? %> |
@@ -58,5 +45,22 @@ | @@ -58,5 +45,22 @@ | ||
58 | <%= render :partial => 'upload_file_form', :locals => { :size => '30' } %> | 45 | <%= render :partial => 'upload_file_form', :locals => { :size => '30' } %> |
59 | <% end %> | 46 | <% end %> |
60 | </div><!-- id='media-listing-upload' --> | 47 | </div><!-- id='media-listing-upload' --> |
48 | + <hr/> | ||
49 | + <div id='media-listing'> | ||
50 | + <h3><%= _('Folders') %></h3> | ||
51 | + <p><%= _('Drag images and documents to add them to the text. If needed, resize images by clicking the tree icon on editor.') %></p> | ||
52 | + | ||
53 | + <div id='media-listing-images'> | ||
54 | + <h4><%= _('Images') %></h4> | ||
55 | + <%= select_folder('', 'folder', 'image_folder_id', @image_folders, {}, :onchange => remote_function(:with => "'image_folder_id=' + value + '&ipage=1'", :url => { :action => :media_listing, :format => 'js' }) ) %> | ||
56 | + <%= render :partial => 'image_thumb', :locals => { :images => @images } %> | ||
57 | + </div><!-- id='media-listing-images' --> | ||
58 | + <div id='media-listing-documents'> | ||
59 | + <h4><%= _('Documents') %></h4> | ||
60 | + <%= select_folder('', 'folder', 'document_folder_id', @document_folders, {}, :onchange => remote_function(:with => "'document_folder_id=' + value + '&dpage=1'", :url => { :action => :media_listing }) ) %> | ||
61 | + <%= render :partial => 'document_link', :locals => { :documents => @documents } %> | ||
62 | + </div><!-- id='media-listing-documents' --> | ||
63 | + <br style="clear:both" /> | ||
64 | + </div><!-- id='media-listing' --> | ||
61 | </body> | 65 | </body> |
62 | </html> | 66 | </html> |
app/views/tasks/_approve_article.rhtml
@@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
21 | 21 | ||
22 | <%= labelled_form_field _('Name for publishing'), f.text_field(:name, :style => 'width:80%;') %> | 22 | <%= labelled_form_field _('Name for publishing'), f.text_field(:name, :style => 'width:80%;') %> |
23 | 23 | ||
24 | - <%= labelled_form_field(_('Select the folder where the article must be published'), select_folder('task', 'article_parent_id', task.target.folders)) %> | 24 | + <%= select_folder(_('Select the folder where the article must be published'), 'task', 'article_parent_id', task.target.folders) %> |
25 | <%= labelled_form_field( _('Highlight'), check_box_tag(:highlighted, true)) %> | 25 | <%= labelled_form_field( _('Highlight'), check_box_tag(:highlighted, true)) %> |
26 | <%= labelled_form_field _('Comment for author'), f.text_area(:closing_statment, :style => 'height:200px; width:80%;') %> | 26 | <%= labelled_form_field _('Comment for author'), f.text_area(:closing_statment, :style => 'height:200px; width:80%;') %> |
27 | 27 |
public/stylesheets/media_listing.css
@@ -5,12 +5,11 @@ body { | @@ -5,12 +5,11 @@ body { | ||
5 | font-size: 14px; | 5 | font-size: 14px; |
6 | color: #444; | 6 | color: #444; |
7 | background-color: #F0F0EE; | 7 | background-color: #F0F0EE; |
8 | - border: 1px solid #CCC; | ||
9 | overflow: hidden; | 8 | overflow: hidden; |
10 | } | 9 | } |
11 | 10 | ||
12 | h3, h4, h5 { | 11 | h3, h4, h5 { |
13 | - margin: 10px 0px; | 12 | + margin: 5px 0px; |
14 | } | 13 | } |
15 | 14 | ||
16 | h3 { | 15 | h3 { |
@@ -23,14 +22,16 @@ h4 { | @@ -23,14 +22,16 @@ h4 { | ||
23 | 22 | ||
24 | #media-listing { | 23 | #media-listing { |
25 | width: 100%; | 24 | width: 100%; |
26 | - height: 65%; | 25 | + height: 48%; |
27 | margin: 0px; | 26 | margin: 0px; |
28 | padding: 0px; | 27 | padding: 0px; |
29 | - border-bottom: 2px solid #444; | 28 | + padding-bottom: 5px; |
30 | } | 29 | } |
31 | 30 | ||
31 | +#media-listing-upload p, | ||
32 | #media-listing p { | 32 | #media-listing p { |
33 | - font-size: 14px; | 33 | + font-size: 13px; |
34 | + font-weight: bold; | ||
34 | margin: 5px 5px; | 35 | margin: 5px 5px; |
35 | } | 36 | } |
36 | 37 | ||
@@ -48,9 +49,7 @@ h4 { | @@ -48,9 +49,7 @@ h4 { | ||
48 | } | 49 | } |
49 | 50 | ||
50 | #media-listing-images { | 51 | #media-listing-images { |
51 | - margin-top: 2px; | ||
52 | width: 46%; | 52 | width: 46%; |
53 | - height: 80%; | ||
54 | float: left; | 53 | float: left; |
55 | text-align: center; | 54 | text-align: center; |
56 | } | 55 | } |
@@ -66,40 +65,43 @@ h4 { | @@ -66,40 +65,43 @@ h4 { | ||
66 | height: 60px; | 65 | height: 60px; |
67 | } | 66 | } |
68 | 67 | ||
69 | -#media-listing-folder-images { | ||
70 | - height: 75%; | 68 | +#media-listing-folder-images, |
69 | +#media-listing-folder-documents { | ||
70 | + height: 80%; | ||
71 | } | 71 | } |
72 | 72 | ||
73 | #media-listing ul { | 73 | #media-listing ul { |
74 | padding: 0px; | 74 | padding: 0px; |
75 | margin: 5px; | 75 | margin: 5px; |
76 | - height: 65%; | 76 | + height: 40%; |
77 | overflow: auto; | 77 | overflow: auto; |
78 | width: 98%; | 78 | width: 98%; |
79 | } | 79 | } |
80 | 80 | ||
81 | +#media-listing ul { | ||
82 | + height: 85%; | ||
83 | +} | ||
84 | + | ||
85 | +#media-listing-images, | ||
86 | +#media-listing-documents { | ||
87 | + height: 55%; | ||
88 | +} | ||
89 | + | ||
81 | #media-listing-documents ul { | 90 | #media-listing-documents ul { |
82 | text-align: left; | 91 | text-align: left; |
83 | } | 92 | } |
84 | 93 | ||
85 | #media-listing-documents { | 94 | #media-listing-documents { |
86 | - margin: 2px 0px 0px 2px; | ||
87 | width: 52%; | 95 | width: 52%; |
88 | - height: 80%; | ||
89 | float: left; | 96 | float: left; |
90 | text-align: center; | 97 | text-align: center; |
91 | } | 98 | } |
92 | 99 | ||
93 | -#media-listing-folder-documents { | ||
94 | - height: 75%; | ||
95 | -} | ||
96 | - | ||
97 | #media-listing-folder-documents img { | 100 | #media-listing-folder-documents img { |
98 | border: none; | 101 | border: none; |
99 | } | 102 | } |
100 | 103 | ||
101 | #media-listing-upload { | 104 | #media-listing-upload { |
102 | - height: 38%; | ||
103 | width: 98%; | 105 | width: 98%; |
104 | padding: 3px; | 106 | padding: 3px; |
105 | } | 107 | } |
@@ -116,6 +118,7 @@ h4 { | @@ -116,6 +118,7 @@ h4 { | ||
116 | overflow-x: hidden; | 118 | overflow-x: hidden; |
117 | overflow-y: scroll; | 119 | overflow-y: scroll; |
118 | height: 100px; | 120 | height: 100px; |
121 | + margin-top: 5px; | ||
119 | } | 122 | } |
120 | 123 | ||
121 | .msie #uploaded_files { | 124 | .msie #uploaded_files { |
@@ -133,7 +136,7 @@ h4 { | @@ -133,7 +136,7 @@ h4 { | ||
133 | div#notice { | 136 | div#notice { |
134 | background: #fee; | 137 | background: #fee; |
135 | border: 1px solid #933; | 138 | border: 1px solid #933; |
136 | - bottom: 150px; | 139 | + top: 150px; |
137 | color: black; | 140 | color: black; |
138 | cursor: pointer; | 141 | cursor: pointer; |
139 | font-weight: bold; | 142 | font-weight: bold; |