form_for replaced with labelled_form_for

This commit is contained in:
Karel Picman 2016-03-09 17:54:48 +01:00
parent 417e80bbcf
commit 6ed40654d6
15 changed files with 104 additions and 105 deletions

View File

@ -350,10 +350,15 @@ class DmsfController < ApplicationController
end end
def save_root def save_root
@project.dmsf_description = params[:project][:dmsf_description] if params[:project]
@project.save! @project.dmsf_description = params[:project][:dmsf_description]
flash[:notice] = l(:notice_folder_details_were_saved) if @project.save
redirect_to :controller => 'dmsf', :action => 'show', :id => @project flash[:notice] = l(:notice_folder_details_were_saved)
else
flash[:error] = @project.errors.full_messages.to_sentence
end
end
redirect_to dmsf_folder_path(:id => @project)
end end
def notify_activate def notify_activate

View File

@ -206,8 +206,8 @@ class DmsfWorkflowsController < ApplicationController
# Reload # Reload
if params[:dmsf_workflow] && params[:dmsf_workflow][:name].present? if params[:dmsf_workflow] && params[:dmsf_workflow][:name].present?
@dmsf_workflow.name = params[:dmsf_workflow][:name] @dmsf_workflow.name = params[:dmsf_workflow][:name]
elsif params[:dmsf_workflow_id].present? elsif params[:dmsf_workflow] && params[:dmsf_workflow][:id].present?
wf = DmsfWorkflow.find_by_id params[:dmsf_workflow_id] wf = DmsfWorkflow.find_by_id params[:dmsf_workflow][:id]
@dmsf_workflow.name = wf.name if wf @dmsf_workflow.name = wf.name if wf
end end
@ -216,8 +216,8 @@ class DmsfWorkflowsController < ApplicationController
def create def create
if params[:dmsf_workflow] if params[:dmsf_workflow]
if (params[:dmsf_workflow_id].to_i > 0) if (params[:dmsf_workflow][:id].to_i > 0)
wf = DmsfWorkflow.find_by_id params[:dmsf_workflow_id] wf = DmsfWorkflow.find_by_id params[:dmsf_workflow][:id]
@dmsf_workflow = wf.copy_to(@project, params[:dmsf_workflow][:name]) if wf @dmsf_workflow = wf.copy_to(@project, params[:dmsf_workflow][:name]) if wf
else else
@dmsf_workflow = DmsfWorkflow.new @dmsf_workflow = DmsfWorkflow.new

View File

@ -68,23 +68,21 @@
<%= render(:partial => 'path', <%= render(:partial => 'path',
:locals => {:folder => @pathfolder, :filename => create ? l(:heading_new_folder) : nil, :title => nil}) %> :locals => {:folder => @pathfolder, :filename => create ? l(:heading_new_folder) : nil, :title => nil}) %>
<%= form_for(@folder, :url => {:action => create ? 'create' : 'save', :id => @project, :folder_id => @folder, :parent_id => @parent}, <%= labelled_form_for(@folder, :url => {:action => create ? 'create' : 'save', :id => @project, :folder_id => @folder, :parent_id => @parent},
:html => {:method=>:post}) do |f| %> :html => {:method=>:post}) do |f| %>
<%= error_messages_for(@folder) %> <%= error_messages_for(@folder) %>
<div class="box tabular"> <div class="box tabular">
<p> <p>
<label for="dmsf_folder_title"><%= l(:label_title) %><span class="required">*</span></label> <%= f.text_field(:title, :required => true) %>
<%= f.text_field(:title, :size => '32', :required => true) %>
</p> </p>
<p> <p>
<%= label_tag('', l(:field_folder)) %>
<%= f.select(:dmsf_folder_id, <%= f.select(:dmsf_folder_id,
options_for_select(DmsfFolder.directory_tree(@project, @folder), options_for_select(DmsfFolder.directory_tree(@project, @folder),
:selected => @parent? @parent.id : (@pathfolder.id if @pathfolder))) :selected => @parent? @parent.id : (@pathfolder.id if @pathfolder)),
:label => l(:field_folder))
%> %>
</p> </p>
<p> <p>
<%= label_tag('dmsf_folder_description', l(:label_description)) %>
<%= f.text_area :description, :rows => 8, :class => 'wiki-edit' %> <%= f.text_area :description, :rows => 8, :class => 'wiki-edit' %>
</p> </p>
<% values = @folder ? @folder.custom_field_values : @parent ? @parent.custom_field_values : DmsfFolder.new(:project => @project).custom_field_values %> <% values = @folder ? @folder.custom_field_values : @parent ? @parent.custom_field_values : DmsfFolder.new(:project => @project).custom_field_values %>

