Fix bug.
This commit is contained in:
parent
919bb6eca3
commit
5f24254ae3
|
@ -611,21 +611,53 @@ class Admin::PersonalPluginFieldsController < OrbitMemberController
|
|||
break
|
||||
end
|
||||
end
|
||||
new_text = new_text.gsub(/parse_again_start((?:(?!parse_again_start).)+)parse_again_end/m) do |ff|
|
||||
parse_content = $1 #last match
|
||||
new_text = new_text.gsub(/[ \t]*parse_again_start((?:(?!parse_again_start).)+)parse_again_end[ \t]*(\r\n|\n)/m) do |ff|
|
||||
@parse_again_mode = true
|
||||
parse_content = $1 #parse_again block contents
|
||||
result = ff
|
||||
if include_key($1,k)
|
||||
start_index = 0
|
||||
end_index = parse_content.length
|
||||
start_index = 2 if parse_content[0..1] == "\r\n"
|
||||
end_index = end_index - 2 if parse_content[(end_index - 2)..(end_index - 1)] == "\r\n"
|
||||
parse_content = parse_content.slice(start_index,end_index)
|
||||
if inner
|
||||
result = (0...vv.count).map {|ii| replace_text_with_pattern(parse_content,false,i,ii,true) }.join("")
|
||||
else
|
||||
result = (0...vv.count).map {|ii| replace_text_with_pattern(parse_content,false,ii) }.join("")
|
||||
end
|
||||
match_count = parse_content.match(/^ *\* *\d+/m)
|
||||
match_count = match_count ? match_count[0] : nil
|
||||
exist_condition = parse_content.split("\n")[0].match(/if[ ]+#{::Regexp.escape(k)}(?=\.| |$)/)
|
||||
extra_cond = nil
|
||||
if exist_condition
|
||||
exist_condition = exist_condition[0]
|
||||
parse_content = parse_content[ parse_content.index(exist_condition) + exist_condition.length..-1]
|
||||
extra_cond = parse_content.match(/^\.count *(\!|\<|\>|\=)(\=|) *\d+/)
|
||||
if extra_cond
|
||||
extra_cond = extra_cond[0]
|
||||
exist_condition += extra_cond
|
||||
parse_content = parse_content[extra_cond.length..-1]
|
||||
exist_condition = eval("vv"+extra_cond) ? exist_condition : nil
|
||||
elsif vv.count == 0
|
||||
exist_condition = nil
|
||||
end
|
||||
if exist_condition.nil?
|
||||
match_count = nil
|
||||
parse_content = ""
|
||||
result = ""
|
||||
end
|
||||
elsif match_count
|
||||
parse_content = parse_content[match_count.length..-1]
|
||||
end
|
||||
parse_content = parse_content.sub(/[ \t]+\z/m, '').sub(/\A(\r\n|\n)/, '')
|
||||
if include_key(parse_content,k)
|
||||
vv_count = vv.count
|
||||
if match_count
|
||||
vv_count = [vv_count, match_count.strip[1..-1].to_i].min
|
||||
end
|
||||
if inner
|
||||
result = (0...vv_count).map {|ii| replace_text_with_pattern(parse_content,false,i,ii,true) }.join("")
|
||||
else
|
||||
result = (0...vv_count).map {|ii| replace_text_with_pattern(parse_content,false,ii) }.join("")
|
||||
end
|
||||
elsif match_count || exist_condition
|
||||
count = 1
|
||||
if match_count
|
||||
count = match_count.strip[1..-1].to_i
|
||||
end
|
||||
result = (0...count).map {|ii| parse_content }.join("")
|
||||
end
|
||||
@parse_again_mode = false
|
||||
result
|
||||
end
|
||||
end
|
||||
|
@ -637,7 +669,9 @@ class Admin::PersonalPluginFieldsController < OrbitMemberController
|
|||
end
|
||||
def gsub_text_by_key_value(text,k,v)
|
||||
@blank_texts = []
|
||||
text.gsub(/\n(\s*)[^\n]*(#{k}|#{k.classify})/m) {|ff| @blank_texts << $1.gsub(/(\r\n|\n)/,'')}
|
||||
if !@parse_again_mode
|
||||
text.gsub(/\n(\s+)[^\n]*(#{k}|#{k.classify})/m) {|ff| @blank_texts << $1.gsub(/(\r\n|\n)/,'')}
|
||||
end
|
||||
i = 0
|
||||
text = text.gsub(k + "s"){|ff| v.pluralize.gsub("\n","\n#{@blank_texts[i]}")}
|
||||
text = text.gsub(k ){|ff| v.gsub("\n","\n#{@blank_texts[i]}")}
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
<div class="controls">
|
||||
<% f.object.related_modal_name.each_with_index do |related_modal_name,i| %>
|
||||
<div>
|
||||
<%= text_field_tag "#{f.object_name}[related_modal_name][]", related_modal_name,placeholder: thead_field("related_modal_name"), class: "related_modal_name" %>
|
||||
<%= text_field_tag "#{f.object_name}[related_modal_name][]", related_modal_name,placeholder: thead_field("related_modal_name"), class: "related_modal_name", title: thead_field("related_modal_name") %>
|
||||
<button type="button" class="remove_related_modal" index="<%=i%>"><%=t(:remove)%></button>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -162,7 +162,7 @@
|
|||
$(this).parents('.start-line').hide();
|
||||
}
|
||||
});
|
||||
var related_modal_name_html = '<%= text_field_tag "#{f.object_name}[related_modal_name][]", '',placeholder: thead_field("related_modal_name"), class: "related_modal_name" %>';
|
||||
var related_modal_name_html = '<%= text_field_tag "#{f.object_name}[related_modal_name][]", '',placeholder: thead_field("related_modal_name"), class: "related_modal_name", title: thead_field("related_modal_name") %>';
|
||||
related_modal_name_html = $("<div></div>").append(related_modal_name_html);
|
||||
related_modal_name_html.append("<button type=\"button\" class=\"remove_related_modal\"><%=t(:remove) %></button>")
|
||||
$(".remove_btn").off("click").on("click",function(){
|
||||
|
@ -276,7 +276,11 @@
|
|||
$('tr >:last-child').css( 'border','');
|
||||
}
|
||||
})
|
||||
|
||||
$(document).on('blur', 'input.related_modal_name', function(){
|
||||
var _this = $(this);
|
||||
var idx = _this.index('input.related_modal_name');
|
||||
$('span.related_modal_name').eq(idx).text(_this.val());
|
||||
})
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.module-area .control-group {
|
||||
|
|
|
@ -11,20 +11,20 @@
|
|||
<% ii = -1 %>
|
||||
<% object.primary_modal_fields.each do |field_value| %>
|
||||
<% next if (!access_field_types.include?(field_value[:field_type]) rescue false) %>
|
||||
<% content = check_box_tag("#{f.object_name}[]", field_value[:field_name] , (object.send(root_name)[page_name].include?(field_value[:field_name]) rescue false),:id=>nil,:class=>"#{page_name}_fields") %>
|
||||
<% content = check_box_tag("#{f.object_name}[#{root_name}][#{page_name}][]", field_value[:field_name] , (object.send(root_name)[page_name].include?(field_value[:field_name]) rescue false),:id=>nil,:class=>"#{page_name}_fields") %>
|
||||
<% tds << "<td data-index=\"#{ii+=1}\">#{field_value[:translation_name][I18n.locale] rescue ""}-#{field_value[:field_name]}<hr class=\"border-hr\">#{content}</td>" %>
|
||||
<% end %>
|
||||
<% if !defined?(access_field_types) %>
|
||||
<% f.object.related_modal_name.each_with_index do |related_modal_name,i| %>
|
||||
<% field_values = f.object.related_modal_fields[i].to_a %>
|
||||
<% field_values.each do |field_value| %>
|
||||
<% content = check_box_tag("#{f.object_name}[]", "#{related_modal_name+'.'+field_value[:field_name]}" , (object.send(root_name)[page_name].include?(related_modal_name+'.'+field_value[:field_name]) rescue false),:id=>nil,:class=>"#{page_name}_fields") %>
|
||||
<% content = check_box_tag("#{f.object_name}[#{root_name}][#{page_name}][]", "#{related_modal_name+'.'+field_value[:field_name]}" , (object.send(root_name)[page_name].include?(related_modal_name+'.'+field_value[:field_name]) rescue false),:id=>nil,:class=>"#{page_name}_fields") %>
|
||||
<% tds << "<td data-index=\"#{ii+=1}\">#{related_modal_name}-#{field_value[:translation_name][I18n.locale] rescue ""}-#{field_value[:field_name]}<hr class=\"border-hr\">#{content}</td>" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% author_name_translation = @personal_plugin_field.author_name_translations[locale] rescue ""
|
||||
author_name_translation = I18n.t("personal_plugins.author") if author_name_translation.blank? %>
|
||||
<% content = check_box_tag("#{f.object_name}[]", "member_profile" , (object.send(root_name)[page_name].include?("member_profile") rescue false),:id=>nil) %>
|
||||
<% content = check_box_tag("#{f.object_name}[#{root_name}][#{page_name}][]", "member_profile" , (object.send(root_name)[page_name].include?("member_profile") rescue false),:id=>nil) %>
|
||||
<% tds << "<td data-index=\"#{ii+=1}\">#{author_name_translation}<hr class=\"border-hr\">#{content}</td>" %>
|
||||
<% end %>
|
||||
<% fields_order = (0...tds.count).to_a
|
||||
|
|
|
@ -39,5 +39,5 @@ class Admin::PluginTemplateRelatedsController < OrbitMemberController
|
|||
def plugin_template_related_params
|
||||
params.require(:plugin_template_related).permit!
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
class Admin::PluginTemplatesController < OrbitMemberController
|
||||
include Admin::PluginTemplatesHelper
|
||||
include Admin::PluginTemplatesHelper
|
||||
layout "member_plugin"
|
||||
before_action :set_plugin_template, only: [:show, :edit , :update, :destroy]
|
||||
before_action :set_plugin
|
||||
|
@ -36,7 +36,7 @@ class Admin::PluginTemplatesController < OrbitMemberController
|
|||
end
|
||||
def new
|
||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||
@plugin_template = PluginTemplate.new
|
||||
@plugin_template = PluginTemplate.new
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -49,28 +49,28 @@ class Admin::PluginTemplatesController < OrbitMemberController
|
|||
def analysis
|
||||
end
|
||||
def analysis_report
|
||||
role = params[:role_id]
|
||||
analysis_field_name_start = params[:analysis_field_name_start]
|
||||
analysis_field_name_end = params[:analysis_field_name_end]
|
||||
graph_by = params[:graph_by]
|
||||
role = params[:role_id]
|
||||
analysis_field_name_start = params[:analysis_field_name_start]
|
||||
analysis_field_name_end = params[:analysis_field_name_end]
|
||||
graph_by = params[:graph_by]
|
||||
|
||||
@data = get_chart_data(analysis_field_name_start,analysis_field_name_end,role,params[:graph_by],params[:time_zone])
|
||||
@data = get_chart_data(analysis_field_name_start,analysis_field_name_end,role,params[:graph_by],params[:time_zone])
|
||||
|
||||
render :layout => false
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def download_excel
|
||||
analysis_field_name_start = params[:analysis_field_name_start]
|
||||
analysis_field_name_end = params[:analysis_field_name_end]
|
||||
@data = get_data_for_excel(analysis_field_name_start,analysis_field_name_end,params[:time_zone])
|
||||
@protocol = (request.referer.blank? ? "http" : URI(request.referer).scheme)
|
||||
@host_url = "#{@protocol}://#{request.host_with_port}"
|
||||
respond_to do |format|
|
||||
format.xlsx {
|
||||
response.headers['Content-Disposition'] = 'attachment; filename="plugin_templates.xlsx"'
|
||||
}
|
||||
end
|
||||
end
|
||||
analysis_field_name_start = params[:analysis_field_name_start]
|
||||
analysis_field_name_end = params[:analysis_field_name_end]
|
||||
@data = get_data_for_excel(analysis_field_name_start,analysis_field_name_end,params[:time_zone])
|
||||
@protocol = (request.referer.blank? ? "http" : URI(request.referer).scheme)
|
||||
@host_url = "#{@protocol}://#{request.host_with_port}"
|
||||
respond_to do |format|
|
||||
format.xlsx {
|
||||
response.headers['Content-Disposition'] = 'attachment; filename="plugin_templates.xlsx"'
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
@ -88,35 +88,35 @@ class Admin::PluginTemplatesController < OrbitMemberController
|
|||
|
||||
|
||||
def setting
|
||||
end
|
||||
end
|
||||
|
||||
def frontend_setting
|
||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||
@intro = PluginTemplateIntro.find_by(:member_profile_id=>@member.id) rescue nil
|
||||
@intro = @intro.nil? ? PluginTemplateIntro.new({:member_profile_id=>@member.id}) : @intro
|
||||
end
|
||||
def frontend_setting
|
||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||
@intro = PluginTemplateIntro.find_by(:member_profile_id=>@member.id) rescue nil
|
||||
@intro = @intro.nil? ? PluginTemplateIntro.new({:member_profile_id=>@member.id}) : @intro
|
||||
end
|
||||
|
||||
def update_frontend_setting
|
||||
@member = MemberProfile.find(intro_params['member_profile_id']) rescue nil
|
||||
@intro = PluginTemplateIntro.find_by(:member_profile_id=>@member.id) rescue nil
|
||||
@intro = @intro.nil? ? PluginTemplateIntro.new({:member_profile_id=>@member.id}) : @intro
|
||||
@intro.update_attributes(intro_params)
|
||||
@intro.save
|
||||
redirect_to URI.encode('/admin/members/'+@member.to_param+'/PluginTemplate')
|
||||
end
|
||||
def update_frontend_setting
|
||||
@member = MemberProfile.find(intro_params['member_profile_id']) rescue nil
|
||||
@intro = PluginTemplateIntro.find_by(:member_profile_id=>@member.id) rescue nil
|
||||
@intro = @intro.nil? ? PluginTemplateIntro.new({:member_profile_id=>@member.id}) : @intro
|
||||
@intro.update_attributes(intro_params)
|
||||
@intro.save
|
||||
redirect_to URI.encode('/admin/members/'+@member.to_param+'/PluginTemplate')
|
||||
end
|
||||
|
||||
def toggle_hide
|
||||
if params[:ids]
|
||||
@projects = PluginTemplate.any_in(_id: params[:ids])
|
||||
def toggle_hide
|
||||
if params[:ids]
|
||||
@projects = PluginTemplate.any_in(_id: params[:ids])
|
||||
|
||||
@projects.each do |project|
|
||||
project.is_hidden = params[:disable]
|
||||
project.save
|
||||
end
|
||||
end
|
||||
@projects.each do |project|
|
||||
project.is_hidden = params[:disable]
|
||||
project.save
|
||||
end
|
||||
end
|
||||
|
||||
render json: {"success"=>true}
|
||||
end
|
||||
render json: {"success"=>true}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
@ -125,28 +125,28 @@ class Admin::PluginTemplatesController < OrbitMemberController
|
|||
end
|
||||
|
||||
def intro_params
|
||||
params.require(:plugin_template_intro).permit! rescue nil
|
||||
end
|
||||
params.require(:plugin_template_intro).permit! rescue nil
|
||||
end
|
||||
|
||||
def get_settings
|
||||
parse_again_start
|
||||
@plugin_template_relateds = PluginTemplateRelated.all
|
||||
parse_again_end
|
||||
@plugin_template_relateds = PluginTemplateRelated.all
|
||||
parse_again_end
|
||||
end
|
||||
|
||||
def set_plugin
|
||||
@plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'PluginTemplate'}.first
|
||||
@plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'PluginTemplate'}.first
|
||||
end
|
||||
|
||||
def set_plugin_template
|
||||
path = request.path.split('/')
|
||||
if path.last.include? '-'
|
||||
uid = path[-1].split("-").last
|
||||
uid = uid.split("?").first
|
||||
else
|
||||
uid = path[-2].split("-").last
|
||||
uid = uid.split("?").first
|
||||
end
|
||||
@plugin_template = PluginTemplate.find_by(:uid => uid) rescue PluginTemplate.find(params[:id])
|
||||
path = request.path.split('/')
|
||||
if path.last.include? '-'
|
||||
uid = path[-1].split("-").last
|
||||
uid = uid.split("?").first
|
||||
else
|
||||
uid = path[-2].split("-").last
|
||||
uid = uid.split("?").first
|
||||
end
|
||||
@plugin_template = PluginTemplate.find_by(:uid => uid) rescue PluginTemplate.find(params[:id])
|
||||
end
|
||||
end
|
|
@ -1,60 +1,60 @@
|
|||
class PersonalPluginTemplatesController < ApplicationController
|
||||
def index
|
||||
params = OrbitHelper.params
|
||||
plugin_templates = PluginTemplate.sort_for_frontend
|
||||
fields_to_show = col_name_to_show_in_index_page
|
||||
if params[:keywords].present?
|
||||
plugin_templates = filter_keywords(plugin_templates,params[:selectbox],params[:keywords])
|
||||
end
|
||||
plugin_templates = plugin_templates.page(params[:page_no]).per(OrbitHelper.page_data_count)
|
||||
plugin_templates_list = plugin_templates.collect do |plugin_template|
|
||||
member = plugin_template.member_profile
|
||||
plugin_templates = PluginTemplate.sort_for_frontend
|
||||
fields_to_show = col_name_to_show_in_index_page
|
||||
if params[:keywords].present?
|
||||
plugin_templates = filter_keywords(plugin_templates,params[:selectbox],params[:keywords])
|
||||
end
|
||||
plugin_templates = plugin_templates.page(params[:page_no]).per(OrbitHelper.page_data_count)
|
||||
plugin_templates_list = plugin_templates.collect do |plugin_template|
|
||||
member = plugin_template.member_profile
|
||||
|
||||
fields_hash = fields_to_show.map{|field| [field, get_display_field(plugin_template,field)]}.to_h
|
||||
|
||||
path = OrbitHelper.url_to_plugin_show(member.to_param, 'member') rescue '#'
|
||||
fields_hash = fields_to_show.map{|field| [field, get_display_field(plugin_template,field)]}.to_h
|
||||
|
||||
path = OrbitHelper.url_to_plugin_show(member.to_param, 'member') rescue '#'
|
||||
fields_hash["authors"] = "<a href='#{path}'>#{member.name}</a>" rescue ""
|
||||
fields_hash["link_to_show"] = OrbitHelper.url_to_show(plugin_template.to_param)
|
||||
fields_hash
|
||||
end
|
||||
fields_hash["link_to_show"] = OrbitHelper.url_to_show(plugin_template.to_param)
|
||||
fields_hash
|
||||
end
|
||||
|
||||
extras = extra_translate_title
|
||||
choice_show = []
|
||||
fields_to_show.each do |fs|
|
||||
choice_show << t("personal_plugin_template.#{fs}")
|
||||
end
|
||||
choice_value = fields_to_show
|
||||
choice_value.unshift('default')
|
||||
choice_select = choice_value.map { |iter| iter == params[:selectbox] ? 'selected' : '' }
|
||||
choice_select = choice_select.map { |value| { 'choice_select' => value } }
|
||||
choice_value = choice_value.map { |value| { 'choice_value' => value } }
|
||||
choice_default = t('personal_plugin_template.extend_translate.select_class')
|
||||
choice_show.unshift(choice_default)
|
||||
choice_show = choice_show.map { |value| { 'choice_show' => value } }
|
||||
choice = choice_value.zip(choice_show, choice_select)
|
||||
choice = choice.map { |value| value.inject :merge }
|
||||
select_text = t('personal_plugin_template.extend_translate.search_class')
|
||||
search_text = t('personal_plugin_template.extend_translate.word_to_search')
|
||||
extras = extra_translate_title
|
||||
choice_show = []
|
||||
fields_to_show.each do |fs|
|
||||
choice_show << t("personal_plugin_template.#{fs}")
|
||||
end
|
||||
choice_value = fields_to_show
|
||||
choice_value.unshift('default')
|
||||
choice_select = choice_value.map { |iter| iter == params[:selectbox] ? 'selected' : '' }
|
||||
choice_select = choice_select.map { |value| { 'choice_select' => value } }
|
||||
choice_value = choice_value.map { |value| { 'choice_value' => value } }
|
||||
choice_default = t('personal_plugin_template.extend_translate.select_class')
|
||||
choice_show.unshift(choice_default)
|
||||
choice_show = choice_show.map { |value| { 'choice_show' => value } }
|
||||
choice = choice_value.zip(choice_show, choice_select)
|
||||
choice = choice.map { |value| value.inject :merge }
|
||||
select_text = t('personal_plugin_template.extend_translate.search_class')
|
||||
search_text = t('personal_plugin_template.extend_translate.word_to_search')
|
||||
|
||||
extras = extras.merge({ 'url' => '/' + I18n.locale.to_s + params[:url],
|
||||
'select_text' => select_text,
|
||||
'search_text' => search_text,
|
||||
'search_value' => params[:keywords].to_s.gsub(/\"/,'')
|
||||
})
|
||||
extras["widget-title"] = I18n.t("module_name.personal_plugin_template")
|
||||
{
|
||||
"plugin_templates" => plugin_templates_list,
|
||||
"extras" => extras,
|
||||
"total_pages" => plugin_templates.total_pages,
|
||||
'choice' => choice
|
||||
}
|
||||
extras = extras.merge({ 'url' => '/' + I18n.locale.to_s + params[:url],
|
||||
'select_text' => select_text,
|
||||
'search_text' => search_text,
|
||||
'search_value' => params[:keywords].to_s.gsub(/\"/,'')
|
||||
})
|
||||
extras["widget-title"] = I18n.t("module_name.personal_plugin_template")
|
||||
{
|
||||
"plugin_templates" => plugin_templates_list,
|
||||
"extras" => extras,
|
||||
"total_pages" => plugin_templates.total_pages,
|
||||
'choice' => choice
|
||||
}
|
||||
end
|
||||
|
||||
def show
|
||||
params = OrbitHelper.params
|
||||
plugin = PluginTemplate.where(:is_hidden=>false).find_by(uid: params[:uid])
|
||||
fields_to_show = col_name_to_show_in_show_page
|
||||
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
|
||||
plugin = PluginTemplate.where(:is_hidden=>false).find_by(uid: params[:uid])
|
||||
fields_to_show = col_name_to_show_in_show_page
|
||||
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
|
||||
end
|
||||
|
||||
def get_display_field(plugin_template,field)
|
||||
|
|
|
@ -1,151 +1,151 @@
|
|||
module Admin::PluginTemplatesHelper
|
||||
include OrbitBackendHelper
|
||||
include OrbitFormHelper
|
||||
alias :org_datetime_picker :datetime_picker
|
||||
def datetime_picker(*arg,**args)
|
||||
org_datetime_picker(arg,args)
|
||||
end
|
||||
def time_iterate(start_time, end_time, step, &block)
|
||||
begin
|
||||
start_time = start_time.to_date if end_time.class == Date
|
||||
yield(start_time)
|
||||
end while (start_time += step) <= end_time
|
||||
end
|
||||
def parse_time(time_str,timezone="+08:00")
|
||||
DateTime.parse("0000-01-01 " + time_str + timezone)
|
||||
end
|
||||
def page_for_plugin_template(plugin_template_object)
|
||||
page = Page.where(:module=>"personal_plugin_template").first
|
||||
("/#{I18n.locale}"+page.url+'/'+plugin_template_object.to_param).gsub('//','/') rescue "#"
|
||||
end
|
||||
include OrbitBackendHelper
|
||||
include OrbitFormHelper
|
||||
alias :org_datetime_picker :datetime_picker
|
||||
def datetime_picker(*arg,**args)
|
||||
org_datetime_picker(arg,args)
|
||||
end
|
||||
def time_iterate(start_time, end_time, step, &block)
|
||||
begin
|
||||
start_time = start_time.to_date if end_time.class == Date
|
||||
yield(start_time)
|
||||
end while (start_time += step) <= end_time
|
||||
end
|
||||
def parse_time(time_str,timezone="+08:00")
|
||||
DateTime.parse("0000-01-01 " + time_str + timezone)
|
||||
end
|
||||
def page_for_plugin_template(plugin_template_object)
|
||||
page = Page.where(:module=>"personal_plugin_template").first
|
||||
("/#{I18n.locale}"+page.url+'/'+plugin_template_object.to_param).gsub('//','/') rescue "#"
|
||||
end
|
||||
|
||||
def get_data_for_excel(analysis_field_name_start,analysis_field_name_end,timezone)
|
||||
analysis_field_name_start = parse_date_time_field("analysis_field_name",analysis_field_name_start,timezone)
|
||||
analysis_field_name_end = parse_date_time_field("analysis_field_name",analysis_field_name_end,timezone)
|
||||
data = []
|
||||
roles = Role.where(:disabled => false, :title.ne => "", :title.ne => nil).asc(:key)
|
||||
roles.each do |role|
|
||||
d = {}
|
||||
d["name"] = role.title
|
||||
mps = role.member_profile_ids
|
||||
d["data"] = filter_data(PluginTemplate, analysis_field_name_start, analysis_field_name_end, mps)
|
||||
data << d
|
||||
end
|
||||
return data
|
||||
end
|
||||
def filter_data(data,analysis_field_name_start,analysis_field_name_end,mps = nil)
|
||||
result = []
|
||||
if @periodic
|
||||
all_ids = data.all.pluck(:id) rescue []
|
||||
out_of_range_ids1 = data.where(:analysis_field_name_start.gt => analysis_field_name_end).pluck(:id) rescue []
|
||||
out_of_range_ids2 = data.where(:analysis_field_name_end.lt => analysis_field_name_start).pluck(:id) rescue []
|
||||
result = data.where(:id.in=>(all_ids - out_of_range_ids1 - out_of_range_ids2)) rescue []
|
||||
else
|
||||
result = data.where(:analysis_field_name.gte => analysis_field_name_start, :analysis_field_name.lte => analysis_field_name_end) rescue []
|
||||
end
|
||||
result = result.where(:member_profile_id.in => mps) rescue [] unless mps.nil?
|
||||
return result
|
||||
end
|
||||
def get_chart_data(analysis_field_name_start,analysis_field_name_end,role,type,timezone)
|
||||
analysis_field_name_start = parse_date_time_field("analysis_field_name",analysis_field_name_start,timezone)
|
||||
analysis_field_name_end = parse_date_time_field("analysis_field_name",analysis_field_name_end,timezone)
|
||||
main_field_name = ""
|
||||
time_fields = time_fields_text
|
||||
max_iterate = 20
|
||||
iterate_step = iterate_step_text
|
||||
iterate_count = ((analysis_field_name_end - analysis_field_name_start) / iterate_step * 1.day.second).ceil
|
||||
if iterate_count > max_iterate
|
||||
iterate_step = (iterate_step * (iterate_count / max_iterate.to_f).ceil).second
|
||||
end
|
||||
case type
|
||||
when "default"
|
||||
jls = []
|
||||
parse_again_start
|
||||
when "plugin_template_related"
|
||||
jls = PluginTemplateRelated.all
|
||||
main_field_name = "plugin_template_related_main_field"
|
||||
parse_again_end
|
||||
else
|
||||
jls = []
|
||||
end
|
||||
def get_data_for_excel(analysis_field_name_start,analysis_field_name_end,timezone)
|
||||
analysis_field_name_start = parse_date_time_field("analysis_field_name",analysis_field_name_start,timezone)
|
||||
analysis_field_name_end = parse_date_time_field("analysis_field_name",analysis_field_name_end,timezone)
|
||||
data = []
|
||||
roles = Role.where(:disabled => false, :title.ne => "", :title.ne => nil).asc(:key)
|
||||
roles.each do |role|
|
||||
d = {}
|
||||
d["name"] = role.title
|
||||
mps = role.member_profile_ids
|
||||
d["data"] = filter_data(PluginTemplate, analysis_field_name_start, analysis_field_name_end, mps)
|
||||
data << d
|
||||
end
|
||||
return data
|
||||
end
|
||||
def filter_data(data,analysis_field_name_start,analysis_field_name_end,mps = nil)
|
||||
result = []
|
||||
if @periodic
|
||||
all_ids = data.all.pluck(:id) rescue []
|
||||
out_of_range_ids1 = data.where(:analysis_field_name_start.gt => analysis_field_name_end).pluck(:id) rescue []
|
||||
out_of_range_ids2 = data.where(:analysis_field_name_end.lt => analysis_field_name_start).pluck(:id) rescue []
|
||||
result = data.where(:id.in=>(all_ids - out_of_range_ids1 - out_of_range_ids2)) rescue []
|
||||
else
|
||||
result = data.where(:analysis_field_name.gte => analysis_field_name_start, :analysis_field_name.lte => analysis_field_name_end) rescue []
|
||||
end
|
||||
result = result.where(:member_profile_id.in => mps) rescue [] unless mps.nil?
|
||||
return result
|
||||
end
|
||||
def get_chart_data(analysis_field_name_start,analysis_field_name_end,role,type,timezone)
|
||||
analysis_field_name_start = parse_date_time_field("analysis_field_name",analysis_field_name_start,timezone)
|
||||
analysis_field_name_end = parse_date_time_field("analysis_field_name",analysis_field_name_end,timezone)
|
||||
main_field_name = ""
|
||||
time_fields = time_fields_text
|
||||
max_iterate = 20
|
||||
iterate_step = iterate_step_text
|
||||
iterate_count = ((analysis_field_name_end - analysis_field_name_start) / iterate_step * 1.day.second).ceil
|
||||
if iterate_count > max_iterate
|
||||
iterate_step = (iterate_step * (iterate_count / max_iterate.to_f).ceil).second
|
||||
end
|
||||
case type
|
||||
when "default"
|
||||
jls = []
|
||||
parse_again_start
|
||||
when "plugin_template_related"
|
||||
jls = PluginTemplateRelated.all
|
||||
main_field_name = "plugin_template_related_main_field"
|
||||
parse_again_end
|
||||
else
|
||||
jls = []
|
||||
end
|
||||
|
||||
finaldata = []
|
||||
role = Role.find(role) rescue nil
|
||||
mps = []
|
||||
if !role.nil?
|
||||
mps = role.member_profile_ids
|
||||
end
|
||||
jls.each do |jl|
|
||||
data = {}
|
||||
data["name"] = jl.send(main_field_name) rescue "N/A"
|
||||
data["data"] = {}
|
||||
time_iterate(analysis_field_name_start,analysis_field_name_end,iterate_step) do |analysis_field_name|
|
||||
next_analysis_field_name = analysis_field_name + iterate_step
|
||||
current_analysis_field_name = analysis_field_name
|
||||
current_analysis_field_name = analysis_field_name.strftime("%H:%M") if time_fields.include?("analysis_field_name")
|
||||
next_analysis_field_name = next_analysis_field_name.strftime("%H:%M") if time_fields.include?("analysis_field_name")
|
||||
t = filter_data(jl.plugin_templates, current_analysis_field_name, next_analysis_field_name, mps)
|
||||
finaldata = []
|
||||
role = Role.find(role) rescue nil
|
||||
mps = []
|
||||
if !role.nil?
|
||||
mps = role.member_profile_ids
|
||||
end
|
||||
jls.each do |jl|
|
||||
data = {}
|
||||
data["name"] = jl.send(main_field_name) rescue "N/A"
|
||||
data["data"] = {}
|
||||
time_iterate(analysis_field_name_start,analysis_field_name_end,iterate_step) do |analysis_field_name|
|
||||
next_analysis_field_name = analysis_field_name + iterate_step
|
||||
current_analysis_field_name = analysis_field_name
|
||||
current_analysis_field_name = analysis_field_name.strftime("%H:%M") if time_fields.include?("analysis_field_name")
|
||||
next_analysis_field_name = next_analysis_field_name.strftime("%H:%M") if time_fields.include?("analysis_field_name")
|
||||
t = filter_data(jl.plugin_templates, current_analysis_field_name, next_analysis_field_name, mps)
|
||||
|
||||
if current_analysis_field_name.class == DateTime
|
||||
current_analysis_field_name = display_date_time(current_analysis_field_name,timezone,iterate_step)
|
||||
end
|
||||
data["data"][current_analysis_field_name.to_s] = t
|
||||
end
|
||||
finaldata << data
|
||||
end
|
||||
data = {"name" => "N/A", "data" => {}}
|
||||
time_iterate(analysis_field_name_start,analysis_field_name_end,iterate_step) do |analysis_field_name|
|
||||
next_analysis_field_name = analysis_field_name + iterate_step
|
||||
current_analysis_field_name = analysis_field_name
|
||||
current_analysis_field_name = analysis_field_name.strftime("%H:%M") if time_fields.include?("analysis_field_name")
|
||||
next_analysis_field_name = next_analysis_field_name.strftime("%H:%M") if time_fields.include?("analysis_field_name")
|
||||
case type
|
||||
when "default"
|
||||
t = filter_data(PluginTemplate, current_analysis_field_name, next_analysis_field_name, mps).count rescue 0
|
||||
parse_again_start
|
||||
when "plugin_template_related"
|
||||
t = filter_data(PluginTemplate, current_analysis_field_name, next_analysis_field_name, mps).where(:plugin_template_related_id => nil).count rescue 0
|
||||
parse_again_end
|
||||
else
|
||||
t = filter_data(PluginTemplate, current_analysis_field_name, next_analysis_field_name, mps).count rescue 0
|
||||
end
|
||||
current_analysis_field_name = current_analysis_field_name.new_offset(timezone) if current_analysis_field_name.class == DateTime
|
||||
if current_analysis_field_name.class == DateTime
|
||||
current_analysis_field_name = display_date_time(current_analysis_field_name,timezone,iterate_step)
|
||||
end
|
||||
data["data"][current_analysis_field_name.to_s] = t
|
||||
end
|
||||
finaldata << data
|
||||
finaldata
|
||||
end
|
||||
def parse_date_time_field(field,value,timezone="+08:00")
|
||||
time_fields = time_fields_text
|
||||
type = PluginTemplate.fields[field].type rescue nil
|
||||
if type.nil?
|
||||
@periodic = true
|
||||
type = PluginTemplate.fields[field + "_start"].type
|
||||
end
|
||||
if time_fields.include?(field)
|
||||
parse_time(value,timezone)
|
||||
elsif type == Integer
|
||||
value.to_i
|
||||
elsif type == Date
|
||||
Date.parse(value)
|
||||
else
|
||||
DateTime.parse(value+timezone).utc
|
||||
end
|
||||
end
|
||||
def display_date_time(date_time,timezone,iterate_step)
|
||||
date_time = date_time.new_offset(timezone)
|
||||
if iterate_step > 1.year
|
||||
date_time = date_time.strftime("%Y")
|
||||
elsif iterate_step > 1.month
|
||||
date_time = date_time.strftime("%Y/%m")
|
||||
elsif iterate_step > 1.day
|
||||
date_time = date_time.strftime("%Y/%m/%d")
|
||||
else
|
||||
date_time = date_time.strftime("%Y/%m/%d %H:%M")
|
||||
end
|
||||
return date_time
|
||||
end
|
||||
if current_analysis_field_name.class == DateTime
|
||||
current_analysis_field_name = display_date_time(current_analysis_field_name,timezone,iterate_step)
|
||||
end
|
||||
data["data"][current_analysis_field_name.to_s] = t
|
||||
end
|
||||
finaldata << data
|
||||
end
|
||||
data = {"name" => "N/A", "data" => {}}
|
||||
time_iterate(analysis_field_name_start,analysis_field_name_end,iterate_step) do |analysis_field_name|
|
||||
next_analysis_field_name = analysis_field_name + iterate_step
|
||||
current_analysis_field_name = analysis_field_name
|
||||
current_analysis_field_name = analysis_field_name.strftime("%H:%M") if time_fields.include?("analysis_field_name")
|
||||
next_analysis_field_name = next_analysis_field_name.strftime("%H:%M") if time_fields.include?("analysis_field_name")
|
||||
case type
|
||||
when "default"
|
||||
t = filter_data(PluginTemplate, current_analysis_field_name, next_analysis_field_name, mps).count rescue 0
|
||||
parse_again_start
|
||||
when "plugin_template_related"
|
||||
t = filter_data(PluginTemplate, current_analysis_field_name, next_analysis_field_name, mps).where(:plugin_template_related_id => nil).count rescue 0
|
||||
parse_again_end
|
||||
else
|
||||
t = filter_data(PluginTemplate, current_analysis_field_name, next_analysis_field_name, mps).count rescue 0
|
||||
end
|
||||
current_analysis_field_name = current_analysis_field_name.new_offset(timezone) if current_analysis_field_name.class == DateTime
|
||||
if current_analysis_field_name.class == DateTime
|
||||
current_analysis_field_name = display_date_time(current_analysis_field_name,timezone,iterate_step)
|
||||
end
|
||||
data["data"][current_analysis_field_name.to_s] = t
|
||||
end
|
||||
finaldata << data
|
||||
finaldata
|
||||
end
|
||||
def parse_date_time_field(field,value,timezone="+08:00")
|
||||
time_fields = time_fields_text
|
||||
type = PluginTemplate.fields[field].type rescue nil
|
||||
if type.nil?
|
||||
@periodic = true
|
||||
type = PluginTemplate.fields[field + "_start"].type
|
||||
end
|
||||
if time_fields.include?(field)
|
||||
parse_time(value,timezone)
|
||||
elsif type == Integer
|
||||
value.to_i
|
||||
elsif type == Date
|
||||
Date.parse(value)
|
||||
else
|
||||
DateTime.parse(value+timezone).utc
|
||||
end
|
||||
end
|
||||
def display_date_time(date_time,timezone,iterate_step)
|
||||
date_time = date_time.new_offset(timezone)
|
||||
if iterate_step > 1.year
|
||||
date_time = date_time.strftime("%Y")
|
||||
elsif iterate_step > 1.month
|
||||
date_time = date_time.strftime("%Y/%m")
|
||||
elsif iterate_step > 1.day
|
||||
date_time = date_time.strftime("%Y/%m/%d")
|
||||
else
|
||||
date_time = date_time.strftime("%Y/%m/%d %H:%M")
|
||||
end
|
||||
return date_time
|
||||
end
|
||||
end
|
|
@ -1,109 +1,113 @@
|
|||
class PluginTemplate
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include OrbitModel::Status
|
||||
include MemberHelper
|
||||
include Slug
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include OrbitModel::Status
|
||||
include MemberHelper
|
||||
include Slug
|
||||
|
||||
col_fields
|
||||
|
||||
col_fields
|
||||
plugin_template_related_files_fields
|
||||
|
||||
plugin_template_related_files_fields
|
||||
parse_again_start
|
||||
belongs_to :plugin_template_related
|
||||
parse_again_end
|
||||
|
||||
parse_again_start
|
||||
belongs_to :plugin_template_related
|
||||
parse_again_end
|
||||
|
||||
field :rss2_id
|
||||
belongs_to :member_profile
|
||||
field :rss2_id
|
||||
belongs_to :member_profile
|
||||
index(plugin_template_sort_hash, { unique: false, background: false })
|
||||
scope :sort_hash, ->{ order_by(plugin_template_sort_hash) }
|
||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(plugin_template_sort_hash) }
|
||||
|
||||
scope :sort_hash, ->{ order_by(plugin_template_sort_hash) }
|
||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(plugin_template_sort_hash) }
|
||||
parse_again_start
|
||||
member_methods_define
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
periodic_methods_define
|
||||
parse_again_end
|
||||
before_save do
|
||||
before_save_codes
|
||||
end
|
||||
def parse_time(time_str)
|
||||
DateTime.parse("0000-01-01 " + time_str)
|
||||
end
|
||||
def self.get_plugin_datas_to_member(datas)
|
||||
|
||||
parse_again_start
|
||||
member_methods_define
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
periodic_methods_define
|
||||
parse_again_end
|
||||
before_save do
|
||||
before_save_codes
|
||||
end
|
||||
def parse_time(time_str)
|
||||
DateTime.parse("0000-01-01 " + time_str)
|
||||
end
|
||||
def self.get_plugin_datas_to_member(datas)
|
||||
fields_to_show = col_name_to_show
|
||||
|
||||
fields_to_show = col_name_to_show
|
||||
fields_to_remove = []
|
||||
|
||||
fields_to_remove = []
|
||||
pd_title = []
|
||||
|
||||
pd_title = []
|
||||
fields_to_show.each do |t|
|
||||
if (self.fields[t].type.to_s == "String" || self.fields[t].type.to_s == "Object" rescue false)
|
||||
fields_to_remove << t if (datas.where(t.to_sym.ne => nil, t.to_sym.ne => "").count == 0 rescue false)
|
||||
elsif (self.relations.include?(t.pluralize) rescue false)
|
||||
fields_to_remove << t if (datas.where(t.pluralize.to_sym.ne=>[]).count == 0 rescue false)
|
||||
elsif period_fields_text.include?(t)
|
||||
fields_to_remove << t if (datas.select{|d| d.send(t) != " ~ " }.count == 0 rescue false)
|
||||
else
|
||||
fields_to_remove << t if (datas.where(t.to_sym.ne => nil).count == 0 rescue false)
|
||||
end
|
||||
pd_title << {
|
||||
"plugin_data_title" => I18n.t("personal_plugin_template.#{t}")
|
||||
} if !fields_to_remove.include?(t)
|
||||
end
|
||||
|
||||
fields_to_show.each do |t|
|
||||
if (self.fields[t].type.to_s == "String" || self.fields[t].type.to_s == "Object" rescue false)
|
||||
fields_to_remove << t if (datas.where(t.to_sym.ne => nil, t.to_sym.ne => "").count == 0 rescue false)
|
||||
elsif (self.relations.include?(t.pluralize) rescue false)
|
||||
fields_to_remove << t if (datas.where(t.pluralize.to_sym.ne=>[]).count == 0 rescue false)
|
||||
elsif period_fields_text.include?(t)
|
||||
fields_to_remove << t if (datas.select{|d| d.send(t) != " ~ " }.count == 0 rescue false)
|
||||
else
|
||||
fields_to_remove << t if (datas.where(t.to_sym.ne => nil).count == 0 rescue false)
|
||||
end
|
||||
pd_title << {
|
||||
"plugin_data_title" => I18n.t("personal_plugin_template.#{t}")
|
||||
} if !fields_to_remove.include?(t)
|
||||
end
|
||||
fields_to_show = fields_to_show - fields_to_remove
|
||||
|
||||
fields_to_show = fields_to_show - fields_to_remove
|
||||
plugin_datas = datas.sort_for_frontend.collect.with_index do |p,idx|
|
||||
|
||||
plugin_datas = datas.sort_for_frontend.collect.with_index do |p,index|
|
||||
|
||||
pd_data = []
|
||||
fields_to_show.collect do |t|
|
||||
pd_data << { "data_title" => p.display_field(t) }
|
||||
end
|
||||
|
||||
{
|
||||
"pd_datas" => pd_data,
|
||||
"type-sort" => (p.course_category.sort_position.to_i rescue 1000),
|
||||
"sort-index" => index
|
||||
}
|
||||
|
||||
end
|
||||
plugin_datas = plugin_datas.sort_by{|pd| [pd["type-sort"], pd["sort-index"]]}
|
||||
return [pd_title,plugin_datas]
|
||||
|
||||
pd_data = []
|
||||
fields_to_show.collect do |t|
|
||||
pd_data << { "data_title" => p.display_field(t) }
|
||||
end
|
||||
parse_again_start * 1 if plugin_template_related.count > 0
|
||||
{
|
||||
"pd_datas" => pd_data,
|
||||
"type-sort" => (p.plugin_template_related.sort_position.to_i rescue 1000),
|
||||
"sort-index" => idx
|
||||
}
|
||||
parse_again_end
|
||||
parse_again_start * 1 if plugin_template_related.count == 0
|
||||
{
|
||||
"pd_datas" => pd_data
|
||||
}
|
||||
parse_again_end
|
||||
end
|
||||
parse_again_start * 1 if plugin_template_related.count > 0
|
||||
plugin_datas = plugin_datas.sort_by{|pd| [pd["type-sort"], pd["sort-index"]]}
|
||||
parse_again_end
|
||||
return [pd_title,plugin_datas]
|
||||
end
|
||||
|
||||
def get_plugin_data(fields_to_show)
|
||||
plugin_datas = []
|
||||
fields_to_show.each do |field|
|
||||
plugin_data = self.get_plugin_field_data(field) rescue nil
|
||||
next if plugin_data.blank? or plugin_data['value'].blank?
|
||||
plugin_datas << plugin_data
|
||||
end
|
||||
plugin_datas
|
||||
end
|
||||
def get_plugin_data(fields_to_show)
|
||||
plugin_datas = []
|
||||
fields_to_show.each do |field|
|
||||
plugin_data = self.get_plugin_field_data(field) rescue nil
|
||||
next if plugin_data.blank? or plugin_data['value'].blank?
|
||||
plugin_datas << plugin_data
|
||||
end
|
||||
plugin_datas
|
||||
end
|
||||
|
||||
def get_plugin_field_data(field)
|
||||
plugin_template = self
|
||||
value_case_codes
|
||||
def get_plugin_field_data(field)
|
||||
plugin_template = self
|
||||
value_case_codes
|
||||
|
||||
value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "<a href='#{value}' target='blank'>#{value}</a>" : value
|
||||
|
||||
{
|
||||
"key"=>field,
|
||||
"title_class"=>"plugin_template-#{field.gsub('_','-')}-field",
|
||||
"value_class"=>"plugin_template-#{field.gsub('_','-')}-value",
|
||||
"title"=>I18n.t('personal_plugin_template.'+field),
|
||||
"value"=>value
|
||||
}
|
||||
end
|
||||
value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "<a href='#{value}' target='blank'>#{value}</a>" : value
|
||||
|
||||
def display_field(field,text_only=false)
|
||||
plugin_template = self
|
||||
display_field_code
|
||||
end
|
||||
{
|
||||
"key"=>field,
|
||||
"title_class"=>"plugin_template-#{field.gsub('_','-')}-field",
|
||||
"value_class"=>"plugin_template-#{field.gsub('_','-')}-value",
|
||||
"title"=>I18n.t('personal_plugin_template.'+field),
|
||||
"value"=>value
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
def display_field(field,text_only=false)
|
||||
plugin_template = self
|
||||
display_field_code
|
||||
end
|
||||
end
|
|
@ -1,4 +1,3 @@
|
|||
class PluginTemplateIntro < PersonalPluginIntro
|
||||
|
||||
|
||||
end
|
||||
end
|
|
@ -2,24 +2,23 @@
|
|||
require 'uri'
|
||||
|
||||
class PluginTemplateLink
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :url
|
||||
field :title, localize: true
|
||||
|
||||
belongs_to :plugin_template
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
before_validation :add_http
|
||||
|
||||
#validates :url, :presence => true, :format => /\A(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?\Z/i
|
||||
field :url
|
||||
field :title, localize: true
|
||||
|
||||
protected
|
||||
belongs_to :plugin_template
|
||||
|
||||
def add_http
|
||||
unless self.url[/^http:\/\//] || self.url[/^https:\/\//]
|
||||
self.url = 'http://' + self.url
|
||||
end
|
||||
end
|
||||
before_validation :add_http
|
||||
|
||||
#validates :url, :presence => true, :format => /\A(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?\Z/i
|
||||
|
||||
protected
|
||||
|
||||
def add_http
|
||||
unless self.url[/^http:\/\//] || self.url[/^https:\/\//]
|
||||
self.url = 'http://' + self.url
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,9 +3,10 @@ class PluginTemplateRelated
|
|||
include Mongoid::Timestamps
|
||||
|
||||
col_related_fields
|
||||
field :sort_position, type: Integer, default: 0
|
||||
|
||||
has_many :plugin_templates
|
||||
parse_again_start
|
||||
related_periodic_methods_define
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
related_periodic_methods_define
|
||||
parse_again_end
|
||||
end
|
|
@ -1,242 +1,242 @@
|
|||
<% # encoding: utf-8 %>
|
||||
<% content_for :page_specific_css do %>
|
||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||
<%= stylesheet_link_tag "lib/fileupload" %>
|
||||
<%= stylesheet_link_tag "lib/main-list" %>
|
||||
<%= stylesheet_link_tag "lib/main-form-col2" %>
|
||||
<style type="text/css">
|
||||
.ui-helper-hidden-accessible{
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||
<%= stylesheet_link_tag "lib/fileupload" %>
|
||||
<%= stylesheet_link_tag "lib/main-list" %>
|
||||
<%= stylesheet_link_tag "lib/main-form-col2" %>
|
||||
<style type="text/css">
|
||||
.ui-helper-hidden-accessible{
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<% end %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
||||
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
||||
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
|
||||
<%= javascript_include_tag "lib/file-type" %>
|
||||
<%= javascript_include_tag "lib/module-area" %>
|
||||
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
||||
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
||||
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
|
||||
<%= javascript_include_tag "lib/file-type" %>
|
||||
<%= javascript_include_tag "lib/module-area" %>
|
||||
<% end %>
|
||||
|
||||
<!-- Input Area -->
|
||||
<div class="input-area">
|
||||
|
||||
<!-- Language Tabs -->
|
||||
<div class="nav-name"><strong><%= t(:language) %></strong></div>
|
||||
<ul class="nav nav-pills language-nav">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<li class="<%= 'active' if i == 0 %>">
|
||||
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
|
||||
</li>
|
||||
<% end %>
|
||||
<li class="pull-right">
|
||||
<%= copy_to_all_language_button(".language-nav", ".language-area") %>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Language Tabs -->
|
||||
<div class="nav-name"><strong><%= t(:language) %></strong></div>
|
||||
<ul class="nav nav-pills language-nav">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<li class="<%= 'active' if i == 0 %>">
|
||||
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
|
||||
</li>
|
||||
<% end %>
|
||||
<li class="pull-right">
|
||||
<%= copy_to_all_language_button(".language-nav", ".language-area") %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- Language -->
|
||||
<div class="tab-content language-area">
|
||||
<!-- Language -->
|
||||
<div class="tab-content language-area">
|
||||
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
|
||||
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
|
||||
parse_again_start
|
||||
<!-- locale_fields -->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.locale_fields") %></label>
|
||||
<div class="controls">
|
||||
locale_fields_input_fields
|
||||
</div>
|
||||
</div>
|
||||
parse_again_end
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- Link -->
|
||||
<%
|
||||
links_hash = {}
|
||||
plugin_template_related_links_text.each do |link|
|
||||
hash = {}
|
||||
hash["html"] = add_attribute("form_link", f, link.pluralize.to_sym)
|
||||
hash["count"] = @plugin_template.send(link.pluralize).count rescue 0
|
||||
links_hash[link] = hash
|
||||
%>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.#{link}") %></label>
|
||||
<div class="controls">
|
||||
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
|
||||
parse_again_start
|
||||
<!-- locale_fields -->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.locale_fields") %></label>
|
||||
<div class="controls">
|
||||
locale_fields_input_fields
|
||||
</div>
|
||||
</div>
|
||||
parse_again_end
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- Link -->
|
||||
<%
|
||||
links_hash = {}
|
||||
plugin_template_related_links_text.each do |link|
|
||||
hash = {}
|
||||
hash["html"] = add_attribute("form_link", f, link.pluralize.to_sym)
|
||||
hash["count"] = @plugin_template.send(link.pluralize).count rescue 0
|
||||
links_hash[link] = hash
|
||||
%>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.#{link}") %></label>
|
||||
<div class="controls">
|
||||
|
||||
<!-- Exist -->
|
||||
<% if !@plugin_template.new_record? && hash["count"] > 0 %>
|
||||
<div class="exist">
|
||||
<% @plugin_template.send(link.pluralize).each_with_index do |obj, i| %>
|
||||
<% if !obj.new_record? %>
|
||||
<%= f.fields_for link.pluralize.to_sym, obj do |f| %>
|
||||
<%= render :partial => "form_link", :object => obj, :locals => {:f => f, :i => i} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- Exist -->
|
||||
<% if !@plugin_template.new_record? && hash["count"] > 0 %>
|
||||
<div class="exist">
|
||||
<% @plugin_template.send(link.pluralize).each_with_index do |obj, i| %>
|
||||
<% if !obj.new_record? %>
|
||||
<%= f.fields_for link.pluralize.to_sym, obj do |f| %>
|
||||
<%= render :partial => "form_link", :object => obj, :locals => {:f => f, :i => i} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Add -->
|
||||
<div class="add-target" for="<%= link %>">
|
||||
</div>
|
||||
<p class="add-btn">
|
||||
<a class="add_link trigger btn btn-small btn-primary" for="<%= link %>"><i class="icons-plus"></i> <%= t(:add) %></a>
|
||||
</p>
|
||||
<!-- Add -->
|
||||
<div class="add-target" for="<%= link %>">
|
||||
</div>
|
||||
<p class="add-btn">
|
||||
<a class="add_link trigger btn btn-small btn-primary" for="<%= link %>"><i class="icons-plus"></i> <%= t(:add) %></a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- File -->
|
||||
<%
|
||||
files_hash = {}
|
||||
plugin_template_related_files_text.each do |file|
|
||||
hash = {}
|
||||
hash["html"] = add_attribute("form_file", f, file.pluralize.to_sym)
|
||||
hash["count"] = @plugin_template.send(file.pluralize).count rescue 0
|
||||
files_hash[file] = hash
|
||||
%>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.#{file}") %></label>
|
||||
<div class="controls">
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- File -->
|
||||
<%
|
||||
files_hash = {}
|
||||
plugin_template_related_files_text.each do |file|
|
||||
hash = {}
|
||||
hash["html"] = add_attribute("form_file", f, file.pluralize.to_sym)
|
||||
hash["count"] = @plugin_template.send(file.pluralize).count rescue 0
|
||||
files_hash[file] = hash
|
||||
%>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.#{file}") %></label>
|
||||
<div class="controls">
|
||||
|
||||
<!-- Exist -->
|
||||
<% if !@plugin_template.new_record? && hash["count"] > 0 %>
|
||||
<div class="exist">
|
||||
<% @plugin_template.send(file.pluralize).each_with_index do |obj, i| %>
|
||||
<% if !obj.new_record? %>
|
||||
<%= f.fields_for file.pluralize.to_sym, obj do |f| %>
|
||||
<%= render :partial => "form_file", :object => obj, :locals => {:f => f, :i => i} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- Exist -->
|
||||
<% if !@plugin_template.new_record? && hash["count"] > 0 %>
|
||||
<div class="exist">
|
||||
<% @plugin_template.send(file.pluralize).each_with_index do |obj, i| %>
|
||||
<% if !obj.new_record? %>
|
||||
<%= f.fields_for file.pluralize.to_sym, obj do |f| %>
|
||||
<%= render :partial => "form_file", :object => obj, :locals => {:f => f, :i => i} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Add -->
|
||||
<div class="add-target" for="<%= file %>">
|
||||
</div>
|
||||
<p class="add-btn">
|
||||
<a class="add_file trigger btn btn-small btn-primary" for="<%= file %>"><i class="icons-plus"></i> <%= t(:add) %></a>
|
||||
</p>
|
||||
<!-- Add -->
|
||||
<div class="add-target" for="<%= file %>">
|
||||
</div>
|
||||
<p class="add-btn">
|
||||
<a class="add_file trigger btn btn-small btn-primary" for="<%= file %>"><i class="icons-plus"></i> <%= t(:add) %></a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="nav-name"><strong><%= t(:module) %></strong></div>
|
||||
<ul class="nav nav-pills module-nav">
|
||||
<li></li>
|
||||
<li class="active">
|
||||
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="nav-name"><strong><%= t(:module) %></strong></div>
|
||||
<ul class="nav nav-pills module-nav">
|
||||
<li></li>
|
||||
<li class="active">
|
||||
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- Module -->
|
||||
<div class="tab-content module-area">
|
||||
<!-- Module -->
|
||||
<div class="tab-content module-area">
|
||||
|
||||
<!-- Basic Module -->
|
||||
<div class="tab-pane fade in active" id="basic">
|
||||
<!-- Basic Module -->
|
||||
<div class="tab-pane fade in active" id="basic">
|
||||
|
||||
<% if !@member.nil? %>
|
||||
<% if !@member.nil? %>
|
||||
|
||||
<div class="control-group big-group">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.author_name_translation") %></label>
|
||||
<div class="controls">
|
||||
<%= @member.name rescue ''%>
|
||||
<%= f.hidden_field :member_profile_id, :value => @member.id %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group big-group">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.author_name_translation") %></label>
|
||||
<div class="controls">
|
||||
<%= @member.name rescue ''%>
|
||||
<%= f.hidden_field :member_profile_id, :value => @member.id %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% else %>
|
||||
<% else %>
|
||||
|
||||
<div class="control-group big-group">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.member_profile") %></label>
|
||||
<div class="controls">
|
||||
<% members = !@plugin_template.member_profile.nil? ? @plugin_template.member_profile.to_a : [] %>
|
||||
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'plugin_template[member_profile_id]', email_members: members,index:'0',select_name:'member_profile_id'} %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group big-group">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.member_profile") %></label>
|
||||
<div class="controls">
|
||||
<% members = !@plugin_template.member_profile.nil? ? @plugin_template.member_profile.to_a : [] %>
|
||||
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'plugin_template[member_profile_id]', email_members: members,index:'0',select_name:'member_profile_id'} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
parse_again_start
|
||||
<!-- none_locale_fields -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.none_locale_fields") %></label>
|
||||
<div class="controls">
|
||||
none_locale_fields_input_fields
|
||||
</div>
|
||||
</div>
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
<!-- plugin_template_related -->
|
||||
<div class="control-group big-group">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.plugin_template_related.plugin_template_related_main_field") %></label>
|
||||
<div class="controls">
|
||||
<%= f.select :plugin_template_related_id, PluginTemplateRelated.all.collect {|t| [ t.plugin_template_related_main_field, t.id ]}, { include_blank: true } %>
|
||||
</div>
|
||||
</div>
|
||||
parse_again_end
|
||||
</div>
|
||||
<!-- Status Module -->
|
||||
<div class="tab-pane fade" id="status">
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:status) %></label>
|
||||
<div class="controls" data-toggle="buttons-checkbox">
|
||||
<label class="checkbox inline btn <%= 'active' if @plugin_template.is_hidden? %>">
|
||||
<%= f.check_box :is_hidden %> <%= t(:hide) %>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
parse_again_start
|
||||
<!-- none_locale_fields -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.none_locale_fields") %></label>
|
||||
<div class="controls">
|
||||
none_locale_fields_input_fields
|
||||
</div>
|
||||
</div>
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
<!-- plugin_template_related -->
|
||||
<div class="control-group big-group">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.plugin_template_related.plugin_template_related_main_field") %></label>
|
||||
<div class="controls">
|
||||
<%= f.select :plugin_template_related_id, PluginTemplateRelated.all.collect {|t| [ t.plugin_template_related_main_field, t.id ]}, { include_blank: true } %>
|
||||
</div>
|
||||
</div>
|
||||
parse_again_end
|
||||
</div>
|
||||
<!-- Status Module -->
|
||||
<div class="tab-pane fade" id="status">
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:status) %></label>
|
||||
<div class="controls" data-toggle="buttons-checkbox">
|
||||
<label class="checkbox inline btn <%= 'active' if @plugin_template.is_hidden? %>">
|
||||
<%= f.check_box :is_hidden %> <%= t(:hide) %>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Form Actions -->
|
||||
<div class="form-actions">
|
||||
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
|
||||
<input type="hidden" name="referer_url" value="<%= request.referer %>">
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
<%= link_to t('cancel'), request.referer, :class=>"btn" %>
|
||||
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
|
||||
<input type="hidden" name="referer_url" value="<%= request.referer %>">
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
<%= link_to t('cancel'), request.referer, :class=>"btn" %>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var files = <%= files_hash.to_json.html_safe %>;
|
||||
$("a.add_file").on("click",function(){
|
||||
var type = $(this).attr("for"),
|
||||
html = files[type].html,
|
||||
count = parseInt(files[type].count),
|
||||
replaceReg = new RegExp("new_" + type + "s","g");
|
||||
html = html.replace(replaceReg,count);
|
||||
$(".add-target[for=" + type + "]").append(html);
|
||||
count++;
|
||||
files[type].count = count;
|
||||
return false;
|
||||
})
|
||||
|
||||
var links = <%= links_hash.to_json.html_safe %>;
|
||||
$("a.add_link").on("click",function(){
|
||||
var type = $(this).attr("for"),
|
||||
html = links[type].html,
|
||||
count = parseInt(links[type].count),
|
||||
replaceReg = new RegExp("new_" + type + "s","g");
|
||||
html = html.replace(replaceReg,count);
|
||||
$(".add-target[for=" + type + "]").append(html);
|
||||
count++;
|
||||
links[type].count = count;
|
||||
return false;
|
||||
})
|
||||
$(document).on('click', '.delete_file', function(){
|
||||
$(this).parents('.input-prepend').remove();
|
||||
});
|
||||
var files = <%= files_hash.to_json.html_safe %>;
|
||||
$("a.add_file").on("click",function(){
|
||||
var type = $(this).attr("for"),
|
||||
html = files[type].html,
|
||||
count = parseInt(files[type].count),
|
||||
replaceReg = new RegExp("new_" + type + "s","g");
|
||||
html = html.replace(replaceReg,count);
|
||||
$(".add-target[for=" + type + "]").append(html);
|
||||
count++;
|
||||
files[type].count = count;
|
||||
return false;
|
||||
})
|
||||
|
||||
var links = <%= links_hash.to_json.html_safe %>;
|
||||
$("a.add_link").on("click",function(){
|
||||
var type = $(this).attr("for"),
|
||||
html = links[type].html,
|
||||
count = parseInt(links[type].count),
|
||||
replaceReg = new RegExp("new_" + type + "s","g");
|
||||
html = html.replace(replaceReg,count);
|
||||
$(".add-target[for=" + type + "]").append(html);
|
||||
count++;
|
||||
links[type].count = count;
|
||||
return false;
|
||||
})
|
||||
$(document).on('click', '.delete_file', function(){
|
||||
$(this).parents('.input-prepend').remove();
|
||||
});
|
||||
|
||||
$(document).on('click', '.remove_existing_record', function(){
|
||||
if(confirm("<%= I18n.t(:sure?)%>")){
|
||||
$(this).children('.should_destroy').attr('value', 1);
|
||||
$(this).parents('.start-line').hide();
|
||||
}
|
||||
});
|
||||
$(document).on('click', '.remove_existing_record', function(){
|
||||
if(confirm("<%= I18n.t(:sure?)%>")){
|
||||
$(this).children('.should_destroy').attr('value', 1);
|
||||
$(this).parents('.start-line').hide();
|
||||
}
|
||||
});
|
||||
</script>
|
|
@ -1,55 +1,55 @@
|
|||
<% if form_file.new_record? %>
|
||||
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
|
||||
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
|
||||
<% else %>
|
||||
<div class="fileupload fileupload-exist start-line" data-provides="fileupload">
|
||||
<% if form_file.file.blank? %>
|
||||
<%= t(:no_file) %>
|
||||
<% else %>
|
||||
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
|
||||
<% end %>
|
||||
<div class="fileupload fileupload-exist start-line" data-provides="fileupload">
|
||||
<% if form_file.file.blank? %>
|
||||
<%= t(:no_file) %>
|
||||
<% else %>
|
||||
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="input-prepend input-append">
|
||||
<label>
|
||||
<span class="add-on btn btn-file" title='<%= t(:file_) %>'>
|
||||
<i class="icons-paperclip"></i>
|
||||
<%= f.file_field :file %>
|
||||
</span>
|
||||
<div class="uneditable-input input-medium">
|
||||
<i class="icon-file fileupload-exists"></i>
|
||||
<span class="fileupload-preview"><%= (form_file.new_record? || form_file.file.blank?) ? t(:select_file) : t(:change_file) %></span>
|
||||
</div>
|
||||
</label>
|
||||
<span class="add-on icons-pencil" title='<%= t(:alternative) %>'></span>
|
||||
<span class="tab-content">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_file.title_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
</span>
|
||||
<span class="add-on icons-pencil" title='<%= t(:description) %>'></span>
|
||||
<span class="tab-content">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
|
||||
<%= f.fields_for :description_translations do |f| %>
|
||||
<%= f.text_field locale, :class => "input-medium", placeholder: t(:description), :value => (form_file.description_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
</span>
|
||||
</span>
|
||||
<% if form_file.new_record? %>
|
||||
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
|
||||
<a class="icon-trash"></a>
|
||||
</span>
|
||||
<% else %>
|
||||
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
|
||||
<%= f.hidden_field :id %>
|
||||
<a class="icon-remove"></a>
|
||||
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="input-prepend input-append">
|
||||
<label>
|
||||
<span class="add-on btn btn-file" title='<%= t(:file_) %>'>
|
||||
<i class="icons-paperclip"></i>
|
||||
<%= f.file_field :file %>
|
||||
</span>
|
||||
<div class="uneditable-input input-medium">
|
||||
<i class="icon-file fileupload-exists"></i>
|
||||
<span class="fileupload-preview"><%= (form_file.new_record? || form_file.file.blank?) ? t(:select_file) : t(:change_file) %></span>
|
||||
</div>
|
||||
</label>
|
||||
<span class="add-on icons-pencil" title='<%= t(:alternative) %>'></span>
|
||||
<span class="tab-content">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_file.title_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
</span>
|
||||
<span class="add-on icons-pencil" title='<%= t(:description) %>'></span>
|
||||
<span class="tab-content">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
|
||||
<%= f.fields_for :description_translations do |f| %>
|
||||
<%= f.text_field locale, :class => "input-medium", placeholder: t(:description), :value => (form_file.description_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
</span>
|
||||
</span>
|
||||
<% if form_file.new_record? %>
|
||||
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
|
||||
<a class="icon-trash"></a>
|
||||
</span>
|
||||
<% else %>
|
||||
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
|
||||
<%= f.hidden_field :id %>
|
||||
<a class="icon-remove"></a>
|
||||
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
|
@ -1,26 +1,26 @@
|
|||
<div class="input-prepend input-append start-line">
|
||||
<span class="add-on icons-link" title="<%= t(:url) %>"></span>
|
||||
<%= f.text_field :url, class: "input-large", placeholder: t(:url) %>
|
||||
<span class="add-on icons-pencil" title="<%= t(:url_alt) %>"></span>
|
||||
<span class="tab-content">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<%= f.text_field locale, :class => "input-large", placeholder: t(:url_alt), :value => (form_link.title_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
</span>
|
||||
|
||||
<% if form_link.new_record? %>
|
||||
<span class="delete_link add-on btn" title="<%= t(:delete_) %>">
|
||||
<a class="icon-trash"></a>
|
||||
</span>
|
||||
<% else %>
|
||||
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
|
||||
<%= f.hidden_field :id %>
|
||||
<a class="icon-remove"></a>
|
||||
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
|
||||
</span>
|
||||
<% end %>
|
||||
<span class="add-on icons-link" title="<%= t(:url) %>"></span>
|
||||
<%= f.text_field :url, class: "input-large", placeholder: t(:url) %>
|
||||
<span class="add-on icons-pencil" title="<%= t(:url_alt) %>"></span>
|
||||
<span class="tab-content">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<%= f.text_field locale, :class => "input-large", placeholder: t(:url_alt), :value => (form_link.title_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
</span>
|
||||
|
||||
<% if form_link.new_record? %>
|
||||
<span class="delete_link add-on btn" title="<%= t(:delete_) %>">
|
||||
<a class="icon-trash"></a>
|
||||
</span>
|
||||
<% else %>
|
||||
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
|
||||
<%= f.hidden_field :id %>
|
||||
<a class="icon-remove"></a>
|
||||
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
<thead>
|
||||
<tr>
|
||||
parse_again_start
|
||||
<th><%= t("personal_plugin_template.plugin_template_related.related_backend_index_fields") %></th>
|
||||
parse_again_end
|
||||
<th><%= t(:action) %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
parse_again_start
|
||||
<th><%= t("personal_plugin_template.plugin_template_related.related_backend_index_fields") %></th>
|
||||
parse_again_end
|
||||
<th><%= t(:action) %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @plugin_template_relateds.each do |plugin_template_related| %>
|
||||
<tr id="<%= dom_id plugin_template_related %>">
|
||||
parse_again_start
|
||||
<td>related_backend_index_fields_contents</td>
|
||||
parse_again_end
|
||||
<td class="span2">
|
||||
<a href="<%= edit_admin_plugin_template_related_path(plugin_template_related) %>#plugin_template_related_modal" data-toggle="modal" data-remote="true" class="action"><%= t(:edit) %></a>
|
||||
<%= link_to t(:delete_), admin_plugin_template_related_path(plugin_template_related), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% @plugin_template_relateds.each do |plugin_template_related| %>
|
||||
<tr id="<%= dom_id plugin_template_related %>">
|
||||
parse_again_start
|
||||
<td>related_backend_index_fields_contents</td>
|
||||
parse_again_end
|
||||
<td class="span2">
|
||||
<a href="<%= edit_admin_plugin_template_related_path(plugin_template_related) %>#plugin_template_related_modal" data-toggle="modal" data-remote="true" class="action">
|
||||
<%= t(:edit) %>
|
||||
</a>
|
||||
<%= link_to t(:delete_), admin_plugin_template_related_path(plugin_template_related), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
|
@ -1,7 +1,7 @@
|
|||
<% @plugin_templates.each do |plugin_template| %>
|
||||
<tr id="<%= dom_id plugin_template %>" class="with_action">
|
||||
parse_again_start
|
||||
parse_again_start
|
||||
<td> backend_index_fields_contents </td>
|
||||
parse_again_end
|
||||
parse_again_end
|
||||
</tr>
|
||||
<% end %>
|
|
@ -1,59 +1,59 @@
|
|||
<% # encoding: utf-8 %>
|
||||
<% content_for :page_specific_css do %>
|
||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||
<%= stylesheet_link_tag "lib/fileupload" %>
|
||||
<%= stylesheet_link_tag "lib/main-list" %>
|
||||
<%= stylesheet_link_tag "lib/main-form-col2" %>
|
||||
<style>
|
||||
.graph-type {
|
||||
margin-right: 10px !important;
|
||||
}
|
||||
.analysis-show-area{
|
||||
margin-top: 25px;
|
||||
}
|
||||
.role {
|
||||
margin: 15px auto;
|
||||
width: 90%;
|
||||
height: 400px;
|
||||
}
|
||||
.role h3{
|
||||
border-bottom: 1px solid #000;
|
||||
}
|
||||
.role .graph-area{
|
||||
text-align: center;
|
||||
}
|
||||
.role .graph-area .loader {
|
||||
margin-top: 170px;
|
||||
}
|
||||
</style>
|
||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||
<%= stylesheet_link_tag "lib/fileupload" %>
|
||||
<%= stylesheet_link_tag "lib/main-list" %>
|
||||
<%= stylesheet_link_tag "lib/main-form-col2" %>
|
||||
<style>
|
||||
.graph-type {
|
||||
margin-right: 10px !important;
|
||||
}
|
||||
.analysis-show-area{
|
||||
margin-top: 25px;
|
||||
}
|
||||
.role {
|
||||
margin: 15px auto;
|
||||
width: 90%;
|
||||
height: 400px;
|
||||
}
|
||||
.role h3{
|
||||
border-bottom: 1px solid #000;
|
||||
}
|
||||
.role .graph-area{
|
||||
text-align: center;
|
||||
}
|
||||
.role .graph-area .loader {
|
||||
margin-top: 170px;
|
||||
}
|
||||
</style>
|
||||
<% end %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "//www.google.com/jsapi", "chartkick"%>
|
||||
<%= javascript_include_tag "justgage.1.0.1.min" %>
|
||||
<%= javascript_include_tag "raphael.2.1.0.min" %>
|
||||
<%= javascript_include_tag "validator" %>
|
||||
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
||||
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
||||
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
||||
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
||||
<% end %>
|
||||
<div id="analysis-area">
|
||||
<div class="analysis-form">
|
||||
<form id="analysis-form" action="" class="form-horizontal main-forms">
|
||||
<div class="input-area">
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.analysis_field_name") %> : </label>
|
||||
<div class="controls">
|
||||
analysis_field_input_fields
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.analysis_field_name") %> : </label>
|
||||
<div class="controls">
|
||||
analysis_field_input_fields
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.graph_by") %> : </label>
|
||||
<div class="controls">
|
||||
parse_again_start
|
||||
<%= t("personal_plugin_template.plugin_template_related.plugin_template_related_main_field") %>
|
||||
<input type="radio" name="graph_by" class="graph-type" value="plugin_template_related">
|
||||
parse_again_end
|
||||
</div>
|
||||
</div>
|
||||
<label class="control-label muted"><%= t("personal_plugin_template.graph_by") %> : </label>
|
||||
<div class="controls">
|
||||
parse_again_start
|
||||
<%= t("personal_plugin_template.plugin_template_related.plugin_template_related_main_field") %>
|
||||
<input type="radio" name="graph_by" class="graph-type" value="plugin_template_related">
|
||||
parse_again_end
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button id="generate_graph" class="btn btn-info">Graphs</button>
|
||||
|
@ -73,19 +73,18 @@ parse_again_end
|
|||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var now = new Date();
|
||||
var late_hour = -(Math.floor(now.getTimezoneOffset() / 60));
|
||||
var minute = -(now.getTimezoneOffset() % 60);
|
||||
var sign = (late_hour < 0) ? "-" : "+";
|
||||
var time_zone_string = sign + ("00" + Math.abs(late_hour)).slice(-2) + ":"+ ("00" + Math.abs(minute)).slice(-2);
|
||||
var now = new Date();
|
||||
var late_hour = -(Math.floor(now.getTimezoneOffset() / 60));
|
||||
var minute = -(now.getTimezoneOffset() % 60);
|
||||
var sign = (late_hour < 0) ? "-" : "+";
|
||||
var time_zone_string = sign + ("00" + Math.abs(late_hour)).slice(-2) + ":"+ ("00" + Math.abs(minute)).slice(-2);
|
||||
var form = new FormValidator($("#analysis-form")),
|
||||
roleArea = $("#analysis-area .analysis-show-area"),
|
||||
totalRoles = roleArea.find(".role").length;
|
||||
form.form.on("submit",function(){return false;})
|
||||
|
||||
$("#generate_excel").on("click",function(){
|
||||
window.location.href = "/admin/plugin_templates/download_excel.xlsx?" + "analysis_field_name_start=" + form.form.find("[name=analysis_field_name_start]").val() + "&analysis_field_name_end=" + form.form.find("[name=analysis_field_name_end]").val() + "&time_zone=" +
|
||||
time_zone_string;
|
||||
window.location.href = "/admin/plugin_templates/download_excel.xlsx?" + "analysis_field_name_start=" + form.form.find("[name=analysis_field_name_start]").val() + "&analysis_field_name_end=" + form.form.find("[name=analysis_field_name_end]").val() + "&time_zone=" + time_zone_string;
|
||||
return false;
|
||||
})
|
||||
|
||||
|
@ -116,8 +115,4 @@ parse_again_end
|
|||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
|
@ -7,66 +7,66 @@ wb = xlsx_package.workbook
|
|||
|
||||
heading = sheet.styles.add_style(:b => true, :locked => true)
|
||||
|
||||
row = [t("personal_plugin_template.member_profile")]
|
||||
parse_again_start
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << t("personal_plugin_template.locale_fields") + " - " + t(locale.to_s)
|
||||
end
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
row << t("personal_plugin_template.none_locale_fields")
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
row << t("personal_plugin_template.plugin_template_related.plugin_template_related_main_field")
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
row << t("personal_plugin_template.plugin_template_file")
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << t("personal_plugin_template.plugin_template_file") + " " + t("description") + " - " + t(locale.to_s)
|
||||
end
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << t("personal_plugin_template.plugin_template_file") + " " + t("alternative") + " - " + t(locale.to_s)
|
||||
end
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
row << t("personal_plugin_template.plugin_template_link")
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << t("personal_plugin_template.plugin_template_link") + " " + t("url_alt") + " - " + t(locale.to_s)
|
||||
end
|
||||
parse_again_end
|
||||
sheet.add_row row, :style => heading
|
||||
row = [t("personal_plugin_template.member_profile")]
|
||||
parse_again_start
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << t("personal_plugin_template.locale_fields") + " - " + t(locale.to_s)
|
||||
end
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
row << t("personal_plugin_template.none_locale_fields")
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
row << t("personal_plugin_template.plugin_template_related.plugin_template_related_main_field")
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
row << t("personal_plugin_template.plugin_template_file")
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << t("personal_plugin_template.plugin_template_file") + " " + t("description") + " - " + t(locale.to_s)
|
||||
end
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << t("personal_plugin_template.plugin_template_file") + " " + t("alternative") + " - " + t(locale.to_s)
|
||||
end
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
row << t("personal_plugin_template.plugin_template_link")
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << t("personal_plugin_template.plugin_template_link") + " " + t("url_alt") + " - " + t(locale.to_s)
|
||||
end
|
||||
parse_again_end
|
||||
sheet.add_row row, :style => heading
|
||||
|
||||
data.each do |plugin_template|
|
||||
row = [(plugin_template.member_profile.name rescue "")]
|
||||
parse_again_start
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << plugin_template.locale_fields_translations[locale.to_s]
|
||||
end
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
row << plugin_template.display_field("none_locale_fields",true)
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
row << (plugin_template.plugin_template_related.plugin_template_related_main_field rescue "")
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
plugin_template_files = plugin_template.plugin_template_files.asc(:created_at)
|
||||
row << plugin_template_files.collect{|f| (@host_url + f.file.url rescue nil)}.join(";")
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << plugin_template_files.collect{|l| l.description_translations[locale]}.join(";")
|
||||
end
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << plugin_template_files.collect{|l| l.title_translations[locale]}.join(";")
|
||||
end
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
plugin_template_links = plugin_template.plugin_template_links.asc(:created_at)
|
||||
row << plugin_template_links.collect{|l| l.url}.join(";")
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << plugin_template_links.collect{|l| l.title_translations[locale]}.join(";")
|
||||
end
|
||||
parse_again_end
|
||||
sheet.add_row row
|
||||
end
|
||||
data.each do |plugin_template|
|
||||
row = [(plugin_template.member_profile.name rescue "")]
|
||||
parse_again_start
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << plugin_template.locale_fields_translations[locale.to_s]
|
||||
end
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
row << plugin_template.display_field("none_locale_fields",true)
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
row << (plugin_template.plugin_template_related.plugin_template_related_main_field rescue "")
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
plugin_template_files = plugin_template.plugin_template_files.asc(:created_at)
|
||||
row << plugin_template_files.collect{|f| (@host_url + f.file.url rescue nil)}.join(";")
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << plugin_template_files.collect{|l| l.description_translations[locale]}.join(";")
|
||||
end
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << plugin_template_files.collect{|l| l.title_translations[locale]}.join(";")
|
||||
end
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
plugin_template_links = plugin_template.plugin_template_links.asc(:created_at)
|
||||
row << plugin_template_links.collect{|l| l.url}.join(";")
|
||||
@site_in_use_locales.each do |locale|
|
||||
row << plugin_template_links.collect{|l| l.title_translations[locale]}.join(";")
|
||||
end
|
||||
parse_again_end
|
||||
sheet.add_row row
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
<%= form_for @plugin_template, url: admin_plugin_template_path(@plugin_template), html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||
<fieldset>
|
||||
<%= render partial: 'form', locals: {f: f} %>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<%= render partial: 'form', locals: {f: f} %>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -1,94 +1,82 @@
|
|||
<% content_for :page_specific_css do %>
|
||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||
<%= stylesheet_link_tag "lib/main-list" %>
|
||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||
<%= stylesheet_link_tag "lib/main-list" %>
|
||||
<% end %>
|
||||
|
||||
<%= form_for(:plugin_template_intro, :url => update_frontend_setting_admin_plugin_templates_path, :method => "post", html: {class: "form-horizontal main-forms previewable"} ) do |f| %>
|
||||
<fieldset>
|
||||
<!-- Input Area -->
|
||||
<div class="input-area">
|
||||
<fieldset>
|
||||
<!-- Input Area -->
|
||||
<div class="input-area">
|
||||
|
||||
<!-- Module Tabs -->
|
||||
<div class="nav-name"><strong><%= t("module_name.personal_plugin_template") %></strong></div>
|
||||
<ul class="nav nav-pills module-nav">
|
||||
<li></li>
|
||||
<li class="active">
|
||||
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Module Tabs -->
|
||||
<div class="nav-name"><strong><%= t("module_name.personal_plugin_template") %></strong></div>
|
||||
<ul class="nav nav-pills module-nav">
|
||||
<li></li>
|
||||
<li class="active">
|
||||
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- Module -->
|
||||
<div class="tab-content module-area">
|
||||
<!-- Basic Module -->
|
||||
<div class="tab-pane fade in active" id="basic">
|
||||
<% if !@member.blank? %>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
|
||||
<div class="controls">
|
||||
<%= @member.name rescue ''%>
|
||||
<%= f.hidden_field :member_profile_id, :value => @member.id %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- frontend_page -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_plugins.frontend_page") %></label>
|
||||
<div class="controls">
|
||||
<%= f.check_box :brief_intro, :checked => @intro.brief_intro %> <%= t("personal_plugins.brief_intro") %>
|
||||
<%= f.check_box :complete_list, :checked => @intro.complete_list %> <%= t("personal_plugins.complete_list") %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Module -->
|
||||
<div class="tab-content module-area">
|
||||
<!-- Basic Module -->
|
||||
<div class="tab-pane fade in active" id="basic">
|
||||
<% if !@member.blank? %>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
|
||||
<div class="controls">
|
||||
<%= @member.name rescue ''%>
|
||||
<%= f.hidden_field :member_profile_id, :value => @member.id %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- frontend_page -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_plugins.frontend_page") %></label>
|
||||
<div class="controls">
|
||||
<%= f.check_box :brief_intro, :checked => @intro.brief_intro %> <%= t("personal_plugins.brief_intro") %>
|
||||
<%= f.check_box :complete_list, :checked => @intro.complete_list %> <%= t("personal_plugins.complete_list") %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Language Tabs -->
|
||||
<div class="nav-name"><strong><%= t(:language) %></strong></div>
|
||||
<ul class="nav nav-pills language-nav">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<li class="<%= 'active' if i == 0 %>">
|
||||
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<!-- Language Tabs -->
|
||||
<div class="nav-name"><strong><%= t(:language) %></strong></div>
|
||||
<ul class="nav nav-pills language-nav">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<li class="<%= 'active' if i == 0 %>">
|
||||
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<!-- Language -->
|
||||
<div class="tab-content language-area">
|
||||
<!-- Language -->
|
||||
<div class="tab-content language-area">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
|
||||
<!-- Content -->
|
||||
<div class="control-group input-content">
|
||||
<label class="control-label muted"><%= t(:content) %></label>
|
||||
<div class="controls">
|
||||
<div class="textarea">
|
||||
<%= f.fields_for :text_translations do |f| %>
|
||||
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@intro.text_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
|
||||
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="control-group input-content">
|
||||
<label class="control-label muted"><%= t(:content) %></label>
|
||||
<div class="controls">
|
||||
<div class="textarea">
|
||||
<%= f.fields_for :text_translations do |f| %>
|
||||
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@intro.text_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Form Actions -->
|
||||
<div class="form-actions">
|
||||
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
|
||||
<%= hidden_field_tag :member_profile_id, @member.id.to_s %>
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<!-- Form Actions -->
|
||||
<div class="form-actions">
|
||||
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
|
||||
<%= hidden_field_tag :member_profile_id, @member.id.to_s %>
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -14,7 +14,9 @@
|
|||
<div class="bottomnav clearfix">
|
||||
<div class="action pull-right">
|
||||
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:new_), new_admin_plugin_template_path, :class => 'btn btn-primary' %>
|
||||
parse_again_start * 1 if plugin_template_related.count == 0
|
||||
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_plugin_template_setting_path, :class => 'btn btn-primary pull-right' %>
|
||||
parse_again_end
|
||||
</div>
|
||||
<div class="pagination pagination-centered">
|
||||
<%= content_tag :div, paginate(@plugin_templates), class: "pagination pagination-centered" %>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<%= form_for @plugin_template, url: admin_plugin_templates_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||
<fieldset>
|
||||
<%= render partial: 'form', locals: {f: f} %>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<%= render partial: 'form', locals: {f: f} %>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -1,72 +1,72 @@
|
|||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "lib/jquery-ui-sortable.min" %>
|
||||
<%= javascript_include_tag "lib/jquery-ui-sortable.min" %>
|
||||
<% end %>
|
||||
<style type="text/css">
|
||||
.element{
|
||||
background: #FFF;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #DDD;
|
||||
}
|
||||
.detail{
|
||||
padding: 10px;
|
||||
min-height: 250px;
|
||||
}
|
||||
.totle{
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
.totle span{
|
||||
font-size: 18px;
|
||||
}
|
||||
.element{
|
||||
background: #FFF;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #DDD;
|
||||
}
|
||||
.detail{
|
||||
padding: 10px;
|
||||
min-height: 250px;
|
||||
}
|
||||
.totle{
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
.totle span{
|
||||
font-size: 18px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="row">
|
||||
parse_again_start
|
||||
<div class="element span4">
|
||||
<div class="detail w-a h-a">
|
||||
<p class="totle">
|
||||
<a class="btn btn-small btn-primary pull-right" href="<%= new_admin_plugin_template_related_path %>#plugin_template_related_modal" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
|
||||
<span><%= t("personal_plugin_template.plugin_template_related.plugin_template_related_main_field") %></span>
|
||||
</p>
|
||||
<div class="detal-list my_scroll">
|
||||
<div class="scrollbar">
|
||||
<div class="track">
|
||||
<div class="thumb">
|
||||
<div class="end"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="viewport">
|
||||
<div class="overview">
|
||||
<table id="plugin_template_relateds" class="table table-striped">
|
||||
<%= render :partial => 'plugin_template_related', :locals => {:@plugin_template_relateds => @plugin_template_relateds} %>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
parse_again_end
|
||||
parse_again_start
|
||||
<div class="element span4">
|
||||
<div class="detail w-a h-a">
|
||||
<p class="totle">
|
||||
<a class="btn btn-small btn-primary pull-right" href="<%= new_admin_plugin_template_related_path %>#plugin_template_related_modal" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
|
||||
<span><%= t("personal_plugin_template.plugin_template_related.plugin_template_related_main_field") %></span>
|
||||
</p>
|
||||
<div class="detal-list my_scroll">
|
||||
<div class="scrollbar">
|
||||
<div class="track">
|
||||
<div class="thumb">
|
||||
<div class="end"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="viewport">
|
||||
<div class="overview">
|
||||
<table id="plugin_template_relateds" class="table table-striped">
|
||||
<%= render :partial => 'plugin_template_related', :locals => {:@plugin_template_relateds => @plugin_template_relateds} %>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
parse_again_end
|
||||
</div>
|
||||
|
||||
parse_again_start
|
||||
<div>
|
||||
<div style="display:none;" class="modal" id="plugin_template_related_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
</div>
|
||||
<div style="display:none;" class="modal" id="plugin_template_related_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$("#plugin_template_relateds tbody").sortable({
|
||||
update : function(){
|
||||
var data = {};
|
||||
$("#plugin_template_relateds tbody tr").each(function(i){
|
||||
data[$(this).data("type-id")] = i;
|
||||
})
|
||||
$.ajax({
|
||||
url : "/admin/plugin_template_relateds/update_order",
|
||||
type : "post",
|
||||
data : {"order" : data}
|
||||
})
|
||||
}
|
||||
});
|
||||
$("#plugin_template_relateds tbody").sortable({
|
||||
update : function(){
|
||||
var data = {};
|
||||
$("#plugin_template_relateds tbody tr").each(function(i){
|
||||
data[$(this).data("type-id")] = i;
|
||||
})
|
||||
$.ajax({
|
||||
url : "/admin/plugin_template_relateds/update_order",
|
||||
type : "post",
|
||||
data : {"order" : data}
|
||||
})
|
||||
}
|
||||
});
|
||||
</script>
|
||||
parse_again_end
|
|
@ -1,75 +1,75 @@
|
|||
<% content_for :page_specific_css do %>
|
||||
<%= stylesheet_link_tag "lib/list-check" %>
|
||||
<%= stylesheet_link_tag "lib/list-check" %>
|
||||
<% end %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "lib/list-check" %>
|
||||
<%= javascript_include_tag "lib/list-check" %>
|
||||
<% end %>
|
||||
|
||||
<%
|
||||
if has_access?
|
||||
@plugin_templates = PluginTemplate.where(member_profile_id: @member.id).sort_hash.page(params[:page]).per(10)
|
||||
else
|
||||
@plugin_templates = PluginTemplate.where(is_hidden: false, member_profile_id: @member.id).sort_hash.page(params[:page]).per(10)
|
||||
end
|
||||
if has_access?
|
||||
@plugin_templates = PluginTemplate.where(member_profile_id: @member.id).sort_hash.page(params[:page]).per(10)
|
||||
else
|
||||
@plugin_templates = PluginTemplate.where(is_hidden: false, member_profile_id: @member.id).sort_hash.page(params[:page]).per(10)
|
||||
end
|
||||
%>
|
||||
|
||||
<% if has_access? %>
|
||||
<div class="list-active">
|
||||
<div class="btn-group">
|
||||
<%= link_to('Hide', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-hide", :rel => toggle_hide_admin_plugin_templates_path(member_profile_id: @member.id.to_s, disable: 'true') ) %>
|
||||
<%= link_to('Show', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-show", :rel => toggle_hide_admin_plugin_templates_path(member_profile_id: @member.id.to_s, disable: 'false') ) %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-active">
|
||||
<div class="btn-group">
|
||||
<%= link_to('Hide', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-hide", :rel => toggle_hide_admin_plugin_templates_path(member_profile_id: @member.id.to_s, disable: 'true') ) %>
|
||||
<%= link_to('Show', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-show", :rel => toggle_hide_admin_plugin_templates_path(member_profile_id: @member.id.to_s, disable: 'false') ) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end -%>
|
||||
|
||||
<table class="table table-condensed table-striped main-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<% if has_access? %>
|
||||
<th><input type="checkbox" /></th>
|
||||
<% end -%>
|
||||
<thead>
|
||||
<tr>
|
||||
<% if has_access? %>
|
||||
<th><input type="checkbox" /></th>
|
||||
<% end -%>
|
||||
parse_again_start
|
||||
<th><%= t('personal_plugin_template.backend_profile_fields') %></th>
|
||||
<th><%= t('personal_plugin_template.backend_profile_fields') %></th>
|
||||
parse_again_end
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @plugin_templates.each do |plugin_template| %>
|
||||
<tr id="<%= dom_id plugin_template %>" class="<%= plugin_template.is_hidden ? "checkHide" : "" %>">
|
||||
<% if has_access? %>
|
||||
<td>
|
||||
<%= check_box_tag 'to_change[]', plugin_template.id.to_s, false, :class => "list-check" %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @plugin_templates.each do |plugin_template| %>
|
||||
<tr id="<%= dom_id plugin_template %>" class="<%= plugin_template.is_hidden ? "checkHide" : "" %>">
|
||||
<% if has_access? %>
|
||||
<td>
|
||||
<%= check_box_tag 'to_change[]', plugin_template.id.to_s, false, :class => "list-check" %>
|
||||
</td>
|
||||
<% end %>
|
||||
parse_again_start
|
||||
<td>backend_profile_fields_contents</td>
|
||||
<td>backend_profile_fields_contents</td>
|
||||
parse_again_end
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<div class="bottomnav clearfix">
|
||||
<% if has_access? %>
|
||||
<div class="action pull-right">
|
||||
<%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/plugin_templates/frontend_setting', :class => 'btn btn-primary' %>
|
||||
<%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'),
|
||||
'/admin/members/'+@member.to_param+'/plugin_templates/new', :class => 'btn btn-primary' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="pagination pagination-centered">
|
||||
<%= paginate @plugin_templates, :params => {:direction => params[:direction], :sort => params[:sort] } %>
|
||||
</div>
|
||||
<% if has_access? %>
|
||||
<div class="action pull-right">
|
||||
<%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/plugin_templates/frontend_setting', :class => 'btn btn-primary' %>
|
||||
<%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'),
|
||||
'/admin/members/'+@member.to_param+'/plugin_templates/new', :class => 'btn btn-primary' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="pagination pagination-centered">
|
||||
<%= paginate @plugin_templates, :params => {:direction => params[:direction], :sort => params[:sort] } %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="dialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="Delete item" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3><%= t(:sure?) %></h3>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
|
||||
<button class="delete-item btn btn-danger"><%= t(:submit) %></button>
|
||||
</div>
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3><%= t(:sure?) %></h3>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
|
||||
<button class="delete-item btn btn-danger"><%= t(:submit) %></button>
|
||||
</div>
|
||||
</div>
|
|
@ -2,31 +2,31 @@ Rails.application.routes.draw do
|
|||
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
|
||||
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||
namespace :admin do
|
||||
get 'plugin_template_setting' => "plugin_templates#setting"
|
||||
resources :plugin_templates do
|
||||
collection do
|
||||
get 'toggle_hide' => 'plugin_templates#toggle_hide'
|
||||
get 'analysis'
|
||||
get 'analysis_report'
|
||||
get "download_excel"
|
||||
end
|
||||
end
|
||||
get 'plugin_template_setting' => "plugin_templates#setting"
|
||||
resources :plugin_templates do
|
||||
collection do
|
||||
get 'toggle_hide' => 'plugin_templates#toggle_hide'
|
||||
get 'analysis'
|
||||
get 'analysis_report'
|
||||
get "download_excel"
|
||||
end
|
||||
end
|
||||
|
||||
resources :members do
|
||||
collection do
|
||||
scope '(:name-:uid)' do
|
||||
resources :plugin_templates do
|
||||
collection do
|
||||
get 'frontend_setting' => 'plugin_templates#frontend_setting'
|
||||
post 'update_frontend_setting' => 'plugin_templates#update_frontend_setting'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
parse_again_start
|
||||
resources :plugin_template_relateds
|
||||
parse_again_end
|
||||
resources :members do
|
||||
collection do
|
||||
scope '(:name-:uid)' do
|
||||
resources :plugin_templates do
|
||||
collection do
|
||||
get 'frontend_setting' => 'plugin_templates#frontend_setting'
|
||||
post 'update_frontend_setting' => 'plugin_templates#update_frontend_setting'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
parse_again_start
|
||||
resources :plugin_template_relateds
|
||||
parse_again_end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue