From 917e35baac56c99adf1be105ab39c8a0cfc4a2d3 Mon Sep 17 00:00:00 2001 From: "vit.jonas@gmail.com" Date: Sun, 15 May 2011 19:48:30 +0000 Subject: [PATCH] * continuing redesign of file details git-svn-id: http://redmine-dmsf.googlecode.com/svn/trunk/redmine_dmsf@43 5e329b0b-a2ee-ea63-e329-299493fc886d --- app/controllers/dmsf_detail_controller.rb | 52 ++++---- app/views/dmsf_detail/_file_locked.html.erb | 1 - .../dmsf_detail/_file_new_revision.html.erb | 117 ++++++++++-------- app/views/dmsf_detail/file_detail.html.erb | 42 +++---- assets/stylesheets/dmsf.css | 14 +-- 5 files changed, 115 insertions(+), 111 deletions(-) delete mode 100644 app/views/dmsf_detail/_file_locked.html.erb diff --git a/app/controllers/dmsf_detail_controller.rb b/app/controllers/dmsf_detail_controller.rb index fc5da019..7da30302 100644 --- a/app/controllers/dmsf_detail_controller.rb +++ b/app/controllers/dmsf_detail_controller.rb @@ -80,8 +80,34 @@ class DmsfDetailController < ApplicationController render_403 end - #TODO: show lock/unlock history def file_detail + @revision = @file.last_revision.clone + @revision.comment = "" + end + + #TODO: separate control for approval + #TODO: don't create revision if nothing change + def save_file + if @file.locked_for_user? + flash[:error] = l(:error_file_is_locked) + redirect_to :action => "file_detail", :id => @project, :file_id => @file + else + new_revision = params[:dmsf_file_revision] + DmsfFileRevision.from_saved_file(@file, new_revision) + if @file.locked? + @file.unlock + flash[:notice] = l(:notice_file_unlocked) + ", " + end + @file.reload + flash[:notice] = (flash[:notice].nil? ? "" : flash[:notice]) + l(:notice_file_revision_created) + Rails.logger.info "#{Time.now} from #{request.remote_ip}/#{request.env["HTTP_X_FORWARDED_FOR"]}: #{User.current.login} created new revision of file #{@project.identifier}://#{@file.dmsf_path_str}" + begin + DmsfMailer.deliver_files_updated(User.current, [@file]) + rescue ActionView::MissingTemplate => e + Rails.logger.error "Could not send email notifications: " + e + end + end + redirect_to :action => "file_detail", :id => @project, :file_id => @file end def delete_file @@ -181,30 +207,6 @@ class DmsfDetailController < ApplicationController redirect_to :controller => "dmsf", :action => "index", :id => @project, :folder_id => @folder end - #TODO: separate control for approval - #TODO: don't create revision if nothing change - def save_file - if @file.locked_for_user? - flash[:error] = l(:error_file_is_locked) - else - saved_file = params[:file] - DmsfFileRevision.from_saved_file(@file, saved_file) - if @file.locked? - @file.unlock - flash[:notice] = l(:notice_file_unlocked) + ", " - end - @file.reload - flash[:notice] = (flash[:notice].nil? ? "" : flash[:notice]) + l(:notice_file_revision_created) - Rails.logger.info "#{Time.now} from #{request.remote_ip}/#{request.env["HTTP_X_FORWARDED_FOR"]}: #{User.current.login} created new revision of file #{@project.identifier}://#{@file.dmsf_path_str}" - begin - DmsfMailer.deliver_files_updated(User.current, [@file]) - rescue ActionView::MissingTemplate => e - Rails.logger.error "Could not send email notifications: " + e - end - end - redirect_to :action => "file_detail", :id => @project, :file_id => @file - end - private def copy_folder(folder) diff --git a/app/views/dmsf_detail/_file_locked.html.erb b/app/views/dmsf_detail/_file_locked.html.erb deleted file mode 100644 index 2f58a463..00000000 --- a/app/views/dmsf_detail/_file_locked.html.erb +++ /dev/null @@ -1 +0,0 @@ -

