* continuing redesign of file details

git-svn-id: http://redmine-dmsf.googlecode.com/svn/trunk/redmine_dmsf@43 5e329b0b-a2ee-ea63-e329-299493fc886d
This commit is contained in:
vit.jonas@gmail.com 2011-05-15 19:48:30 +00:00
parent c7051d82ec
commit 917e35baac
5 changed files with 115 additions and 111 deletions

View File

@ -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)

View File

@ -1 +0,0 @@
<p class="warning"><%= l(:info_file_locked) %></p>

View File

@ -1,3 +1,9 @@
<div class="box dmsf_detail dmsf_revision">
<strong>Create New Revision <a href="#" id="newRevisionFormContentToggle">[-]</a></strong>
<div id="newRevisionFormContent">
<% if @file.locked_for_user? %>
<p class="warning"><%= l(:info_file_locked) %></p>
<% 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|
%>
<div class="box dmsf_detail">
<fieldset class="tabular">
<legend>Create New Revision <a href="#" id="newRevisionFormContentToggle">[-]</a></legend>
<div id="newRevisionFormContent">
<div class="splitcontentleft">
<p>
<%= label_tag("file[title]", "Title:") %>
<%= text_field_tag("file[title]", @file.last_revision.title, :size => "32") %>
<div class="clear">
<div class="splitcontentleft">
<p>
<%= label_tag("dmsf_file_revision_title", "Title:") %>
<%= f.text_field(:title, :size => "32") %>
</p>
</div>
<div class="splitcontentright">
<p>
<%= label_tag("", "Filename:") %>
<%= h(@revision.name) %>
</p>
</div>
</div>
<p class="no-ident">
<%= label_tag("dmsf_file_revision_description", "Description:") %>
</p>
<div class="wiki clear" style="margin-left: 110px">
<%= f.text_area(:description, :rows=> "6", :class => "wiki-edit") %>
</div>
<div class="splitcontentleft">
<p>
<%= label_tag("fileMinorVersionRadio", "Version:") %>
</p>
<div class="wiki clear" style="margin-left: 110px">
<%= 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<br />
<%= 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<br />
<%= radio_button_tag("dmsf_file_revision[version]", "major", @revision.major_version != @file.last_revision.major_version) %>
<%= @file.last_revision.major_version + 1 %>.0 Major<br />
</div>
<p>
<%= 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)) %>
</p>
</div>
<div class="splitcontentright clear">
<p>
<%= label_tag("fileFileUpload", "New content:") %>
<%= file_field_tag("dmsf_file_revision[file]", :size => 30, :id => "fileFileUpload") %>
<br />
<small>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</small>
</p>
</div>
<br style="clear: both"/>
<p>
<%= 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%;") %>
</p>
<p>
<%= label_tag("file[file]", "New content:") %>
<%= file_field_tag("file[file]", :size => 30, :id => "fileFileUpload") %>
<br />
<small>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</small>
</p>
<p>
<%= 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<br />
<%= radio_button_tag("file[version]", "minor", false, :id => "fileMinorVersionRadio") %>
<%= @file.last_revision.major_version %>.<%= @file.last_revision.minor_version + 1 %> Minor<br />
<%= radio_button_tag("file[version]", "major") %>
<%= @file.last_revision.major_version + 1 %>.0 Major<br />
</p>
<p>
<%= 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)) %>
</p>
</div>
<div class="splitcontentright">
<p>
<%= label_tag("file[comment]", "Comment:") %>
<%= text_area_tag("file[comment]", "", :rows=> "2") %>
</p>
</div>
<br style="clear: both;"/>
<br />
<%= submit_tag("Create") %>
</div>
</fieldset>
</div>
<br />
<%= submit_tag("Create") %>
<% end %>
<% end %>
</div>
</div>
<%= wikitoolbar_for "dmsf_file_revision_description" %>

View File

@ -15,23 +15,25 @@
</h2>
<% 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 %>
<h3>Revisions</h3>
<% @file.revisions.each do |revision| %>
<div class="box dmsf_detail">
<fieldset>
<legend>
<%= revision.source_revision.nil? ? "Created:" : "Changed:" %>
<%= revision.updated_at.strftime("%Y-%m-%d %H:%M:%S") %>
by
<%= h(revision.user) %>
</legend>
<div class="box dmsf_detail dmsf_revision">
<div style="float:right">
<%= 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 %>
</div>
<p class="no-ident">
<%= label_tag("", revision.source_revision.nil? ? "Created:" : "Changed:") %>
<%= revision.updated_at.strftime("%Y-%m-%d %H:%M:%S") %> by <%= h(revision.user) %>
</p>
<div class="clear">
<div class="splitcontentleft">
<p>
@ -47,9 +49,9 @@
</div>
</div>
<p class="no-ident">
<%= label_tag("", "Description:") %><br class="clear" />
<%= label_tag("", "Description:") %>
</p>
<div class="wiki">
<div class="wiki clear" style="margin-left: 110px">
<%= textilizable(revision.description) %>
</div>
@ -81,16 +83,6 @@
<%= label_tag("", "Comment:") %>
<%= h(revision.comment) %>
</p>
<div>
<%= 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 %>
</div>
</fieldset>
</div>
<% end %>

View File

@ -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 {