View File

@ -43,15 +43,15 @@
<%= render(:partial => 'path', <%= render(:partial => 'path',
:locals => {:folder => nil, :filename => nil, :title => nil}) %> :locals => {:folder => nil, :filename => nil, :title => nil}) %>
<%= form_for(@project, :url => {:action => 'save_root', :id => @project}, <%= labelled_form_for(@project, :url => {:action => 'save_root', :id => @project},
:html => {:method=>:post}) do |f| %> :html => {:method => :post}) do |f| %>
<div class="box tabular"> <div class="box tabular">
<p> <p>
<%= label_tag('project_dmsf_description', l(:label_description)) %> <%= f.text_area(:dmsf_description, :rows => 8, :class => 'wiki-edit',
<%= f.text_area(:dmsf_description, :rows => 8, :class => 'wiki-edit') %> :label => l(:field_description)) %>
</p> </p>
</div> </div>
<%= submit_tag(l(:submit_save)) %> <%= f.submit l(:submit_save) %>
<% end %> <% end %>
<%= wikitoolbar_for 'project_dmsf_description' %> <%= wikitoolbar_for 'project_dmsf_description' %>

View File

@ -28,24 +28,21 @@
<% if @file.locked_for_user? %> <% if @file.locked_for_user? %>
<p class="warning"><%= l(:info_file_locked) %></p> <p class="warning"><%= l(:info_file_locked) %></p>
<% else %> <% else %>
<%= form_for(@revision, :url => { :action => 'create_revision', :id => @file }, <%= labelled_form_for(@revision, :url => { :action => 'create_revision', :id => @file },
:html => { :method => :post, :multipart => true, :id => 'new_revision_form' }) do |f| %> :html => { :method => :post, :multipart => true, :id => 'new_revision_form' }) do |f| %>
<div class="clear"> <div class="clear">
<div class="splitcontentleft"> <div class="splitcontentleft">
<p> <p>
<%= label_tag('dmsf_file_revision_title', l(:label_title)) %> <%= f.text_field(:title) %>
<%= f.text_field(:title, :size => 32) %>
</p> </p>
</div> </div>
<div class="splitcontentright"> <div class="splitcontentright">
<p> <p>
<%= label_tag('', l(:label_file)) %> <%= f.text_field(:name, :label => l(:label_file)) %>
<%= f.text_field(:name, :size => 22) %>
</p> </p>
</div> </div>
</div> </div>
<p> <p>
<%= label_tag('dmsf_file_revision_description', l(:label_description)) %>
<%= f.text_area(:description, :rows => 6, :class => 'wiki-edit') %> <%= f.text_area(:description, :rows => 6, :class => 'wiki-edit') %>
</p> </p>
<div class="clear"> <div class="clear">
@ -93,11 +90,10 @@
<p><%= custom_field_tag_with_label(:dmsf_file_revision, value) %></p> <p><%= custom_field_tag_with_label(:dmsf_file_revision, value) %></p>
<% end %> <% end %>
</div> </div>
<p> <p>
<%= label_tag('dmsf_file_revision_comment', l(:label_comment)) %> <%= f.text_area(:comment, :rows => 2, :label => l(:label_comment)) %>
<%= f.text_area(:comment, :rows => 2) %>
</p> </p>
<%= submit_tag(l(:submit_create)) %> <%= f.submit l(:submit_create) %>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>