<%= l(:info_file_locked) %>

\ No newline at end of file diff --git a/app/views/dmsf_detail/_file_new_revision.html.erb b/app/views/dmsf_detail/_file_new_revision.html.erb index 2bc3e816..6f324dfa 100644 --- a/app/views/dmsf_detail/_file_new_revision.html.erb +++ b/app/views/dmsf_detail/_file_new_revision.html.erb @@ -1,3 +1,9 @@ +
+ Create New Revision [-] +
+ <% if @file.locked_for_user? %> +

<%= l(:info_file_locked) %>

+ <% else %> <% disabled_workflow = [] selected_workflow = nil @@ -12,57 +18,70 @@ else selected_workflow = @file.last_revision.workflow end -form_tag({:action => "save_file", :id => @project, :file_id => @file}, - :method=>:post, :multipart => true, :class => "tabular") do +form_for(:dmsf_file_revision, @revision, :url => {:action => "save_file", :id => @project, :file_id => @file}, + :html => {:method=>:post, :multipart => true}) do |f| %> -
-
- Create New Revision [-] -
-
-

- <%= label_tag("file[title]", "Title:") %> - <%= text_field_tag("file[title]", @file.last_revision.title, :size => "32") %> +

+
+

+ <%= label_tag("dmsf_file_revision_title", "Title:") %> + <%= f.text_field(:title, :size => "32") %> +

+
+
+

+ <%= label_tag("", "Filename:") %> + <%= h(@revision.name) %> +

+
+
+

+ <%= label_tag("dmsf_file_revision_description", "Description:") %>

+
+ <%= f.text_area(:description, :rows=> "6", :class => "wiki-edit") %> +
+
+

+ <%= label_tag("fileMinorVersionRadio", "Version:") %> +

+
+ <%= radio_button_tag("dmsf_file_revision[version]", "same", @revision.version == @file.last_revision.version, :id => "fileSameVersionRadio") %> + <%= @file.last_revision.major_version %>.<%= @file.last_revision.minor_version %> Same
+ <%= radio_button_tag("dmsf_file_revision[version]", "minor", + @revision.major_version == @file.last_revision.major_version && @revision.minor_version != @file.last_revision.minor_version, + :id => "fileMinorVersionRadio") %> + <%= @file.last_revision.major_version %>.<%= @file.last_revision.minor_version + 1 %> Minor
+ <%= radio_button_tag("dmsf_file_revision[version]", "major", @revision.major_version != @file.last_revision.major_version) %> + <%= @file.last_revision.major_version + 1 %>.0 Major
+
+

+ <%= label_tag("dmsf_file_revision_workflow", "Workflow:") %> + <%= f.select(:workflow, + options_for_select([["None", nil], ["Waiting for approval", 1], ["Approved", 2]], + :selected => selected_workflow, :disabled => disabled_workflow)) %> +

+
+
+

+ <%= label_tag("fileFileUpload", "New content:") %> + <%= file_field_tag("dmsf_file_revision[file]", :size => 30, :id => "fileFileUpload") %> +
+ + (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) + +

+
+

- <%= label_tag("file[description]", "Description:") %> - <%= text_area_tag("file[description]", @file.last_revision.description, :rows=> "6") %> + <%= label_tag("dmsf_file_revision_comment", "Comment:") %> + <%= f.text_area(:comment, :rows=> "2", :style => "width: 99%;") %>

- -

- <%= label_tag("file[file]", "New content:") %> - <%= file_field_tag("file[file]", :size => 30, :id => "fileFileUpload") %> -
- - (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) - -

-

- <%= label_tag("file[version]_minor", "Version:") %> - <%= radio_button_tag("file[version]", "same", true, :id => "fileSameVersionRadio") %> - <%= @file.last_revision.major_version %>.<%= @file.last_revision.minor_version %> Same
- <%= radio_button_tag("file[version]", "minor", false, :id => "fileMinorVersionRadio") %> - <%= @file.last_revision.major_version %>.<%= @file.last_revision.minor_version + 1 %> Minor
- <%= radio_button_tag("file[version]", "major") %> - <%= @file.last_revision.major_version + 1 %>.0 Major
-

