Select2 userd for all project, folder, file and workflow pick lists

This commit is contained in:
Karel Picman 2016-03-10 13:42:45 +01:00
parent afd6ecccc3
commit 0a824117e1
7 changed files with 43 additions and 33 deletions

View File

@ -93,4 +93,8 @@
<p><%= submit_tag(create ? l(:submit_create) : l(:submit_save)) %></p> <p><%= submit_tag(create ? l(:submit_create) : l(:submit_save)) %></p>
<% end %> <% end %>
<%= wikitoolbar_for 'dmsf_folder_description' %> <%= wikitoolbar_for 'dmsf_folder_description' %>
<script type="text/javascript">
$('#dmsf_folder_dmsf_folder_id').select2();
</script>

View File

@ -22,10 +22,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%> %>
<!--Select2 Files-->
<%= stylesheet_link_tag 'select2.min.css', :plugin => 'redmine_dmsf' %>
<%= javascript_include_tag 'select2.min.js', :plugin => 'redmine_dmsf' %>
<% html_title(l(:dmsf)) %> <% html_title(l(:dmsf)) %>
<%= render(:partial => '/dmsf/path', <%= render(:partial => '/dmsf/path',
@ -58,16 +54,15 @@
<% end %> <% end %>
<script type="text/javascript"> <script type="text/javascript">
jQuery('#move_button').click(function(event) { $('#move_button').click(function(event) {
jQuery('#copyForm').attr('action', "<%= url_for(:action => 'move', :id => @file) %>"); $('#copyForm').attr('action', "<%= url_for(:action => 'move', :id => @file) %>");
jQuery('#copyForm').submit(); $('#copyForm').submit();
}); });
jQuery('#target_project_id').change(function () { $('#target_project_id').change(function () {
jQuery('#content').load("<%= url_for(:action => 'new') %>", jQuery('#copyForm').serialize()); $('#content').load("<%= url_for(:action => 'new') %>", $('#copyForm').serialize());
jQuery('#target_folder_id' ).select2({ width: "600px" });
}); });
jQuery('#target_project_id' ).select2({ width: "600px" }); $('#target_project_id').select2();
jQuery('#target_folder_id' ).select2({ width: "600px" }); $('#target_folder_id').select2();
</script> </script>

View File

@ -22,10 +22,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%> %>
<!--Select2 Files-->
<%= stylesheet_link_tag 'select2.min.css', :plugin => 'redmine_dmsf' %>
<%= javascript_include_tag 'select2.min.js', :plugin => 'redmine_dmsf' %>
<% html_title(l(:dmsf)) %> <% html_title(l(:dmsf)) %>
<%= render(:partial => '/dmsf/path', <%= render(:partial => '/dmsf/path',
@ -51,11 +47,10 @@
<% end %> <% end %>
<script type="text/javascript"> <script type="text/javascript">
jQuery('#target_project_id').change(function () { $('#target_project_id').change(function () {
jQuery('#content').load("<%= url_for(:action => 'new') %>", jQuery('#copyForm').serialize()); $('#content').load("<%= url_for(:action => 'new') %>", $('#copyForm').serialize());
jQuery('#target_folder_id' ).select2({ width: "600px" });
}); });
jQuery('#target_project_id' ).select2({ width: "600px" }); $('#target_project_id').select2();
jQuery('#target_folder_id' ).select2({ width: "600px" }); $('#target_folder_id').select2();
</script> </script>

View File

@ -80,13 +80,12 @@
</div> </div>
<div id="link_external" style="<%= @link_external ? '' : 'display:none' %>"> <div id="link_external" style="<%= @link_external ? '' : 'display:none' %>">
<p> <p>
<%= f.text_field :external_url, <%= f.text_field :external_url, :required => true,
:maxlength => 255, :required => true, :label => l(:label_link_external_url) %> :label => l(:label_link_external_url) %>
</p> </p>
</div> </div>
<p> <p>
<%= f.text_field :name, <%= f.text_field :name, :required => true, :label => l(:label_link_name) %>
: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>
@ -96,14 +95,21 @@
$('#dmsf_link_target_project_id').change(function () { $('#dmsf_link_target_project_id').change(function () {
$('#content').load("<%= url_for(:action => 'new', :project_id => @project.id, :reload => true) %>", $('#new_dmsf_link').serialize()); $('#content').load("<%= url_for(:action => 'new', :project_id => @project.id, :reload => true) %>", $('#new_dmsf_link').serialize());
}); });
$('#dmsf_link_target_folder_id').change(function () { $('#dmsf_link_target_folder_id').change(function () {
$('#content').load("<%= url_for(:action => 'new', :project_id => @project.id) %>", $('#new_dmsf_link').serialize()); $('#content').load("<%= url_for(:action => 'new', :project_id => @project.id) %>", $('#new_dmsf_link').serialize());
}); });
$('#dmsf_link_target_file_id').change(function () { $('#dmsf_link_target_file_id').change(function () {
$('#content').load("<%= url_for(:action => 'new', :project_id => @project.id) %>", $('#new_dmsf_link').serialize()); $('#content').load("<%= url_for(:action => 'new', :project_id => @project.id) %>", $('#new_dmsf_link').serialize());
}); });
$("input[name=external_link]:radio").change(function(){ $("input[name=external_link]:radio").change(function(){
$("#link_internal").toggle(); $("#link_internal").toggle();
$("#link_external").toggle(); $("#link_external").toggle();
}); });
</script>
$('#dmsf_link_target_project_id').select2();
$('#dmsf_link_target_folder_id').select2();
$('#dmsf_link_target_file_id').select2();
</script>

View File

@ -1,6 +1,9 @@
<%# Redmine plugin for Document Management System "Features" <%
# encoding: utf-8
# #
# Copyright (C) 2014 Karel Pičman <karel.picman@lbcfree.net> # 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,6 +17,7 @@
# #
# 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.
%>
<%= render 'form' %> <%= render 'form' %>

View File

@ -47,4 +47,6 @@
$('#dmsf_workflow_id').change(function () { $('#dmsf_workflow_id').change(function () {
$('#content').load("<%= url_for(:action => 'new', :project_id => @project) %>", $('#new_dmsf_workflow').serialize()); $('#content').load("<%= url_for(:action => 'new', :project_id => @project) %>", $('#new_dmsf_workflow').serialize());
}); });
$('#dmsf_workflow_id').select2();
</script> </script>

View File

@ -1,6 +1,8 @@
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features" # Redmine plugin for Document Management System "Features"
# #
# Copyright (C) 2013 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
@ -23,9 +25,11 @@ module RedmineDmsf
class DmsfViewListener < Redmine::Hook::ViewListener class DmsfViewListener < Redmine::Hook::ViewListener
def view_layouts_base_html_head(context={}) def view_layouts_base_html_head(context={})
"\n".html_safe + stylesheet_link_tag('dmsf', :plugin => :redmine_dmsf) "\n".html_safe + stylesheet_link_tag('dmsf', :plugin => :redmine_dmsf) +
"\n".html_safe + stylesheet_link_tag('select2.min.css', :plugin => :redmine_dmsf) +
"\n".html_safe + javascript_include_tag('select2.min.js', :plugin => :redmine_dmsf)
end end
end end
end end
end end