Fast links

This commit is contained in:
Karel Pičman 2018-09-04 13:28:26 +02:00
parent 2dbadfc2c2
commit 5d6ed07eb3
23 changed files with 175 additions and 45 deletions

View File

@ -46,12 +46,13 @@ class DmsfLinksController < ApplicationController
def new def new
@dmsf_link = DmsfLink.new @dmsf_link = DmsfLink.new
member = Member.find_by_project_id_and_user_id(params[:project_id], User.current.id)
@fast_links = member && member.dmsf_fast_links
@dmsf_link.project_id = params[:project_id] @dmsf_link.project_id = params[:project_id]
@dmsf_link.dmsf_folder_id = params[:dmsf_folder_id] @dmsf_link.dmsf_folder_id = params[:dmsf_folder_id]
@dmsf_file_id = params[:dmsf_file_id] @dmsf_file_id = params[:dmsf_file_id]
@type = params[:type] @type = params[:type]
@dmsf_link.target_project_id = params[:project_id] @dmsf_link.target_project_id = params[:project_id]
@dmsf_link.project_id = params[:project_id]
@target_folder_id = params[:dmsf_folder_id].to_i if params[:dmsf_folder_id].present? @target_folder_id = params[:dmsf_folder_id].to_i if params[:dmsf_folder_id].present?
if @type == 'link_to' if @type == 'link_to'
if @dmsf_file_id if @dmsf_file_id
@ -115,9 +116,18 @@ class DmsfLinksController < ApplicationController
end end
else else
# Link to # Link to
@dmsf_link.project_id = params[:dmsf_link][:target_project_id]
@dmsf_link.dmsf_folder_id = DmsfLinksHelper.is_a_number?( @dmsf_link.dmsf_folder_id = DmsfLinksHelper.is_a_number?(
params[:dmsf_link][:target_folder_id]) ? params[:dmsf_link][:target_folder_id].to_i : nil params[:dmsf_link][:target_folder_id]) ? params[:dmsf_link][:target_folder_id].to_i : nil
if params[:dmsf_link][:target_project_id].present?
@dmsf_link.project_id = params[:dmsf_link][:target_project_id]
else
target_folder = DmsfFolder.find_by_id(params[:dmsf_link][:target_folder_id])
unless target_folder
render_404
return
end
@dmsf_link.project_id = target_folder.project_id
end
@dmsf_link.target_project_id = params[:dmsf_link][:project_id] @dmsf_link.target_project_id = params[:dmsf_link][:project_id]
if params[:dmsf_link][:dmsf_file_id].present? if params[:dmsf_link][:dmsf_file_id].present?
@dmsf_link.target_id = params[:dmsf_link][:dmsf_file_id] @dmsf_link.target_id = params[:dmsf_link][:dmsf_file_id]

View File

@ -31,6 +31,7 @@ class DmsfStateController < ApplicationController
if member if member
member.dmsf_mail_notification = params[:email_notify] member.dmsf_mail_notification = params[:email_notify]
member.dmsf_title_format = params[:title_format] member.dmsf_title_format = params[:title_format]
member.dmsf_fast_links = params[:fast_links].present?
if format_valid?(member.dmsf_title_format) && member.save if format_valid?(member.dmsf_title_format) && member.save
flash[:notice] = l(:notice_your_preferences_were_saved) flash[:notice] = l(:notice_your_preferences_were_saved)
else else

View File

@ -36,43 +36,53 @@
<%= radio_button_tag(:external_link, 'true', false) %> <%= l(:label_external) %> <%= radio_button_tag(:external_link, 'true', false) %> <%= l(:label_external) %>
</p> </p>
<% end %> <% end %>
<div id="link_internal"> <div id="dmsf_link_internal">
<p> <% unless @fast_links && (@type == 'link_to') %>
<% if @type == 'link_from' %> <p>
<label for="dmsf_link[target_project_id]"><%= l(:label_source_project) %></label> <% if @type == 'link_from' %>
<% else %> <label for="dmsf_link[target_project_id]"><%= l(:label_source_project) %></label>
<label for="dmsf_link[target_project_id]"><%= l(:label_target_project) %></label> <% else %>
<% end %> <label for="dmsf_link[target_project_id]"><%= l(:label_target_project) %></label>
<%= select_tag('dmsf_link[target_project_id]', <% end %>
project_tree_options_for_select(DmsfFile.allowed_target_projects_on_copy, <%= select_tag('dmsf_link[target_project_id]',
:selected => @dmsf_link.target_project), :style => "width=100%") %> project_tree_options_for_select(DmsfFile.allowed_target_projects_on_copy,
<%= late_javascript_tag do %> :selected => @dmsf_link.target_project)) %>
$('#dmsf_link_target_project_id').change(function(){ <%= late_javascript_tag do %>
$.ajax({ $('#dmsf_link_target_project_id').change(function(){
url: '<%= autocomplete_for_project_dmsf_link_path(@project, :format => 'js') %>', $.ajax({
type: 'get', url: '<%= autocomplete_for_project_dmsf_link_path(@project, :format => 'js') %>',
data: $('#new_dmsf_link').serialize() type: 'get',
data: $('#new_dmsf_link').serialize()
});
}); });
}); <% end %>
<% end %> </p>
</p> <% end %>
<p> <p>
<% if @type == 'link_from' %> <% if @type == 'link_from' %>
<%= label_tag('dmsf_link[target_folder_id]', l(:label_source_folder)) %> <%= label_tag('dmsf_link[target_folder_id]', l(:label_source_folder)) %>
<% else %> <% else %>
<%= label_tag('dmsf_link[target_folder_id]', l(:label_target_folder)) %> <label for="dmsf_link_target_folder_id">
<%= "#{l(:label_target_folder)} #" %>
<span class="required">*</span>
</label>
<% if @fast_links %>
<%= text_field_tag 'dmsf_link[target_folder_id]', '', :required => true, :max_length => 255 %>
<% end %>
<% end %> <% end %>
<%= select_tag('dmsf_link[target_folder_id]', <% unless @fast_links && (@type == 'link_to') %>
folder_tree_options_for_select(DmsfFolder.directory_tree(@dmsf_link.target_project), <%= select_tag('dmsf_link[target_folder_id]',
:selected => @target_folder_id)) %> folder_tree_options_for_select(DmsfFolder.directory_tree(@dmsf_link.target_project),
<%= late_javascript_tag do %> :selected => @target_folder_id)) %>
$('#dmsf_link_target_folder_id').change(function(){ <%= late_javascript_tag do %>
$.ajax({ $('#dmsf_link_target_folder_id').change(function(){
url: '<%= autocomplete_for_folder_dmsf_link_path(@project, :format => 'js') %>', $.ajax({
type: 'get', url: '<%= autocomplete_for_folder_dmsf_link_path(@project, :format => 'js') %>',
data: $('#new_dmsf_link').serialize() type: 'get',
data: $('#new_dmsf_link').serialize()
});
}); });
}); <% end %>
<% end %> <% end %>
</p> </p>
<% if @type == 'link_from' %> <% if @type == 'link_from' %>
@ -85,7 +95,7 @@
<% end %> <% end %>
</div> </div>
<% if (@type == 'link_from') && !@container %> <% if (@type == 'link_from') && !@container %>
<div id="link_external" style="display: none"> <div id="dmsf_link_external">
<p> <p>
<%= f.text_field :external_url, :required => false %> <%= f.text_field :external_url, :required => false %>
</p> </p>
@ -106,7 +116,7 @@
<%= late_javascript_tag do %> <%= late_javascript_tag do %>
<%# Select2 extension, TODO: in case of a modal window, select2 makes problems %> <%# Select2 extension, TODO: in case of a modal window, select2 makes problems %>
<% unless modal %> <% unless modal || @fast_links %>
$('#dmsf_link_target_project_id').select2(); $('#dmsf_link_target_project_id').select2();
$('#dmsf_link_target_folder_id').select2(); $('#dmsf_link_target_folder_id').select2();
$('#dmsf_link_target_file_id').select2(); $('#dmsf_link_target_file_id').select2();
@ -121,8 +131,8 @@
}); });
<%# Internal/External link switch %> <%# Internal/External link switch %>
$("input[name=external_link]:radio").change(function(){ $("input[name=external_link]:radio").change(function(){
$("#link_internal").toggle(); $("#dmsf_link_internal").toggle();
$("#link_external").toggle(); $("#dmsf_link_external").toggle();
$("#dmsf_link_external_url").toggleClass('required', $(this).val()); $("#dmsf_link_external_url").toggleClass('required', $(this).val());
var labelUrl = $('label[for="dmsf_link_external_url"]'); var labelUrl = $('label[for="dmsf_link_external_url"]');
labelUrl.toggleClass('required', $(this).val()); labelUrl.toggleClass('required', $(this).val());

View File

@ -18,28 +18,40 @@
# 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.%>
<% member = @project.members.where(:user_id => User.current.id).first %> <% member = Member.find_by_project_id_and_user_id(@project.id, User.current.id) %>
<% if member %> <% if member %>
<% mail_notification = member.dmsf_mail_notification %> <% mail_notification = member.dmsf_mail_notification %>
<% title_format = member.dmsf_title_format %> <% title_format = member.dmsf_title_format %>
<% fast_links = member.dmsf_fast_links %>
<% else %>
<% mail_notification = false %>
<% title_format = '' %>
<% fast_links = false %>
<% end %> <% end %>
<%= form_tag(dmsf_user_pref_save_path(@project)) do %> <%= form_tag(dmsf_user_pref_save_path(@project)) do %>
<fieldset class="box tabular"> <fieldset class="box tabular">
<legend><%= l(:link_user_preferences) %></legend> <legend><%= l(:link_user_preferences) %></legend>
<p> <p>
<%= content_tag(:label, "#{l(:label_notifications)}:") %> <%= content_tag(:label, l(:label_notifications)) %>
<%= select_tag( <%= select_tag(
'email_notify', 'email_notify',
options_for_select([[l(:select_option_default), nil], options_for_select([[l(:select_option_default), nil],
[l(:select_option_activated), true], [l(:select_option_deactivated), false]], [l(:select_option_activated), true], [l(:select_option_deactivated), false]],
:selected => mail_notification)) %> :selected => mail_notification)) %>
</p> </p>
<p> <p>
<%= content_tag(:label, "#{l(:label_title_format)}:") %> <%= content_tag(:label, l(:label_title_format)) %>
<%= text_field_tag 'title_format', title_format, :size => 10 %> <%= text_field_tag 'title_format', title_format, :size => 10 %>
<em class="info"><%= l(:text_title_format) %></em> <em class="info"><%= l(:text_title_format) %></em>
</p> </p>
<p>
<%= content_tag(:label, l(:label_dmsf_fast_links)) %>
<%= check_box_tag('fast_links', 1, fast_links) %>
<em class="info">
<%= l(:text_dmsf_fast_links_info) %>
</em>
</p>
</fieldset> </fieldset>
<% if Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] %> <% if Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] %>
<fieldset class="box tabular"> <fieldset class="box tabular">

View File

@ -358,10 +358,10 @@ div.dmsf_revision_inner_box .attribute .label {
#dmsf_links_attachments_fields input.filename {border:0; height:1.8em; width:250px; color:#555; background-color:inherit; background:url(../../../images/link.png) no-repeat 1px 50%; padding-left:18px;} #dmsf_links_attachments_fields input.filename {border:0; height:1.8em; width:250px; color:#555; background-color:inherit; background:url(../../../images/link.png) no-repeat 1px 50%; padding-left:18px;}
/* New link form*/ /* New link form*/
#dmsf_link_target_file_id, #dmsf_link_target_folder_id, #dmsf_link_target_project_id{ #dmsf_link_target_file_id, #dmsf_link_target_folder_id, #dmsf_link_target_project_id, #dmsf_link_name{
min-width: 40%; min-width: 40%;
} }
#dmsf_link_name{ #dmsf_link_external{
min-width: 38%; display: none;
} }