-

- <%= label_tag("file[workflow]", "Workflow:") %> - <%= select_tag("file[workflow]", - options_for_select([["None", nil], ["Waiting for approval", 1], ["Approved", 2]], - :selected => selected_workflow, :disabled => disabled_workflow)) %> -

-
-
-

- <%= label_tag("file[comment]", "Comment:") %> - <%= text_area_tag("file[comment]", "", :rows=> "2") %> -

-
-
-
- <%= submit_tag("Create") %> -
-
-
+
+ <%= submit_tag("Create") %> <% end %> + <% end %> +
+
+ +<%= wikitoolbar_for "dmsf_file_revision_description" %> diff --git a/app/views/dmsf_detail/file_detail.html.erb b/app/views/dmsf_detail/file_detail.html.erb index 43dbd574..2206c6c2 100644 --- a/app/views/dmsf_detail/file_detail.html.erb +++ b/app/views/dmsf_detail/file_detail.html.erb @@ -15,23 +15,25 @@ <% if User.current.allowed_to?(:file_manipulation, @file.project) %> - <% if @file.locked_for_user? %> - <%= render(:partial => 'file_locked') %> - <% else %> - <%= render(:partial => 'file_new_revision') %> - <% end %> + <%= render(:partial => 'file_new_revision') %> <% end %>

Revisions

<% @file.revisions.each do |revision| %> -
-
- - <%= revision.source_revision.nil? ? "Created:" : "Changed:" %> - <%= revision.updated_at.strftime("%Y-%m-%d %H:%M:%S") %> - by - <%= h(revision.user) %> - +
+
+ <%= link_to("Download", + {:controller=>"dmsf", :action => "download_revision", :id => @project, :revision_id => revision}) %> + <% if User.current.allowed_to?(:file_approval, @project) %> + | <%= link_to("Delete", + {:action => "delete_revision", :id => @project, :revision_id => revision}, + :class => "delete-link", :title => "Delete revision") %> + <% end %> +
+

+ <%= label_tag("", revision.source_revision.nil? ? "Created:" : "Changed:") %> + <%= revision.updated_at.strftime("%Y-%m-%d %H:%M:%S") %> by <%= h(revision.user) %> +

@@ -47,9 +49,9 @@

- <%= label_tag("", "Description:") %>
+ <%= label_tag("", "Description:") %>

-
+
<%= textilizable(revision.description) %>
@@ -81,16 +83,6 @@ <%= label_tag("", "Comment:") %> <%= h(revision.comment) %>

-
- <%= link_to("Download", - {:controller=>"dmsf", :action => "download_revision", :id => @project, :revision_id => revision}) %> - <% if User.current.allowed_to?(:file_approval, @project) %> - | <%= link_to("Delete", - {:action => "delete_revision", :id => @project, :revision_id => revision}, - :class => "delete-link", :title => "Delete revision") %> - <% end %> -
-
<% end %> diff --git a/assets/stylesheets/dmsf.css b/assets/stylesheets/dmsf.css index 2a3164e4..56dbc34e 100644 --- a/assets/stylesheets/dmsf.css +++ b/assets/stylesheets/dmsf.css @@ -101,10 +101,6 @@ div.right_icon_box img.detail_icon { padding: 4px 4px 4px 30px; } -.dmsf_detail textarea { - width: 90%; -} - .dmsf_detail legend { font-weight: bold; } @@ -113,16 +109,12 @@ div.right_icon_box img.detail_icon { padding: 4px 4px 4px 30px; } -.dmsf_detail label { +.dmsf_revision label { font-weight: bold; width: 100px; float: left; -} - -.dmsf_detail .wiki { - background-color: white; - border: 1px solid #E4E4E4; - padding-left: 5px; + text-align: right; + padding-right: 10px; } p.no-ident {