View File

@ -17,7 +17,8 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%>
<% html_title l(:dmsf) %> <% html_title l(:dmsf) %>
@ -73,19 +74,19 @@
<% files = @dmsf_link.target_project.dmsf_files.visible if @dmsf_link.target_project %> <% files = @dmsf_link.target_project.dmsf_files.visible if @dmsf_link.target_project %>
<% end %> <% end %>
<%= f.select(:target_file_id, <%= f.select(:target_file_id,
options_for_select(DmsfFolder.file_list(files), @target_file_id)) %> options_for_select(DmsfFolder.file_list(files), @target_file_id)) %>
</p> </p>
<% end %> <% end %>
</div> </div>
<div id="link_external" style="<%= @link_external ? '' : 'display:none' %>"> <div id="link_external" style="<%= @link_external ? '' : 'display:none' %>">
<p> <p>
<label for="dmsf_link[external_url]"><%= l(:label_link_external_url) %><span class="required">*</span></label> <%= f.text_field :external_url,
<%= text_field_tag 'dmsf_link[external_url]', @dmsf_link.external_url, :size => 40, :maxlength => 255 %> :maxlength => 255, :required => true, :label => l(:label_link_external_url) %>
</p> </p>
</div> </div>
<p> <p>
<label for="dmsf_link[name]"><%= l(:label_link_name) %><span class="required">*</span></label> <%= f.text_field :name,
<%= text_field_tag 'dmsf_link[name]', @dmsf_link.name, :size => 40, :maxlength => 255 %> :maxlength => 255, :required => true, :label => l(:label_link_name) %>
</p> </p>
</div> </div>
<p><%= f.submit l(:button_create) %></p> <p><%= f.submit l(:button_create) %></p>

View File

@ -1,10 +1,11 @@
<% <%
# encoding: utf-8 # encoding: utf-8
#
# Redmine plugin for Document Management System "Features" # Redmine plugin for Document Management System "Features"
# #
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com> # Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk> # Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright (C) 2011-15 Karel Pičman <karel.picman@kontron.com> # Copyright (C) 2011-16 Karel Pičman <karel.picman@kontron.com>
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License

View File

@ -1,8 +1,11 @@
<%# Redmine plugin for Document Management System "Features" <%
# encoding: utf-8
# #
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com> # Redmine plugin for Document Management System "Features"
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk> #
# Copyright (C) 2014 Karel Pičman <karel.picman@kontron.com> # Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright (C) 2011-16 Karel Pičman <karel.picman@kontron.com>
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License

View File

@ -19,21 +19,23 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%>
<% html_title(l(:dmsf)) %> <% html_title l(:dmsf) %>
<%= render(:partial => '/dmsf/path', :locals => {:folder => @folder, :filename => nil}) %> <%= render(:partial => '/dmsf/path',
:locals => {:folder => @folder, :filename => nil, :title => l(:heading_uploaded_files)}) %>
<div class="wiki"> <% if (@folder && @folder.description.present?) || @project.description.present? %>
<%= textilizable(@folder.description) if @folder %> <div class="wiki">
</div> <%= textilizable(@folder ? @folder.description : @project.description) %>
</div>
<% end %>
<h3><%=l(:heading_uploaded_files)%></h3>
<% i = 1 %>
<%= form_tag({:action => 'commit_files', :id => @project, :folder_id => @folder}, <%= form_tag({:action => 'commit_files', :id => @project, :folder_id => @folder},
:method=>:post) do %> :method => :post) do %>
<% @uploads.each do |upload| %> <% @uploads.each_with_index do |upload, i| %>
<% if upload.locked %> <% if upload.locked %>
<%= render(:partial => 'upload_file_locked', :locals => {:upload => upload, :i => i}) %> <%= render(:partial => 'upload_file_locked', :locals => {:upload => upload, :i => i}) %>
<% else %> <% else %>
@ -41,5 +43,5 @@
<% end %> <% end %>
<% i += 1 %> <% i += 1 %>
<% end %> <% end %>
<%= submit_tag(l(:submit_commit)) %> <%= submit_tag l(:submit_commit) %>
<% end %> <% end %>