View File

@ -409,6 +409,10 @@ cs:
slov. Odpovídající proměná prostředí musí být použita při indexaci. slov. Odpovídající proměná prostředí musí být použita při indexaci.
např.: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" např.: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Rychlé odkazy
text_dmsf_fast_links_info: Při vytváření odkazů budete moci zadat přímo ID cílového adresáře za účelem zrychlení
procesu vytváření odkazů.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ de:
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ en:
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ es:
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ fr:
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ hu:
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ it: # Italian strings thx 2 Matteo Arceci!
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ ja:
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ ko:
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ nl:
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ pl:
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ pt-BR:
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ ru:
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ sl:
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ zh-TW:
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -409,6 +409,10 @@ zh:
option needs to have been used at index time. option needs to have been used at index time.
e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv" e.g: XAPIAN_CJK_NGRAM=true ruby plugins/redmine_dmsf/extra/xapian_indexer.rb -fv"
label_dmsf_fast_links: Fast links
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
easy_pages: easy_pages:
modules: modules:
dmsf_locked_documents: My locked documents dmsf_locked_documents: My locked documents

View File

@ -0,0 +1,30 @@
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class FastLinks < ActiveRecord::Migration
def self.up
add_column :members, :dmsf_fast_links, :boolean, :default => false, :null => false
Member.update_all(:dmsf_fast_links => false)
end
def self.down
remove_column :members, :dmsf_fast_links
end
end

View File

@ -41,5 +41,8 @@ module RedmineDmsf
end end
end end
RedmineExtensions::PatchManager.register_helper_patch 'ProjectsHelper', #RedmineExtensions::PatchManager.register_helper_patch 'ProjectsHelper',
'RedmineDmsf::Patches::ProjectHelperPatch', prepend: true # 'RedmineDmsf::Patches::ProjectHelperPatch', prepend: true
RedmineExtensions::PatchManager.register_patch_to_be_first 'ProjectsHelper',
'RedmineDmsf::Patches::ProjectHelperPatch', prepend: true, first: true