Actualizar plugin Glossary a 1.1.0
This commit is contained in:
parent
24560c8598
commit
b9e569d03f
103 changed files with 954 additions and 2967 deletions
|
@ -0,0 +1,64 @@
|
|||
class GlossaryCategoriesController < ApplicationController
|
||||
|
||||
before_action :find_category_from_id, only: [:show, :edit, :update, :destroy]
|
||||
before_action :find_project_by_project_id, :authorize
|
||||
|
||||
def index
|
||||
@categories = GlossaryCategory.where(project_id: @project.id).sorted
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
@category = GlossaryCategory.new
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def create
|
||||
category = GlossaryCategory.new(glossary_category_params)
|
||||
category.project = @project
|
||||
if category.save
|
||||
redirect_to [@project, category], notice: l(:notice_successful_create)
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@category.attributes = glossary_category_params
|
||||
if @category.save
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to [@project, @category],
|
||||
notice: l(:notice_successful_update)
|
||||
}
|
||||
format.js {
|
||||
head 200
|
||||
}
|
||||
end
|
||||
end
|
||||
rescue ActiveRecord::StaleObjectError
|
||||
flash.now[:error] = l(:notice_locking_conflict)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@category.destroy
|
||||
redirect_to project_glossary_categories_path(@project)
|
||||
end
|
||||
|
||||
# Find the category whose id is the :id parameter
|
||||
def find_category_from_id
|
||||
@category = GlossaryCategory.find(params[:id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def glossary_category_params
|
||||
params.require(:glossary_category).permit(
|
||||
:name, :position
|
||||
)
|
||||
end
|
||||
end
|
|
@ -1,386 +0,0 @@
|
|||
|
||||
class GlossaryController < ApplicationController
|
||||
menu_item :glossary
|
||||
unloadable
|
||||
|
||||
layout 'base'
|
||||
before_filter :find_project, :authorize
|
||||
before_filter :find_term, :only => [:show, :edit, :destroy]
|
||||
before_filter :retrieve_glossary_style, :only => [:index, :show, :show_all, :import_csv_exec]
|
||||
|
||||
helper :attachments
|
||||
include AttachmentsHelper
|
||||
helper :sort
|
||||
include SortHelper
|
||||
helper :glossary
|
||||
include GlossaryHelper
|
||||
helper :glossary_port
|
||||
include GlossaryPortHelper
|
||||
helper :glossary_styles
|
||||
include GlossaryStylesHelper
|
||||
|
||||
|
||||
def index
|
||||
|
||||
@is_index = true
|
||||
set_show_params
|
||||
@terms = find_terms(@glossary_style.project_scope)
|
||||
unless @terms.empty?
|
||||
sortparams = @glossary_style.sort_params
|
||||
sort_terms(@terms, sortparams) unless sortparams.empty?
|
||||
off_params = @show_params.clone
|
||||
off_params.delete("category")
|
||||
off_params.delete("project")
|
||||
if (!@glossary_style.grouping?)
|
||||
check_nouse_params(@terms, off_params)
|
||||
else
|
||||
@terms = grouping(@glossary_style.groupby, @terms, off_params)
|
||||
end
|
||||
@show_params.delete_if {|prm| off_params.member?(prm) }
|
||||
end
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :template => 'glossary/index.html.erb', :layout => !request.xhr? }
|
||||
format.csv {
|
||||
ary = @terms
|
||||
ary = GroupingTerms.flatten(@terms) if (@glossary_style.grouping?)
|
||||
send_data(glossary_to_csv(ary), :type => 'text',
|
||||
:filename => "glossary-export.csv")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def index_clear
|
||||
params[:search_index_ch] = nil
|
||||
redirect_to :controller => 'glossary', :action => 'index', :project_id => @project
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
set_show_params
|
||||
@term_categories = TermCategory.where(:project_id => @project.id).order(:position)
|
||||
respond_to do |format|
|
||||
format.html { render :template => 'glossary/show.html.erb', :layout => !request.xhr? }
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@term_categories = TermCategory.where(:project_id => @project.id).order(:position)
|
||||
@term = Term.new(params[:term])
|
||||
@term.name = CGI::unescapeHTML(params[:new_term_name]) if params[:new_term_name]
|
||||
@term.project_id = @project.id
|
||||
|
||||
unless (request.get? || request.xhr?)
|
||||
@term.author_id = User.current.id
|
||||
@term.updater_id = User.current.id
|
||||
if @term.save
|
||||
attach_files(@term, params[:attachments])
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
if (params[:continue])
|
||||
redirect_to :controller => 'glossary', :action => 'new', :project_id => @project
|
||||
else
|
||||
redirect_to :controller => 'glossary', :action => 'show', :project_id => @project,
|
||||
:id => @term
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def preview
|
||||
@text = params[:term][:description]
|
||||
render :partial => 'common/preview'
|
||||
end
|
||||
|
||||
def edit
|
||||
@term_categories = TermCategory.where(:project_id => @project.id).order(:position)
|
||||
|
||||
if request.post? || request.put? || request.patch?
|
||||
@term.attributes = params[:term]
|
||||
@term.updater_id = User.current.id
|
||||
if @term.save
|
||||
attach_files(@term, params[:attachments])
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to(:controller => 'glossary', :action => 'show',
|
||||
:project_id => @project, :id => @term.id)
|
||||
return
|
||||
end
|
||||
end
|
||||
rescue ActiveRecord::StaleObjectError
|
||||
# Optimistic locking exception
|
||||
flash.now[:error] = l(:notice_locking_conflict)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@term.destroy
|
||||
redirect_to :action => 'index', :project_id => @project
|
||||
end
|
||||
|
||||
def add_term_category
|
||||
@category = TermCategory.new(params[:category])
|
||||
@category.project_id = @project.id
|
||||
if request.post? and @category.save
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to :controller => 'term_categories', :action => 'index', :project_id => @project
|
||||
end
|
||||
format.js do
|
||||
term_categories = TermCategory.where(:project_id => @project.id)
|
||||
render(:update) {|page| page.replace "term_category_id",
|
||||
content_tag('select', '<option></option>' + options_from_collection_for_select(term_categories, 'id', 'name', @category.id), :id => 'term_category_id', :name => 'term[category_id]')
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def move_all
|
||||
projs = Project.visible.all
|
||||
@allowed_projs = projs.find_all {|proj|
|
||||
User.current.allowed_to?({:controller =>'glossary', :action => 'index'}, proj) and
|
||||
User.current.allowed_to?({:controller =>'glossary', :action => 'move_all'}, proj) and
|
||||
proj != @project
|
||||
}
|
||||
if request.post?
|
||||
newproj = Project.find(params[:new_project_id])
|
||||
cats = TermCategory.where(:project_id => newproj.id).order(:position)
|
||||
posbase = (cats.blank?) ? 0 : cats.last.position - 1;
|
||||
cats = TermCategory.where(:project_id => @project.id)
|
||||
cats.each {|cat|
|
||||
cat.project_id = newproj.id
|
||||
cat.position += cat.position + posbase
|
||||
cat.save
|
||||
}
|
||||
Term.where(project_id: @project.id).update_all(project_id: newproj.id)
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to({:action => 'index', :project_id => newproj})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def import_csv
|
||||
end
|
||||
|
||||
def import_csv_exec
|
||||
@import_info = CsvGlossaryImportInfo.new(params)
|
||||
glossary_from_csv(@import_info, @project.id)
|
||||
if (@import_info.success?)
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
else
|
||||
flash.now[:error] = l(:error_import_failed) + " " + @import_info.err_string
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def show_param?(prmname)
|
||||
case prmname
|
||||
when 'project'
|
||||
return false unless @glossary_style.project_scope != GlossaryStyle::ProjectCurrent
|
||||
return true unless @is_index
|
||||
@glossary_style.groupby != GlossaryStyle::GroupByProject
|
||||
when 'category'
|
||||
return true unless @is_index
|
||||
@glossary_style.groupby != GlossaryStyle::GroupByCategory
|
||||
when 'rubi'
|
||||
(param_visible?(prmname) and !@is_index)
|
||||
when 'abbr_whole'
|
||||
(param_visible?(prmname) and !@is_index)
|
||||
else
|
||||
param_visible?(prmname)
|
||||
end
|
||||
end
|
||||
|
||||
def set_show_params
|
||||
@show_params = default_show_params.find_all {|prmname|
|
||||
show_param?(prmname)
|
||||
}
|
||||
end
|
||||
|
||||
def check_nouse_params(terms, off_params)
|
||||
terms.each {|term|
|
||||
return if off_params.empty?
|
||||
off_params.delete_if {|prm| !term[prm].empty? }
|
||||
}
|
||||
end
|
||||
|
||||
def grouping(type, terms, off_params)
|
||||
grouptbl = {}
|
||||
terms.each {|term|
|
||||
off_params.delete_if {|prm| !term[prm].empty? }
|
||||
tgt = (type == GlossaryStyle::GroupByProject) ? term.project : term.category
|
||||
gterms = grouptbl[tgt];
|
||||
unless (gterms)
|
||||
gterms = GroupingTerms.new(type, tgt)
|
||||
grouptbl[tgt] = gterms
|
||||
end
|
||||
gterms.ary << term
|
||||
}
|
||||
grouptbl.values.sort
|
||||
end
|
||||
|
||||
|
||||
#### sort
|
||||
|
||||
def sort_terms(terms, prms)
|
||||
terms.to_a.sort! {|a, b|
|
||||
re = nil
|
||||
prms.each {|prm|
|
||||
re = Term.compare_by_param(prm, a, b)
|
||||
break if (re != 0)
|
||||
}
|
||||
(re == 0) ? a.id <=> b.id : re
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
#### find
|
||||
|
||||
def join_queries(ary, ex = 'OR')
|
||||
joinstr = " #{ex} "
|
||||
((ary.size == 1) ? ary[0] : "( #{ary.join(joinstr)} )")
|
||||
end
|
||||
|
||||
def query_project_scope(projscope, queries)
|
||||
ary = authorized_projects(projscope, @project,
|
||||
{:controller => :glossary, :action => :index})
|
||||
return false if ary.empty?
|
||||
queries << join_queries(ary.collect{|proj| "project_id = #{proj.id}" })
|
||||
true
|
||||
end
|
||||
|
||||
def query_category(catname, queries)
|
||||
return if (!catname or catname.empty? )
|
||||
if (catname == "(#{l(:label_not_categorized)})")
|
||||
queries << "( category_id IS NULL )"
|
||||
else
|
||||
cats = TermCategory.where(["name LIKE :catname",
|
||||
{:catname => catname + "%"}])
|
||||
ary = []
|
||||
ptn = /^#{Regexp.escape(catname)}\//
|
||||
cats.each {|encat|
|
||||
if (encat.name == catname or encat.name =~ ptn)
|
||||
ary << "category_id = #{encat.id}"
|
||||
end
|
||||
}
|
||||
queries << join_queries(ary) unless (ary.empty?)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def query_search_str(str, queries, symbols)
|
||||
return unless (str and !str.empty?)
|
||||
strs = tokenize_by_space(str)
|
||||
cnt = 0
|
||||
strs.each {|ss|
|
||||
symbols["search_str_#{cnt}".to_sym] = "%#{ss}%"
|
||||
cnt += 1
|
||||
}
|
||||
ary = []
|
||||
default_searched_params.each {|prm|
|
||||
subary = []
|
||||
cnt = 0
|
||||
strs.each {|ss|
|
||||
subary << "( #{prm} LIKE :search_str_#{cnt} )"
|
||||
cnt += 1
|
||||
}
|
||||
ary << join_queries(subary, 'AND')
|
||||
}
|
||||
queries << join_queries(ary) if (0 < ary.size)
|
||||
end
|
||||
|
||||
|
||||
def get_search_index_charset(ch, type)
|
||||
charset = [ch]
|
||||
return charset if type
|
||||
idx = l(:index_ary).index(ch)
|
||||
subary = l(:index_subary)
|
||||
if (subary.is_a?(Array) and subary[idx] and !subary[idx].empty?)
|
||||
if (subary[idx].is_a?(Array))
|
||||
subary[idx].each {|subch|
|
||||
charset << subch
|
||||
}
|
||||
else
|
||||
charset << subary[idx]
|
||||
end
|
||||
end
|
||||
charset
|
||||
end
|
||||
|
||||
|
||||
def query_search_index(ch, type, queries, symbols)
|
||||
return unless (ch and !ch.empty?)
|
||||
charset = get_search_index_charset(ch, type)
|
||||
searchprms = [:name, :abbr_whole, :rubi]
|
||||
searchprms << :name_en if (type)
|
||||
cnt = 0
|
||||
charset.each {|tch|
|
||||
symbols["search_ch_#{cnt}".to_sym] = tch + '%'
|
||||
cnt += 1
|
||||
}
|
||||
ary = []
|
||||
searchprms.each {|prm|
|
||||
subary = []
|
||||
cnt = 0
|
||||
charset.each {|tch|
|
||||
subary << "( #{prm} LIKE :search_ch_#{cnt} )"
|
||||
cnt += 1
|
||||
}
|
||||
ary << join_queries(subary)
|
||||
}
|
||||
@query_string = join_queries(ary)
|
||||
queries << join_queries(ary) if (0 < ary.size)
|
||||
end
|
||||
|
||||
|
||||
def find_terms(project_scope)
|
||||
queries = []
|
||||
symbols = {}
|
||||
return [] unless query_project_scope(project_scope, queries)
|
||||
query_category(params[:search_category], queries)
|
||||
query_search_str(params[:search_str], queries, symbols)
|
||||
query_search_index(params[:search_index_ch], params[:search_index_type],
|
||||
queries, symbols)
|
||||
terms = nil
|
||||
if (queries.empty?)
|
||||
terms = Term.all
|
||||
else
|
||||
query_str = join_queries(queries, "AND")
|
||||
terms = Term.where(query_str, symbols)
|
||||
end
|
||||
if (terms and params[:latest_days] and !params[:latest_days].empty?)
|
||||
limitsec = Time.now.to_i - params[:latest_days].to_i * 60 * 60 * 24
|
||||
limittm = Time.at(limitsec)
|
||||
# terms.delete_if {|prm| (prm.datetime < limittm)}
|
||||
recent_terms = []
|
||||
terms.collect{|prm| recent_terms << prm if prm.datetime >= limittm}
|
||||
recent_terms
|
||||
else
|
||||
terms
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def find_project
|
||||
project_id = params[:project_id] || (params[:issue] && params[:issue][:project_id])
|
||||
@project = Project.find(project_id)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def find_term
|
||||
@term = Term.find_by(project_id: @project.id, id: params[:id])
|
||||
render_404 unless @term
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
|
||||
def attach_files(val, prm)
|
||||
Attachment.attach_files(val, prm)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,61 +0,0 @@
|
|||
class GlossaryStylesController < ApplicationController
|
||||
unloadable
|
||||
|
||||
helper :glossary_styles
|
||||
include GlossaryStylesHelper
|
||||
|
||||
def search
|
||||
newparams = {
|
||||
:controller => 'glossary', :action => 'index', :project_id => Project.find(params[:project_id])
|
||||
}
|
||||
unless (params[:search_clear])
|
||||
for prm in [:search_category, :search_str, :latest_days]
|
||||
if (params[prm] and !params[prm].empty?)
|
||||
if (prm == :latest_days and !(params[prm] =~ /^\d+$/))
|
||||
flash[:warning] = sprintf(l(:error_to_number), params[prm])
|
||||
else
|
||||
newparams[prm] = params[prm]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
redirect_to(newparams)
|
||||
end
|
||||
|
||||
|
||||
def edit
|
||||
if (User.current.anonymous?)
|
||||
if (params[:clear])
|
||||
session[:glossary_style] = nil
|
||||
else
|
||||
session[:glossary_style] = params[:glossary_style]
|
||||
end
|
||||
else
|
||||
unless params[:glossary_style_id].blank?
|
||||
@glossary_style = GlossaryStyle.find_by(:user_id => User.current.id)
|
||||
end
|
||||
|
||||
if (@glossary_style)
|
||||
if (params[:clear])
|
||||
@glossary_style.set_default!
|
||||
else
|
||||
params[:glossary_style].each {|key,val|
|
||||
@glossary_style[key] = val
|
||||
}
|
||||
end
|
||||
else
|
||||
@glossary_style = GlossaryStyle.new(params[:glossary_style])
|
||||
end
|
||||
|
||||
@glossary_style.user_id = User.current.id
|
||||
unless @glossary_style.save
|
||||
flash[:error] = l(:notice_glossary_style_create_f)
|
||||
end
|
||||
end
|
||||
newparams = {:controller => 'glossary', :action => 'index',
|
||||
:project_id => Project.find(params[:project_id]),
|
||||
:glossary_style_id => @glossary_style_id}
|
||||
add_search_params(newparams)
|
||||
redirect_to(newparams)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,80 @@
|
|||
class GlossaryTermsController < ApplicationController
|
||||
|
||||
before_action :find_term_from_id, only: [:show, :edit, :update, :destroy]
|
||||
before_action :find_project_by_project_id, :authorize, except: [:preview]
|
||||
before_action :find_attachments, only: [:preview]
|
||||
|
||||
def index
|
||||
@glossary_terms = GlossaryTerm.where(project_id: @project.id)
|
||||
if not params[:index].nil?
|
||||
@glossary_terms = @glossary_terms.search_by_name(params[:index])
|
||||
elsif not params[:index_rubi].nil?
|
||||
@glossary_terms = @glossary_terms.search_by_rubi(params[:index_rubi])
|
||||
end
|
||||
@grouping = params[:grouping] unless params[:grouping].nil?
|
||||
end
|
||||
|
||||
def new
|
||||
@term = GlossaryTerm.new
|
||||
end
|
||||
|
||||
def create
|
||||
term = GlossaryTerm.new(glossary_term_params)
|
||||
term.project = @project
|
||||
term.save_attachments params[:attachments]
|
||||
if term.save
|
||||
render_attachment_warning_if_needed term
|
||||
redirect_to [@project, term], notice: l(:notice_successful_create)
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
@term.attributes = glossary_term_params
|
||||
@term.save_attachments params[:attachments]
|
||||
if @term.save
|
||||
render_attachment_warning_if_needed @term
|
||||
redirect_to [@project, @term], notice: l(:notice_successful_update)
|
||||
end
|
||||
rescue ActiveRecord::StaleObjectError
|
||||
flash.now[:error] = l(:notice_locking_conflict)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@term.destroy
|
||||
redirect_to project_glossary_terms_path(@project)
|
||||
end
|
||||
|
||||
def preview
|
||||
term = GlossaryTerm.find_by_id(params[:id])
|
||||
if term
|
||||
@attachments += term.attachments
|
||||
@previewed = term
|
||||
end
|
||||
@text = params[:glossary_term][:description]
|
||||
render partial: 'common/preview'
|
||||
end
|
||||
|
||||
# Find the term whose id is the :id parameter
|
||||
def find_term_from_id
|
||||
@term = GlossaryTerm.find(params[:id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def import
|
||||
GlossaryTerm.import(params[:file], @project)
|
||||
redirect_to project_glossary_terms_path(@project)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def glossary_term_params
|
||||
params.require(:glossary_term).permit(
|
||||
:name, :description, :category_id,
|
||||
:name_en, :rubi, :abbr_whole, :datatype, :codename
|
||||
)
|
||||
end
|
||||
end
|
|
@ -1,75 +0,0 @@
|
|||
class TermCategoriesController < ApplicationController
|
||||
unloadable
|
||||
|
||||
layout 'base'
|
||||
menu_item :glossary, :only => [:index, :edit, :destroy]
|
||||
|
||||
before_filter :find_project, :authorize
|
||||
before_filter :retrieve_glossary_style, :only => [:index]
|
||||
|
||||
helper :glossary
|
||||
include GlossaryHelper
|
||||
helper :glossary_styles
|
||||
include GlossaryStylesHelper
|
||||
|
||||
|
||||
def index
|
||||
@categories = TermCategory.where(project_id: @project.id).order(:position)
|
||||
end
|
||||
|
||||
def edit
|
||||
@category = TermCategory.find_by(project_id: @project.id, id: params[:id])
|
||||
if request.patch? and @category.update_attributes(params[:category])
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to :controller => 'term_categories', :action => 'index', :project_id => @project
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def change_order
|
||||
if request.post?
|
||||
category = TermCategory.find_by(project_id: @project.id, id: params[:id])
|
||||
case params[:position]
|
||||
when 'highest'; category.move_to_top
|
||||
when 'higher'; category.move_higher
|
||||
when 'lower'; category.move_lower
|
||||
when 'lowest'; category.move_to_bottom
|
||||
end if params[:position]
|
||||
redirect_to :controller => 'term_categories', :action => 'index', :project_id => @project
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def destroy
|
||||
@category = TermCategory.find_by(project_id: @project.id, id: params[:id])
|
||||
@term_count = @category.terms.size
|
||||
if @term_count == 0
|
||||
@category.destroy
|
||||
redirect_to :controller => 'term_categories', :action => 'index', :project_id => @project
|
||||
elsif params[:todo]
|
||||
reassign_to = TermCategory.find_by(project_id: @project.id, id: params[:reassign_to_id]) if params[:todo] == 'reassign'
|
||||
@category.destroy(reassign_to)
|
||||
redirect_to :controller => 'term_categories', :action => 'index', :project_id => @project
|
||||
end
|
||||
@categories = TermCategory.where(project_id: @project.id) - [@category]
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
private
|
||||
def find_project
|
||||
@project = Project.find(params[:project_id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def conditions_projects()
|
||||
ary = authorized_projects(@glossary_style.project_scope, @project,
|
||||
{:controller => :term_categories, :action => :edit})
|
||||
return nil if ary.empty?
|
||||
return ary.collect{|proj| "project_id = #{proj.id}" }.join(" OR ")
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module GlossaryCategoriesHelper
|
||||
end
|
|
@ -1,73 +0,0 @@
|
|||
require 'glossary_import_info'
|
||||
|
||||
module GlossaryHelper
|
||||
|
||||
def label_param(prmname)
|
||||
case prmname
|
||||
when 'id'
|
||||
'#'
|
||||
when 'project'
|
||||
I18n.t(:label_project)
|
||||
when 'category'
|
||||
I18n.t(:field_category)
|
||||
when 'datetime'
|
||||
I18n.t(:field_updated_on)
|
||||
when 'author'
|
||||
I18n.t(:field_author)
|
||||
when 'updater'
|
||||
I18n.t(:label_updater)
|
||||
when 'created_on'
|
||||
I18n.t(:field_created_on)
|
||||
when 'updated_on'
|
||||
I18n.t(:field_updated_on)
|
||||
when 'description'
|
||||
I18n.t(:field_description)
|
||||
else
|
||||
I18n.t("label.#{prmname}")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def param_visible?(prmname)
|
||||
!Setting.plugin_redmine_glossary["hide_item_#{prmname}"]
|
||||
end
|
||||
|
||||
def collect_visible_params(prmary)
|
||||
ary = []
|
||||
prmary.collect{|prm| ary << prm if param_visible?(prm)}
|
||||
ary
|
||||
end
|
||||
|
||||
def default_show_params; Term.default_show_params; end
|
||||
def default_searched_params; Term.default_searched_params; end
|
||||
def default_sort_params; Term.default_sort_params; end
|
||||
|
||||
|
||||
def params_select(form, name, prms)
|
||||
vprms = collect_visible_params(prms)
|
||||
options = vprms.collect{|prm| [label_param(prm), prm]}
|
||||
form.select(name, options, :include_blank=>true)
|
||||
end
|
||||
|
||||
def params_select_tag(name, prms, defaultprm)
|
||||
options = [""]
|
||||
options += prms.collect{|prm| [label_param(prm), prm]}
|
||||
select_tag(name, options_from_collection_for_select(options), defaultprm)
|
||||
end
|
||||
|
||||
|
||||
# extract tokens from the question
|
||||
# eg. hello "bye bye" => ["hello", "bye bye"]
|
||||
def tokenize_by_space(str)
|
||||
str.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).collect {|m|
|
||||
m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
|
||||
def updated_by(updated, author)
|
||||
l(:label_updated_time_by, :author => link_to_user(author), :age => time_tag(updated)).html_safe
|
||||
end
|
||||
|
||||
end
|
|
@ -1,99 +0,0 @@
|
|||
module GlossaryPortHelper
|
||||
|
||||
|
||||
#def glossary_csvout(csv, ic, ary)
|
||||
def glossary_csvout(csv, ary)
|
||||
csv << ary.collect {|c|
|
||||
begin
|
||||
#ic.iconv(c.to_s)
|
||||
Redmine::CodesetUtil.from_utf8(c.to_s, l(:general_csv_encoding))
|
||||
rescue
|
||||
c.to_s
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def glossary_to_csv(terms)
|
||||
#ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
||||
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
|
||||
# csv header fields
|
||||
headers = Term.export_params.collect {|prm|
|
||||
label_param(prm)
|
||||
}
|
||||
|
||||
#glossary_csvout(csv, ic, headers)
|
||||
glossary_csvout(csv, headers)
|
||||
|
||||
# csv lines
|
||||
terms.each do |term|
|
||||
fields = Term.export_params.collect {|prm|
|
||||
term.param_to_s(prm)
|
||||
}
|
||||
#glossary_csvout(csv, ic, fields)
|
||||
glossary_csvout(csv, fields)
|
||||
end
|
||||
end
|
||||
export
|
||||
end
|
||||
|
||||
|
||||
def glossary_from_csv(portinfo, projid)
|
||||
line_count = 0
|
||||
begin
|
||||
#ic = Iconv.new('UTF-8', portinfo.in_encoding)
|
||||
|
||||
raise l(:error_file_none) if (!portinfo.import_file)
|
||||
FCSV::parse(portinfo.import_file.read) { |row|
|
||||
line_count += 1
|
||||
next if (portinfo.is_first_comment and line_count == 1)
|
||||
next if (row.empty?)
|
||||
|
||||
name = row[portinfo.param_col('name')]
|
||||
raise sprintf(l(:error_no_name), t("label.name")) unless name
|
||||
|
||||
#name = ic.iconv(name)
|
||||
name = Redmine::CodesetUtil.to_utf8(name, portinfo.in_encoding)
|
||||
term = Term.find_by(project_id: projid, name: name)
|
||||
if (term)
|
||||
portinfo.upterm_num += 1
|
||||
else
|
||||
term = Term.new(:name => name, :project_id => projid)
|
||||
portinfo.newterm_num += 1
|
||||
end
|
||||
|
||||
for col in 0 ... row.size
|
||||
prm = portinfo.col_param(col)
|
||||
next unless prm
|
||||
#val = ic.iconv(row[col].to_s)
|
||||
val = Redmine::CodesetUtil.to_utf8(row[col].to_s, portinfo.in_encoding)
|
||||
case prm
|
||||
when 'name'
|
||||
when 'category'
|
||||
unless val.empty? then
|
||||
cat = TermCategory.find_by_name(val)
|
||||
unless (cat)
|
||||
cat = TermCategory.new(:name => val, :project_id => projid)
|
||||
unless (cat.save)
|
||||
raise l(:error_create_term_category)
|
||||
end
|
||||
portinfo.cat_num += 1
|
||||
end
|
||||
term['category_id'] = cat.id
|
||||
end
|
||||
else
|
||||
term[prm] = val
|
||||
end
|
||||
end
|
||||
unless (term.save)
|
||||
raise l(:error_create_term)
|
||||
end
|
||||
}
|
||||
rescue => evar
|
||||
portinfo.err_string = evar.to_s
|
||||
if (0 < line_count)
|
||||
portinfo.err_string += sprintf(l(:error_csv_import_row), line_count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,107 +0,0 @@
|
|||
module GlossaryStylesHelper
|
||||
|
||||
def retrieve_glossary_style
|
||||
if (User.current.anonymous?)
|
||||
if (session[:glossary_style])
|
||||
@glossary_style = GlossaryStyle.new(session[:glossary_style])
|
||||
end
|
||||
else
|
||||
if !params[:glossary_style_id].blank?
|
||||
@glossary_style = GlossaryStyle.find_by(params[:glossary_style_id])
|
||||
else
|
||||
@glossary_style= GlossaryStyle.find_by(:user_id => User.current.id)
|
||||
end
|
||||
end
|
||||
|
||||
unless (@glossary_style)
|
||||
@glossary_style = GlossaryStyle.new(:groupby => GlossaryStyle::GroupByCategory)
|
||||
@glossary_style.user_id = User.current.id
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def search_index_table(ary, sepcnt, proj, search_index_type = nil)
|
||||
return "" if (!ary.is_a?(Array) or sepcnt <= 0)
|
||||
str = '<table id="glossary_index"><tr>'
|
||||
cnt = 0
|
||||
for ch in ary
|
||||
str += '</tr><tr>' if ((cnt != 0) and (cnt % sepcnt) == 0 )
|
||||
cnt += 1
|
||||
str += '<td>'
|
||||
if (ch and !ch.empty?)
|
||||
prms = {:controller => 'glossary', :action => 'index', :project_id => proj,
|
||||
:search_index_ch => ch}
|
||||
prms[:search_index_type] = search_index_type if (search_index_type)
|
||||
str += link_to(ch, prms)
|
||||
end
|
||||
str += '</td>'
|
||||
end
|
||||
str += '</tr></table>'
|
||||
str.html_safe
|
||||
end
|
||||
|
||||
def search_params
|
||||
[:search_str, :search_category, :latest_days]
|
||||
end
|
||||
|
||||
def search_params_all
|
||||
search_params + [:search_index_ch, :search_index_type]
|
||||
end
|
||||
|
||||
def add_search_params(prms)
|
||||
search_params_all.each {|prm|
|
||||
prms[prm] = params[prm] if (params[prm] and !params[prm].empty?)
|
||||
}
|
||||
end
|
||||
|
||||
def glossary_searching?
|
||||
search_params.each {|prm|
|
||||
return true if (params[prm] and !params[prm].empty?)
|
||||
}
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
def authorized_projects(projscope, curproj, authcnd)
|
||||
ary = []
|
||||
case projscope
|
||||
when GlossaryStyle::ProjectCurrent
|
||||
return [curproj]
|
||||
when GlossaryStyle::ProjectMine
|
||||
ary = User.current.memberships.collect(&:project).compact.uniq
|
||||
when GlossaryStyle::ProjectAll
|
||||
ary = Project.visible.all
|
||||
end
|
||||
ary.find_all {|proj|
|
||||
User.current.allowed_to?(authcnd, proj)
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
def break_categories(cats)
|
||||
catstrs = []
|
||||
cats.each {|cat|
|
||||
catstrs << cat.name
|
||||
if (cat.name.include?('/'))
|
||||
str = cat.name
|
||||
while (str =~ /^(.+)\/[^\/]+$/)
|
||||
str = $1
|
||||
catstrs << str
|
||||
end
|
||||
end
|
||||
}
|
||||
catstrs
|
||||
end
|
||||
|
||||
def seach_category_options(projscope, curproj)
|
||||
options = [""]
|
||||
projs = authorized_projects(projscope, curproj, {:controller => :glossary, :action => :index})
|
||||
unless (projs.empty?)
|
||||
querystr = projs.collect {|proj| "project_id = #{proj.id}"}.join(" OR ")
|
||||
options += break_categories(TermCategory.where(querystr)).sort.uniq
|
||||
end
|
||||
options << "(#{l(:label_not_categorized)})"
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module GlossaryTermsHelper
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module TermCategoriesHelper
|
||||
end
|
9
plugins/redmine_glossary/app/models/glossary_category.rb
Normal file
9
plugins/redmine_glossary/app/models/glossary_category.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class GlossaryCategory < ActiveRecord::Base
|
||||
has_many :terms, class_name: 'GlossaryTerm', foreign_key: 'category_id'
|
||||
belongs_to :project
|
||||
|
||||
acts_as_positioned
|
||||
|
||||
scope :sorted, lambda { order(:position) }
|
||||
|
||||
end
|
|
@ -1,52 +0,0 @@
|
|||
class GlossaryStyle < ActiveRecord::Base
|
||||
unloadable
|
||||
|
||||
GroupByNone = 0
|
||||
GroupByCategory = 1
|
||||
GroupByProject = 2
|
||||
|
||||
ProjectCurrent = 0
|
||||
ProjectMine = 1
|
||||
ProjectAll = 2
|
||||
|
||||
belongs_to :project
|
||||
|
||||
attr_accessible :groupby
|
||||
|
||||
def grouping?
|
||||
case groupby
|
||||
when GroupByCategory
|
||||
return true
|
||||
when GroupByProject
|
||||
return (project_scope != ProjectCurrent)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def set_default!
|
||||
self['show_desc'] = false
|
||||
self['groupby'] = 1
|
||||
self['project_scope'] = 0
|
||||
self['sort_item_0'] = ''
|
||||
self['sort_item_1'] = ''
|
||||
self['sort_item_2'] = ''
|
||||
end
|
||||
|
||||
def sort_params
|
||||
ary = []
|
||||
for cnt in 0...3
|
||||
prm = self["sort_item_#{cnt}"]
|
||||
if (prm and !prm.empty?)
|
||||
case prm
|
||||
when 'project'
|
||||
next if (groupby == GroupByProject or project_scope == ProjectCurrent)
|
||||
when 'category'
|
||||
next if (groupby == GroupByCategory)
|
||||
end
|
||||
ary << prm
|
||||
end
|
||||
end
|
||||
ary.uniq
|
||||
end
|
||||
|
||||
end
|
59
plugins/redmine_glossary/app/models/glossary_term.rb
Normal file
59
plugins/redmine_glossary/app/models/glossary_term.rb
Normal file
|
@ -0,0 +1,59 @@
|
|||
require 'csv'
|
||||
|
||||
class GlossaryTerm < ActiveRecord::Base
|
||||
belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id'
|
||||
belongs_to :project
|
||||
belongs_to :author, class_name: 'User', foreign_key: 'author_id'
|
||||
belongs_to :updater, class_name: 'User', foreign_key: 'updater_id'
|
||||
|
||||
# class method from Redmine::Acts::Attachable::ClassMethods
|
||||
acts_as_attachable view_permission: :view_glossary_terms, edit_permission: :manage_glossary_terms,
|
||||
delete_permission: :manage_glossary_terms
|
||||
|
||||
acts_as_event datetime: :updated_at,
|
||||
description: :description,
|
||||
author: nil,
|
||||
title: Proc.new {|o| "#{l(:glossary_title)} ##{o.id} - #{o.name}" },
|
||||
url: Proc.new {|o| { controller: 'glossary_terms',
|
||||
action: 'show',
|
||||
id: o.id,
|
||||
project_id: o.project }
|
||||
}
|
||||
|
||||
acts_as_searchable columns: [ "#{table_name}.name", "#{table_name}.description", "#{table_name}.rubi"],
|
||||
preload: [:project ],
|
||||
date_column: "#{table_name}.created_at",
|
||||
scope: joins(:project),
|
||||
permission: :view_glossary_terms
|
||||
|
||||
acts_as_activity_provider scope: joins(:project),
|
||||
type: 'glossary_terms',
|
||||
permission: :view_glossary_terms,
|
||||
timestamp: :updated_at
|
||||
|
||||
scope :search_by_name, -> (keyword) {
|
||||
where 'name like ?', "#{sanitize_sql_like(keyword)}%"
|
||||
}
|
||||
|
||||
scope :search_by_rubi, -> (keyword) {
|
||||
where 'rubi like ?', "#{sanitize_sql_like(keyword)}%"
|
||||
}
|
||||
|
||||
def self.csv_attributes
|
||||
["name", "name_en", "datatype", "codename", "description", "rubi", "abbr_whole"]
|
||||
end
|
||||
|
||||
def self.import(file, project)
|
||||
CSV.foreach(file.path, headers: true, encoding: "CP932:UTF-8" ) do |row|
|
||||
term = new
|
||||
term.attributes = row.to_hash.slice(*csv_attributes)
|
||||
term.project = project
|
||||
unless row["category"].blank?
|
||||
term.category = GlossaryCategory.find_by(name: row["category"]) ||
|
||||
GlossaryCategory.create(name: row["category"], project: project)
|
||||
end
|
||||
term.save!
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,149 +0,0 @@
|
|||
class Term < ActiveRecord::Base
|
||||
unloadable
|
||||
|
||||
belongs_to :category, :class_name => 'TermCategory', :foreign_key => 'category_id'
|
||||
belongs_to :project
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
|
||||
validates_presence_of :name, :project
|
||||
validates_length_of :name, :maximum => 255
|
||||
|
||||
acts_as_attachable
|
||||
|
||||
acts_as_searchable :columns => ["#{table_name}.name", "#{table_name}.description"],
|
||||
:project_key => [:project]
|
||||
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:glossary_title)} ##{o.id}: #{o.name}" },
|
||||
:description => Proc.new {|o| "#{o.description}"},
|
||||
:datetime => :created_on,
|
||||
:type => 'terms',
|
||||
:url => Proc.new {|o| {:controller => 'glossary', :action => 'show', :id => o.project, :term_id => o.id} }
|
||||
|
||||
attr_accessible :project_id, :category_id, :author, :name, :name_en, :datatype, :codename, :description,
|
||||
:rubi, :abbr_whole
|
||||
|
||||
def author
|
||||
author_id ? User.find_by_id(author_id) : nil
|
||||
end
|
||||
|
||||
def updater
|
||||
updater_id ? User.find_by_id(updater_id) : nil
|
||||
end
|
||||
|
||||
def project
|
||||
Project.find_by_id(project_id)
|
||||
end
|
||||
|
||||
def datetime
|
||||
(self[:created_on] != self[:updated_on]) ? self[:updated_on] : self[:created_on]
|
||||
end
|
||||
|
||||
def value(prmname)
|
||||
case prmname
|
||||
when 'project'
|
||||
(project) ? project.name : ""
|
||||
when 'category'
|
||||
(category) ? category : ""
|
||||
when 'datetime'
|
||||
datetime
|
||||
else
|
||||
self[prmname]
|
||||
end
|
||||
end
|
||||
|
||||
def param_to_s(prmname)
|
||||
if (prmname == 'created_on' or prmname == 'updated_on')
|
||||
format_time(self[prmname])
|
||||
else
|
||||
value(prmname).to_s
|
||||
end
|
||||
end
|
||||
|
||||
def <=>(term)
|
||||
id <=> term.id
|
||||
end
|
||||
|
||||
|
||||
def self.compare_safe(a, b, &blk)
|
||||
if (!a and !b)
|
||||
return 0
|
||||
elsif (!a or !b)
|
||||
return -1 if a
|
||||
return 1 if b
|
||||
end
|
||||
yield(a,b)
|
||||
end
|
||||
|
||||
|
||||
def self.compare_by_param(prm, a, b)
|
||||
case prm
|
||||
when 'project'
|
||||
a.project.identifier <=> b.project.identifier
|
||||
when 'category'
|
||||
self.compare_safe(a.category, b.category) {|acat, bcat|
|
||||
acat.position <=> bcat.position
|
||||
}
|
||||
when 'datetime'
|
||||
self.compare_safe(a.value(prm), b.value(prm)) {|aval, bval|
|
||||
(aval <=> bval) * -1
|
||||
}
|
||||
when 'name'
|
||||
((a.rubi.empty?) ? a.name : a.rubi) <=> ((b.rubi.empty?) ? b.name : b.rubi)
|
||||
else
|
||||
self.compare_safe(a.value(prm), b.value(prm)) {|aval, bval|
|
||||
aval <=> bval
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def to_s
|
||||
"##{id}: #{name}"
|
||||
end
|
||||
|
||||
def self.find_for_macro(tname, proj, all_project = false)
|
||||
if proj
|
||||
term = Term.find_by(:project_id => proj.id, :name => tname)
|
||||
return term if term
|
||||
end
|
||||
return nil unless all_project
|
||||
return self.find_by_name(tname)
|
||||
end
|
||||
|
||||
def self.default_show_params
|
||||
['name_en', 'rubi', 'abbr_whole', 'datatype', 'codename', 'project', 'category']
|
||||
end
|
||||
|
||||
def self.default_searched_params
|
||||
['name', 'name_en', 'abbr_whole', 'datatype', 'codename', 'description']
|
||||
end
|
||||
|
||||
def self.default_sort_params
|
||||
['id', 'name', 'name_en', 'abbr_whole', 'datatype', 'codename', 'project', 'category',
|
||||
'datetime']
|
||||
end
|
||||
|
||||
def self.hidable_params
|
||||
['name_en', 'rubi', 'abbr_whole', 'datatype', 'codename']
|
||||
end
|
||||
|
||||
def self.setting_params
|
||||
['name_en', 'rubi', 'abbr_whole', 'datatype', 'codename']
|
||||
end
|
||||
|
||||
def self.export_params
|
||||
['id','project',
|
||||
'name', 'name_en', 'rubi', 'abbr_whole', 'category', 'datatype', 'codename',
|
||||
'author', 'updater', 'created_on', 'updated_on',
|
||||
'description']
|
||||
end
|
||||
|
||||
def self.import_params
|
||||
['name', 'name_en', 'rubi', 'abbr_whole', 'category', 'datatype', 'codename',
|
||||
'description']
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
|
@ -1,29 +0,0 @@
|
|||
class TermCategory < ActiveRecord::Base
|
||||
belongs_to :project
|
||||
has_many :terms, :foreign_key => 'category_id', :dependent => :nullify
|
||||
|
||||
acts_as_list :scope => :project_id
|
||||
|
||||
attr_accessible :name, :project_id, :position
|
||||
|
||||
validates_presence_of :name
|
||||
validates_uniqueness_of :name, :scope => [:project_id]
|
||||
|
||||
alias :destroy_without_reassign :destroy
|
||||
|
||||
# Destroy the category
|
||||
# If a category is specified, terms are reassigned to this category
|
||||
def destroy(reassign_to = nil)
|
||||
if reassign_to && reassign_to.is_a?(TermCategory) && reassign_to.project == self.project
|
||||
Term.update_all("category_id = #{reassign_to.id}", "category_id = #{id}")
|
||||
end
|
||||
destroy_without_reassign
|
||||
end
|
||||
|
||||
def <=>(category)
|
||||
position <=> category.position
|
||||
end
|
||||
|
||||
def to_s; name end
|
||||
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
<h3 class="title"><%=l(:label_term_category_new)%></h3>
|
||||
|
||||
<% form = labelled_form_for @category, :as => :category, :url => { :action => 'add_term_category', :project_id => @project }, :html => {:class => 'tabular'} do |f| %>
|
||||
<%= render :partial => 'term_categories/form', :locals => { :f => f } %>
|
||||
<p class="buttons">
|
||||
<%= submit_tag l(:button_create), :name => nil %>
|
||||
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "hideModal(this);", :type => 'button' %>
|
||||
</p>
|
||||
<% end %>
|
||||
<%= form if Rails::VERSION::MAJOR >= 3 %>
|
|
@ -1,38 +0,0 @@
|
|||
|
||||
<p><%= f.text_field :name, :label=>t('label.name'), :size => 100, :required => true %></p>
|
||||
|
||||
<% for prm in Term.setting_params %>
|
||||
<% if param_visible?(prm) %>
|
||||
<p><%= f.text_field prm, :label=>label_param(prm), :size => 100 %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<div class="splitcontentleft">
|
||||
<p><%= f.select :category_id, (@term_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>
|
||||
<% if Rails::VERSION::MAJOR >= 3 %>
|
||||
<%= link_to(l(:label_term_category_new),
|
||||
{:controller => 'glossary', :action => 'add_term_category', :project_id => @project.id },
|
||||
:category => 'category[name]',
|
||||
:class => 'icon icon-add',
|
||||
:tabindex => 199,
|
||||
:method => 'get',
|
||||
:remote => true) if authorize_for('glossary', 'add_term_category') %></p>
|
||||
<% else %>
|
||||
<%= prompt_to_remote(l(:label_term_category_new),
|
||||
l(:label_term_category_new), 'category[name]',
|
||||
{:controller => 'glossary', :action => 'add_term_category', :project_id => @project },
|
||||
:class => 'icon icon-add', :tabindex => 199) if authorize_for('glossary', 'add_term_category') %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
<p><%= f.text_area :description, :label=>t('label.description'),
|
||||
:cols => 60,
|
||||
:rows => (@term.description.blank? ? 10 : [[10, @term.description.length / 50].max, 100].min),
|
||||
:accesskey => accesskey(:edit),
|
||||
:class => 'wiki-edit' %></p>
|
||||
|
||||
|
||||
|
||||
<p />
|
||||
<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
|
||||
|
||||
<%= wikitoolbar_for 'term_description' %>
|
|
@ -1,31 +0,0 @@
|
|||
<table class="list glossary">
|
||||
<thead><tr align="left">
|
||||
<th>#</th>
|
||||
<th><%=h t('label.name') %></th>
|
||||
<% for prm in @show_params %>
|
||||
<th><%=h label_param(prm) %></th>
|
||||
<% end %>
|
||||
<th><%=h l(:field_description)%></th>
|
||||
<th></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% for term in index_in_category -%>
|
||||
<tr class="<%= cycle("odd", "even") %> term">
|
||||
<td><%=h term.id %></td>
|
||||
<td><%= term_link(term) %></td>
|
||||
<% for prm in @show_params %>
|
||||
<td><%=h term.value(prm) %></td>
|
||||
<% end %>
|
||||
<!--td><%=h truncate(term.description, :length=>50) %></td-->
|
||||
<td><% @paragraphs = Nokogiri::HTML.parse(term.description).css('p') %><%=textilizable @paragraphs.first.inner_html + (@paragraphs.size > 1 ? '<p>…</p>' : '') %></td>
|
||||
<td align="right" width="40px">
|
||||
<% if term.project_id == @project.id %>
|
||||
<%= link_to_if_authorized(image_tag('edit.png'), {:action => 'edit', :project_id => @project, :id => term}, :title => l(:button_edit)) %>
|
||||
<%= link_to_if_authorized(image_tag('delete.png'), {:action => 'destroy', :project_id => @project, :id => term}, :confirm => l(:text_are_you_sure), :method => :post, :title => l(:button_delete)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<br />
|
|
@ -1,9 +0,0 @@
|
|||
|
||||
<% for term in show_all_in_category -%>
|
||||
<div class="term" >
|
||||
<h3> <%= term_link(term) %> </h3>
|
||||
<%= render(:partial => "glossary/show_one", :object => term) %>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
<br />
|
|
@ -1,21 +0,0 @@
|
|||
|
||||
<% term = show_one %>
|
||||
<% if @show_params.size > 1 %>
|
||||
<table class="term_items">
|
||||
<% for prm in @show_params %>
|
||||
<% unless term.value(prm).blank? %><tr><th><%=h label_param(prm) %>:</th><td><%= term.value(prm) %></td></tr><% end %>
|
||||
<% end %>
|
||||
</table>
|
||||
<% end %>
|
||||
<% unless (term.description.empty?) %>
|
||||
<% if @show_params.size > 1 %><strong><%= l(:field_description) %></strong>:<% end %>
|
||||
<div class="wiki">
|
||||
<%= textilizable term, :description, :attachments => term.attachments %>
|
||||
</div>
|
||||
|
||||
<% if term.attachments.any? %>
|
||||
<%= (@is_index) ? "" : '<hr />' %>
|
||||
<%= link_to_attachments term %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
|
||||
<% if User.current.allowed_to?(:view_terms, @project, :global => true) %>
|
||||
<h3><%= l(:label_view) %></h3>
|
||||
<%= render(:partial => "glossary_styles/form",
|
||||
:object => @view_style) %>
|
||||
<br />
|
||||
<% end %>
|
||||
|
||||
|
||||
<% if User.current.allowed_to?(:manage_terms, @project, :global => true) %>
|
||||
<h3><%= l(:label_term) %></h3>
|
||||
<%= link_to(l(:label_term_new), {:controller => 'glossary', :action => 'new', :project_id => @project}, :class => 'icon icon-add') %>
|
||||
<br />
|
||||
<% if (Term.find_by(:project_id => @project.id)) %>
|
||||
<%= link_to_if_authorized(l(:label_move_all_terms), {:controller => 'glossary', :action => 'move_all', :project_id => @project}, :class => 'icon icon-move') %>
|
||||
<br />
|
||||
<% end %>
|
||||
<%= link_to(l(:label_glossary_import_csv), {:controller => 'glossary', :action => 'import_csv', :project_id => @project}, :id => 'glossary_import_csv') %>
|
||||
<br />
|
||||
<% end %>
|
||||
|
||||
|
||||
<% if User.current.allowed_to?(:manage_term_categories, @project, :global => true) %>
|
||||
<h3><%= l(:label_term_category) %></h3>
|
||||
<%= link_to(l(:label_term_category_new), {:controller => 'glossary', :action => 'add_term_category', :project_id => @project}, :class => 'icon icon-add') %>
|
||||
<br />
|
||||
<%= link_to(l(:label_manage_term_category), { :controller => 'term_categories', :action => 'index', :project_id => @project }, :id => 'glossary_term_categories') %>
|
||||
<br />
|
||||
<% end %>
|
||||
|
||||
|
||||
<% if User.current.allowed_to?(:view_terms, @project, :global => true) %>
|
||||
<h3><%= l(:label_glossary_style_index) %></h3>
|
||||
|
||||
<% if params[:search_index_ch] %>
|
||||
<div class="contextual">
|
||||
<%= link_to_if_authorized(l(:button_clear), {:controller => 'glossary', :action => 'index_clear', :project_id => @project}, :class => 'icon icon-reload') %>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= search_index_table(l(:index_ary_en), l(:index_ary_en_sep_cnt), @project, 'en') %>
|
||||
<br />
|
||||
<%= search_index_table(l(:index_ary), l(:index_ary_sep_cnt), @project) %>
|
||||
<br />
|
||||
<% end %>
|
|
@ -1,10 +0,0 @@
|
|||
|
||||
<% content_for :sidebar do %>
|
||||
<%= render :partial => 'glossary/sidebar' %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= stylesheet_link_tag 'glossary', :plugin => 'redmine_glossary' %>
|
||||
<% end %>
|
||||
|
||||
<% html_title(l(:glossary_title)) -%>
|
|
@ -1,9 +0,0 @@
|
|||
<h2><%=l(:label_term_category_new)%></h2>
|
||||
|
||||
<% form = labelled_form_for @category, :as => :category, :url => { :action => 'add_term_category', :project_id => @project }, :html => {:class => 'tabular'} do |f| %>
|
||||
<%= render :partial => 'term_categories/form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<% end %>
|
||||
<%= form if Rails::VERSION::MAJOR >= 3 %>
|
||||
|
||||
<% html_title(l(:glossary_title)) -%>
|
|
@ -1,2 +0,0 @@
|
|||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'glossary/add_term_category_modal') %>');
|
||||
showModal('ajax-modal', '600px');
|
|
@ -1,29 +0,0 @@
|
|||
<h2><%= l(:label_term) %> #<%= @term.id %></h2>
|
||||
|
||||
<% form = labelled_form_for @term, :as => :term,
|
||||
:url => {:action => 'edit', :project_id => @project, :id => @term},
|
||||
:html => {:class => 'tabular', :multipart => true, :id => 'term-form'} do |f| %>
|
||||
<%= error_messages_for 'term' %>
|
||||
<div class="box">
|
||||
<%= render :partial => 'glossary/form', :locals => {:f => f} %>
|
||||
</div>
|
||||
<%= submit_tag l(:button_edit) %>
|
||||
<% if Rails::VERSION::MAJOR >= 3 %>
|
||||
<%= preview_link({:controller => 'glossary', :action => 'preview', :project_id => @project.id },
|
||||
"term-form",
|
||||
"preview") %>
|
||||
<% else %>
|
||||
<%= link_to_remote l(:label_preview),
|
||||
{ :url => { :controller => 'glossary', :action => 'preview', :project_id => @project },
|
||||
:method => 'post',
|
||||
:update => 'preview',
|
||||
:with => "Form.serialize('term-form')",
|
||||
:complete => "Element.scrollTo('preview')"
|
||||
}, :accesskey => accesskey(:preview) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= form if Rails::VERSION::MAJOR >= 3 %>
|
||||
|
||||
<div id="preview" class="wiki"></div>
|
||||
|
||||
<% html_title(l(:glossary_title)) -%>
|
|
@ -1,57 +0,0 @@
|
|||
<h2><%=h l(:label_glossary_import_csv) %> </h2>
|
||||
|
||||
|
||||
<% form = form_tag({:controller => 'glossary', :action => 'import_csv_exec', :project_id=>@project},
|
||||
{:multipart => true}) do %>
|
||||
|
||||
<%= l(:label_csv_file) %>
|
||||
<%= file_field_tag 'import_file', :accept => 'text/csv', :size => '60%' %>
|
||||
<br />
|
||||
<br />
|
||||
<% encs = l(:in_encoding_candidates)
|
||||
if (encs and encs.is_a?(Array) and !encs.empty?)
|
||||
enc_options = []
|
||||
encs.each {|enc|
|
||||
enc_options << enc
|
||||
}
|
||||
%>
|
||||
<%=h l(:label_file_encoding) %>
|
||||
<%= select_tag("in_encoding", options_for_select(enc_options)) %>
|
||||
<br />
|
||||
<% end %>
|
||||
|
||||
<label> <%= check_box_tag("is_first_comment", '1', true) %>
|
||||
<%= l(:label_csv_import_is_first_comment) %> </label>
|
||||
<br />
|
||||
|
||||
<br />
|
||||
|
||||
<%
|
||||
name_options = []
|
||||
options = [""]
|
||||
for num in 1 ... 30
|
||||
name_options << num
|
||||
options << num
|
||||
end
|
||||
%>
|
||||
<fieldset>
|
||||
<legend><%= l(:label_import_items) %></legend>
|
||||
|
||||
<table>
|
||||
<tr><th><%=h l(:label_item) %></th><th><%=h l(:label_column) %></th></tr>
|
||||
<% CsvGlossaryImportInfo.default_param_cols {|prm, col| %>
|
||||
<tr><td><%=h label_param(prm) %></td><td>
|
||||
<%= select_tag("colno_#{prm}",
|
||||
options_for_select((prm == 'name') ? name_options : options, col)) %>
|
||||
</td></tr>
|
||||
<% } %>
|
||||
</table>
|
||||
* <%=h l(:message_import_item) %>
|
||||
</fieldset>
|
||||
<br />
|
||||
|
||||
<%= submit_tag(l(:label_import)) %>
|
||||
<% end %>
|
||||
<%= form if Rails::VERSION::MAJOR >= 3 %>
|
||||
|
||||
<% html_title(l(:glossary_title)) -%>
|
|
@ -1,13 +0,0 @@
|
|||
<h2> <%=h l(:label_csv_import_finished) %> </h2>
|
||||
|
||||
|
||||
<table class="term_items">
|
||||
<tr><th><%=h l(:label_csv_file) %> : </th><td>
|
||||
<%=h (@import_info.import_file) ? @import_info.import_file.original_filename : "" %>
|
||||
</td></tr>
|
||||
<tr><th><%=h l(:label_create_category_num) %> : </th><td> <%= @import_info.cat_num %> </td></tr>
|
||||
<tr><th><%=h l(:label_create_term_num) %> : </th><td> <%= @import_info.newterm_num %> </td></tr>
|
||||
<tr><th><%=h l(:label_update_term_num) %> : </th><td> <%= @import_info.upterm_num %> </td></tr>
|
||||
</table>
|
||||
|
||||
<%= render :partial => 'glossary/view_term' %>
|
|
@ -1,42 +0,0 @@
|
|||
|
||||
<div class="contextual">
|
||||
<%= link_to_if_authorized(l(:label_term_new), {:controller => 'glossary', :action => 'new', :project_id => @project}, :class => 'icon icon-add') %>
|
||||
</div>
|
||||
|
||||
<%
|
||||
subtitle = ""
|
||||
if params[:search_index_ch]
|
||||
subtitlle = "- #{params[:search_index_ch]} -"
|
||||
end %>
|
||||
|
||||
<h2><%= t('glossary_title') %> <%= subtitlle %> </h2>
|
||||
|
||||
<br />
|
||||
<% if User.current.allowed_to?(:view_terms, @project, :global => true) %>
|
||||
<%= render(:partial => "glossary_styles/search") %>
|
||||
<br />
|
||||
<% end %>
|
||||
|
||||
<% tempname = "glossary/#{@glossary_style.show_desc ? 'show_all' : 'index'}_in_category" %>
|
||||
<% unless @terms.empty? %>
|
||||
<% if @glossary_style.grouping? %>
|
||||
<% list_number = 1 %>
|
||||
<% @terms.each do |gterms| %>
|
||||
<h3><%= "#{list_number}. #{gterms.name}" %></h3>
|
||||
<% list_number += 1 %>
|
||||
<%= render(:partial => tempname, :object => gterms.ary) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render(:partial => tempname, :object => @terms) %>
|
||||
<% end %>
|
||||
|
||||
<% other_formats_links do |f| %>
|
||||
<%= f.link_to 'CSV', :url => params %>
|
||||
<% end %>
|
||||
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% end %>
|
||||
|
||||
|
||||
<%= render :partial => 'glossary/view_term' %>
|
|
@ -1,22 +0,0 @@
|
|||
<h2><%= l(:label_move_all_terms) %></h2>
|
||||
|
||||
<% if params[:new_project_id] %>
|
||||
|
||||
<% elsif @allowed_projs.blank? %>
|
||||
<div class="nodata">
|
||||
<%= simple_format(l(:error_no_movement_project)) %>
|
||||
</div>
|
||||
<% else %>
|
||||
<% form = form_tag({:project_id => @project}, :id => 'move_all_form') do %>
|
||||
|
||||
<div class="box tabular">
|
||||
<p><label for="new_project_id"><%=l(:label_movement_project)%>:</label>
|
||||
<%= select_tag "new_project_id",
|
||||
project_tree_options_for_select(@allowed_projs) %>
|
||||
</p>
|
||||
</div>
|
||||
<%= submit_tag l(:button_move) %>
|
||||
<% end %>
|
||||
<%= form if Rails::VERSION::MAJOR >= 3 %>
|
||||
<% end %>
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
<h2><%=l(:label_term_new)%></h2>
|
||||
|
||||
<% form = labelled_form_for @term, :as => :term,
|
||||
:url => {:action => 'new', :project_id => @project, :id => @term},
|
||||
:html => {:class => 'tabular', :multipart => true, :id => 'term-form'} do |f| %>
|
||||
<%= error_messages_for 'term' %>
|
||||
<div class="box">
|
||||
<%= render :partial => 'glossary/form', :locals => {:f => f} %>
|
||||
</div>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
|
||||
<% if Rails::VERSION::MAJOR >= 3 %>
|
||||
<%= preview_link({:controller => 'glossary', :action => 'preview', :project_id => @project.id },
|
||||
"term-form",
|
||||
"preview") %>
|
||||
<% else %>
|
||||
<%= link_to_remote l(:label_preview),
|
||||
{ :url => { :controller => 'glossary', :action => 'preview', :project_id => @project },
|
||||
:method => 'post',
|
||||
:update => 'preview',
|
||||
:with => "Form.serialize('term-form')",
|
||||
:complete => "Element.scrollTo('preview')"
|
||||
}, :accesskey => accesskey(:preview) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= form if Rails::VERSION::MAJOR >= 3 %>
|
||||
|
||||
<div id="preview" class="wiki"></div>
|
||||
|
||||
<% html_title(l(:glossary_title)) -%>
|
|
@ -1,29 +0,0 @@
|
|||
<div class="contextual">
|
||||
<%= link_to_if_authorized(l(:button_edit), {:controller => 'glossary', :action => 'edit', :project_id => @project, :id => @term}, :class => 'icon icon-edit', :accesskey => accesskey(:edit)) %>
|
||||
<%= link_to_if_authorized l(:button_delete), {:controller => 'glossary', :action => 'destroy', :project_id => @project, :id => @term}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
|
||||
</div>
|
||||
|
||||
<h2><%= l(:label_term) %> #<%= @term.id %></h2>
|
||||
|
||||
<div class="term" >
|
||||
|
||||
<h3><%=h @term.name %> </h3>
|
||||
<%= render(:partial => "glossary/show_one", :object => @term) %>
|
||||
|
||||
<p class="author">
|
||||
<%= authoring @term.created_on, @term.author %>.
|
||||
<% if @term.created_on != @term.updated_on
|
||||
if (@term.author_id == @term.updater_id) %>
|
||||
<%= l(:label_updated_time, time_tag(@term.updated_on)).html_safe + '.' %>
|
||||
<% else %>
|
||||
<%= updated_by(@term.updated_on, @term.updater) + '.' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<%= render :partial => 'glossary/view_term' %>
|
||||
|
||||
<% html_title "##{@term.id}: #{@term.name}" -%>
|
|
@ -0,0 +1,3 @@
|
|||
<div class="box">
|
||||
<p><%= form.text_field :name, size: 60, required: true %></p>
|
||||
</div>
|
|
@ -0,0 +1,7 @@
|
|||
<h2><%=l :label_glossary_category %> $<%= @category.id %></h2>
|
||||
|
||||
<%= labelled_form_for :glossary_category, @category,
|
||||
url: project_glossary_category_path do |f| %>
|
||||
<%= render partial: 'glossary_categories/form', locals: {form: f} %>
|
||||
<%= f.submit l(:button_edit) %>
|
||||
<% end %>
|
|
@ -0,0 +1,43 @@
|
|||
<h2><%=l :label_glossary_categories %></h2>
|
||||
|
||||
<div class="contextual">
|
||||
<%= link_to_if_authorized l(:label_glossary_category_new),
|
||||
{ controller: :glossary_categories, action: :new, project_id: @project },
|
||||
class: 'icon icon-add' %>
|
||||
</div>
|
||||
|
||||
<%= render partial: 'glossary_terms/sidebar' %>
|
||||
|
||||
<table class="list table-sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th><%=l :field_name %></th>
|
||||
<th/>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @categories.each do |category| %>
|
||||
<tr>
|
||||
<td class="id"><%= category.id %></td>
|
||||
<td class="name"><%= link_to category.name, [@project, category] %></td>
|
||||
<td class="buttons">
|
||||
<%= reorder_handle(category, url: project_glossary_category_path(@project, category)) %>
|
||||
<%= link_to_if_authorized l(:button_edit), {
|
||||
controller: :glossary_categories, action: :edit, id: category,
|
||||
project_id: @project
|
||||
}, class: 'icon icon-edit' %>
|
||||
<%= link_to_if_authorized l(:button_delete), {
|
||||
controller: :glossary_categories, action: :destroy, id: category,
|
||||
project_id: @project
|
||||
}, method: :delete, data: {confirm: l(:text_are_you_sure)},
|
||||
class: 'icon icon-del' %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= javascript_tag do %>
|
||||
$(function() { $("table.table-sortable tbody").positionedItems(); });
|
||||
<% end %>
|
|
@ -0,0 +1,7 @@
|
|||
<h2><%=l :label_glossary_category_new %></h2>
|
||||
|
||||
<%= labelled_form_for :glossary_category, @category,
|
||||
url: project_glossary_categories_path do |f| %>
|
||||
<%= render partial: 'glossary_categories/form', locals: {form: f} %>
|
||||
<%= f.submit l(:button_create) %>
|
||||
<% end %>
|
|
@ -0,0 +1,17 @@
|
|||
<div class="contextual">
|
||||
<%= link_to_if_authorized l(:button_edit),
|
||||
{ controller: :glossary_categories, action: :edit, project_id: @project },
|
||||
class: 'icon icon-edit' %>
|
||||
<%= link_to_if_authorized l(:button_delete),
|
||||
{ controller: :glossary_categories, action: :destroy,
|
||||
id: @category, project_id: @project },
|
||||
method: :delete, data: {confirm: l(:text_are_you_sure)}, class: 'icon icon-del' %>
|
||||
</div>
|
||||
|
||||
<%= render partial: 'glossary_terms/sidebar' %>
|
||||
|
||||
<h2><%=l :label_glossary_category %> #<%=@category.id %></h2>
|
||||
|
||||
<h3><%= @category.name %></h3>
|
||||
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
|
||||
<% urlopts = {:controller => 'glossary_styles', :action => 'edit',
|
||||
:project_id => @project,
|
||||
:glossary_style_id => @glossary_style.id}
|
||||
add_search_params(urlopts)
|
||||
form = form_for @glossary_style, :url => urlopts do |f| %>
|
||||
|
||||
|
||||
<%=h l(:label_project) %>
|
||||
<%=
|
||||
options = []
|
||||
options << [l(:label_glossary_style_project_current), GlossaryStyle::ProjectCurrent]
|
||||
options << [l(:label_glossary_style_project_mine), GlossaryStyle::ProjectMine] if User.current.logged?
|
||||
options << [l(:label_glossary_style_project_all), GlossaryStyle::ProjectAll]
|
||||
f.select('project_scope', options)
|
||||
%>
|
||||
|
||||
|
||||
<fieldset id="grouping"><legend><%= l(:label_grouping) %></legend>
|
||||
<% group_labels = [:label_none, :field_category, :label_project] %>
|
||||
<% for gby in [GlossaryStyle::GroupByNone,
|
||||
GlossaryStyle::GroupByCategory,
|
||||
GlossaryStyle::GroupByProject] %>
|
||||
<label><%= f.radio_button('groupby', gby,
|
||||
{ :checked => (gby == @glossary_style.groupby ) } ) %>
|
||||
<%= l(group_labels[gby]) %></label>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
|
||||
|
||||
<fieldset id="sort"><legend><%= l(:label_sort) %></legend>
|
||||
<% for cnt in 0...2 %>
|
||||
<%= cnt+1 %> : <%= params_select(f, "sort_item_#{cnt}", default_sort_params) %><br />
|
||||
<% end %>
|
||||
</fieldset>
|
||||
|
||||
|
||||
<label id="show_desc"> <%= f.check_box "show_desc" %> <%= l(:label_glossary_style_show_desc) %> </label>
|
||||
|
||||
<br />
|
||||
|
||||
<%= submit_tag l(:label_view) %>
|
||||
<%= submit_tag l(:button_clear), :name => 'clear' %>
|
||||
|
||||
<% end %>
|
||||
<%= form if Rails::VERSION::MAJOR >= 3 %>
|
|
@ -1,46 +0,0 @@
|
|||
|
||||
<% form = form_tag({:controller => 'glossary_styles', :action => 'search', :project_id => @project},
|
||||
{:method => 'get', :id=>'search_form'}
|
||||
) do %>
|
||||
<%= hidden_field_tag 'project_id', @project.id.to_s %>
|
||||
<div id="glossary_search" class="hide-when-print">
|
||||
<fieldset id="filters" class="collapsible <%= (glossary_searching?) ? "" : "collapsed" %>">
|
||||
<legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
|
||||
<div style="<%= (glossary_searching?) ? '' : 'display: none;' %>">
|
||||
|
||||
<table id="glossary_search_params">
|
||||
|
||||
<tr><th><%=h l(:label_search) %></th>
|
||||
<td>
|
||||
<%= text_field_tag("search_str", params[:search_str]) %>
|
||||
</td></tr>
|
||||
|
||||
<tr><th><%=h l(:field_category) %></th>
|
||||
<td>
|
||||
<%=
|
||||
select_tag(:search_category,
|
||||
options_for_select(seach_category_options(@glossary_style.project_scope, @project),
|
||||
params[:search_category]),
|
||||
{:include_blank => true})
|
||||
%>
|
||||
</td></tr>
|
||||
|
||||
<tr><th><%=h l(:label_latest) %></th>
|
||||
<td>
|
||||
<%= text_field_tag("latest_days", params[:latest_days], :size=>'10') %>
|
||||
<%=h l(:label_indays) %>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
<%= submit_tag l(:label_search) %>
|
||||
<%= submit_tag l(:button_clear), :name => 'search_clear' %>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
<%= form if Rails::VERSION::MAJOR >= 3 %>
|
||||
|
|
@ -1 +0,0 @@
|
|||
<h2>GlossaryStyles#edit</h2>
|
|
@ -0,0 +1,19 @@
|
|||
<div class="box tabular">
|
||||
<p><%= form.text_field :name, size: 80, required: true %></p>
|
||||
<p><%= form.text_field :name_en, size: 80 %></p>
|
||||
<p><%= form.text_field :rubi, size: 80 %></p>
|
||||
<p><%= form.text_field :abbr_whole, size: 80 %></p>
|
||||
<p><%= form.text_field :datatype, size: 80 %></p>
|
||||
<p><%= form.text_field :codename, size: 80 %></p>
|
||||
<p><%= form.select :category_id, GlossaryCategory.pluck(:name, :id), include_blank: true %></p>
|
||||
<p><%= form.text_area :description, rows: 10, class: 'wiki-edit', required: false %></p>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<p>
|
||||
<label><%=l :label_attachment_plural %></label>
|
||||
<%= render partial: 'attachments/form' %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<%= wikitoolbar_for 'glossary_term_description' %>
|
|
@ -0,0 +1,28 @@
|
|||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th><%=l :field_name %></th>
|
||||
<th><%=l :field_category %></th>
|
||||
<th><%=l :field_description %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% terms.each do |term| %>
|
||||
<tr>
|
||||
<td class="id">
|
||||
<%= term.id %>
|
||||
</td>
|
||||
<td class="name">
|
||||
<%= link_to term.name, [@project, term] %>
|
||||
</td>
|
||||
<td class="roles">
|
||||
<%= term.category.try!(:name) %>
|
||||
</td>
|
||||
<td class="description">
|
||||
<%= term.description %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
|
@ -0,0 +1,61 @@
|
|||
<% content_for :sidebar do %>
|
||||
<h3><%=l :label_view %></h3>
|
||||
|
||||
<%= form_with url: project_glossary_terms_path, method: :get, local: true do |form| %>
|
||||
<fieldset>
|
||||
<legend><%=l :label_grouping %></legend>
|
||||
<%= form.radio_button :grouping, 1, checked: @grouping == '1' ? 'checked' : nil %>
|
||||
<%= form.label :grouping, l(:label_categorized), vaule: 1 %>
|
||||
<%= form.radio_button :grouping, 0, checked: @grouping == '0' ? 'checked' : nil %>
|
||||
<%= form.label :grouping, l(:label_not_categorized), value: 0 %>
|
||||
</fieldset>
|
||||
<%= form.submit l(:label_view) %>
|
||||
<% end %>
|
||||
|
||||
<h3><%=l :label_glossary_term %></h3>
|
||||
<p><%= link_to_if_authorized l(:label_glossary_term_new),
|
||||
{ controller: :glossary_terms, action: :new, project_id: @project },
|
||||
class: 'icon icon-add' %></p>
|
||||
|
||||
<fieldset class="collapsible collapsed">
|
||||
<legend onclick="toggleFieldset(this);" class="icon icon-collapsed">
|
||||
<%=l :label_glossary_term_import_csv %>
|
||||
</legend>
|
||||
<div style="display: none;">
|
||||
<%= form_with url: import_project_glossary_terms_path, method: :post, local: true do |form| %>
|
||||
<%= form.file_field :file %>
|
||||
<%= form.submit l(:label_import) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h3><%=l :label_glossary_category %></h3>
|
||||
<p><%= link_to_if_authorized l(:label_glossary_category_new),
|
||||
{ controller: :glossary_categories, action: :new, project_id: @project},
|
||||
class: 'icon icon-add' %></p>
|
||||
|
||||
<p><%= link_to l(:label_glossary_categories),
|
||||
project_glossary_categories_path %></p>
|
||||
|
||||
<h3><%=l :label_glossary_index %></h3>
|
||||
<table>
|
||||
<% l(:index_en).each_line do |line| %>
|
||||
<tr>
|
||||
<% line.split(" ").each do |ch| %>
|
||||
<td><%= link_to ch, project_glossary_terms_path(index: ch) %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<table>
|
||||
<% l(:index_rubi).each_line do |line| %>
|
||||
<tr>
|
||||
<% line.split(" ").each do |char| %>
|
||||
<td>
|
||||
<%= link_to char, project_glossary_terms_path(index_rubi: char) %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<% end %>
|
|
@ -0,0 +1,6 @@
|
|||
<h2><%=l :label_glossary_term %> #<%= @term.id %></h2>
|
||||
|
||||
<%= labelled_form_for :glossary_term, @term, url: project_glossary_term_path, html: {multipart: true, id: 'term-form'} do |f| %>
|
||||
<%= render partial: 'glossary_terms/form', locals: {form: f} %>
|
||||
<%= f.submit l(:button_edit) %>
|
||||
<% end %>
|
|
@ -0,0 +1,19 @@
|
|||
require 'csv'
|
||||
|
||||
CSV.generate(row_sep: "\r\n", encoding: "CP932") do |csv|
|
||||
column_names = ["name", "name_en", "category", "datatype", "codename", "description", "rubi", "abbr_whole"]
|
||||
csv << column_names
|
||||
@glossary_terms.each do |term|
|
||||
column_values = [
|
||||
term.name,
|
||||
term.name_en,
|
||||
term.category&.name,
|
||||
term.datatype,
|
||||
term.codename,
|
||||
term.description,
|
||||
term.rubi,
|
||||
term.abbr_whole
|
||||
]
|
||||
csv << column_values
|
||||
end
|
||||
end
|
|
@ -0,0 +1,28 @@
|
|||
<h2><%=l :label_glossary_terms %></h2>
|
||||
|
||||
<div class="contextual">
|
||||
<%= link_to_if_authorized l(:label_glossary_term_new),
|
||||
{ controller: :glossary_terms, action: :new, project_id: @project },
|
||||
class: 'icon icon-add' %>
|
||||
</div>
|
||||
|
||||
<%= render partial: 'sidebar' %>
|
||||
|
||||
<% if @grouping == '1' %>
|
||||
<% categorized_terms = @glossary_terms.reject { |t| t.category_id.nil? } %>
|
||||
<% uncategorized_terms = @glossary_terms.where(category_id: nil) %>
|
||||
|
||||
<% categorized_terms.group_by(&:category).each do |category, terms| %>
|
||||
<h3><%= category.name %></h3>
|
||||
<%= render partial: 'index_terms', locals: {terms: terms} %>
|
||||
<% end %>
|
||||
|
||||
<h3><%=l :label_not_categorized %></h3>
|
||||
<%= render 'index_terms', terms: uncategorized_terms %>
|
||||
<% else %>
|
||||
<%= render 'index_terms', terms: @glossary_terms %>
|
||||
<% end %>
|
||||
|
||||
<% other_formats_links do |f| %>
|
||||
<%= f.link_to_with_query_parameters 'CSV' %>
|
||||
<% end %>
|
|
@ -0,0 +1,11 @@
|
|||
<h2><%=l :label_glossary_term_new %></h2>
|
||||
|
||||
<%= labelled_form_for :glossary_term, @term,
|
||||
url: project_glossary_terms_path, html: {multipart: true, id: 'term-form'} do |f| %>
|
||||
<%= render partial: 'glossary_terms/form', locals: {form: f} %>
|
||||
<%= f.submit l(:button_create) %>
|
||||
<% end %>
|
||||
|
||||
<div id="preview" class="wiki"></div>
|
||||
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
<% content_for :header_tags do %>
|
||||
<%= stylesheet_link_tag 'glossary', plugin: 'redmine_glossary' %>
|
||||
<% end %>
|
||||
|
||||
<div class="contextual">
|
||||
<%= link_to_if_authorized l(:button_edit),
|
||||
{ controller: :glossary_terms, action: :edit, project_id: @project },
|
||||
class: 'icon icon-edit' %>
|
||||
<%= link_to_if_authorized l(:button_delete),
|
||||
{ controller: :glossary_terms, action: :destroy,
|
||||
id: @term, project_id: @project },
|
||||
method: :delete, data: {confirm: l(:text_are_you_sure)}, class: 'icon icon-del' %>
|
||||
</div>
|
||||
|
||||
<%= render partial: 'sidebar' %>
|
||||
|
||||
<h2><%=l :label_glossary_term %> #<%= @term.id %></h2>
|
||||
|
||||
<h3><%= @term.name %></h3>
|
||||
|
||||
<table class="term">
|
||||
<tr>
|
||||
<th><%=l :field_name_en %>:</th>
|
||||
<td><%= @term.name_en %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%=l :field_rubi %>:</th>
|
||||
<td><%= @term.rubi %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%=l :field_abbr_whole %>:</th>
|
||||
<td><%= @term.abbr_whole %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%=l :field_datatype %>:</th>
|
||||
<td><%= @term.datatype %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%=l :field_codename %>:</th>
|
||||
<td><%= @term.codename %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%=l :field_category %>:</th>
|
||||
<td><%= @term.category.try!(:name) %>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%=l :field_description %>:</th>
|
||||
<td><div class="wiki"><%= textilizable @term, :description %></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%=l :field_created_on %>:</th>
|
||||
<td><%= format_time(@term.created_at) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%=l :field_updated_on %>:</th>
|
||||
<td><%= format_time(@term.updated_at) %></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<%= render partial: 'attachments/links',
|
||||
locals: {attachments: @term.attachments,
|
||||
options: {deletable: User.current.allowed_to?(:manage_glossary_terms, @project)}
|
||||
}%>
|
|
@ -1,12 +0,0 @@
|
|||
|
||||
<h2> <%= t('label_hide_item') %> </h2>
|
||||
<table>
|
||||
<% for item in Term.hidable_params %>
|
||||
<% name = "hide_item_#{item}" %>
|
||||
<tr><td>
|
||||
<%= check_box_tag("settings[#{name}]", 1, @settings[name]) %>
|
||||
</td><td>
|
||||
<%= t("label.#{item}") %>
|
||||
</td><tr>
|
||||
<% end %>
|
||||
</table>
|
|
@ -1,5 +0,0 @@
|
|||
<%= error_messages_for 'category' %>
|
||||
|
||||
<div class="box">
|
||||
<p><%= f.text_field :name, :size => 30, :required => true %></p>
|
||||
</div>
|
|
@ -1,19 +0,0 @@
|
|||
<h2><%=l(:label_term_category)%>: <%=h @category.name %></h2>
|
||||
|
||||
<% form = form_tag({}) do %>
|
||||
<div class="box">
|
||||
<p><strong><%= l(:text_term_category_destroy_question, :value => @term_count) %></strong></p>
|
||||
<p><label><%= radio_button_tag 'todo', 'nullify', true %> <%= l(:text_term_category_destroy_assignments) %></label><br />
|
||||
<% if @categories.size > 0 %>
|
||||
<label><%= radio_button_tag 'todo', 'reassign', false %> <%= l(:text_term_category_reassign_to) %></label>:
|
||||
<%= select_tag 'reassign_to_id', options_from_collection_for_select(@categories, 'id', 'name') %></p>
|
||||
<% end %>
|
||||
<%= hidden_field_tag 'id', @category.id %>
|
||||
</div>
|
||||
|
||||
<%= submit_tag l(:button_apply) %>
|
||||
<%= link_to l(:button_cancel), :controller => 'term_categories', :action => 'index', :project_id => @project %>
|
||||
<% end %>
|
||||
<%= form if Rails::VERSION::MAJOR >= 3 %>
|
||||
|
||||
<% html_title(l(:glossary_title)) -%>
|
|
@ -1,9 +0,0 @@
|
|||
<h2><%=l(:label_term_category)%></h2>
|
||||
|
||||
<% form = labelled_form_for @category, :as => :category, :url => { :action => 'edit', :project_id => @project, :id => @category }, :html => {:class => 'tabular'} do |f| %>
|
||||
<%= render :partial => 'term_categories/form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<% end %>
|
||||
<%= form if Rails::VERSION::MAJOR >= 3 %>
|
||||
|
||||
<% html_title(l(:glossary_title)) -%>
|
|
@ -1,44 +0,0 @@
|
|||
<div class="contextual">
|
||||
<%= link_to_if_authorized(l(:label_term_category_new), {:controller => 'glossary', :action => 'add_term_category', :project_id => @project}, :class => 'icon icon-add') %>
|
||||
</div>
|
||||
|
||||
|
||||
<h2><%= l(:label_term_category) %></h2>
|
||||
|
||||
<% if @categories.any? %>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<th style="text-align:left">#</th>
|
||||
<th style="text-align:left"><%= l(:field_name) %></th>
|
||||
<th style="text-align:left"><%= l(:field_term_counts_under_category) %></th>
|
||||
<th style="text-align:left;width:100px"></th>
|
||||
<th style="text-align:left;width:40px"></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% for category in @categories %>
|
||||
<% unless category.new_record? %>
|
||||
<tr class="<%= cycle 'odd', 'even' %>">
|
||||
<td><%=category.position%></td>
|
||||
<td><%=h(category.name) %></td>
|
||||
<td><%=h(category.terms.size) %></td>
|
||||
<td align="center">
|
||||
<% if authorize_for("term_categories", "edit") %>
|
||||
<%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:controller => 'term_categories', :action => 'change_order', :project_id => @project, :id => category, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
|
||||
<%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:controller => 'term_categories', :action => 'change_order', :project_id => @project, :id => category, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
|
||||
<%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:controller => 'term_categories', :action => 'change_order', :project_id => @project, :id => category, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
|
||||
<%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:controller => 'term_categories', :action => 'change_order', :project_id => @project, :id => category, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td align="right">
|
||||
<%= link_to_if_authorized(image_tag('edit.png'), { :action => 'edit', :controller => 'term_categories', :project_id => @project, :id => category }, :title => l(:button_edit)) %>
|
||||
<%= link_to_if_authorized(image_tag('delete.png'), {:action => 'destroy', :controller => 'term_categories', :project_id => @project, :id => category}, :method => :post, :title => l(:button_delete)) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => 'glossary/view_term' %>
|
Loading…
Add table
Add a link
Reference in a new issue