View File

@ -1,8 +1,9 @@
<% <%
# encoding: utf-8 # encoding: utf-8
#
# Redmine plugin for Document Management System "Features" # Redmine plugin for Document Management System "Features"
# #
# Copyright (C) 2011-15 Karel Pičman <karel.picman@kontron.com> # Copyright (C) 2011-16 Karel Pičman <karel.picman@kontron.com>
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@ -20,7 +21,7 @@
%> %>
<fieldset class="box"> <fieldset class="box">
<legend><%=l(:label_dmsf_workflow_add_approver)%></legend> <legend><%= l(:label_dmsf_workflow_add_approver) %></legend>
<p><%= label_tag 'user_search', l(:label_user_search) %><%= text_field_tag 'user_search', nil %></p> <p><%= label_tag 'user_search', l(:label_user_search) %><%= text_field_tag 'user_search', nil %></p>
<%= javascript_tag "observeSearchfield('user_search', 'users', '#{ escape_javascript autocomplete_for_user_dmsf_workflow_path(@dmsf_workflow, :dmsf_workflow_step_assignment_id => nil, :dmsf_file_revision_id => nil, :project_id => @project ? @project.id : nil) }')" %> <%= javascript_tag "observeSearchfield('user_search', 'users', '#{ escape_javascript autocomplete_for_user_dmsf_workflow_path(@dmsf_workflow, :dmsf_workflow_step_assignment_id => nil, :dmsf_file_revision_id => nil, :project_id => @project ? @project.id : nil) }')" %>

View File

@ -1,8 +1,9 @@
<% <%
# encoding: utf-8 # encoding: utf-8
#
# Redmine plugin for Document Management System "Features" # Redmine plugin for Document Management System "Features"
# #
# Copyright (C) 2011-15 Karel Pičman <karel.picman@kontron.com> # Copyright (C) 2011-16 Karel Pičman <karel.picman@kontron.com>
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@ -21,11 +22,11 @@
<h3 class="title"><%= l(:dmsf_new_step) %></h3> <h3 class="title"><%= l(:dmsf_new_step) %></h3>
<%= form_for(:dmsf_workflow, {:url => edit_dmsf_workflow_path(@dmsf_workflow), :method => :post}) do |f| %> <%= labelled_form_for(@dmsf_workflow, {:url => edit_dmsf_workflow_path(@dmsf_workflow), :method => :post}) do |f| %>
<%= render :partial => 'new_step_form' %> <%= render :partial => 'new_step_form' %>
<p class="buttons"> <p class="buttons">
<%= submit_tag l(:dmsf_and), :id => 'add-step-and' %> <%= f.submit l(:dmsf_and), :id => 'add-step-and' %>
<%= submit_tag l(:dmsf_or), :id => 'add-step-or' %> <%= f.submit l(:dmsf_or), :id => 'add-step-or' %>
<%= submit_tag l(:button_cancel), :name => nil, :onclick => 'hideModal(this);', :type => 'button' %> <%= f.submit l(:button_cancel), :name => nil, :onclick => 'hideModal(this);', :type => 'button' %>
</p> </p>
<% end %> <% end %>

View File

@ -1,8 +1,9 @@
<% <%
# encoding: utf-8 # encoding: utf-8
#
# Redmine plugin for Document Management System "Features" # Redmine plugin for Document Management System "Features"
# #
# Copyright (C) 2011-15 Karel Pičman <karel.picman@kontron.com> # Copyright (C) 2011-16 Karel Pičman <karel.picman@kontron.com>
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@ -27,8 +28,11 @@
<%= labelled_form_for @dmsf_workflow do |f| %> <%= labelled_form_for @dmsf_workflow do |f| %>
<%= error_messages_for 'workflow' %> <%= error_messages_for 'workflow' %>
<div class="box tabular"> <div class="box tabular">
<p><%= f.text_field :name, :value => @dmsf_workflow.name, :required => true %><%= submit_tag l(:button_save) %></p> <p>
<%= f.text_field :name, :required => true %>
<%= f.submit l(:button_save) %>
</p>
</div> </div>
<% end %> <% end %>

View File

@ -1,6 +1,9 @@
<%# Redmine plugin for Document Management System "Features" <%
# encoding: utf-8
# #
# Copyright (C) 2011-14 Karel Pičman <karel.picman@kontron.com> # Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2011-16 Karel Pičman <karel.picman@kontron.com>
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
@ -14,30 +17,30 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%>
<% project = Project.find_by_id params[:project_id] if params[:project_id] %> <% project = Project.find_by_id params[:project_id] if params[:project_id] %>
<% if project %> <% if project %>
<h2><%= link_to l(:label_dmsf_workflow_plural), settings_project_path(project, :tab => 'dmsf_workflow') %> &#187; <%= l(:label_dmsf_workflow_new) %></h2> <h2><%= link_to l(:label_dmsf_workflow_plural), settings_project_path(project, :tab => 'dmsf_workflow') %> &#187; <%= l(:label_dmsf_workflow_new) %></h2>
<% else %> <% else %>
<h2><%= link_to l(:label_dmsf_workflow_plural), dmsf_workflows_path %> &#187; <%= l(:label_dmsf_workflow_new) %></h2> <h2><%= link_to l(:label_dmsf_workflow_plural), dmsf_workflows_path %> &#187; <%= l(:label_dmsf_workflow_new) %></h2>
<% end %> <% end %>
<%= labelled_form_for @dmsf_workflow do |f| %> <%= labelled_form_for @dmsf_workflow do |f| %>
<%= f.hidden_field(:project_id) if project %>
<%= error_messages_for 'dmsf_workflow' %> <%= error_messages_for 'dmsf_workflow' %>
<div class="box tabular"> <div class="box tabular">
<p> <p>
<%= f.text_field :name, :value => @dmsf_workflow.name, :size => 25, :maxlength => 255, :required => true %> <%= f.text_field :name, :required => true %>
</p> </p>
<p> <p>
<%= label_tag :label_copy_workflow_from, l(:label_copy_workflow_from) %> <%= f.select(:id,
<%= select_tag('dmsf_workflow_id', dmsf_all_workflows_for_select(params[:dmsf_workflow_id])) %> dmsf_all_workflows_for_select(params[:dmsf_workflow] ? params[:dmsf_workflow][:id] : nil),
</p> :label => l(:label_copy_workflow_from)) %>
<% if project %> </p>
<p><%= hidden_field_tag :project_id, project.id %></p>
<% end %>
</div> </div>
<%= submit_tag l(:button_create) %> <%= f.submit l(:button_create) %>
<% end %> <% end %>
<script type="text/javascript"> <script type="text/javascript">

View File

@ -1,19 +0,0 @@
<%
# encoding: utf-8
#
# Redmine plugin for Kontron customisation
# Copyright (c) 2011-15 Kontron
# Karel Pičman <karel.picman@kontron.com>
#
# Repository folders
%>
<h2><%= l(:label_repository_folders) %></h2>
<%= form_for(:repository_folder, {:url => edit_dmsf_workflow_path(@dmsf_workflow), :method => :post}) do |f| %>
<%= render :partial => 'new_step_form' %>
<p>
<%= submit_tag l(:dmsf_and), :id => 'add-step-and' %>
<%= submit_tag l(:dmsf_or), :id => 'add-step-or' %>
</p>
<% end %>

View File

@ -1,6 +1,9 @@
<%# Redmine plugin for Document Management System "Features" <%
# encoding: utf-8
# #
# Copyright (C) 2011-15 Karel Pičman <karel.picman@kontron.com> # Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2011-16 Karel Pičman <karel.picman@kontron.com>
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License