First version.
This commit is contained in:
commit
ed01254efc
|
@ -0,0 +1,8 @@
|
||||||
|
.bundle/
|
||||||
|
log/*.log
|
||||||
|
pkg/
|
||||||
|
test/dummy/db/*.sqlite3
|
||||||
|
test/dummy/db/*.sqlite3-journal
|
||||||
|
test/dummy/log/*.log
|
||||||
|
test/dummy/tmp/
|
||||||
|
test/dummy/.sass-cache
|
|
@ -0,0 +1,14 @@
|
||||||
|
source "https://rubygems.org"
|
||||||
|
|
||||||
|
# Declare your gem's dependencies in personal_course.gemspec.
|
||||||
|
# Bundler will treat runtime dependencies like base dependencies, and
|
||||||
|
# development dependencies will be added by default to the :development group.
|
||||||
|
gemspec
|
||||||
|
|
||||||
|
# Declare any dependencies that are still in development here instead of in
|
||||||
|
# your gemspec. These might include edge Rails or gems from your path or
|
||||||
|
# Git. Remember to move these dependencies to your gemspec before releasing
|
||||||
|
# your gem to rubygems.org.
|
||||||
|
|
||||||
|
# To use debugger
|
||||||
|
# gem 'debugger'
|
|
@ -0,0 +1,20 @@
|
||||||
|
Copyright 2015 YOURNAME
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,3 @@
|
||||||
|
= ModuleGenerator
|
||||||
|
|
||||||
|
This project rocks and uses MIT-LICENSE.
|
|
@ -0,0 +1,34 @@
|
||||||
|
begin
|
||||||
|
require 'bundler/setup'
|
||||||
|
rescue LoadError
|
||||||
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
||||||
|
end
|
||||||
|
|
||||||
|
require 'rdoc/task'
|
||||||
|
|
||||||
|
RDoc::Task.new(:rdoc) do |rdoc|
|
||||||
|
rdoc.rdoc_dir = 'rdoc'
|
||||||
|
rdoc.title = 'PersonalCourse'
|
||||||
|
rdoc.options << '--line-numbers'
|
||||||
|
rdoc.rdoc_files.include('README.rdoc')
|
||||||
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||||
|
end
|
||||||
|
|
||||||
|
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
||||||
|
load 'rails/tasks/engine.rake'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Bundler::GemHelper.install_tasks
|
||||||
|
|
||||||
|
require 'rake/testtask'
|
||||||
|
|
||||||
|
Rake::TestTask.new(:test) do |t|
|
||||||
|
t.libs << 'lib'
|
||||||
|
t.libs << 'test'
|
||||||
|
t.pattern = 'test/**/*_test.rb'
|
||||||
|
t.verbose = false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
task default: :test
|
|
@ -0,0 +1,13 @@
|
||||||
|
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||||
|
// listed below.
|
||||||
|
//
|
||||||
|
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||||
|
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
||||||
|
//
|
||||||
|
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||||
|
// compiled file.
|
||||||
|
//
|
||||||
|
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
||||||
|
// about supported directives.
|
||||||
|
//
|
||||||
|
//= require_tree .
|
|
@ -0,0 +1,15 @@
|
||||||
|
/*
|
||||||
|
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||||
|
* listed below.
|
||||||
|
*
|
||||||
|
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
||||||
|
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
||||||
|
*
|
||||||
|
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
||||||
|
* compiled file so the styles you add here take precedence over styles defined in any styles
|
||||||
|
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
||||||
|
* file per style scope.
|
||||||
|
*
|
||||||
|
*= require_tree .
|
||||||
|
*= require_self
|
||||||
|
*/
|
|
@ -0,0 +1,961 @@
|
||||||
|
class Admin::ModuleGeneratorsController < OrbitAdminController
|
||||||
|
require 'fileutils'
|
||||||
|
include Admin::ModuleGeneratorsHelper
|
||||||
|
before_action :set_module_field, only: [:show, :edit , :update, :destroy, :fields_setting, :update_fields_setting,:generate_module]
|
||||||
|
|
||||||
|
def index
|
||||||
|
@module_fields = ModuleField.order_by(:created_at=>'desc').page(params[:page]).per(10)
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@member = MemberProfile.find_by(:uid=>params['uid'].to_s) rescue nil
|
||||||
|
@module_field = ModuleField.new
|
||||||
|
end
|
||||||
|
def download
|
||||||
|
zip_path = "tmp/"
|
||||||
|
FileUtils.mkdir_p(zip_path) if !Dir.exist?(zip_path)
|
||||||
|
module_field = ModuleField.find(params[:module_generator_id]) rescue nil
|
||||||
|
if module_field
|
||||||
|
module_key = File.basename(module_field.module_key)
|
||||||
|
zip_file_path = zip_path + "#{module_key}.zip"
|
||||||
|
zip_file= ZipFileGenerator.new(zip_path + module_key ,zip_file_path)
|
||||||
|
begin
|
||||||
|
zip_file.write
|
||||||
|
rescue
|
||||||
|
File.delete(zip_path + "#{module_key}.zip")
|
||||||
|
zip_file.write
|
||||||
|
end
|
||||||
|
send_file(zip_file_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def copy
|
||||||
|
@member = MemberProfile.find_by(:uid=>params['uid'].to_s) rescue nil
|
||||||
|
attributes = ModuleField.find(params[:module_generator_id]).attributes rescue {}
|
||||||
|
attributes = attributes.except("_id")
|
||||||
|
copy_attributes = {}
|
||||||
|
attributes.each do |k,v|
|
||||||
|
if (ModuleField.fields[k].options[:localize] rescue false)
|
||||||
|
copy_attributes["#{k}_translations"] = v
|
||||||
|
else
|
||||||
|
copy_attributes[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#render :html => attributes and return
|
||||||
|
@module_field = ModuleField.new(copy_attributes)
|
||||||
|
end
|
||||||
|
def create
|
||||||
|
module_field = ModuleField.create(module_field_params)
|
||||||
|
redirect_to admin_module_fields_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@module_field.destroy
|
||||||
|
redirect_to admin_module_fields_path(:page => params[:page])
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@module_field.update_attributes(module_field_params)
|
||||||
|
@module_field.save
|
||||||
|
redirect_to admin_module_fields_path
|
||||||
|
end
|
||||||
|
def fields_setting
|
||||||
|
end
|
||||||
|
def update_fields_setting
|
||||||
|
field_params = params.require(:module_field).permit! rescue {}
|
||||||
|
field_params[:fields_order] = field_params[:fields_order].map do |k, v|
|
||||||
|
[k, v.sort_by{|k,vv| k.to_i}.map{|vv| vv[1].to_i}]
|
||||||
|
end.to_h
|
||||||
|
@module_field.update_attributes(field_params)
|
||||||
|
@module_field.save
|
||||||
|
redirect_to params[:referer_url]
|
||||||
|
end
|
||||||
|
def scan_word_block(word)
|
||||||
|
words_idx = []
|
||||||
|
tmp = []
|
||||||
|
is_word = false
|
||||||
|
word.split('').each_with_index do |w, i|
|
||||||
|
if w.match(/\w/)
|
||||||
|
if !is_word
|
||||||
|
tmp << i
|
||||||
|
is_word = true
|
||||||
|
end
|
||||||
|
elsif is_word
|
||||||
|
tmp << i - 1
|
||||||
|
words_idx << tmp
|
||||||
|
tmp = []
|
||||||
|
is_word = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if tmp.count == 1
|
||||||
|
tmp << word.length - 1
|
||||||
|
words_idx << tmp
|
||||||
|
tmp = []
|
||||||
|
end
|
||||||
|
last_idx = word.length - 1
|
||||||
|
new_res = []
|
||||||
|
words_idx_reverse = words_idx.reverse
|
||||||
|
words_idx_reverse.each_with_index do |v, i|
|
||||||
|
s = v[0]
|
||||||
|
e = v[1]
|
||||||
|
tmp_str = word[s..e]
|
||||||
|
tmp = word[e+1..last_idx]
|
||||||
|
need_find_quote = tmp.match(/['"]/)
|
||||||
|
need_find_quote = need_find_quote ? need_find_quote[0] : nil
|
||||||
|
tmp_str += tmp
|
||||||
|
prev_word_range = words_idx_reverse[i + 1]
|
||||||
|
start_idx = 0
|
||||||
|
if prev_word_range
|
||||||
|
start_idx = prev_word_range[1] + 1
|
||||||
|
end
|
||||||
|
if need_find_quote
|
||||||
|
tmp = word[start_idx...s].match(/(,\s+|)[,#{need_find_quote}]+\s*$/)
|
||||||
|
else
|
||||||
|
tmp = word[start_idx...s].match(/(,\s+|)\s*$/)
|
||||||
|
end
|
||||||
|
if tmp
|
||||||
|
tmp = tmp[0]
|
||||||
|
tmp_str = tmp + tmp_str
|
||||||
|
last_idx = s - 1 - tmp.length
|
||||||
|
else
|
||||||
|
last_idx = s - 1
|
||||||
|
end
|
||||||
|
new_res << tmp_str
|
||||||
|
end
|
||||||
|
new_res.reverse
|
||||||
|
end
|
||||||
|
def generate_module
|
||||||
|
template_dir_path = File.expand_path("../../../../template_generator/", __FILE__) + "/"
|
||||||
|
cp_template_dir_path = "#{Rails.root}/tmp/#{@module_field.module_key}/"
|
||||||
|
Bundler.with_clean_env { system("cd #{File.dirname(template_dir_path)} && git checkout -- template_generator") }
|
||||||
|
FileUtils.rm_rf(cp_template_dir_path)
|
||||||
|
FileUtils.cp_r(template_dir_path,cp_template_dir_path)
|
||||||
|
dirs = Dir.glob("#{cp_template_dir_path}*/")
|
||||||
|
files = Dir.glob("#{cp_template_dir_path}*").select { |fn| File.file?(fn) }
|
||||||
|
begin
|
||||||
|
in_use_locales = Site.first.in_use_locales
|
||||||
|
primary_modal_fields = @module_field.primary_modal_fields.select{|f| (f[:field_name].present? rescue false)}
|
||||||
|
primary_modal_fields << {:field_name=>"authors", :translation_name=>{"zh_tw"=>"全部作者", "en"=>"Authors"}, :field_type=>"text_editor", :localize=>"1", :slug_title=>"0", :periodic_time=>"0"} if primary_modal_fields.select{|f| f[:field_name] == "authors"}.count == 0
|
||||||
|
yml_files = Dir.glob("#{cp_template_dir_path}config/locales/*.yml")
|
||||||
|
yml_files.each do |yml_file|
|
||||||
|
locale = yml_file.split("/").last.split(".yml").first
|
||||||
|
yml_text = File.read(yml_file)
|
||||||
|
translate_hash = {}
|
||||||
|
primary_modal_fields.each do |field_value|
|
||||||
|
if (field_value[:translation_name][locale].present? rescue false)
|
||||||
|
translate_hash[field_value[:field_name]] = field_value[:translation_name][locale]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@module_field.related_modal_name.each_with_index do |related_modal_name,i|
|
||||||
|
field_values = @module_field.related_modal_fields[i].to_a rescue []
|
||||||
|
sub_hash = {}
|
||||||
|
field_values.each do |field_value|
|
||||||
|
if field_value[:field_name] && (field_value[:translation_name][locale].present? rescue false)
|
||||||
|
sub_hash[field_value[:field_name]] = field_value[:translation_name][locale]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if related_modal_name.present? && sub_hash.present?
|
||||||
|
translate_hash[related_modal_name] = sub_hash
|
||||||
|
end
|
||||||
|
#sub_hash["modal_name"] = "關聯欄位翻譯"
|
||||||
|
end
|
||||||
|
col_name_translate_yaml = ""
|
||||||
|
if translate_hash.present?
|
||||||
|
col_name_translate_yaml = translate_hash.to_yaml.gsub("---\n", '')
|
||||||
|
end
|
||||||
|
yml_text = gsub_text_by_key_value(yml_text,"col_name_translate_yaml",col_name_translate_yaml)
|
||||||
|
yml_text = yml_text.gsub("module_template_translate",@module_field.title_translations[locale])
|
||||||
|
File.open(yml_file,'w+') do |f|
|
||||||
|
f.write(yml_text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@blank_text = " "
|
||||||
|
slug_title = primary_modal_fields.select{|field_value| field_value[:slug_title] == "1" rescue false}.first[:field_name].to_s rescue ""
|
||||||
|
module_modal_template_related_files = primary_modal_fields.select{|field_value| field_value[:field_type] == "file" rescue false}.map{|v| v[:field_name]}
|
||||||
|
module_modal_template_related_links = primary_modal_fields.select{|field_value| field_value[:field_type] == "link" rescue false}.map{|v| v[:field_name]}
|
||||||
|
module_modal_template_related_members = primary_modal_fields.select{|field_value| field_value[:field_type] == "member" rescue false}.map{|v| v[:field_name]}
|
||||||
|
module_modal_template_related_files_text = module_modal_template_related_files.to_s
|
||||||
|
module_modal_template_related_links_text = module_modal_template_related_links.to_s
|
||||||
|
fields = module_modal_template_related_files + module_modal_template_related_links
|
||||||
|
module_modal_template_related_files_fields = fields.map{|field_name|
|
||||||
|
"has_many :#{field_name.pluralize}, :dependent => :destroy, :autosave => true\n" +
|
||||||
|
"accepts_nested_attributes_for :#{field_name.pluralize}, :allow_destroy => true"
|
||||||
|
}.join("\n")
|
||||||
|
module_modal_template = @module_field.primary_modal_name
|
||||||
|
all_fields = primary_modal_fields.map{|f| f[:field_name]} + ["member_profile"]
|
||||||
|
@module_field.related_modal_name.each_with_index do |k,i|
|
||||||
|
all_fields += @module_field.related_modal_fields[i].to_a.map{|f| "#{k}.#{f[:field_name]}"}
|
||||||
|
end
|
||||||
|
@module_field.frontend_fields.each do |k,v|
|
||||||
|
@module_field.frontend_fields[k] = v & all_fields
|
||||||
|
end
|
||||||
|
@module_field.backend_fields.each do |k,v|
|
||||||
|
@module_field.backend_fields[k] = v & all_fields
|
||||||
|
end
|
||||||
|
date_fields = []
|
||||||
|
year_month_fields = []
|
||||||
|
date_time_fields = []
|
||||||
|
primary_modal_fields.each do |field_value|
|
||||||
|
if (field_value[:field_type].present? rescue false)
|
||||||
|
case field_value[:field_type]
|
||||||
|
when "date"
|
||||||
|
date_fields << field_value[:field_name]
|
||||||
|
when "year_month"
|
||||||
|
year_month_fields << field_value[:field_name]
|
||||||
|
when "date_time"
|
||||||
|
date_time_fields << field_value[:field_name]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@module_field.related_modal_name.each_with_index do |k,i|
|
||||||
|
@module_field.related_modal_fields[i].to_a.each do |field_value|
|
||||||
|
field_name = "#{k}.#{field_value[:field_name]}"
|
||||||
|
if (field_value[:field_type].present? rescue false)
|
||||||
|
case field_value[:field_type]
|
||||||
|
when "date"
|
||||||
|
date_fields << field_name
|
||||||
|
when "year_month"
|
||||||
|
year_month_fields << field_name
|
||||||
|
when "date_time"
|
||||||
|
date_time_fields << field_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
backend_index_fields = @module_field.backend_fields["index"].to_a rescue []
|
||||||
|
backend_index_fields_contents = backend_index_fields.map do |field_name|
|
||||||
|
if field_name == slug_title
|
||||||
|
"\n <%= link_to #{module_modal_template}.#{field_name}, page_for_#{module_modal_template}(#{module_modal_template}), target: \"blank\" %>\n" +
|
||||||
|
" <div class=\"quick-edit\">\n"+
|
||||||
|
" <ul class=\"nav nav-pills hide\">\n"+
|
||||||
|
" <li><%= link_to t('edit'), edit_admin_#{module_modal_template}_path(#{module_modal_template},:page => params[:page]) %></li>\n"+
|
||||||
|
" <li><%= link_to t(:delete_), admin_#{module_modal_template}_path(id: #{module_modal_template}.id, :page => params[:page]), method: :delete, data: { confirm: 'Are you sure?' } %></li>\n"+
|
||||||
|
" </ul>\n"+
|
||||||
|
" </div>\n "
|
||||||
|
elsif date_fields.include?(field_name)
|
||||||
|
"<%= #{module_modal_template}.#{field_name}.strftime('%Y/%m/%d') rescue \"\" %>"
|
||||||
|
elsif year_month_fields.include?(field_name)
|
||||||
|
"<%= #{module_modal_template}.#{field_name}.strftime('%Y/%m') rescue \"\" %>"
|
||||||
|
elsif date_time_fields.include?(field_name)
|
||||||
|
"<%= #{module_modal_template}.#{field_name}.strftime('%Y/%m/%d %H:%M') rescue \"\" %>"
|
||||||
|
elsif field_name.include?(".")
|
||||||
|
"<%= #{module_modal_template}.#{field_name} rescue \"\" %>"
|
||||||
|
elsif fields.include?(field_name) || module_modal_template_related_members.include?(field_name) || field_name == "member_profile" #file or link or member
|
||||||
|
"<%= #{module_modal_template}.display_field(\"#{field_name}\").html_safe rescue \"\" %>"
|
||||||
|
else
|
||||||
|
"<%= #{module_modal_template}.#{field_name} %>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
backend_profile_fields = @module_field.backend_fields["profile"].to_a rescue []
|
||||||
|
backend_profile_fields_contents = backend_profile_fields.map do |field_name|
|
||||||
|
if field_name == slug_title
|
||||||
|
"\n <%= link_to #{module_modal_template}.#{field_name}, page_for_#{module_modal_template}(#{module_modal_template}), target: \"blank\" %>\n" +
|
||||||
|
" <div class=\"quick-edit\">\n"+
|
||||||
|
" <ul class=\"nav nav-pills hide\">\n"+
|
||||||
|
" <li><%= link_to t('edit'), edit_admin_#{module_modal_template}_path(#{module_modal_template},:page => params[:page]) %></li>\n"+
|
||||||
|
" <li><%= link_to t(:delete_), admin_#{module_modal_template}_path(id: #{module_modal_template}.id, :page => params[:page]), method: :delete, data: { confirm: 'Are you sure?' } %></li>\n"+
|
||||||
|
" </ul>\n"+
|
||||||
|
" </div>\n "
|
||||||
|
elsif field_name.include?(".")
|
||||||
|
"<%= #{module_modal_template}.#{field_name} rescue \"\" %>"
|
||||||
|
elsif fields.include?(field_name) || module_modal_template_related_members.include?(field_name) || field_name == "member_profile" #file or link or member
|
||||||
|
"<%= #{module_modal_template}.display_field(\"#{field_name}\").html_safe rescue \"\" %>"
|
||||||
|
else
|
||||||
|
"<%= #{module_modal_template}.#{field_name} %>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
col_name_to_show = @module_field.frontend_fields["member_show"].to_a rescue []
|
||||||
|
col_name_to_show_in_show_page = @module_field.frontend_fields["show"].to_a rescue []
|
||||||
|
col_name_to_show_in_index_page = @module_field.frontend_fields["index"].to_a rescue []
|
||||||
|
extra_translate_title = col_name_to_show_in_index_page.map{|field_name| #在個人外掛前台index頁面的欄位翻譯名稱hash
|
||||||
|
["th-#{field_name}","I18n.t(\"#{@module_field.module_key}.#{field_name}\")"]
|
||||||
|
}
|
||||||
|
col_fields = get_fields_text(primary_modal_fields)
|
||||||
|
col_related_fields = @module_field.related_modal_fields.map{|field_values| get_fields_text(field_values)}
|
||||||
|
module_modal_template_related = @module_field.related_modal_name.select{|n| n.present?}
|
||||||
|
module_modal_template_related_main_field = @module_field.related_modal_fields.map{|field_values|
|
||||||
|
slug_titles = field_values.select{|field_value| (field_value[:slug_title] == "1" rescue false)}
|
||||||
|
if slug_titles.count == 0
|
||||||
|
slug_titles = field_values
|
||||||
|
end
|
||||||
|
slug_titles.map{|field_value| field_value[:field_name]}.select{|t| t.present?}.first
|
||||||
|
}
|
||||||
|
locale_fields , none_locale_fields , locale_fields_input_fields,none_locale_fields_input_fields = get_input_fields(primary_modal_fields)
|
||||||
|
related_locale_fields = []
|
||||||
|
related_none_locale_fields = []
|
||||||
|
related_locale_fields_input_fields = []
|
||||||
|
related_none_locale_fields_input_fields = []
|
||||||
|
@module_field.related_modal_fields.each_with_index do |field_values,i|
|
||||||
|
related_modal_name = @module_field.related_modal_name[i]
|
||||||
|
f1 , f2 , f3 , f4 = get_input_fields(field_values,related_modal_name,related_modal_name)
|
||||||
|
related_locale_fields << f1
|
||||||
|
related_none_locale_fields << f2
|
||||||
|
related_locale_fields_input_fields << f3
|
||||||
|
related_none_locale_fields_input_fields << f4
|
||||||
|
end
|
||||||
|
datetime_field_types_hash = {"year_month"=>"%Y/%m","date"=>"%Y/%m/%d","time"=>"%H:%M","date_time"=>"%Y/%m/%d %H:%M"}
|
||||||
|
datetime_fields = primary_modal_fields.select{|field_value| datetime_field_types_hash.keys.include?(field_value[:field_type])}.map{|field_value|
|
||||||
|
[field_value[:field_name],datetime_field_types_hash[field_value[:field_type]]]
|
||||||
|
}.to_h
|
||||||
|
value_case_codes = ["value = #{module_modal_template}.send(field) rescue \"\"",
|
||||||
|
"if field.include?(\".\")",
|
||||||
|
"#{@blank_text}value = #{module_modal_template}",
|
||||||
|
"#{@blank_text}field.split(\".\").each{|f| value = value.send(f) rescue nil }",
|
||||||
|
"end",
|
||||||
|
"file_fields = #{module_modal_template_related_files}",
|
||||||
|
"link_fields = #{module_modal_template_related_links}",
|
||||||
|
"member_fields = #{module_modal_template_related_members}",
|
||||||
|
"if file_fields.include?(field)",
|
||||||
|
"#{@blank_text}files = #{module_modal_template}.send(field.pluralize)",
|
||||||
|
"#{@blank_text}value = files.map do |file|",
|
||||||
|
"#{@blank_text * 2}url = file.file.url",
|
||||||
|
"#{@blank_text * 2}title = (file.title.blank? ? File.basename(file.file.path) : file.title)",
|
||||||
|
"#{@blank_text * 2}\"<li><a href='\#{url}'' target='_blank'>\#{title}</li>\"",
|
||||||
|
"#{@blank_text}end",
|
||||||
|
"#{@blank_text}value = value.join(\"\")",
|
||||||
|
"elsif link_fields.include?(field)",
|
||||||
|
"#{@blank_text}links = #{module_modal_template}.send(field.pluralize)",
|
||||||
|
"#{@blank_text}value = links.map do |link|",
|
||||||
|
"#{@blank_text * 2}url = link.url",
|
||||||
|
"#{@blank_text * 2}title = (link.title.blank? ? url : link.title)",
|
||||||
|
"#{@blank_text * 2}\"<li><a href='\#{url}'' target='_blank'>\#{title}</li>\"",
|
||||||
|
"#{@blank_text}end",
|
||||||
|
"#{@blank_text}value = value.join(\"\")",
|
||||||
|
"elsif member_fields.include?(field)",
|
||||||
|
"#{@blank_text}members = #{module_modal_template}.send(field.pluralize)",
|
||||||
|
"#{@blank_text}value = members.map{|m|",
|
||||||
|
"#{@blank_text*2}path = OrbitHelper.url_to_plugin_show(m.to_param, 'member') rescue '#'",
|
||||||
|
"#{@blank_text*2}((text_only rescue false) ? m.name : \"<a href='\#{path}'>\#{m.name}</a>\")",
|
||||||
|
"#{@blank_text}}",
|
||||||
|
"#{@blank_text}join_text = (text_only rescue false) ? \",\" : \"<br>\"",
|
||||||
|
"#{@blank_text}value = value.join(join_text)",
|
||||||
|
"elsif field == \"member_profile\" || field == \"authors\"",
|
||||||
|
"#{@blank_text}value = get_authors_show(#{module_modal_template})",
|
||||||
|
"end",
|
||||||
|
"strftime_hash = #{datetime_fields}",
|
||||||
|
"if strftime_hash.keys.include?(field)",
|
||||||
|
"#{@blank_text}value = value.strftime(strftime_hash[field]) rescue value",
|
||||||
|
"end"
|
||||||
|
].join("\n")
|
||||||
|
enable_one_line_title = @module_field.enable_one_line_title && @module_field.one_line_title_format.present?
|
||||||
|
tmp_title = enable_one_line_title ? "(title_is_paper_format ? #{module_modal_template}.create_link : value)" : "value"
|
||||||
|
display_field_code = value_case_codes + "\n" +
|
||||||
|
"if field == \"#{slug_title}\"\n" +
|
||||||
|
"#{@blank_text}link = OrbitHelper.url_to_plugin_show(#{module_modal_template}.to_param,'#{@module_field.module_key}')\n" +
|
||||||
|
"#{@blank_text}tmp_title = #{tmp_title}\n"+
|
||||||
|
"#{@blank_text}url_to_plugin_show_blank = OrbitHelper.instance_variable_get(:@url_to_plugin_show_blank)\n" +
|
||||||
|
"#{@blank_text}value = url_to_plugin_show_blank ? tmp_title : \"<a href='\#{link}' target='_blank' title='\#{tmp_title}'>\#{tmp_title}</a>\"\n" +
|
||||||
|
"end\n" +
|
||||||
|
"value"
|
||||||
|
value_case_codes += "\nvalue"
|
||||||
|
related_backend_index_fields = @module_field.related_modal_fields.map{|field_values|
|
||||||
|
field_values.map{|field_value| (field_value[:field_name] rescue nil)}.select{|t| t.present?}
|
||||||
|
}
|
||||||
|
related_backend_index_fields_contents = related_backend_index_fields.map.with_index{|field_names,i|
|
||||||
|
related_modal_name = @module_field.related_modal_name[i]
|
||||||
|
field_names.map{|field_name| "<%= #{related_modal_name}.#{field_name} %>"}
|
||||||
|
}
|
||||||
|
member_methods_define = primary_modal_fields.select{|f| (f[:field_type] == "member" rescue false)}.map{|field_value|
|
||||||
|
["def #{field_value[:field_name].pluralize}",
|
||||||
|
" MemberProfile.find(self.#{field_value[:field_name].singularize}_ids) rescue []",
|
||||||
|
"end"]
|
||||||
|
}.flatten
|
||||||
|
date_time_strftime = {"date"=>"%Y/%m/%d","date_time"=>"%Y/%m/%d %H:%M","year_month"=>"%Y/%m"}
|
||||||
|
periodic_methods_define = primary_modal_fields.select{|f| (f[:periodic_time] == "1" rescue false)}.map{|field_value|
|
||||||
|
strftime_string = ""
|
||||||
|
if date_time_strftime.keys.include?(field_value[:field_type])
|
||||||
|
strftime_string = ".strftime(\"#{date_time_strftime[field_value[:field_type]]}\")"
|
||||||
|
end
|
||||||
|
["def #{field_value[:field_name]}",
|
||||||
|
" #{field_value[:field_name]}_start = self.#{field_value[:field_name]}_start#{strftime_string} rescue \"\"",
|
||||||
|
" #{field_value[:field_name]}_end = self.#{field_value[:field_name]}_end#{strftime_string} rescue \"\"",
|
||||||
|
" \"\#{#{field_value[:field_name]}_start} ~ \#{#{field_value[:field_name]}_end}\"",
|
||||||
|
"end"]
|
||||||
|
}.flatten
|
||||||
|
related_periodic_methods_define = @module_field.related_modal_fields.map{|field_values|
|
||||||
|
field_values.select{|f| (f[:periodic_time] == "1" rescue false)}.map{|field_value|
|
||||||
|
strftime_string = ""
|
||||||
|
if date_time_strftime.keys.include? field_value[:field_type]
|
||||||
|
strftime_string = ".strftime(\"#{date_time_strftime[field_value[:field_type]]}\")"
|
||||||
|
end
|
||||||
|
["def #{field_value[:field_name]}",
|
||||||
|
" \"\#{self.#{field_value[:field_name]}_start#{strftime_string}} ~ \#{self.#{field_value[:field_name]}_end#{strftime_string}}\"",
|
||||||
|
"end"]
|
||||||
|
}.flatten
|
||||||
|
}
|
||||||
|
analysis_field_name = @module_field.backend_fields[:analysis][0] rescue ""
|
||||||
|
analysis_field_name = "year" if analysis_field_name.blank?
|
||||||
|
analysis_field_input_fields = ""
|
||||||
|
module_template = @module_field.module_key
|
||||||
|
iterate_step_text = "1.minute"
|
||||||
|
if analysis_field_name.present?
|
||||||
|
field_type = primary_modal_fields.select{|f| f[:field_name] == analysis_field_name}.first[:field_type] rescue "date_time"
|
||||||
|
|
||||||
|
analysis_field_input_fields = ["start","end"].map{|f|
|
||||||
|
"<span><%=t(\"#{module_template}.extend_translate.#{f}_#{field_type}\")%></span>" +
|
||||||
|
generate_input_field(field_type,"#{analysis_field_name}_#{f}" ).gsub("<%= f.","<%= ").gsub(", :new_record => @#{module_modal_template}.new_record?","")
|
||||||
|
}.join("")
|
||||||
|
if field_type == "date" || field_type == "date_time"
|
||||||
|
iterate_step_text = "1.day"
|
||||||
|
elsif field_type == "year"
|
||||||
|
iterate_step_text = "1"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
period_fields = primary_modal_fields.select{|f| (f[:periodic_time] == "1" rescue false)}.map{|f| f[:field_name]}
|
||||||
|
time_fields = primary_modal_fields.select{|f| f[:field_type] == "time"}.map{|f| f[:field_name]}
|
||||||
|
before_save_codes = ""#time_fields.map{|f| "self.#{f} = parse_time(self.#{f}.strftime('%H:%M'))"}.join("\n")
|
||||||
|
module_modal_template_sort_hash = {}
|
||||||
|
@module_field.backend_fields[:sort_asc].to_a.each do |f|
|
||||||
|
module_modal_template_sort_hash[f.to_sym] = 1
|
||||||
|
end rescue nil
|
||||||
|
@module_field.backend_fields[:sort_desc].to_a.each do |f|
|
||||||
|
module_modal_template_sort_hash[f.to_sym] = -1
|
||||||
|
end rescue nil
|
||||||
|
if @module_field.backend_fields[:sort_desc].to_a.count != 0
|
||||||
|
module_modal_template_sort_hash[:id] = -1
|
||||||
|
end
|
||||||
|
all_fields_types = {
|
||||||
|
"member_profile"=>"authors",
|
||||||
|
"authors" => "authors"
|
||||||
|
}
|
||||||
|
all_fields_to_show = []
|
||||||
|
@module_field.primary_modal_fields.each do |f|
|
||||||
|
field_name = f[:field_name]
|
||||||
|
if field_name.present?
|
||||||
|
all_fields_types[field_name] = f[:field_type]
|
||||||
|
all_fields_to_show << field_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@module_field.related_modal_name.each_with_index do |k,i|
|
||||||
|
@module_field.related_modal_fields[i].to_a.map do |f|
|
||||||
|
field_name = f[:field_name]
|
||||||
|
if field_name.present?
|
||||||
|
field_name = "#{k}.#{field_name}"
|
||||||
|
all_fields_types[field_name] = f[:field_type]
|
||||||
|
all_fields_to_show << field_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
all_fields_to_show_in_index = @module_field.get_sorted_fields(:frontend_fields, :index, all_fields_to_show)
|
||||||
|
one_line_title_format_code = []
|
||||||
|
scan_code = scan_word_block(@module_field.one_line_title_format)
|
||||||
|
one_line_title_format_code << "title = ''"
|
||||||
|
scan_code.each do |c|
|
||||||
|
left_space = c.match(/^[\s\'\",]+/)
|
||||||
|
right_space = c.match(/[\s\'\",]+$/)
|
||||||
|
variable_name = c.sub(/^[\s\'\",]+/,'').sub(/[\s\'\",]+$/, '')
|
||||||
|
if variable_name.present?
|
||||||
|
field_type = all_fields_types[variable_name]
|
||||||
|
if field_type
|
||||||
|
if_condition = "if self.#{variable_name}.present?"
|
||||||
|
variable_contents = "self.#{variable_name}"
|
||||||
|
if field_type == 'date' || field_type == 'year_month' || field_type == 'date_time'
|
||||||
|
variable_contents += ".strftime('%b. %Y')"
|
||||||
|
elsif field_type == 'year'
|
||||||
|
variable_contents += '.to_s'
|
||||||
|
elsif field_type == 'member'
|
||||||
|
variable_contents = "MemberProfile.where(:id.in=>self.#{variable_name}_ids).pluck(:tmp_name).map{|h| h[I18n.locale]}.to_sentence({:locale=>:en})"
|
||||||
|
elsif field_type == 'authors'
|
||||||
|
variable_contents = "get_authors_text(self, true, :en)"
|
||||||
|
if_condition += ' || self.member_profile_id.present?'
|
||||||
|
end
|
||||||
|
if left_space || right_space
|
||||||
|
left_space = left_space ? left_space[0] : ''
|
||||||
|
right_space = right_space ? right_space[0] : ''
|
||||||
|
one_line_title_format_code << "title += \"#{left_space.gsub('"','\\"')}\#{#{variable_contents}}#{right_space.gsub('"','\\"')}\" #{if_condition}"
|
||||||
|
else
|
||||||
|
one_line_title_format_code << "title += #{variable_contents} #{if_condition}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
one_line_title_format_code << "title.sub(/^\\s*,/,'').gsub(/,(\\s*,)+/,',')"
|
||||||
|
one_line_title_format_code = one_line_title_format_code.join("\n")
|
||||||
|
col_name_to_show_short = []
|
||||||
|
col_name_to_show_short << analysis_field_name
|
||||||
|
col_name_to_show_short << slug_title
|
||||||
|
@match_pattern = {"module_template" => module_template,
|
||||||
|
"module_modal_template" => module_modal_template,
|
||||||
|
"module_modal_template_related" => module_modal_template_related,
|
||||||
|
"module_modal_template_related_files_fields" => module_modal_template_related_files_fields,
|
||||||
|
"all_fields_to_show" => all_fields_to_show , #所有該模組的欄位
|
||||||
|
"all_fields_to_show_in_index" => all_fields_to_show_in_index , #所有該模組的欄位在前台index頁面
|
||||||
|
"col_name_to_show_short" => col_name_to_show_short.to_s, #在會員前台頁面的顯示欄位
|
||||||
|
"col_name_to_show" => col_name_to_show.to_s, #在會員前台頁面的顯示欄位
|
||||||
|
"col_name_to_show_in_show_page" => col_name_to_show_in_show_page.to_s, #在個人外掛前台show頁面的顯示欄位
|
||||||
|
"col_name_to_show_in_index_page" => col_name_to_show_in_index_page.to_s, #在個人外掛前台index頁面的顯示欄位
|
||||||
|
"extra_translate_title" => extra_translate_title.map{|k,v| "\"#{k}\" => #{v}"}.join(", ").prepend("{").concat("}"),
|
||||||
|
"col_fields" => col_fields,
|
||||||
|
"col_related_fields" => col_related_fields,
|
||||||
|
"module_modal_template_file" => module_modal_template_related_files,
|
||||||
|
"module_modal_template_link" => module_modal_template_related_links,
|
||||||
|
"module_modal_template_sort_hash" => module_modal_template_sort_hash.to_s,
|
||||||
|
"col_name_to_show_in_index_page_arr" => col_name_to_show_in_index_page,
|
||||||
|
"related_backend_index_fields" => related_backend_index_fields,
|
||||||
|
"related_backend_index_fields_contents" => related_backend_index_fields_contents,
|
||||||
|
"backend_index_fields" => backend_index_fields,
|
||||||
|
"backend_index_fields_contents" => backend_index_fields_contents,
|
||||||
|
"module_modal_template_related_links_text" => module_modal_template_related_links_text,
|
||||||
|
"module_modal_template_related_files_text" => module_modal_template_related_files_text,
|
||||||
|
"locale_fields" => locale_fields,
|
||||||
|
"none_locale_fields" => none_locale_fields,
|
||||||
|
"none_locale_fields_input_fields" => none_locale_fields_input_fields,
|
||||||
|
"locale_fields_input_fields" => locale_fields_input_fields,
|
||||||
|
"related_locale_fields" => related_locale_fields,
|
||||||
|
"related_none_locale_fields" => related_none_locale_fields,
|
||||||
|
"related_none_locale_fields_input_fields" => related_none_locale_fields_input_fields,
|
||||||
|
"related_locale_fields_input_fields" => related_locale_fields_input_fields,
|
||||||
|
"module_modal_template_related_main_field" => module_modal_template_related_main_field,
|
||||||
|
"backend_profile_fields" => backend_profile_fields,
|
||||||
|
"backend_profile_fields_contents" => backend_profile_fields_contents,
|
||||||
|
"value_case_codes" => value_case_codes,
|
||||||
|
"display_field_code" => display_field_code,
|
||||||
|
"member_methods_define" => member_methods_define,
|
||||||
|
"analysis_field_name" => analysis_field_name,
|
||||||
|
"analysis_field_input_fields" => analysis_field_input_fields,
|
||||||
|
"before_save_codes" => before_save_codes,
|
||||||
|
"time_fields_text" => time_fields.to_s,
|
||||||
|
"iterate_step_text" => iterate_step_text,
|
||||||
|
"module_modal_template_related_members" => module_modal_template_related_members.to_s,
|
||||||
|
"periodic_methods_define" => periodic_methods_define,
|
||||||
|
"related_periodic_methods_define" => related_periodic_methods_define,
|
||||||
|
"period_fields_text" => period_fields.to_s,
|
||||||
|
"enable_one_line_title" => enable_one_line_title.to_s,
|
||||||
|
"one_line_title_format_code" => one_line_title_format_code,
|
||||||
|
"is_one_line_title" => (enable_one_line_title ? [true] : []), #used in parse_again block if condition
|
||||||
|
"slug_title_text" => slug_title
|
||||||
|
}
|
||||||
|
max_length = @match_pattern.keys.map{|k| k.length}.max
|
||||||
|
@match_pattern = @match_pattern.sort_by{|k,v| -k.length}
|
||||||
|
#sort_by{|k,v| (v.class != Array) ? (max_length - k.length) : -k.length}
|
||||||
|
@logs = []
|
||||||
|
replace_files(files)
|
||||||
|
#Thread.new do
|
||||||
|
replace_dirs(dirs,false)
|
||||||
|
#end
|
||||||
|
copy_templates("#{cp_template_dir_path}modules/#{@module_field.module_key}/")
|
||||||
|
#render :html => @logs#@match_pattern#@logs.join("<br>").html_safe#@match_pattern
|
||||||
|
@module_field.update(:log_text=>"")
|
||||||
|
@module_field.update(:finished=>true)
|
||||||
|
add_plugin("downloaded_extensions.rb",@module_field.module_key)
|
||||||
|
bundle_install
|
||||||
|
render :json => {:success=>true,:url=>"/admin/#{module_modal_template.pluralize}/",:name=>@module_field.title}
|
||||||
|
rescue => e
|
||||||
|
@match_pattern = {"parse_again_start"=>"","parse_again_end"=>"","col_name_translate_yaml"=>""}
|
||||||
|
replace_files(files)
|
||||||
|
replace_dirs(dirs,false)
|
||||||
|
error = e.backtrace.join("<br>")
|
||||||
|
@module_field.update(:log_text=>error)
|
||||||
|
@module_field.update(:finished=>false)
|
||||||
|
render :json => {:success=>false,:error=>error}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def copy_templates(source)
|
||||||
|
templates = Dir.glob('app/templates/*/').select{|f| File.basename(f) != 'mobile'}
|
||||||
|
templates.each do |template|
|
||||||
|
FileUtils.cp_r(source,"#{template}modules/.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def get_input_fields(field_values,extra_field_name=nil,module_modal_template = nil)
|
||||||
|
none_locale_fields = []
|
||||||
|
locale_fields = []
|
||||||
|
locale_fields_input_fields = []
|
||||||
|
none_locale_fields_input_fields = []
|
||||||
|
@index = 0
|
||||||
|
field_values.each do |field_value|
|
||||||
|
field_name = field_value[:field_name]
|
||||||
|
field_type = field_value[:field_type]
|
||||||
|
next if field_name.blank?
|
||||||
|
next if field_type == "file" || field_type == "link"
|
||||||
|
localize = (field_value[:localize] == "1" rescue false)
|
||||||
|
periodic = (field_value[:periodic_time] == "1" rescue false)
|
||||||
|
input_field = generate_input_field(field_type,field_name,localize,extra_field_name,module_modal_template,periodic)
|
||||||
|
if localize
|
||||||
|
locale_fields << field_name
|
||||||
|
locale_fields_input_fields << input_field
|
||||||
|
else
|
||||||
|
none_locale_fields << field_name
|
||||||
|
none_locale_fields_input_fields << input_field
|
||||||
|
end
|
||||||
|
@index += 1
|
||||||
|
end
|
||||||
|
return locale_fields , none_locale_fields , locale_fields_input_fields,none_locale_fields_input_fields
|
||||||
|
end
|
||||||
|
def generate_input_field(field_type,field_name,localize = false,extra_field_name = nil, module_modal_template = nil,periodic = false)
|
||||||
|
module_template = @module_field.module_key
|
||||||
|
module_modal_template = @module_field.primary_modal_name if module_modal_template.nil?
|
||||||
|
input_field = ""
|
||||||
|
field_value_text = "@#{module_modal_template}.#{field_name}"
|
||||||
|
field_name_text = "\"#{field_name}\""
|
||||||
|
field_name_text = "locale" if localize
|
||||||
|
org_field_name = field_name
|
||||||
|
if periodic
|
||||||
|
if localize
|
||||||
|
field_name = "periodic_time_field"
|
||||||
|
else
|
||||||
|
field_name_text = "\"periodic_time_field\""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
placeholder = "#{module_template}.#{field_name}"
|
||||||
|
placeholder = "#{module_template}.#{extra_field_name}.#{field_name}" if extra_field_name
|
||||||
|
if localize
|
||||||
|
field_value_text = "@#{module_modal_template}.#{field_name}_translations[locale]"
|
||||||
|
end
|
||||||
|
case field_type
|
||||||
|
when "year"
|
||||||
|
input_field = datetime_picker_text(module_modal_template,field_name_text, "yyyy")#"<%= select_year((#{field_value_text} ? #{field_value_text}.to_i : DateTime.now.year), {:start_year => DateTime.now.year + 5, :end_year => 1930}, {:name => '#{module_modal_template}[#{field_name}]',:class => 'span1'} ) %>"
|
||||||
|
when "year_month"
|
||||||
|
input_field = datetime_picker_text(module_modal_template,field_name_text, "yyyy/MM")
|
||||||
|
when "date"
|
||||||
|
input_field = datetime_picker_text(module_modal_template,field_name_text, "yyyy/MM/dd")
|
||||||
|
when "time"
|
||||||
|
input_field = datetime_picker_text(module_modal_template,field_name_text, "HH:mm",true)
|
||||||
|
when "date_time"
|
||||||
|
input_field = datetime_picker_text(module_modal_template,field_name_text)
|
||||||
|
when "text_editor"
|
||||||
|
input_field = "<%= f.text_area #{field_name_text}, class: \"input-block-level ckeditor\", placeholder: t(\"#{placeholder}\"), value: (#{field_value_text} rescue nil) %>"
|
||||||
|
when "member"
|
||||||
|
input_field = "<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: '#{module_modal_template}[#{field_name.singularize}_ids][]', email_members: @#{module_modal_template}.#{field_name.pluralize},index:'#{@index}',select_name:'#{field_name.pluralize}'} %>"
|
||||||
|
else #text_field
|
||||||
|
input_field = "<%= f.text_field #{field_name_text}, class: \"input-block-level\", placeholder: t(\"#{placeholder}\"), value: (#{field_value_text} rescue nil) %>"
|
||||||
|
end
|
||||||
|
if localize
|
||||||
|
input_field.prepend("<%= f.fields_for :#{field_name}_translations do |f| %>\n ").concat("\n<% end %>")
|
||||||
|
end
|
||||||
|
if periodic
|
||||||
|
input_fields = []
|
||||||
|
input_fields[0] = input_field.gsub("periodic_time_field","#{org_field_name}_start")
|
||||||
|
input_fields[1] = input_field.gsub("periodic_time_field","#{org_field_name}_end")
|
||||||
|
input_field = ["start","end"].map.with_index{|f,i|
|
||||||
|
"<span><%=t(\"#{module_template}.extend_translate.#{f}_#{field_type}\")%></span>" +
|
||||||
|
input_fields[i]
|
||||||
|
}.join("")
|
||||||
|
end
|
||||||
|
input_field
|
||||||
|
end
|
||||||
|
def datetime_picker_text(module_modal_template,field_name_text,format = "yyyy/MM/dd hh:mm",timepicker = false)
|
||||||
|
extra_txt = ""
|
||||||
|
extra_txt = ":picker_type => \"time\"," if timepicker
|
||||||
|
"<%= f.datetime_picker #{field_name_text},:format => \"#{format}\",#{extra_txt} :no_label => true, :new_record => @#{module_modal_template}.new_record? %>"
|
||||||
|
end
|
||||||
|
def get_fields_text(field_values)
|
||||||
|
fields_text = field_values.map do |field_value|
|
||||||
|
next if field_value[:field_type] == "file" || field_value[:field_type] == "link" || field_value[:field_name].blank?
|
||||||
|
type = "String"
|
||||||
|
default = "\"\""
|
||||||
|
field_name = field_value[:field_name]
|
||||||
|
case field_value[:field_type]
|
||||||
|
when "year"
|
||||||
|
type = "Integer"
|
||||||
|
default = "DateTime.now.year"
|
||||||
|
when "date"
|
||||||
|
type = "Date"
|
||||||
|
default = "Date.today"
|
||||||
|
when "time"
|
||||||
|
type = "String"
|
||||||
|
default = "\"\""
|
||||||
|
when "date_time"
|
||||||
|
type = "DateTime"
|
||||||
|
default = "DateTime.now"
|
||||||
|
when "year_month"
|
||||||
|
type = "DateTime"
|
||||||
|
default = "DateTime.now"
|
||||||
|
when "member"
|
||||||
|
type = "Array"
|
||||||
|
default = "[]"
|
||||||
|
field_name = "#{field_name.singularize}_ids"
|
||||||
|
end
|
||||||
|
no_localize_types = ["date","time","date_time","year_month"]
|
||||||
|
field_text = ""
|
||||||
|
if field_value[:periodic_time] == "1" && no_localize_types.include?(field_value[:field_type])
|
||||||
|
field_text = []
|
||||||
|
field_text[0] = "field :#{field_name}_start, :type => #{type}, :default => #{default}"
|
||||||
|
field_text[0] += ", :localize => true" if field_value[:localize] == "1" && !no_localize_types.include?(field_value[:field_type])
|
||||||
|
field_text[0] += ", as: :slug_title" if field_value[:slug_title] == "1"
|
||||||
|
field_text[1] = "field :#{field_name}_end, :type => #{type}, :default => #{default}"
|
||||||
|
field_text[1] += ", :localize => true" if field_value[:localize] == "1" && !no_localize_types.include?(field_value[:field_type])
|
||||||
|
field_text[1] += ", as: :slug_title" if field_value[:slug_title] == "1"
|
||||||
|
else
|
||||||
|
field_text = "field :#{field_name}, :type => #{type}, :default => #{default}"
|
||||||
|
field_text += ", :localize => true" if field_value[:localize] == "1" && !no_localize_types.include?(field_value[:field_type])
|
||||||
|
field_text += ", as: :slug_title" if field_value[:slug_title] == "1"
|
||||||
|
end
|
||||||
|
field_text
|
||||||
|
end
|
||||||
|
fields_text = fields_text.flatten
|
||||||
|
fields_text.select{|t| t.present?}.join("\n")
|
||||||
|
end
|
||||||
|
def replace_dirs(dirs,is_array = true)
|
||||||
|
dirs.each_with_index do |dir,i|
|
||||||
|
if is_array
|
||||||
|
replace_dir(dir,i)
|
||||||
|
else
|
||||||
|
replace_dir(dir)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def replace_dir(dir,current_index = nil)
|
||||||
|
dir = replace_file(dir,current_index)
|
||||||
|
return true if dir.blank?
|
||||||
|
if dir.class == Array
|
||||||
|
replace_dirs(dir)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
sub_dirs = Dir.glob("#{dir}/*/")
|
||||||
|
files = Dir.glob("#{dir}/*").select { |fn| File.file?(fn) }
|
||||||
|
replace_files(files,current_index)
|
||||||
|
if sub_dirs.present?
|
||||||
|
sub_dirs.each do |sub_dir|
|
||||||
|
replace_dir(sub_dir,current_index)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def replace_files(files,current_index = nil)
|
||||||
|
files.each do |file|
|
||||||
|
replace_file(file,current_index)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def replace_file(file,current_index = nil)
|
||||||
|
isfile = File.file?(file)
|
||||||
|
path = File.dirname(file)
|
||||||
|
file_name = File.basename(file)
|
||||||
|
new_filename = replace_text_with_pattern(file_name,true)
|
||||||
|
if new_filename.blank?
|
||||||
|
FileUtils.rm_rf("#{path}/#{file_name}")
|
||||||
|
elsif file_name != new_filename
|
||||||
|
if new_filename.class == Array
|
||||||
|
new_filename.each do |f|
|
||||||
|
next if f.blank?
|
||||||
|
FileUtils.cp_r("#{path}/#{file_name}", "#{path}/#{f}")
|
||||||
|
end
|
||||||
|
FileUtils.rm_rf("#{path}/#{file_name}")
|
||||||
|
else
|
||||||
|
FileUtils.mv("#{path}/#{file_name}", "#{path}/#{new_filename}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if new_filename.blank?
|
||||||
|
return ""
|
||||||
|
else
|
||||||
|
is_array = new_filename.class == Array
|
||||||
|
if isfile
|
||||||
|
files = Array(new_filename)
|
||||||
|
files.each_with_index do |sub_file,i|
|
||||||
|
next if File.extname(sub_file).match(/(png|jpg)/i)
|
||||||
|
file_text = File.read("#{path}/#{sub_file}")
|
||||||
|
if is_array
|
||||||
|
file_text = replace_text_with_pattern(file_text,false,i,nil,true)
|
||||||
|
elsif current_index
|
||||||
|
file_text = replace_text_with_pattern(file_text,false,current_index,nil,true)
|
||||||
|
else
|
||||||
|
file_text = replace_text_with_pattern(file_text)
|
||||||
|
end
|
||||||
|
File.open("#{path}/#{sub_file}",'w+'){|f| f.write(file_text)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if is_array
|
||||||
|
return new_filename.map{|sub_file| "#{path}/#{sub_file}" if sub_file.present?}.select{|f| f.present?}
|
||||||
|
else
|
||||||
|
return "#{path}/#{new_filename}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def replace_text_with_pattern(text,is_file=false,i = nil,sub_i = nil,inner = false)
|
||||||
|
new_text = text
|
||||||
|
@match_pattern.each do |k,v|
|
||||||
|
next if !include_key(new_text,k)
|
||||||
|
vv = v
|
||||||
|
vv = vv[i] if i && vv.class == Array
|
||||||
|
vv = vv[sub_i] if sub_i && vv.class == Array
|
||||||
|
if vv.class == String
|
||||||
|
if i && vv == "" && is_file
|
||||||
|
new_text = ""
|
||||||
|
else
|
||||||
|
new_text = gsub_text_by_key_value(new_text,k,vv)
|
||||||
|
end
|
||||||
|
elsif vv.class == Array
|
||||||
|
if is_file
|
||||||
|
if v.count == 0
|
||||||
|
new_text = ""
|
||||||
|
break
|
||||||
|
else
|
||||||
|
new_text = vv.map{|sub_v| gsub_text_by_key_value(new_text,k,sub_v)}
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
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
|
||||||
|
match_count = parse_content.match(/^ *\* *\d+/m)
|
||||||
|
match_count = match_count ? match_count[0] : nil
|
||||||
|
has_exist_condition = parse_content.split("\n")[0].match(/if[ ]+\w+/).present?
|
||||||
|
exist_condition = parse_content.split("\n")[0].match(/if[ ]+#{::Regexp.escape(k)}(?=\.| |$)/)
|
||||||
|
if has_exist_condition && exist_condition.nil? #if this block is for other variables, then not proccessing
|
||||||
|
@parse_again_mode = false
|
||||||
|
result
|
||||||
|
else
|
||||||
|
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
|
||||||
|
new_text = gsub_text_by_key_value(new_text,k,vv.to_s)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return new_text
|
||||||
|
end
|
||||||
|
def include_key(text,key)
|
||||||
|
return text.include?(key) || text.include?(key.camelize)
|
||||||
|
end
|
||||||
|
def gsub_text_by_key_value(text,k,v)
|
||||||
|
@blank_texts = []
|
||||||
|
if !@parse_again_mode
|
||||||
|
text.gsub(/\n(\s+)[^\n]*(#{k}|#{k.camelize})/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]}")}
|
||||||
|
text = text.gsub(k.camelize + "s"){|ff| v.camelize.pluralize.gsub("\n","\n#{@blank_texts[i]}")}
|
||||||
|
text = text.gsub(k.camelize){|ff| v.camelize.gsub("\n","\n#{@blank_texts[i]}")}
|
||||||
|
end
|
||||||
|
def get_all_gem_plugins
|
||||||
|
extention_files = ["downloaded_extensions.rb","built_in_extensions.rb"]
|
||||||
|
gem_plugins = extention_files.map{|f| (File.read(f).scan(/\n\s*gem\s*["'](.*)["']\s*,/).flatten rescue [])}.flatten
|
||||||
|
end
|
||||||
|
def check_plugin_exist
|
||||||
|
gem_plugins = get_all_gem_plugins
|
||||||
|
can_install = !gem_plugins.include?(params[:plugin_name])
|
||||||
|
can_install = (ModuleField.find(params[:id]).module_key == params[:plugin_name] rescue false) if !can_install
|
||||||
|
render :json => {:can_install => can_install }
|
||||||
|
end
|
||||||
|
def add_plugin(extention_file,plugin_name)
|
||||||
|
txt = File.read(extention_file) rescue nil
|
||||||
|
if txt.nil?
|
||||||
|
File.open(extention_file,'w+'){|f| f.write("")}
|
||||||
|
txt = ""
|
||||||
|
end
|
||||||
|
txt_scan = txt.scan(/^[\n]*gem\s*["']#{plugin_name}["'].*\n/)
|
||||||
|
if txt_scan.count != 1
|
||||||
|
delete_plugin(extention_file,plugin_name)
|
||||||
|
txt = File.read(extention_file) rescue ""
|
||||||
|
txt = txt + "\ngem \"#{plugin_name}\", path: \"#{Rails.root}/tmp/#{plugin_name}\"\n"
|
||||||
|
File.open(extention_file,'w+') do |f|
|
||||||
|
f.write(txt)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def delete_plugin(extention_file,plugin_name)
|
||||||
|
txt = File.read(extention_file) rescue nil
|
||||||
|
return if txt.nil?
|
||||||
|
txt_change = txt.gsub(/^[\s#]*gem\s*["']#{plugin_name}["'].*(\n|$)/m,'')
|
||||||
|
if txt_change != txt
|
||||||
|
File.open(extention_file,'w+') do |f|
|
||||||
|
f.write(txt_change)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def check_modal_name
|
||||||
|
id = params[:id].to_s
|
||||||
|
other_module_fields = ModuleField.where(:id.ne=>id)
|
||||||
|
primary_modal_names = other_module_fields.pluck(:primary_modal_name)
|
||||||
|
related_modal_names = other_module_fields.pluck(:related_modal_name).flatten.uniq
|
||||||
|
other_modal_names = primary_modal_names + related_modal_names
|
||||||
|
module_field = ModuleField.where(:id=>id).first
|
||||||
|
all_modal_names = ModuleField.get_modal_names_cache
|
||||||
|
if module_field.present?
|
||||||
|
except_modals = Dir.glob("tmp/#{module_field.module_key}/app/models/*.rb").map{|f|
|
||||||
|
fn = File.basename(f)
|
||||||
|
fn.slice(0,fn.length - 3)
|
||||||
|
}
|
||||||
|
all_modal_names = all_modal_names - except_modals
|
||||||
|
end
|
||||||
|
all_modal_names = all_modal_names + other_modal_names
|
||||||
|
all_modal_names = all_modal_names.uniq
|
||||||
|
self_modal_names = params[:modal_names]
|
||||||
|
invalid_modal_names = self_modal_names.select{|n| all_modal_names.include?(n)}
|
||||||
|
if invalid_modal_names.count != 0
|
||||||
|
render :json => {:success=>false,:invalid_modal_names=>invalid_modal_names}
|
||||||
|
else
|
||||||
|
render :json => {:success=>true}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
private
|
||||||
|
def module_field_params
|
||||||
|
module_field_params = params.require(:module_field).permit! rescue {}
|
||||||
|
if module_field_params[:related_modal_name].nil?
|
||||||
|
module_field_params[:related_modal_name] = []
|
||||||
|
end
|
||||||
|
if module_field_params[:primary_modal_fields]
|
||||||
|
module_field_params[:primary_modal_fields] = module_field_params[:primary_modal_fields].sort_by{|k, h| h[:order].to_i}.map{|v| v[1]}
|
||||||
|
else
|
||||||
|
module_field_params[:primary_modal_fields] = []
|
||||||
|
end
|
||||||
|
if module_field_params[:related_modal_fields]
|
||||||
|
module_field_params[:related_modal_fields] = module_field_params[:related_modal_fields].values.map{|h| h.sort_by{|k, h| h[:order].to_i}.map{|v| v[1]}}
|
||||||
|
else
|
||||||
|
module_field_params[:related_modal_fields] = []
|
||||||
|
end
|
||||||
|
return module_field_params
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def set_module_field
|
||||||
|
ModuleField.get_modal_names_cache
|
||||||
|
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
|
||||||
|
@module_field = ModuleField.find_by(:uid => uid) rescue ModuleField.find(params[:id] || params[:module_generator_id])
|
||||||
|
end
|
||||||
|
def bundle_install
|
||||||
|
Bundler.with_clean_env { system("cd #{Rails.root} && bundle install") }
|
||||||
|
%x(kill -s USR2 `cat tmp/pids/unicorn.pid`)
|
||||||
|
sleep 2
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,6 @@
|
||||||
|
module Admin::ModuleGeneratorsHelper
|
||||||
|
include OrbitBackendHelper
|
||||||
|
def thead_field_for_mg(field)
|
||||||
|
return I18n.t("module_generator.#{field}")
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,158 @@
|
||||||
|
class ModuleField
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
include OrbitModel::Status
|
||||||
|
include MemberHelper
|
||||||
|
field :one_line_title_format, :type => String, :default => ""
|
||||||
|
field :enable_one_line_title, :type => Boolean, :default => false
|
||||||
|
field :title, :type => String, :default => "",:localize => true
|
||||||
|
field :module_key, :type => String, :default => ""
|
||||||
|
field :primary_modal_name, :type => String, :default => ""
|
||||||
|
field :related_modal_name, :type => Array, :default => []
|
||||||
|
field :primary_modal_fields, :type => Array, :default => []
|
||||||
|
field :related_modal_fields, :type => Array, :default => [] #ex: [[],[]]
|
||||||
|
field :backend_fields, :type => Hash, :default => {}
|
||||||
|
field :frontend_fields, :type => Hash, :default => {}
|
||||||
|
field :log_text, :type => String, :default => ""
|
||||||
|
field :fields_order, :type => Hash, :default => {}
|
||||||
|
field :copy_id
|
||||||
|
field :finished, :type => Boolean, :default => false
|
||||||
|
before_save :change_extensions,:check_modal_name,:auto_add_display_fields
|
||||||
|
after_destroy do
|
||||||
|
delete_plugin("downloaded_extensions.rb",self.module_key)
|
||||||
|
restart_server
|
||||||
|
end
|
||||||
|
before_create do
|
||||||
|
if self.copy_id
|
||||||
|
copy_item = self.class.find(copy_id) rescue nil
|
||||||
|
if !copy_item.nil?
|
||||||
|
self.backend_fields = copy_item.backend_fields
|
||||||
|
self.frontend_fields = copy_item.frontend_fields
|
||||||
|
self.fields_order = copy_item.fields_order
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def get_all_gem_plugins
|
||||||
|
extention_files = ["downloaded_extensions.rb","built_in_extensions.rb"]
|
||||||
|
gem_plugins = extention_files.map{|f| (File.read(f).scan(/\n\s*gem\s*["'](.*)["']\s*,/).flatten rescue [])}.flatten
|
||||||
|
end
|
||||||
|
def check_plugin_exist
|
||||||
|
gem_plugins = get_all_gem_plugins
|
||||||
|
can_install = !gem_plugins.include?(self.module_key)
|
||||||
|
can_install = (self.class.where(:module_key=>self.module_key,:id.ne=>self.id).count == 0 rescue false) if !can_install
|
||||||
|
return can_install
|
||||||
|
end
|
||||||
|
def change_extensions
|
||||||
|
if !check_plugin_exist
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
extention_file = "downloaded_extensions.rb"
|
||||||
|
if self.module_key_changed?
|
||||||
|
if self.module_key_was.present?
|
||||||
|
delete_plugin(extention_file,module_key_was)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def delete_plugin(extention_file,plugin_name)
|
||||||
|
txt = File.read(extention_file) rescue nil
|
||||||
|
return if txt.nil?
|
||||||
|
txt_change = txt.gsub(/^[\n]*gem\s*["']#{plugin_name}["'].*\n/,'')
|
||||||
|
if txt_change != txt
|
||||||
|
File.open(extention_file,'w+') do |f|
|
||||||
|
f.write(txt_change)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def check_modal_name
|
||||||
|
primary_modal_names = self.class.where(:id.ne=>self.id).pluck(:primary_modal_name)
|
||||||
|
related_modal_names = self.class.where(:id.ne=>self.id).pluck(:related_modal_name).flatten.uniq
|
||||||
|
other_modal_names = primary_modal_names + related_modal_names
|
||||||
|
all_modal_names = self.class.get_modal_names_cache
|
||||||
|
except_modals = Dir.glob("tmp/#{self.module_key}/app/models/*.rb").map{|f|
|
||||||
|
fn = File.basename(f)
|
||||||
|
fn.slice(0,fn.length - 3)
|
||||||
|
}
|
||||||
|
all_modal_names = all_modal_names - except_modals
|
||||||
|
all_modal_names = all_modal_names + other_modal_names
|
||||||
|
all_modal_names = all_modal_names.uniq
|
||||||
|
self_modal_names = ([self.primary_modal_name]+self.related_modal_name).flatten
|
||||||
|
if self_modal_names.select{|n| all_modal_names.include?(n)}.count != 0
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def get_sorted_fields(root_name, page_name, tds=nil)
|
||||||
|
if self.fields_order.present?
|
||||||
|
fields_order = (0...tds.count).to_a
|
||||||
|
if (self.fields_order["#{root_name}_#{page_name}"].present? rescue false)
|
||||||
|
self.fields_order["#{root_name}_#{page_name}"].to_a.each_with_index do |order,i|
|
||||||
|
fields_order[i] = order.to_i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if tds.respond_to?(:values)
|
||||||
|
tds = tds.values
|
||||||
|
end
|
||||||
|
tds = tds.sort_by.with_index{|td,i| fields_order[i]}
|
||||||
|
else
|
||||||
|
field_values = self[root_name][page_name] rescue []
|
||||||
|
if field_values.present?
|
||||||
|
if tds.respond_to?(:values)
|
||||||
|
new_tds = {}
|
||||||
|
field_values.each do |field_value|
|
||||||
|
new_tds[field_value] = tds[field_value] if tds[field_value]
|
||||||
|
end
|
||||||
|
tds.each do |k,v|
|
||||||
|
if new_tds[k].nil?
|
||||||
|
new_tds[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
tds = new_tds.values
|
||||||
|
else
|
||||||
|
new_tds = field_values.clone
|
||||||
|
tds.each do |v|
|
||||||
|
new_tds << v unless new_tds.include?(v)
|
||||||
|
end
|
||||||
|
tds = new_tds
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if tds.respond_to?(:values)
|
||||||
|
tds = tds.values
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
tds
|
||||||
|
end
|
||||||
|
def auto_add_display_fields
|
||||||
|
change_primary_fields = self.primary_modal_fields.map{|f| f["field_name"]} - self.primary_modal_fields_was.to_a.map{|f| f["field_name"]}
|
||||||
|
change_related_fields = []
|
||||||
|
self.related_modal_fields.each_with_index do |field_values,i|
|
||||||
|
old_field_values = self.related_modal_fields_was[i].to_a rescue []
|
||||||
|
related_modal_name = self.related_modal_name[i].to_s
|
||||||
|
change_related_fields = change_related_fields + (field_values.to_a.map{|f| f["field_name"]} - old_field_values.map{|f| f["field_name"]}).select{|f| f.present?}.map{|f| "#{related_modal_name}.#{f}"}
|
||||||
|
end
|
||||||
|
change_fields = change_primary_fields + change_related_fields
|
||||||
|
change_fields = change_fields.select{|f| f.present?}
|
||||||
|
if change_fields.count > 0
|
||||||
|
["index","profile"].each do |f|
|
||||||
|
self.backend_fields[f] = self.backend_fields[f].to_a + change_fields
|
||||||
|
end
|
||||||
|
["index","show","member_show"].each do |f|
|
||||||
|
self.frontend_fields[f] = self.frontend_fields[f].to_a + change_fields
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def self.get_modal_names
|
||||||
|
name_routes = Rails.application.routes.named_routes.map{|k,v| k}.select{|s| s.to_s[0..4] == "admin"}.map{|s| s.to_s.split('admin_').last}
|
||||||
|
modal_names = name_routes.map{|n| n.camelize}.select{|n| (n.constantize rescue nil)}
|
||||||
|
modal_names = modal_names.map{|n| n.constantize}.select{|n| n.class == Class }.uniq
|
||||||
|
@@modal_names = modal_names.map{|n| n.to_s.underscore}
|
||||||
|
end
|
||||||
|
def self.get_modal_names_cache
|
||||||
|
@@modal_names ||= get_modal_names
|
||||||
|
end
|
||||||
|
def restart_server
|
||||||
|
%x(kill -s USR2 `cat tmp/pids/unicorn.pid`)
|
||||||
|
sleep 2
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,295 @@
|
||||||
|
<% # 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" %>
|
||||||
|
<%= stylesheet_link_tag "lib/togglebox"%>
|
||||||
|
<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" %>
|
||||||
|
<% 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 -->
|
||||||
|
<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" : '' %>">
|
||||||
|
|
||||||
|
<!-- module_field title-->
|
||||||
|
<div class="control-group input-title">
|
||||||
|
<label class="control-label muted"><%= t("module_generator.module_name") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.fields_for :title_translations do |f| %>
|
||||||
|
<%= f.text_field locale, class: "input-block-level", placeholder: t("module_generator.module_name"), value: (@module_field.title_translations[locale] rescue nil) %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</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">
|
||||||
|
|
||||||
|
<!-- Basic Module -->
|
||||||
|
<div class="tab-pane fade in active" id="basic">
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%=thead_field_for_mg("module_key")%></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.text_field :module_key, placeholder: thead_field_for_mg("module_key") %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%=thead_field_for_mg("primary_modal_name")%></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.text_field :primary_modal_name, placeholder: thead_field_for_mg("primary_modal_name"), class: "primary_modal_name" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%=thead_field_for_mg("related_modal_name")%></label>
|
||||||
|
<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_for_mg("related_modal_name"), class: "related_modal_name", title: thead_field_for_mg("related_modal_name") %>
|
||||||
|
<button type="button" class="remove_related_modal" index="<%=i%>"><%=t(:remove)%></button>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<button type="button" class="btn btn-primary" id="add_related_modal"><%= t(:add) %></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</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 @module_field.is_hidden? %>">
|
||||||
|
<%= f.check_box :is_hidden %> <%= t(:hide) %>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div> -->
|
||||||
|
</div>
|
||||||
|
<% field_types = ["text_field","text_editor","file","link","year","year_month","date","time","date_time","member"].map{|field| [thead_field_for_mg(field),field]}
|
||||||
|
field_types1 = field_types.select{|a| a[1] != "file" && a[1] != "member"}
|
||||||
|
%>
|
||||||
|
<div class="tab-content language-area">
|
||||||
|
<div id="primary_modal_plane">
|
||||||
|
<h4><%=thead_field_for_mg("primary_modal_name")%> : <span class="primary_modal_name"><%= f.object.primary_modal_name%></span></h4>
|
||||||
|
<% if f.object.primary_modal_fields.present? %>
|
||||||
|
<%= render :partial => 'render_table',locals: {:f => f,:root_name => "primary_modal_fields",:field_values => f.object.primary_modal_fields,:field_types => field_types } %>
|
||||||
|
<% else %>
|
||||||
|
<%= render :partial => 'render_table',locals: {:f => f,:root_name => "primary_modal_fields",:field_values => [nil,nil],:field_types => field_types,:@include_blank => true} %>
|
||||||
|
<% end %>
|
||||||
|
<button type="button" onclick="add_primary_modal_field()" class="btn btn-primary"><%= thead_field_for_mg('add_field') %></button>
|
||||||
|
</div>
|
||||||
|
<div id="related_modal_plane">
|
||||||
|
<% if f.object.related_modal_name.present? %>
|
||||||
|
<% f.object.related_modal_name.each_with_index do |related_modal_name,i| %>
|
||||||
|
<% field_values = f.object.related_modal_fields[i].to_a %>
|
||||||
|
<div index="<%= i %>">
|
||||||
|
<h4><%=thead_field_for_mg("related_modal_name")%> : <span class="related_modal_name"><%= related_modal_name %></span></h4>
|
||||||
|
<%= render :partial => 'render_table',locals: {:f => f,:root_name => "related_modal_fields][#{i}",:field_values => field_values,:field_types => field_types1 } %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</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" %>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).on('click', '.delete_file', function(){
|
||||||
|
$(this).parents('.input-prepend').remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.remove_existing_record', function(){
|
||||||
|
if(window.confirm("<%= I18n.t(:sure?)%>")){
|
||||||
|
$(this).children('.should_destroy').attr('value', 1);
|
||||||
|
$(this).parents('.start-line').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var related_modal_name_html = '<%= text_field_tag "#{f.object_name}[related_modal_name][]", '',placeholder: thead_field_for_mg("related_modal_name"), class: "related_modal_name", title: thead_field_for_mg("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(){
|
||||||
|
if(window.confirm("<%=thead_field_for_mg('remove_text')%>")){
|
||||||
|
$(this).parent().parent().remove();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
<%
|
||||||
|
related_modal_fields_html = "<div index=\"new_index\"><h4>#{thead_field_for_mg("related_modal_name")} : <span class=\"related_modal_name\"></span></h4>"
|
||||||
|
related_modal_fields_html += render(:partial => 'render_table',locals: {:f => f,:root_name => "related_modal_fields][new_index",:field_values => [nil],:field_types => field_types1,:@include_blank=>false})
|
||||||
|
related_modal_fields_html += "</div>"
|
||||||
|
primary_modal_field_html = render(:partial => 'render_table',locals: {:f => f,:root_name => "primary_modal_fields",:field_values => [nil],:field_types => field_types,:@include_blank=>false})
|
||||||
|
%>
|
||||||
|
var related_modal_fields_html = "<%= escape_javascript(related_modal_fields_html.html_safe) %>";
|
||||||
|
var primary_modal_field_html = $("<%= escape_javascript(primary_modal_field_html.html_safe) %>").find("tbody tr")[0].outerHTML;
|
||||||
|
var add_related_modal_field_btn = '<button type="button" onclick="add_related_modal_field(this)" class="btn btn-primary"><%=thead_field_for_mg('add_field')%></button>';
|
||||||
|
$("#add_related_modal").click(function(){
|
||||||
|
var clone_modal = related_modal_name_html.clone();
|
||||||
|
var new_index = $("#related_modal_plane > div").length;
|
||||||
|
clone_modal.find(".remove_related_modal").attr("index",new_index);
|
||||||
|
$(this).before(clone_modal);
|
||||||
|
$("#related_modal_plane").append(related_modal_fields_html.replaceAll("new_index",new_index).replaceAll("new_field_index",0));
|
||||||
|
$("#related_modal_plane >").eq(-1).append(add_related_modal_field_btn);
|
||||||
|
clone_modal.find(".remove_related_modal").click(function(){
|
||||||
|
remove_related_modal_func(this);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
$("#related_modal_plane >").append(add_related_modal_field_btn);
|
||||||
|
$(".remove_related_modal").click(function(){
|
||||||
|
remove_related_modal_func(this);
|
||||||
|
});
|
||||||
|
function remove_related_modal_func(item){
|
||||||
|
if(window.confirm("<%=thead_field_for_mg('remove_text')%>")){
|
||||||
|
var index = $(item).attr("index");
|
||||||
|
$(item).parent().remove();
|
||||||
|
console.log(index);
|
||||||
|
$("#related_modal_plane > div[index=\""+index+"\"]").remove();
|
||||||
|
$("#related_modal_plane > div").each(function(i,v){
|
||||||
|
$(v).attr("index",i);
|
||||||
|
})
|
||||||
|
$(".remove_related_modal").each(function(i,v){
|
||||||
|
$(v).attr("index",i);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function add_related_modal_field(item){
|
||||||
|
var current_index = $(item).parent().attr("index");
|
||||||
|
var related_modal = $(related_modal_fields_html.replaceAll("new_field_index",$(item).parent().find("tbody tr").length));
|
||||||
|
$(item).parent().find("tbody").append(related_modal.find("tbody tr")[0].outerHTML.replaceAll("new_index",current_index));
|
||||||
|
$(".remove_btn").off("click").on("click",function(){
|
||||||
|
if(window.confirm("<%=thead_field_for_mg('remove_text')%>")){
|
||||||
|
$(this).parent().parent().remove();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_primary_modal_field(){
|
||||||
|
var primary_modal = $(primary_modal_field_html.replaceAll("new_field_index",$("#primary_modal_plane tbody tr").length));
|
||||||
|
$("#primary_modal_plane tbody").append(primary_modal);
|
||||||
|
$(".remove_btn").off("click").on("click",function(){
|
||||||
|
if(window.confirm("<%=thead_field_for_mg('remove_text')%>")){
|
||||||
|
$(this).parent().parent().remove();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
$.ajaxSetup({async: false});
|
||||||
|
$(".main-forms").submit(function(){
|
||||||
|
if($("#primary_modal_plane .slug_title:checked").length == 0){
|
||||||
|
alert("<%=thead_field_for_mg('please_choose_one_slug_title')%>");
|
||||||
|
}else if($("#primary_modal_plane .slug_title:checked").length > 1){
|
||||||
|
alert("<%=thead_field_for_mg('slug_title_can_only_choose_one')%>");
|
||||||
|
}else{
|
||||||
|
var can_install;
|
||||||
|
$.post("<%=check_plugin_exist_admin_module_field_path%>",{plugin_name: $("#module_field_module_key").val(), id: "<%=f.object.id %>"}).done(function(data){
|
||||||
|
console.log(data);
|
||||||
|
if(data["can_install"]){
|
||||||
|
$("#module_field_module_key").css('border', '');
|
||||||
|
can_install = true;
|
||||||
|
var modal_names = $("[name*=modal_name]").map(function(i,v){return v.value})
|
||||||
|
modal_names = Array.from(modal_names);
|
||||||
|
$.post("<%=check_modal_name_admin_module_field_path%>",{modal_names: modal_names, id: "<%=f.object.id %>"}).done(function(data){
|
||||||
|
if(!data["success"]){
|
||||||
|
var invalid_modal_names = data["invalid_modal_names"];
|
||||||
|
console.log(invalid_modal_names)
|
||||||
|
$("[name*=modal_name]").each(function(i,v){
|
||||||
|
if(invalid_modal_names.indexOf($(v).val()) != -1){
|
||||||
|
$(v).css("border", '2px solid red');
|
||||||
|
window.location.href = "#" + $(".main-forms")[0].id;
|
||||||
|
}else{
|
||||||
|
$(v).css("border", '');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
can_install = false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$("#module_field_module_key").css('border', '2px solid red');
|
||||||
|
alert("<%=thead_field_for_mg("please_change_module_key")%>");
|
||||||
|
window.location.href = "#" + $(".main-forms")[0].id;
|
||||||
|
can_install = false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return can_install;
|
||||||
|
}
|
||||||
|
$('.main-forms tr').find('th:eq(-2),td:eq(-2)').css( 'border', '2px solid red');
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
$('.slug_title').click(function(){
|
||||||
|
if($('.slug_title:checked').length == 1){
|
||||||
|
$('.main-forms tr').find('th:eq(-2),td:eq(-2)').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());
|
||||||
|
})
|
||||||
|
$(document).on('blur', 'input.primary_modal_name', function(){
|
||||||
|
var _this = $(this);
|
||||||
|
$('span.primary_modal_name').text(_this.val());
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<style type="text/css">
|
||||||
|
.module-area .control-group {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
span.fade{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
span.fade.in{
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.remove_btn{
|
||||||
|
cursor: pointer;
|
||||||
|
color: red;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -0,0 +1,55 @@
|
||||||
|
<% if form_file.new_record? %>
|
||||||
|
<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 %>
|
||||||
|
<% 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>
|
|
@ -0,0 +1,20 @@
|
||||||
|
<% @module_fields.each do |module_field| %>
|
||||||
|
<tr id="<%= dom_id module_field %>" class="with_action">
|
||||||
|
<td>
|
||||||
|
<% title = module_field.title %>
|
||||||
|
<% if module_field.finished %>
|
||||||
|
<a href="/admin/<%=module_field.primary_modal_name.pluralize%>" title="<%= title %>"><%= title %></a>
|
||||||
|
<% else %>
|
||||||
|
<%= title %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td><%= module_field.module_key %></td>
|
||||||
|
<td><%= link_to t(:edit) ,edit_admin_module_generator_path(module_field.id),:class=> "btn btn-primary" %>
|
||||||
|
<%= link_to thead_field_for_mg('fields_display_setting') ,admin_module_generator_fields_setting_path(module_field.id),:class=> "btn btn-primary" %>
|
||||||
|
<%= link_to thead_field_for_mg(:copy) ,admin_module_generator_copy_path(module_field.id),:class=> "btn btn-primary" %>
|
||||||
|
<button class="generate_module btn btn-primary" type="button" data-url="<%= admin_module_generator_generate_module_path(module_field.id) %>"><%= thead_field_for_mg("generate_module") %></button>
|
||||||
|
<%= link_to thead_field_for_mg(:download) ,admin_module_generator_download_path(module_field.id),:class=> "btn btn-primary" %>
|
||||||
|
<a data-confirm="Are you sure?" data-method="delete" href="<%=admin_module_generator_path(module_field.id) %>" rel="nofollow" class="delete btn btn-primary"><%= t(:delete_) %></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,49 @@
|
||||||
|
<div id="<%= "#{root_name}_#{page_name}" %>">
|
||||||
|
<% object = f.object
|
||||||
|
%>
|
||||||
|
<h5><%=thead_field_for_mg(page_name)%></h5>
|
||||||
|
<button type="button" class="select_all btn"><%=t("select_all")%></button>
|
||||||
|
<button type="button" class="de_select_all btn"><%=t("de_select_all")%></button>
|
||||||
|
<table class="table table-bordered" id="<%="#{root_name}_#{page_name}"%>">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<% tds = {} %>
|
||||||
|
<% ii = -1 %>
|
||||||
|
<% tmp_fields_order = {} %>
|
||||||
|
<% object.primary_modal_fields.each do |field_value| %>
|
||||||
|
<% next if (!access_field_types.include?(field_value[:field_type]) rescue false) %>
|
||||||
|
<% field_name = field_value[:field_name] %>
|
||||||
|
<% content = check_box_tag("#{f.object_name}[#{root_name}][#{page_name}][]", field_name , (object.send(root_name)[page_name].include?(field_name) rescue false),:id=>nil,:class=>"#{page_name}_fields") %>
|
||||||
|
<% ii+=1 %>
|
||||||
|
<% tmp_fields_order = "<input class=\"fields_order_hidden_input\" type=\"hidden\" name=\"#{f.object_name}[fields_order][#{root_name}_#{page_name}][#{ii}]\" value=\"${sort_order}\">" %>
|
||||||
|
<% tds[field_name] = "<td data-index=\"#{ii}\">#{field_value[:translation_name][I18n.locale] rescue ""}-#{field_value[:field_name]}<hr class=\"border-hr\">#{content}#{tmp_fields_order}</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| %>
|
||||||
|
<% field_name = related_modal_name+'.'+field_value[:field_name] %>
|
||||||
|
<% content = check_box_tag("#{f.object_name}[#{root_name}][#{page_name}][]", field_name , (object.send(root_name)[page_name].include?(field_name) rescue false),:id=>nil,:class=>"#{page_name}_fields") %>
|
||||||
|
<% ii+=1 %>
|
||||||
|
<% tmp_fields_order = "<input class=\"fields_order_hidden_input\" type=\"hidden\" name=\"#{f.object_name}[fields_order][#{root_name}_#{page_name}][#{ii}]\" value=\"${sort_order}\">" %>
|
||||||
|
<% tds[field_name] = "<td data-index=\"#{ii}\">#{related_modal_name}-#{field_value[:translation_name][I18n.locale] rescue ""}-#{field_value[:field_name]}<hr class=\"border-hr\">#{content}#{tmp_fields_order}</td>" %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% author_name_translation = @module_field.author_name_translations[locale] rescue ""
|
||||||
|
author_name_translation = I18n.t("modules.author") if author_name_translation.blank? %>
|
||||||
|
<% 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) %>
|
||||||
|
<% ii+=1 %>
|
||||||
|
<% tmp_fields_order = "<input class=\"fields_order_hidden_input\" type=\"hidden\" name=\"#{f.object_name}[fields_order][#{root_name}_#{page_name}][#{ii}]\" value=\"${sort_order}\">" %>
|
||||||
|
<% tds["member_profile"] = "<td data-index=\"#{ii}\">#{author_name_translation}<hr class=\"border-hr\">#{content}#{tmp_fields_order}</td>" %>
|
||||||
|
<% end %>
|
||||||
|
<%
|
||||||
|
tds = object.get_sorted_fields(root_name, page_name, tds)
|
||||||
|
%>
|
||||||
|
<% tds.each_with_index do |td, i| %>
|
||||||
|
<% td = td.sub('${sort_order}', i.to_s) %>
|
||||||
|
<%= td.html_safe %>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
|
@ -0,0 +1,79 @@
|
||||||
|
<table class="table table-bordered sortable_table">
|
||||||
|
<thead>
|
||||||
|
<th></th>
|
||||||
|
<th><%= t(:remove) %></th>
|
||||||
|
<th><%= thead_field_for_mg("field_name") %></th>
|
||||||
|
<th><%= thead_field_for_mg("translation_name") %></th>
|
||||||
|
<th><%= thead_field_for_mg("field_type") %></th>
|
||||||
|
<th><%= thead_field_for_mg("localize") %></th>
|
||||||
|
<th><%= thead_field_for_mg("slug_title") %></th>
|
||||||
|
<th><%= thead_field_for_mg("periodic_time") %></th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<%= f.fields_for root_name do |f| %>
|
||||||
|
<% field_values.each_with_index do |field_value,i| %>
|
||||||
|
<% i = "new_field_index" if field_value.nil? && !@include_blank %>
|
||||||
|
<tr index="<%=i%>">
|
||||||
|
<td>
|
||||||
|
<span class="brand ui-sortable-handle"><i class="icons-list-2"></i></span>
|
||||||
|
<input class="hidden_order" type="hidden" name="<%= "#{f.object_name}[#{i}][order]" %>" value="<%= i %>">
|
||||||
|
</td>
|
||||||
|
<td><span class="remove_btn">X</span></td>
|
||||||
|
<td><%= text_field_tag "#{f.object_name}[#{i}][field_name]",(field_value["field_name"] rescue nil) %></td>
|
||||||
|
<td>
|
||||||
|
<% @site_in_use_locales.each_with_index do |locale, ii| %>
|
||||||
|
<span class="<%= locale %> tab-pane fade <%= ( ii == 0 ) ? "in active" : '' %>">
|
||||||
|
<%= f.fields_for "#{i}][translation_name" do |f| %>
|
||||||
|
<%= text_field_tag "#{f.object_name}[#{locale}]", (field_value["translation_name"][locale] rescue nil) , class: "input-block-level" %>
|
||||||
|
<% end %>
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td><%= select_tag "#{f.object_name}[#{i}][field_type]",options_for_select(field_types,(field_value["field_type"] rescue nil)) %></td>
|
||||||
|
<td>
|
||||||
|
<%= hidden_field_tag "#{f.object_name}[#{i}][localize]", "0",:id=>nil %>
|
||||||
|
<%= check_box_tag "#{f.object_name}[#{i}][localize]", "1" , (field_value["localize"] == "1" rescue false),:id=>nil %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= hidden_field_tag "#{f.object_name}[#{i}][slug_title]", "0",:id=>nil %>
|
||||||
|
<%= check_box_tag "#{f.object_name}[#{i}][slug_title]", "1" , (field_value["slug_title"] == "1" rescue false),:id=>nil,:class=>"slug_title" %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= hidden_field_tag "#{f.object_name}[#{i}][periodic_time]", "0",:id=>nil %>
|
||||||
|
<%= check_box_tag "#{f.object_name}[#{i}][periodic_time]", "1" , (field_value["periodic_time"] == "1" rescue false),:id=>nil,:class=>"periodic_time" %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<style type="text/css">
|
||||||
|
.icons-list-2{
|
||||||
|
cursor: all-scroll;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
$('.sortable_table').each(function(i,v){
|
||||||
|
if(!($(v).hasClass('already_init_sortable'))){
|
||||||
|
$(v).find('tbody').sortable({
|
||||||
|
axis: "y",
|
||||||
|
revert: true,
|
||||||
|
handle: ".brand",
|
||||||
|
update: function(event, ui) {
|
||||||
|
var item = ui.item;
|
||||||
|
var n_index = item.index();
|
||||||
|
var o_index = item.attr("index");
|
||||||
|
var indices = [n_index,o_index].sort();
|
||||||
|
for(var new_i=indices[0];new_i<=indices[1];new_i++){
|
||||||
|
var td = item.parent().find(">").eq(new_i);
|
||||||
|
td.attr("index",new_i);
|
||||||
|
td.find('.hidden_order').val(new_i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(v).addClass('already_init_sortable')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<%= form_for @module_field, url: admin_module_generators_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<%= f.hidden_field :copy_id, :value => params[:module_field_id] %>
|
||||||
|
<%= render partial: 'form', locals: {f: f} %>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<%= form_for @module_field, url: admin_module_generator_path(@module_field), html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<%= render partial: 'form', locals: {f: f} %>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,120 @@
|
||||||
|
<% # 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>
|
||||||
|
<% 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" %>
|
||||||
|
<% end %>
|
||||||
|
<h3 style="padding: 20px 20px 0;"><%= @module_field.title %></h3>
|
||||||
|
<%= form_for @module_field, url: admin_module_generator_update_fields_setting_path(@module_field), html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
|
||||||
|
<!-- Input Area -->
|
||||||
|
<div class="input-area">
|
||||||
|
<h4><%= thead_field_for_mg('backend_page') %></h4>
|
||||||
|
<div id="backend_page">
|
||||||
|
<%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'backend_fields',:page_name=>'index'} %>
|
||||||
|
<%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'backend_fields',:page_name=>'profile'} %>
|
||||||
|
<%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'backend_fields',:page_name=>'analysis',:access_field_types=>["date","date_time","year","year_month","time"]} %>
|
||||||
|
<%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'backend_fields',:page_name=>'sort_asc',:access_field_types=>["date","date_time","year","year_month","time"]} %>
|
||||||
|
<%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'backend_fields',:page_name=>'sort_desc',:access_field_types=>["date","date_time","year","year_month","time"]} %>
|
||||||
|
</div>
|
||||||
|
<h4><%= thead_field_for_mg('frontend_page') %></h4>
|
||||||
|
<div id="frontend_page">
|
||||||
|
<%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'frontend_fields',:page_name=>'index'} %>
|
||||||
|
<%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'frontend_fields',:page_name=>'show'} %>
|
||||||
|
<%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'frontend_fields',:page_name=>'member_show'} %>
|
||||||
|
</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" %>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
|
<style type="text/css">
|
||||||
|
.icons-list-2{
|
||||||
|
cursor: all-scroll;
|
||||||
|
}
|
||||||
|
hr.border-hr{
|
||||||
|
border-top: 1px solid #dddddd;
|
||||||
|
margin-top: 8px;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
margin-left: -8px;
|
||||||
|
margin-right: -8px;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
.table tbody td {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(".select_all").click(function(){
|
||||||
|
$(this).parent().find("table input").prop("checked",true);
|
||||||
|
})
|
||||||
|
$(".de_select_all").click(function(){
|
||||||
|
$(this).parent().find("table input").prop("checked",false);
|
||||||
|
})
|
||||||
|
if($("#backend_fields_analysis input").length > 0){
|
||||||
|
$(".main-forms").submit(function(){
|
||||||
|
if($("#backend_fields_analysis input:checked").length == 0){
|
||||||
|
alert("<%=thead_field_for_mg('please_choose_one_analysis_field')%>");
|
||||||
|
}else if($("#backend_fields_analysis input:checked").length > 1){
|
||||||
|
alert("<%=thead_field_for_mg('analysis_field_can_only_choose_one')%>");
|
||||||
|
}else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$('#backend_fields_analysis').css( 'border', '2px solid red');
|
||||||
|
window.location.href = "#backend_fields_analysis";
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
$('#backend_fields_analysis input').click(function(){
|
||||||
|
if($('#backend_fields_analysis input:checked').length == 1){
|
||||||
|
$('#backend_fields_analysis').css( 'border','');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$( ".sort_asc_fields, .sort_desc_fields" ).on("click", function(){
|
||||||
|
var _this = $(this);
|
||||||
|
if(_this.prop('checked')){
|
||||||
|
var other_field_class = _this.hasClass('sort_asc_fields') ? '.sort_desc_fields' : '.sort_asc_fields';
|
||||||
|
$(other_field_class).filter('[value="' + _this.attr('value') + '"]').prop('checked', false);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
$( ".table tbody td" ).each(function(i,v){
|
||||||
|
$(v).attr("index",$(v).index());
|
||||||
|
$(v).html("<span class=\"brand ui-sortable-handle\"><i class=\"icons-list-2\"></i></span>" + $(v).html());
|
||||||
|
})
|
||||||
|
$( ".table tbody >" ).sortable({
|
||||||
|
axis: "x",
|
||||||
|
revert: true,
|
||||||
|
handle: ".brand",
|
||||||
|
update: function(event, ui) {
|
||||||
|
var new_index = ui.item.index();
|
||||||
|
var old_index = ui.item.attr("index");
|
||||||
|
var indices = [new_index,old_index].sort();
|
||||||
|
for(var new_i=indices[0];new_i<=indices[1];new_i++){
|
||||||
|
var td = ui.item.parent().find(">").eq(new_i);
|
||||||
|
var old_i =td.attr("index");
|
||||||
|
var org_i = td.data("index");
|
||||||
|
td.attr("index",new_i);
|
||||||
|
td.find('.fields_order_hidden_input').val(new_i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -0,0 +1,52 @@
|
||||||
|
<table class="table main-list">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><%= thead_field_for_mg("module_name") %></th>
|
||||||
|
<th><%= thead_field_for_mg("module_key") %></th>
|
||||||
|
<th><%= thead_field_for_mg("action") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="tbody_writing_journals" class="sort-holder">
|
||||||
|
<%= render 'module_fields' %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div id='dialog-confirm' title="<%= thead_field_for_mg("generate_module") %>" style="display: none;">
|
||||||
|
<div style="clear:both;"></div>
|
||||||
|
<div id="info_texts">
|
||||||
|
<image src="/assets/preloader.gif" id="preloader"></image>
|
||||||
|
<div id="generating_module"><%=thead_field_for_mg("generating_module")%></div>
|
||||||
|
<div id="info_logs"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="bottomnav clearfix">
|
||||||
|
<div class="action pull-right">
|
||||||
|
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:new_), new_admin_module_generator_path, :class => 'btn btn-primary' %>
|
||||||
|
</div>
|
||||||
|
<div class="pagination pagination-centered">
|
||||||
|
<%= content_tag :div, paginate(@module_fields), class: "pagination pagination-centered" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(".generate_module").off("click").on("click",function(){
|
||||||
|
$( "#dialog-confirm" ).dialog({
|
||||||
|
resizable: true,
|
||||||
|
minHeight: 300,
|
||||||
|
maxHeight: 400,
|
||||||
|
modal: true,
|
||||||
|
width: '80%',
|
||||||
|
close: function(){$( this ).dialog( "close" );},
|
||||||
|
open: function(){$("#preloader").css("display",'');$("#generating_module").css("display",'');$( "#info_logs" ).html("");}
|
||||||
|
})
|
||||||
|
var url = $(this).data("url");
|
||||||
|
$.get(url).done(function(data){
|
||||||
|
console.log(data);
|
||||||
|
$("#preloader").css("display",'none');
|
||||||
|
$("#generating_module").css("display",'none');
|
||||||
|
if(data["success"]){
|
||||||
|
$( "#info_logs" ).html("<span><%=thead_field_for_mg("goto")%><a target=\"_blank\" href=\""+data["url"]+"\" title=\"<%=thead_field_for_mg("goto")%> "+data["name"]+"\">"+data["name"]+"</a></span>")
|
||||||
|
}else{
|
||||||
|
$( "#info_logs" ).html(data["error"]);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<%= form_for @module_field, url: admin_module_generators_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<%= render partial: 'form', locals: {f: f} %>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
||||||
|
|
||||||
|
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
||||||
|
ENGINE_PATH = File.expand_path('../../lib/personal_course/engine', __FILE__)
|
||||||
|
|
||||||
|
# Set up gems listed in the Gemfile.
|
||||||
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||||||
|
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
||||||
|
|
||||||
|
require 'rails/all'
|
||||||
|
require 'rails/engine/commands'
|
|
@ -0,0 +1,54 @@
|
||||||
|
en:
|
||||||
|
module_name:
|
||||||
|
module_generator: Module Generator
|
||||||
|
restful_actions:
|
||||||
|
fields_setting: Fields Setting
|
||||||
|
module_generator:
|
||||||
|
enable: Enable
|
||||||
|
one_line_title_format: "Paper Format Title"
|
||||||
|
download: Download
|
||||||
|
author_translation_name: Author translation name
|
||||||
|
module_generate: Module Generate
|
||||||
|
module_name: Module Name
|
||||||
|
module_key: Module Key
|
||||||
|
action: Action
|
||||||
|
primary_modal_name: Primary Modal Name
|
||||||
|
related_modal_name: Related Modal Name
|
||||||
|
field_name: Field Name
|
||||||
|
translation_name: translation_name
|
||||||
|
remove_text: Do you really want to delete this field?
|
||||||
|
field_type: Field Type
|
||||||
|
text_field: Text Field
|
||||||
|
text_editor: Text Editor
|
||||||
|
file: File
|
||||||
|
select: Select field
|
||||||
|
year: Year
|
||||||
|
year_month: Year Month
|
||||||
|
date: Date
|
||||||
|
time: Time
|
||||||
|
date_time: Date time
|
||||||
|
localize: Localize
|
||||||
|
add_field: Add field
|
||||||
|
fields_display_setting: Fields display setting
|
||||||
|
backend_page: Backend Page
|
||||||
|
frontend_page: Frontend Page
|
||||||
|
profile: Personal Profile
|
||||||
|
index: Index Page
|
||||||
|
show: Show Page
|
||||||
|
member_show: Member show page
|
||||||
|
slug_title: Slug title
|
||||||
|
please_choose_one_slug_title: Please choose one Slug title!
|
||||||
|
slug_title_can_only_choose_one: Slug title can only choose one!
|
||||||
|
please_choose_one_analysis_field: Please choose one analysis field!
|
||||||
|
analysis_field_can_only_choose_one: Analysis field can only choose one!
|
||||||
|
generate_module: Generate Module
|
||||||
|
member: Member
|
||||||
|
link: Link
|
||||||
|
analysis: Analysis Page
|
||||||
|
goto: "Go to "
|
||||||
|
generating_module: Generating Module
|
||||||
|
please_change_module_key: "Please change module name(This name already exist)."
|
||||||
|
copy: Copy
|
||||||
|
periodic_time: Periodic time
|
||||||
|
sort_asc: "Sort(Ascending)"
|
||||||
|
sort_desc: "Sort(Descending)"
|
|
@ -0,0 +1,54 @@
|
||||||
|
zh_tw:
|
||||||
|
module_name:
|
||||||
|
module_generator: 模組生成器
|
||||||
|
restful_actions:
|
||||||
|
fields_setting: 欄位設定
|
||||||
|
module_generator:
|
||||||
|
enable: 啟用
|
||||||
|
one_line_title_format: "論文格式標題"
|
||||||
|
download: 下載
|
||||||
|
author_translation_name: 著作人翻譯名稱
|
||||||
|
module_generate: 模組生成
|
||||||
|
module_name: 模組名稱
|
||||||
|
module_key: 模組Key
|
||||||
|
action: 動作
|
||||||
|
primary_modal_name: 主要modal名稱(均英文小寫,可加底線)
|
||||||
|
related_modal_name: 關聯modal名稱(用來存論文類型、期刊等級...等)
|
||||||
|
field_name: 欄位名稱
|
||||||
|
translation_name: 翻譯名稱
|
||||||
|
remove_text: 您確定要刪除這個欄位嗎
|
||||||
|
field_type: 欄位類型
|
||||||
|
text_field: 文字欄位
|
||||||
|
text_editor: 文字編輯器
|
||||||
|
file: 檔案
|
||||||
|
select: 選項欄位
|
||||||
|
year: 年份
|
||||||
|
year_month: 年月
|
||||||
|
date: 日期
|
||||||
|
time: 時間
|
||||||
|
date_time: 日期與時間
|
||||||
|
localize: 隨語言變化
|
||||||
|
add_field: 新增欄位
|
||||||
|
fields_display_setting: 欄位顯示設定
|
||||||
|
backend_page: 後台頁面
|
||||||
|
frontend_page: 前台頁面
|
||||||
|
profile: 個人資料
|
||||||
|
index: Index 頁面
|
||||||
|
show: Show 頁面
|
||||||
|
member_show: 會員show頁面
|
||||||
|
slug_title: "頭銜標題(show頁面會顯示於網址)"
|
||||||
|
please_choose_one_slug_title: 請選擇一個頭銜標題!
|
||||||
|
slug_title_can_only_choose_one: 頭銜標題只能選擇一個!
|
||||||
|
please_choose_one_analysis_field: 請至少選擇一個分析欄位!
|
||||||
|
analysis_field_can_only_choose_one: 分析欄位只能選擇一個!
|
||||||
|
generate_module: 生成模組
|
||||||
|
member: 會員
|
||||||
|
link: 連結
|
||||||
|
analysis: 分析頁面
|
||||||
|
goto: "前往 "
|
||||||
|
generating_module: 正在生成模組中...
|
||||||
|
please_change_module_key: "請更改模組名稱(此名稱已存在)"
|
||||||
|
copy: 複製
|
||||||
|
periodic_time: 週期性時間
|
||||||
|
sort_asc: "排序(升序)"
|
||||||
|
sort_desc: "排序(降序)"
|
|
@ -0,0 +1,19 @@
|
||||||
|
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
|
||||||
|
resources :module_generators do
|
||||||
|
get 'fields_setting' , to: 'module_generators#fields_setting'
|
||||||
|
post 'update_fields_setting' , to: 'module_generators#update_fields_setting'
|
||||||
|
patch 'update_fields_setting' , to: 'module_generators#update_fields_setting'
|
||||||
|
get 'generate_module' , to: 'module_generators#generate_module'
|
||||||
|
get 'copy' , to: 'module_generators#copy'
|
||||||
|
get 'download' , to: 'module_generators#download'
|
||||||
|
collection do
|
||||||
|
post 'check_plugin_exist' ,to: 'module_generators#check_plugin_exist'
|
||||||
|
post 'check_modal_name' ,to: 'module_generators#check_modal_name'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,4 @@
|
||||||
|
require "module_generator/engine"
|
||||||
|
|
||||||
|
module ModuleGenerator
|
||||||
|
end
|
|
@ -0,0 +1,58 @@
|
||||||
|
require "yaml"
|
||||||
|
module ModuleGenerator
|
||||||
|
class Engine < ::Rails::Engine
|
||||||
|
initializer "module_generator" do
|
||||||
|
OrbitApp.registration "ModuleGenerator", :type => "ModuleApp" do
|
||||||
|
base_url File.expand_path File.dirname(__FILE__)
|
||||||
|
categorizable
|
||||||
|
authorizable
|
||||||
|
side_bar do
|
||||||
|
head_label_i18n 'module_name.module_generator', icon_class: "icons-graduation"
|
||||||
|
available_for "users"
|
||||||
|
active_for_controllers (['admin/module_fields'])
|
||||||
|
head_link_path "admin_module_generators_path"
|
||||||
|
context_link 'module_generator.module_generate',
|
||||||
|
:link_path=>"admin_module_generators_path" ,
|
||||||
|
:priority=>1,
|
||||||
|
:active_for_action=>{'admin/module_fields'=>'index'},
|
||||||
|
:available_for => 'users'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def self.git_reset(commit,type)
|
||||||
|
ubuntu_version = `lsb_release -a | grep Release`.scan(/\d.*\d/)[0]
|
||||||
|
git = 'git'
|
||||||
|
if Float(ubuntu_version) <= 14.04 && Float(%x[git --version].scan(/\d.\d/)[0]) < 1.9
|
||||||
|
if %x[uname -m].scan('64').count !=0
|
||||||
|
cmd0 = system("wget https://ruling.digital/uploads/asset/git_1.9.1-1_amd64.deb && dpkg -x git_1.9.1-1_amd64.deb ./git_1.9.1")
|
||||||
|
else
|
||||||
|
cmd0 = system("wget https://ruling.digital/uploads/asset/git_1.9.1-1_i386.deb && dpkg -x git_1.9.1-1_i386.deb ./git_1.9.1")
|
||||||
|
end
|
||||||
|
git = 'git_1.9.1/usr/bin/git'
|
||||||
|
end
|
||||||
|
%x(cd #{ENV['PWD']} && #{git} fetch origin)
|
||||||
|
@branch = %x(cd #{ENV['PWD']} && #{git} rev-parse --abbrev-ref HEAD).gsub("\n","")
|
||||||
|
new_commit_id = %x(cd #{ENV['PWD']} && #{git} log #{@branch}..origin/#{@branch} --pretty=format:"%H")
|
||||||
|
new_updates = %x(cd #{ENV['PWD']} && #{git} log #{@branch}..origin/#{@branch} --pretty=format:"%ad' , '%s" --date=short).split("\n").map{|log| log.gsub("'","")}
|
||||||
|
if new_commit_id.present?
|
||||||
|
git_add_except_public = Dir['*'].select{|v| v!= 'public' && v!= 'log' && v != 'dump' && v != 'tmp'}.collect do |v|
|
||||||
|
"#{git} add -f --all --ignore-errors '#{v}'"
|
||||||
|
end.join(' ; ')
|
||||||
|
git_add_custom = (Dir['*'].select{|v| v !='app' && v != 'lib' && v != 'config' && v != 'public' && v!= 'log' && v != 'dump' && v != 'tmp'} + ['app/templates','config/mongoid.yml','config/extra_lang.txt']).collect do |v|
|
||||||
|
"#{git} add -f --all --ignore-errors '#{v}'"
|
||||||
|
end.join(' ; ')
|
||||||
|
git_restore = "#{git} checkout ."
|
||||||
|
time_now = Time.now.strftime('%Y_%m_%d_%H_%M')
|
||||||
|
if %x[#{git} config user.name].empty?
|
||||||
|
%x[#{git} config --global user.name "rulingcom"]
|
||||||
|
end
|
||||||
|
if %x[#{git} config user.email].empty?
|
||||||
|
%x[#{git} config --global user.email "orbit@rulingcom.com"]
|
||||||
|
end
|
||||||
|
puts "Updating orbit-kernel..."
|
||||||
|
system("cd #{ENV['PWD']} && bash -l -c \"#{git_add_except_public} ; #{git} commit -m auto_backup_before_#{type}_#{time_now} --allow-empty && #{git} reset #{commit} --mixed ; #{git_add_custom} ; #{git_restore} ; #{git_add_except_public} ; #{git} clean -f -- app/models ; #{git} commit -m complete_#{type}_#{time_now} --allow-empty\" > /dev/null")
|
||||||
|
puts "Updated! " + new_updates.first.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,3 @@
|
||||||
|
module ModuleGenerator
|
||||||
|
VERSION = "0.0.1"
|
||||||
|
end
|
|
@ -0,0 +1,4 @@
|
||||||
|
# desc "Explaining what the task does"
|
||||||
|
# task :module_generator do
|
||||||
|
# # Task goes here
|
||||||
|
# end
|
|
@ -0,0 +1,21 @@
|
||||||
|
$:.push File.expand_path("../lib", __FILE__)
|
||||||
|
|
||||||
|
# Maintain your gem's version:
|
||||||
|
# require "rails"
|
||||||
|
require "module_generator/version"
|
||||||
|
# require "module_generator/engine"
|
||||||
|
# ModuleGenerator.git_reset('origin','update')
|
||||||
|
# Describe your gem and declare its dependencies:
|
||||||
|
Gem::Specification.new do |s|
|
||||||
|
s.name = "module_generator"
|
||||||
|
s.version = ModuleGenerator::VERSION
|
||||||
|
s.authors = ["Bohung"]
|
||||||
|
s.email = ["bohung@rulingcom.com"]
|
||||||
|
s.homepage = "http://www.rulingcom.com"
|
||||||
|
s.summary = "A Generator for Personal plugin."
|
||||||
|
s.description = "A Generator for Personal plugin."
|
||||||
|
s.license = "MIT"
|
||||||
|
|
||||||
|
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
|
||||||
|
s.test_files = Dir["test/**/*"]
|
||||||
|
end
|
|
@ -0,0 +1,8 @@
|
||||||
|
.bundle/
|
||||||
|
log/*.log
|
||||||
|
pkg/
|
||||||
|
test/dummy/db/*.sqlite3
|
||||||
|
test/dummy/db/*.sqlite3-journal
|
||||||
|
test/dummy/log/*.log
|
||||||
|
test/dummy/tmp/
|
||||||
|
test/dummy/.sass-cache
|
|
@ -0,0 +1,14 @@
|
||||||
|
source "https://rubygems.org"
|
||||||
|
|
||||||
|
# Declare your gem's dependencies in personal_course.gemspec.
|
||||||
|
# Bundler will treat runtime dependencies like base dependencies, and
|
||||||
|
# development dependencies will be added by default to the :development group.
|
||||||
|
gemspec
|
||||||
|
|
||||||
|
# Declare any dependencies that are still in development here instead of in
|
||||||
|
# your gemspec. These might include edge Rails or gems from your path or
|
||||||
|
# Git. Remember to move these dependencies to your gemspec before releasing
|
||||||
|
# your gem to rubygems.org.
|
||||||
|
|
||||||
|
# To use debugger
|
||||||
|
# gem 'debugger'
|
|
@ -0,0 +1,20 @@
|
||||||
|
Copyright 2022 YOURNAME
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,3 @@
|
||||||
|
= PersonalPluginTemplate
|
||||||
|
|
||||||
|
This project rocks and uses MIT-LICENSE.
|
|
@ -0,0 +1,34 @@
|
||||||
|
begin
|
||||||
|
require 'bundler/setup'
|
||||||
|
rescue LoadError
|
||||||
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
||||||
|
end
|
||||||
|
|
||||||
|
require 'rdoc/task'
|
||||||
|
|
||||||
|
RDoc::Task.new(:rdoc) do |rdoc|
|
||||||
|
rdoc.rdoc_dir = 'rdoc'
|
||||||
|
rdoc.title = 'PersonalPluginTemplate'
|
||||||
|
rdoc.options << '--line-numbers'
|
||||||
|
rdoc.rdoc_files.include('README.rdoc')
|
||||||
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||||
|
end
|
||||||
|
|
||||||
|
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
||||||
|
load 'rails/tasks/engine.rake'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Bundler::GemHelper.install_tasks
|
||||||
|
|
||||||
|
require 'rake/testtask'
|
||||||
|
|
||||||
|
Rake::TestTask.new(:test) do |t|
|
||||||
|
t.libs << 'lib'
|
||||||
|
t.libs << 'test'
|
||||||
|
t.pattern = 'test/**/*_test.rb'
|
||||||
|
t.verbose = false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
task default: :test
|
|
@ -0,0 +1,13 @@
|
||||||
|
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||||
|
// listed below.
|
||||||
|
//
|
||||||
|
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||||
|
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
||||||
|
//
|
||||||
|
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||||
|
// compiled file.
|
||||||
|
//
|
||||||
|
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
||||||
|
// about supported directives.
|
||||||
|
//
|
||||||
|
//= require_tree .
|
|
@ -0,0 +1,15 @@
|
||||||
|
/*
|
||||||
|
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||||
|
* listed below.
|
||||||
|
*
|
||||||
|
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
||||||
|
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
||||||
|
*
|
||||||
|
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
||||||
|
* compiled file so the styles you add here take precedence over styles defined in any styles
|
||||||
|
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
||||||
|
* file per style scope.
|
||||||
|
*
|
||||||
|
*= require_tree .
|
||||||
|
*= require_self
|
||||||
|
*/
|
|
@ -0,0 +1,43 @@
|
||||||
|
class Admin::ModuleModalTemplateRelatedsController < OrbitMemberController
|
||||||
|
|
||||||
|
def index
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@module_modal_template_related = ModuleModalTemplateRelated.new
|
||||||
|
@url = admin_module_modal_template_relateds_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@module_modal_template_related = ModuleModalTemplateRelated.find(params[:id])
|
||||||
|
@url = admin_module_modal_template_related_path(@module_modal_template_related)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
module_modal_template_related = ModuleModalTemplateRelated.create(module_modal_template_related_params)
|
||||||
|
@module_modal_template_relateds = ModuleModalTemplateRelated.all
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
module_modal_template_related = ModuleModalTemplateRelated.find(params[:id]) rescue nil
|
||||||
|
if !module_modal_template_related.nil?
|
||||||
|
module_modal_template_related.update_attributes(module_modal_template_related_params)
|
||||||
|
end
|
||||||
|
@module_modal_template_relateds = ModuleModalTemplateRelated.all
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
module_modal_template_related = ModuleModalTemplateRelated.find(params[:id]) rescue nil
|
||||||
|
if !module_modal_template_related.nil?
|
||||||
|
module_modal_template_related.destroy
|
||||||
|
end
|
||||||
|
@module_modal_template_relateds = ModuleModalTemplateRelated.all
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def module_modal_template_related_params
|
||||||
|
params.require(:module_modal_template_related).permit!
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,152 @@
|
||||||
|
class Admin::ModuleModalTemplatesController < OrbitMemberController
|
||||||
|
include Admin::ModuleModalTemplatesHelper
|
||||||
|
layout "member_plugin"
|
||||||
|
before_action :set_module_modal_template, only: [:show, :edit , :update, :destroy]
|
||||||
|
before_action :set_plugin
|
||||||
|
before_action :get_settings,:only => [:new, :edit, :setting]
|
||||||
|
|
||||||
|
before_action :need_access_right
|
||||||
|
before_action :allow_admin_only, :only => [:index, :setting]
|
||||||
|
|
||||||
|
def index
|
||||||
|
if params[:sort].present?
|
||||||
|
@module_modal_templates = ModuleModalTemplate.order_by(sort).page(params[:page]).per(10)
|
||||||
|
else
|
||||||
|
@module_modal_templates = ModuleModalTemplate.sort_hash.page(params[:page]).per(10)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def sort
|
||||||
|
case params[:sort]
|
||||||
|
when "status"
|
||||||
|
@sort = [[:is_top, params[:order]],
|
||||||
|
[:is_hot, params[:order]],
|
||||||
|
[:is_hidden,params[:order]],
|
||||||
|
[:id,params[:order]]]
|
||||||
|
when "category"
|
||||||
|
@sort = {:category_id=>params[:order]}.merge({:id=>params[:order]})
|
||||||
|
else
|
||||||
|
if params[:sort].present?
|
||||||
|
s = params[:sort].to_s
|
||||||
|
@sort = {s=>params[:order]}.merge({:id=>params[:order]})
|
||||||
|
else
|
||||||
|
@sort = {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@sort
|
||||||
|
end
|
||||||
|
def new
|
||||||
|
@member = MemberProfile.find_by(:uid=>params[:uid].to_s) rescue nil
|
||||||
|
@module_modal_template = ModuleModalTemplate.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
module_modal_template = ModuleModalTemplate.create(module_modal_template_params)
|
||||||
|
redirect_to params[:referer_url]
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
end
|
||||||
|
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]
|
||||||
|
|
||||||
|
@data = get_chart_data(analysis_field_name_start,analysis_field_name_end,role,params[:graph_by],params[:time_zone])
|
||||||
|
|
||||||
|
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="module_modal_templates.xlsx"'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@module_modal_template.destroy
|
||||||
|
redirect_to admin_module_modal_templates_path(:page => params[:page])
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@module_modal_template.update_attributes(module_modal_template_params)
|
||||||
|
@module_modal_template.save
|
||||||
|
redirect_to params[:referer_url]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def setting
|
||||||
|
end
|
||||||
|
|
||||||
|
def frontend_setting
|
||||||
|
@member = MemberProfile.find_by(:uid=>params[:uid].to_s) rescue nil
|
||||||
|
@intro = ModuleModalTemplateIntro.find_by(:member_profile_id=>@member.id) rescue nil
|
||||||
|
@intro = @intro.nil? ? ModuleModalTemplateIntro.new({:member_profile_id=>@member.id}) : @intro
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_frontend_setting
|
||||||
|
@member = MemberProfile.find(intro_params['member_profile_id']) rescue nil
|
||||||
|
@intro = ModuleModalTemplateIntro.find_by(:member_profile_id=>@member.id) rescue nil
|
||||||
|
@intro = @intro.nil? ? ModuleModalTemplateIntro.new({:member_profile_id=>@member.id}) : @intro
|
||||||
|
@intro.update_attributes(intro_params)
|
||||||
|
@intro.save
|
||||||
|
redirect_to URI.encode('/admin/members/'+@member.to_param+'/ModuleModalTemplate')
|
||||||
|
end
|
||||||
|
|
||||||
|
def toggle_hide
|
||||||
|
if params[:ids]
|
||||||
|
@projects = ModuleModalTemplate.any_in(_id: params[:ids])
|
||||||
|
|
||||||
|
@projects.each do |project|
|
||||||
|
project.is_hidden = params[:disable]
|
||||||
|
project.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
render json: {"success"=>true}
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def module_modal_template_params
|
||||||
|
params.require(:module_modal_template).permit!
|
||||||
|
end
|
||||||
|
|
||||||
|
def intro_params
|
||||||
|
params.require(:module_modal_template_intro).permit! rescue nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_settings
|
||||||
|
parse_again_start
|
||||||
|
@module_modal_template_relateds = ModuleModalTemplateRelated.all
|
||||||
|
parse_again_end
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_plugin
|
||||||
|
@plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'ModuleModalTemplate'}.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_module_modal_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
|
||||||
|
@module_modal_template = ModuleModalTemplate.find_by(:uid => uid) rescue ModuleModalTemplate.find(params[:id])
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,172 @@
|
||||||
|
class ModuleTemplatesController < ApplicationController
|
||||||
|
include Admin::ModuleModalTemplatesHelper
|
||||||
|
def index
|
||||||
|
params = OrbitHelper.params
|
||||||
|
module_modal_templates = ModuleModalTemplate.sort_for_frontend
|
||||||
|
page = OrbitHelper.page rescue Page.where(page_id: params[:page_id]).first
|
||||||
|
parse_again_start * 1 if is_one_line_title.count > 0
|
||||||
|
title_is_paper_format = true
|
||||||
|
if page.custom_string_field == 'table'
|
||||||
|
title_is_paper_format = false
|
||||||
|
fields_to_show = page.custom_array_field rescue []
|
||||||
|
if fields_to_show.blank?
|
||||||
|
fields_to_show = col_name_to_show_in_index_page
|
||||||
|
end
|
||||||
|
else
|
||||||
|
fields_to_show = col_name_to_show_short
|
||||||
|
end
|
||||||
|
parse_again_end
|
||||||
|
parse_again_start * 1 if is_one_line_title.count == 0
|
||||||
|
title_is_paper_format = false
|
||||||
|
fields_to_show = page.custom_array_field rescue []
|
||||||
|
if fields_to_show.blank?
|
||||||
|
fields_to_show = col_name_to_show_in_index_page
|
||||||
|
end
|
||||||
|
parse_again_end
|
||||||
|
if params[:keywords].present?
|
||||||
|
module_modal_templates = filter_keywords(module_modal_templates,params[:selectbox],params[:keywords])
|
||||||
|
end
|
||||||
|
module_modal_templates = module_modal_templates.page(params[:page_no]).per(OrbitHelper.page_data_count)
|
||||||
|
module_modal_templates_list = module_modal_templates.collect do |module_modal_template|
|
||||||
|
{'jps' => fields_to_show.map{|field| {"value"=> get_display_field(module_modal_template,field, title_is_paper_format)}}}
|
||||||
|
end
|
||||||
|
|
||||||
|
extras = extra_translate_title
|
||||||
|
choice_show = []
|
||||||
|
headers = []
|
||||||
|
fields_to_show.each do |fs|
|
||||||
|
col = 2
|
||||||
|
col = 3 if fs == 'slug_title_text'
|
||||||
|
headers << {
|
||||||
|
'head-title' => t("module_template.#{fs}"),
|
||||||
|
'col' => col
|
||||||
|
}
|
||||||
|
choice_show << t("module_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('module_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('module_template.extend_translate.search_class')
|
||||||
|
search_text = t('module_template.extend_translate.word_to_search')
|
||||||
|
@_request = OrbitHelper.request
|
||||||
|
csrf_value = form_authenticity_token
|
||||||
|
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(/\"/,''),
|
||||||
|
'csrf_value' => csrf_value
|
||||||
|
})
|
||||||
|
extras["widget-title"] = I18n.t("module_key.module_template")
|
||||||
|
{
|
||||||
|
"module_modal_templates" => module_modal_templates_list,
|
||||||
|
"headers" => headers,
|
||||||
|
"extras" => extras,
|
||||||
|
"total_pages" => module_modal_templates.total_pages,
|
||||||
|
'choice' => choice
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
params = OrbitHelper.params
|
||||||
|
plugin = ModuleModalTemplate.where(:is_hidden=>false).find_by(uid: params[:uid].to_s)
|
||||||
|
fields_to_show = col_name_to_show_in_show_page
|
||||||
|
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_display_field(module_modal_template,field, title_is_paper_format=false)
|
||||||
|
text_only = false
|
||||||
|
display_field_code
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
def get_fields_for_index
|
||||||
|
@page = Page.find(params[:page_id]) rescue nil
|
||||||
|
@fields_to_show = all_fields_to_show_in_index
|
||||||
|
@fields_to_show = @fields_to_show.map { |fs| [t("module_template.#{fs}"), fs] }
|
||||||
|
if @page.present? && @page.custom_string_field == 'table'
|
||||||
|
@default_fields_to_show = col_name_to_show_in_index_page
|
||||||
|
else
|
||||||
|
@default_fields_to_show = col_name_to_show_short
|
||||||
|
end
|
||||||
|
render layout: false
|
||||||
|
end
|
||||||
|
|
||||||
|
def save_index_fields
|
||||||
|
page = Page.find(params[:page_id]) rescue nil
|
||||||
|
page.custom_array_field = params[:keys]
|
||||||
|
page.save
|
||||||
|
render json: { 'success' => true }.to_json
|
||||||
|
end
|
||||||
|
def filter_keywords(module_modal_templates,select_field,keywords)
|
||||||
|
member_fields = module_modal_template_related_members
|
||||||
|
file_fields = module_modal_template_related_files_text
|
||||||
|
link_fields = module_modal_template_related_links_text
|
||||||
|
if select_field == "default"
|
||||||
|
module_modal_templates = module_modal_templates.where(:slug_title=>/#{gsub_invalid_character(keywords)}/)
|
||||||
|
elsif select_field == "member_profile"
|
||||||
|
ms = MemberProfile.all.select{|m| m.name.include?(keywords)}
|
||||||
|
module_modal_templates = module_modal_templates.where(:member_profile_id.in=>ms.map{|m| m.id})
|
||||||
|
elsif member_fields.include?(select_field)
|
||||||
|
ms = MemberProfile.all.select{|m| m.name.include?(keywords)}
|
||||||
|
m_ids = ms.map{|m| m.id.to_s }
|
||||||
|
tmp_module_modal_templates = module_modal_templates.select{|p| (p.send("#{select_field.singularize}_ids") & m_ids).count != 0}
|
||||||
|
module_modal_templates = module_modal_templates.where(:id.in=>tmp_module_modal_templates.map{|p| p.id})
|
||||||
|
elsif select_field.split(".").count > 1
|
||||||
|
relate_name = select_field.split(".").first
|
||||||
|
field_name = select_field.split(".").last.gsub(/^\$+/, '')
|
||||||
|
relate = relate_name.camelize.constantize
|
||||||
|
relate_ids = relate.where(field_name=>/#{gsub_invalid_character(keywords)}/).pluck(:id)
|
||||||
|
module_modal_templates = module_modal_templates.where("#{relate_name.singularize}_id"=>{'$in'=>relate_ids})
|
||||||
|
elsif (ModuleModalTemplate.fields[select_field].options[:type] == Date rescue false)
|
||||||
|
keywords = keywords.split(/[\/\-]/)
|
||||||
|
if keywords.count > 1
|
||||||
|
Date.parse(keywords.join("/"))
|
||||||
|
else
|
||||||
|
start_time = Date.parse(keywords[0] + "/1/1")
|
||||||
|
end_time = Date.parse(keywords[0] + "/12/31")
|
||||||
|
module_modal_templates = module_modal_templates.where(select_field=>{'$gte'=>start_time,'$lte'=>end_time})
|
||||||
|
end
|
||||||
|
elsif (ModuleModalTemplate.fields[select_field].options[:type] == DateTime rescue false)
|
||||||
|
keywords = keywords.split(/[\/\-]/)
|
||||||
|
if keywords.count > 1
|
||||||
|
DateTime.parse(keywords.join("/"))
|
||||||
|
elsif keywords[0].include?(":")
|
||||||
|
tmp_module_modal_templates = module_modal_templates.select{|p| (p.send(select_field).strftime('%Y/%m/%d %H:%M').include?(keywords[0]) rescue false)}
|
||||||
|
module_modal_templates = module_modal_templates.where(:id.in=>tmp_module_modal_templates.map{|p| p.id})
|
||||||
|
else
|
||||||
|
start_time = DateTime.parse(keywords[0] + "/1/1 00:00")
|
||||||
|
end_time = DateTime.parse(keywords[0] + "/12/31 23:59")
|
||||||
|
module_modal_templates = module_modal_templates.where(select_field=>{'$gte'=>start_time,'$lte'=>end_time})
|
||||||
|
end
|
||||||
|
elsif (ModuleModalTemplate.fields[select_field].options[:type] == Integer rescue false)
|
||||||
|
tmp_module_modal_templates = module_modal_templates.select{|p| p.send(select_field).to_s.include?(keywords)}
|
||||||
|
module_modal_templates = module_modal_templates.where(:id.in=>tmp_module_modal_templates.map{|p| p.id})
|
||||||
|
elsif file_fields.include?(select_field)
|
||||||
|
file_field = select_field.camelize.constantize
|
||||||
|
ids1 = file_field.where(:file=>/#{gsub_invalid_character(keywords)}/).pluck(:id)
|
||||||
|
ids2 = file_field.where(:title=>/#{gsub_invalid_character(keywords)}/).pluck(:id)
|
||||||
|
ids = ids1 + ids2
|
||||||
|
tmp_module_modal_templates = module_modal_templates.select{|p| (p.send("#{select_field}_ids") & ids).count != 0}
|
||||||
|
module_modal_templates = module_modal_templates.where(:id.in=>tmp_module_modal_templates.map{|p| p.id})
|
||||||
|
elsif link_fields.include?(select_field)
|
||||||
|
link_field = select_field.camelize.constantize
|
||||||
|
ids1 = link_field.where(:title=>/#{gsub_invalid_character(keywords)}/).pluck(:id)
|
||||||
|
ids2 = link_field.where(:url=>/#{gsub_invalid_character(keywords)}/).pluck(:id)
|
||||||
|
ids = ids1 + ids2
|
||||||
|
tmp_module_modal_templates = module_modal_templates.select{|p| (p.send("#{select_field}_ids") & ids).count != 0}
|
||||||
|
module_modal_templates = module_modal_templates.where(:id.in=>tmp_module_modal_templates.map{|p| p.id})
|
||||||
|
else
|
||||||
|
module_modal_templates = module_modal_templates.where(select_field=>/#{gsub_invalid_character(keywords)}/)
|
||||||
|
end
|
||||||
|
return module_modal_templates
|
||||||
|
end
|
||||||
|
def gsub_invalid_character(text)
|
||||||
|
text.to_s.gsub(/(\/|\*|\\|\]|\[|\(|\)|\.|\+|\?|\!)/){|ff| "\\"+ff}
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,192 @@
|
||||||
|
module Admin::ModuleModalTemplatesHelper
|
||||||
|
include OrbitBackendHelper
|
||||||
|
include OrbitFormHelper
|
||||||
|
alias :org_datetime_picker :datetime_picker
|
||||||
|
def get_authors_text(module_modal_template, is_to_sentence=false, locale=nil)
|
||||||
|
authors_text = Nokogiri::HTML(module_modal_template.authors.to_s).text
|
||||||
|
split_text = authors_text.match(/[、,,\/]/)
|
||||||
|
split_text = split_text.nil? ? '/' : split_text[0]
|
||||||
|
full_authors_names = get_member(module_modal_template).collect(&:name)
|
||||||
|
if authors_text.present?
|
||||||
|
authors_names = authors_text.split(split_text).select{|a| !(full_authors_names.include?(a.strip()))}
|
||||||
|
full_authors_names += authors_names
|
||||||
|
end
|
||||||
|
if is_to_sentence
|
||||||
|
full_authors_names.to_sentence({:locale=>locale})
|
||||||
|
else
|
||||||
|
full_authors_names.join(split_text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def get_authors_show(module_modal_template, is_to_sentence=false, locale=nil)
|
||||||
|
authors_text = Nokogiri::HTML(module_modal_template.authors.to_s).text
|
||||||
|
split_text = authors_text.match(/[、,,\/]/)
|
||||||
|
split_text = split_text.nil? ? '/' : split_text[0]
|
||||||
|
full_authors_names = []
|
||||||
|
full_authors = get_member(module_modal_template).collect do |member|
|
||||||
|
member_name = member.name
|
||||||
|
full_authors_names << member_name
|
||||||
|
"<a href='#{OrbitHelper.url_to_plugin_show(member.to_param,'member')}' title='#{member_name}'>#{member_name}</a>"
|
||||||
|
end
|
||||||
|
if authors_text.present?
|
||||||
|
authors_names = authors_text.split(split_text).select{|a| !(full_authors_names.include?(a.strip()))}
|
||||||
|
full_authors += authors_names
|
||||||
|
end
|
||||||
|
if is_to_sentence
|
||||||
|
full_authors.to_sentence({:locale=>locale})
|
||||||
|
else
|
||||||
|
full_authors.join(split_text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def get_member(module_modal_template)
|
||||||
|
Array(MemberProfile.where(:id.in=>Array(module_modal_template).collect(&:member_profile_id).flatten))
|
||||||
|
end
|
||||||
|
def get_member_show(module_modal_template)
|
||||||
|
get_member(module_modal_template).collect{|member| "<a href='#{OrbitHelper.url_to_plugin_show(member.to_param,'member')}' title='#{member.name}'>#{member.name}</a>"}.join('/')
|
||||||
|
end
|
||||||
|
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_module_modal_template(module_modal_template_object)
|
||||||
|
page = Page.where(:module=>"module_template").first
|
||||||
|
("/#{I18n.locale}"+page.url+'/'+module_modal_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(ModuleModalTemplate, 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 "module_modal_template_related"
|
||||||
|
jls = ModuleModalTemplateRelated.all
|
||||||
|
main_field_name = "module_modal_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.module_modal_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(ModuleModalTemplate, current_analysis_field_name, next_analysis_field_name, mps).count rescue 0
|
||||||
|
parse_again_start
|
||||||
|
when "module_modal_template_related"
|
||||||
|
t = filter_data(ModuleModalTemplate, current_analysis_field_name, next_analysis_field_name, mps).where(:module_modal_template_related_id => nil).count rescue 0
|
||||||
|
parse_again_end
|
||||||
|
else
|
||||||
|
t = filter_data(ModuleModalTemplate, 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 = ModuleModalTemplate.fields[field].type rescue nil
|
||||||
|
if type.nil?
|
||||||
|
@periodic = true
|
||||||
|
type = ModuleModalTemplate.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
|
|
@ -0,0 +1,139 @@
|
||||||
|
class ModuleModalTemplate
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
include OrbitModel::Status
|
||||||
|
include MemberHelper
|
||||||
|
include Admin::ModuleModalTemplatesHelper
|
||||||
|
include Slug
|
||||||
|
|
||||||
|
col_fields
|
||||||
|
|
||||||
|
module_modal_template_related_files_fields
|
||||||
|
|
||||||
|
parse_again_start
|
||||||
|
belongs_to :module_modal_template_related
|
||||||
|
parse_again_end
|
||||||
|
|
||||||
|
field :rss2_id
|
||||||
|
belongs_to :member_profile
|
||||||
|
index(module_modal_template_sort_hash, { unique: false, background: false })
|
||||||
|
scope :sort_hash, ->{ order_by(module_modal_template_sort_hash) }
|
||||||
|
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(module_modal_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
|
||||||
|
parse_again_start * 1 if is_one_line_title.count > 0
|
||||||
|
def create_link
|
||||||
|
one_line_title_format_code
|
||||||
|
end
|
||||||
|
parse_again_end
|
||||||
|
def self.get_plugin_datas_to_member(datas)
|
||||||
|
page = Page.where(:module => "module_template").first rescue nil
|
||||||
|
parse_again_start * 1 if is_one_line_title.count > 0
|
||||||
|
title_is_paper_format = true
|
||||||
|
if !page.nil? && page.custom_string_field == "table"
|
||||||
|
title_is_paper_format = false
|
||||||
|
if !page.custom_array_field.blank?
|
||||||
|
fields_to_show = page.custom_array_field
|
||||||
|
else
|
||||||
|
fields_to_show = col_name_to_show
|
||||||
|
end
|
||||||
|
else
|
||||||
|
fields_to_show = col_name_to_show_short
|
||||||
|
end
|
||||||
|
parse_again_end
|
||||||
|
parse_again_start * 1 if is_one_line_title.count == 0
|
||||||
|
title_is_paper_format = false
|
||||||
|
if !page.nil? && !page.custom_array_field.blank?
|
||||||
|
fields_to_show = page.custom_array_field
|
||||||
|
else
|
||||||
|
fields_to_show = col_name_to_show
|
||||||
|
end
|
||||||
|
parse_again_end
|
||||||
|
|
||||||
|
fields_to_remove = []
|
||||||
|
|
||||||
|
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("module_template.#{t}")
|
||||||
|
} if !fields_to_remove.include?(t)
|
||||||
|
end
|
||||||
|
|
||||||
|
fields_to_show = fields_to_show - fields_to_remove
|
||||||
|
|
||||||
|
plugin_datas = datas.sort_for_frontend.collect.with_index do |p,idx|
|
||||||
|
|
||||||
|
pd_data = []
|
||||||
|
fields_to_show.collect do |t|
|
||||||
|
pd_data << { "data_title" => p.display_field(t, false, title_is_paper_format) }
|
||||||
|
end
|
||||||
|
parse_again_start * 1 if module_modal_template_related.count > 0
|
||||||
|
{
|
||||||
|
"pd_datas" => pd_data,
|
||||||
|
"type-sort" => (p.module_modal_template_related.sort_position.to_i rescue 1000),
|
||||||
|
"sort-index" => idx
|
||||||
|
}
|
||||||
|
parse_again_end
|
||||||
|
parse_again_start * 1 if module_modal_template_related.count == 0
|
||||||
|
{
|
||||||
|
"pd_datas" => pd_data
|
||||||
|
}
|
||||||
|
parse_again_end
|
||||||
|
end
|
||||||
|
parse_again_start * 1 if module_modal_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_field_data(field)
|
||||||
|
module_modal_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"=>"module_modal_template-#{field.gsub('_','-')}-field",
|
||||||
|
"value_class"=>"module_modal_template-#{field.gsub('_','-')}-value",
|
||||||
|
"title"=>I18n.t('module_template.'+field),
|
||||||
|
"value"=>value
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def display_field(field,text_only=false,title_is_paper_format=false)
|
||||||
|
module_modal_template = self
|
||||||
|
display_field_code
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,12 @@
|
||||||
|
class ModuleModalTemplateFile
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
|
||||||
|
field :title, localize: true
|
||||||
|
field :description, localize: true
|
||||||
|
field :should_destroy, :type => Boolean
|
||||||
|
|
||||||
|
mount_uploader :file, AssetUploader
|
||||||
|
|
||||||
|
belongs_to :module_modal_template
|
||||||
|
end
|
|
@ -0,0 +1,3 @@
|
||||||
|
class ModuleModalTemplateIntro < ModuleIntro
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,24 @@
|
||||||
|
# encoding: utf-8
|
||||||
|
require 'uri'
|
||||||
|
|
||||||
|
class ModuleModalTemplateLink
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
|
||||||
|
field :url
|
||||||
|
field :title, localize: true
|
||||||
|
|
||||||
|
belongs_to :module_modal_template
|
||||||
|
|
||||||
|
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
|
|
@ -0,0 +1,12 @@
|
||||||
|
class ModuleModalTemplateRelated
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
|
||||||
|
col_related_fields
|
||||||
|
field :sort_position, type: Integer, default: 0
|
||||||
|
|
||||||
|
has_many :module_modal_templates
|
||||||
|
parse_again_start
|
||||||
|
related_periodic_methods_define
|
||||||
|
parse_again_end
|
||||||
|
end
|
|
@ -0,0 +1,42 @@
|
||||||
|
<%= form_for(@module_modal_template_related, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %>
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h3 id="myModalLabel"><%= t("module_template.module_modal_template_related.module_modal_template_related_main_field") %></h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-body">
|
||||||
|
parse_again_start
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t("module_template.module_modal_template_related.related_locale_fields") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<div class="tab-content">
|
||||||
|
<% @site_in_use_locales.each_with_index do |locale,i| %>
|
||||||
|
<div class="tab-pane fade <%= "active in" if i == 0 %>" id="related_locale_fields_<%=locale%>">
|
||||||
|
related_locale_fields_input_fields
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="btn-group" data-toggle="buttons-radio">
|
||||||
|
<% @site_in_use_locales.each_with_index do |locale,i| %>
|
||||||
|
<a class="btn <%= "active" if i == 0 %>" href="#related_locale_fields_<%=locale%>" data-toggle="tab"><%= t(locale) %></a>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
parse_again_end
|
||||||
|
parse_again_start
|
||||||
|
<!-- related_none_locale_fields -->
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t("module_template.module_modal_template_related.related_none_locale_fields") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
related_none_locale_fields_input_fields
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
parse_again_end
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer">
|
||||||
|
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
|
||||||
|
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,2 @@
|
||||||
|
$("#module_modal_template_relateds").html("<%= j render :partial => '/admin/module_modal_templates/module_modal_template_related' %>");
|
||||||
|
$("#module_modal_template_related_modal").modal("hide");
|
|
@ -0,0 +1,2 @@
|
||||||
|
$("#module_modal_template_relateds").html("<%= j render :partial => '/admin/module_modal_templates/module_modal_template_related' %>");
|
||||||
|
$("#module_modal_template_related_modal").modal("hide");
|
|
@ -0,0 +1 @@
|
||||||
|
$('#module_modal_template_related_modal').html("<%= j render 'form' %>");
|
|
@ -0,0 +1 @@
|
||||||
|
$('#module_modal_template_related_modal').html("<%= j render 'form' %>");
|
|
@ -0,0 +1,2 @@
|
||||||
|
$("#module_modal_template_relateds").html("<%= j render :partial => '/admin/module_modal_templates/module_modal_template_related' %>");
|
||||||
|
$("#module_modal_template_related_modal").modal("hide");
|
|
@ -0,0 +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>
|
||||||
|
<% 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" %>
|
||||||
|
<% 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 -->
|
||||||
|
<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" : '' %>">
|
||||||
|
parse_again_start
|
||||||
|
<!-- locale_fields -->
|
||||||
|
<div class="control-group input-title">
|
||||||
|
<label class="control-label muted"><%= t("module_template.locale_fields") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
locale_fields_input_fields
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
parse_again_end
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<!-- Link -->
|
||||||
|
<%
|
||||||
|
links_hash = {}
|
||||||
|
module_modal_template_related_links_text.each do |link|
|
||||||
|
hash = {}
|
||||||
|
hash["html"] = add_attribute("form_link", f, link.pluralize.to_sym)
|
||||||
|
hash["count"] = @module_modal_template.send(link.pluralize).count rescue 0
|
||||||
|
links_hash[link] = hash
|
||||||
|
%>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t("module_template.#{link}") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
|
||||||
|
<!-- Exist -->
|
||||||
|
<% if !@module_modal_template.new_record? && hash["count"] > 0 %>
|
||||||
|
<div class="exist">
|
||||||
|
<% @module_modal_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>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<!-- File -->
|
||||||
|
<%
|
||||||
|
files_hash = {}
|
||||||
|
module_modal_template_related_files_text.each do |file|
|
||||||
|
hash = {}
|
||||||
|
hash["html"] = add_attribute("form_file", f, file.pluralize.to_sym)
|
||||||
|
hash["count"] = @module_modal_template.send(file.pluralize).count rescue 0
|
||||||
|
files_hash[file] = hash
|
||||||
|
%>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t("module_template.#{file}") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
|
||||||
|
<!-- Exist -->
|
||||||
|
<% if !@module_modal_template.new_record? && hash["count"] > 0 %>
|
||||||
|
<div class="exist">
|
||||||
|
<% @module_modal_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>
|
||||||
|
|
||||||
|
</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">
|
||||||
|
|
||||||
|
<!-- Basic Module -->
|
||||||
|
<div class="tab-pane fade in active" id="basic">
|
||||||
|
|
||||||
|
<% if !@member.nil? %>
|
||||||
|
|
||||||
|
<div class="control-group big-group">
|
||||||
|
<label class="control-label muted"><%= t("module_template.author_name_translation") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= @member.name rescue ''%>
|
||||||
|
<%= f.hidden_field :member_profile_id, :value => @member.id %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% else %>
|
||||||
|
|
||||||
|
<div class="control-group big-group">
|
||||||
|
<label class="control-label muted"><%= t("module_template.member_profile") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<% members = !@module_modal_template.member_profile_id.nil? ? MemberProfile.where(:id.in=>Array(@module_modal_template.member_profile_id)).to_a : [] %>
|
||||||
|
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'module_modal_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("module_template.none_locale_fields") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
none_locale_fields_input_fields
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
parse_again_end
|
||||||
|
parse_again_start
|
||||||
|
<!-- module_modal_template_related -->
|
||||||
|
<div class="control-group big-group">
|
||||||
|
<label class="control-label muted"><%= t("module_template.module_modal_template_related.module_modal_template_related_main_field") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.select :module_modal_template_related_id, ModuleModalTemplateRelated.all.collect {|t| [ t.module_modal_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 @module_modal_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" %>
|
||||||
|
</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();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(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>
|
|
@ -0,0 +1,55 @@
|
||||||
|
<% if form_file.new_record? %>
|
||||||
|
<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 %>
|
||||||
|
<% 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>
|
|
@ -0,0 +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 %>
|
||||||
|
</div>
|
|
@ -0,0 +1,23 @@
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
parse_again_start
|
||||||
|
<th><%= t("module_template.module_modal_template_related.related_backend_index_fields") %></th>
|
||||||
|
parse_again_end
|
||||||
|
<th><%= t(:action) %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @module_modal_template_relateds.each do |module_modal_template_related| %>
|
||||||
|
<tr id="<%= dom_id module_modal_template_related %>">
|
||||||
|
parse_again_start
|
||||||
|
<td>related_backend_index_fields_contents</td>
|
||||||
|
parse_again_end
|
||||||
|
<td class="span2">
|
||||||
|
<a href="<%= edit_admin_module_modal_template_related_path(module_modal_template_related) %>#module_modal_template_related_modal" data-toggle="modal" data-remote="true" class="action">
|
||||||
|
<%= t(:edit) %>
|
||||||
|
</a>
|
||||||
|
<%= link_to t(:delete_), admin_module_modal_template_related_path(module_modal_template_related), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
|
@ -0,0 +1,7 @@
|
||||||
|
<% @module_modal_templates.each do |module_modal_template| %>
|
||||||
|
<tr id="<%= dom_id module_modal_template %>" class="with_action">
|
||||||
|
parse_again_start
|
||||||
|
<td> backend_index_fields_contents </td>
|
||||||
|
parse_again_end
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,118 @@
|
||||||
|
<% # 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>
|
||||||
|
<% 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" %>
|
||||||
|
<% 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("module_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("module_template.graph_by") %> : </label>
|
||||||
|
<div class="controls">
|
||||||
|
parse_again_start
|
||||||
|
<%= t("module_template.module_modal_template_related.module_modal_template_related_main_field") %>
|
||||||
|
<input type="radio" name="graph_by" class="graph-type" value="module_modal_template_related">
|
||||||
|
parse_again_end
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-actions">
|
||||||
|
<button id="generate_graph" class="btn btn-info">Graphs</button>
|
||||||
|
<a href="" id="generate_excel" class="btn btn-primary">Export</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="analysis-show-area hide in">
|
||||||
|
<% Role.where(:disabled => false, :title.ne => "", :title.ne => nil).asc(:key).each do |role| %>
|
||||||
|
<div class="role muted" data-role-id="<%= role.id.to_s %>">
|
||||||
|
<h3><%= role.title %></h3>
|
||||||
|
<div class="graph-area">
|
||||||
|
<img class="loader" src="/assets/preloader.gif" alt="loading" width="70" height="70">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% 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 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/module_modal_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;
|
||||||
|
})
|
||||||
|
|
||||||
|
$("#generate_graph").on("click",function(){
|
||||||
|
if(form.isFormValidated()){
|
||||||
|
generateCharts(0);
|
||||||
|
roleArea.removeClass("hide");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
|
||||||
|
var generateCharts = function(index){
|
||||||
|
var role = roleArea.find(".role").eq(index);
|
||||||
|
$.ajax({
|
||||||
|
url : "/admin/module_modal_templates/analysis_report",
|
||||||
|
data : {"role_id" : role.data("role-id"), "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(), "graph_by" : form.form.find("input[name=graph_by]:checked").val(),"time_zone": time_zone_string},
|
||||||
|
type : "get",
|
||||||
|
dataType : "html"
|
||||||
|
}).done(function(html){
|
||||||
|
role.find(".graph-area").html(html);
|
||||||
|
if(index < totalRoles){
|
||||||
|
generateCharts(index + 1);
|
||||||
|
}
|
||||||
|
}).error(function(){
|
||||||
|
role.find(".graph-area").html("There was an error loading this graph.");
|
||||||
|
if(index < totalRoles){
|
||||||
|
generateCharts(index + 1);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -0,0 +1 @@
|
||||||
|
<%= column_chart @data, :id => params[:role_id], :height => "350px", :xtitle => "#{I18n.t("module_template.analysis_field_name")}", :ytitle => "#{I18n.t("module_template.extend_translate.total_number")}" %>
|
|
@ -0,0 +1,72 @@
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
wb = xlsx_package.workbook
|
||||||
|
@data.each_with_index do |role,idx|
|
||||||
|
data = role["data"]
|
||||||
|
wb.add_worksheet(name: role["name"] + "-" + idx.to_s) do |sheet|
|
||||||
|
|
||||||
|
heading = sheet.styles.add_style(:b => true, :locked => true)
|
||||||
|
|
||||||
|
row = [t("module_template.member_profile")]
|
||||||
|
parse_again_start
|
||||||
|
@site_in_use_locales.each do |locale|
|
||||||
|
row << t("module_template.locale_fields") + " - " + t(locale.to_s)
|
||||||
|
end
|
||||||
|
parse_again_end
|
||||||
|
parse_again_start
|
||||||
|
row << t("module_template.none_locale_fields")
|
||||||
|
parse_again_end
|
||||||
|
parse_again_start
|
||||||
|
row << t("module_template.module_modal_template_related.module_modal_template_related_main_field")
|
||||||
|
parse_again_end
|
||||||
|
parse_again_start
|
||||||
|
row << t("module_template.module_modal_template_file")
|
||||||
|
@site_in_use_locales.each do |locale|
|
||||||
|
row << t("module_template.module_modal_template_file") + " " + t("description") + " - " + t(locale.to_s)
|
||||||
|
end
|
||||||
|
@site_in_use_locales.each do |locale|
|
||||||
|
row << t("module_template.module_modal_template_file") + " " + t("alternative") + " - " + t(locale.to_s)
|
||||||
|
end
|
||||||
|
parse_again_end
|
||||||
|
parse_again_start
|
||||||
|
row << t("module_template.module_modal_template_link")
|
||||||
|
@site_in_use_locales.each do |locale|
|
||||||
|
row << t("module_template.module_modal_template_link") + " " + t("url_alt") + " - " + t(locale.to_s)
|
||||||
|
end
|
||||||
|
parse_again_end
|
||||||
|
sheet.add_row row, :style => heading
|
||||||
|
|
||||||
|
data.each do |module_modal_template|
|
||||||
|
row = [(module_modal_template.member_profile.name rescue "")]
|
||||||
|
parse_again_start
|
||||||
|
@site_in_use_locales.each do |locale|
|
||||||
|
row << module_modal_template.locale_fields_translations[locale.to_s]
|
||||||
|
end
|
||||||
|
parse_again_end
|
||||||
|
parse_again_start
|
||||||
|
row << module_modal_template.display_field("none_locale_fields",true)
|
||||||
|
parse_again_end
|
||||||
|
parse_again_start
|
||||||
|
row << (module_modal_template.module_modal_template_related.module_modal_template_related_main_field rescue "")
|
||||||
|
parse_again_end
|
||||||
|
parse_again_start
|
||||||
|
module_modal_template_files = module_modal_template.module_modal_template_files.asc(:created_at)
|
||||||
|
row << module_modal_template_files.collect{|f| (@host_url + f.file.url rescue nil)}.join(";")
|
||||||
|
@site_in_use_locales.each do |locale|
|
||||||
|
row << module_modal_template_files.collect{|l| l.description_translations[locale]}.join(";")
|
||||||
|
end
|
||||||
|
@site_in_use_locales.each do |locale|
|
||||||
|
row << module_modal_template_files.collect{|l| l.title_translations[locale]}.join(";")
|
||||||
|
end
|
||||||
|
parse_again_end
|
||||||
|
parse_again_start
|
||||||
|
module_modal_template_links = module_modal_template.module_modal_template_links.asc(:created_at)
|
||||||
|
row << module_modal_template_links.collect{|l| l.url}.join(";")
|
||||||
|
@site_in_use_locales.each do |locale|
|
||||||
|
row << module_modal_template_links.collect{|l| l.title_translations[locale]}.join(";")
|
||||||
|
end
|
||||||
|
parse_again_end
|
||||||
|
sheet.add_row row
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
<%= form_for @module_modal_template, url: admin_module_modal_template_path(@module_modal_template), html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<%= render partial: 'form', locals: {f: f} %>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,82 @@
|
||||||
|
<% content_for :page_specific_css do %>
|
||||||
|
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||||
|
<%= stylesheet_link_tag "lib/main-list" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= form_for(:module_modal_template_intro, :url => update_frontend_setting_admin_module_modal_templates_path, :method => "post", html: {class: "form-horizontal main-forms previewable"} ) do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<!-- Input Area -->
|
||||||
|
<div class="input-area">
|
||||||
|
|
||||||
|
<!-- Module Tabs -->
|
||||||
|
<div class="nav-name"><strong><%= t("module_key.module_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("modules.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("modules.frontend_page") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.check_box :brief_intro, :checked => @intro.brief_intro %> <%= t("modules.brief_intro") %>
|
||||||
|
<%= f.check_box :complete_list, :checked => @intro.complete_list %> <%= t("modules.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 -->
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<!-- 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 %>
|
|
@ -0,0 +1,24 @@
|
||||||
|
<table class="table main-list tablet footable-loaded">
|
||||||
|
<thead>
|
||||||
|
<tr class="sort-header">
|
||||||
|
parse_again_start
|
||||||
|
<%= thead('module_template.backend_index_fields') %>
|
||||||
|
parse_again_end
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="tbody_writing_journals" class="sort-holder">
|
||||||
|
<%= render 'module_modal_templates' %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="bottomnav clearfix">
|
||||||
|
<div class="action pull-right">
|
||||||
|
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:new_), new_admin_module_modal_template_path, :class => 'btn btn-primary' %>
|
||||||
|
parse_again_start * 1 if module_modal_template_related
|
||||||
|
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_module_modal_template_setting_path, :class => 'btn btn-primary pull-right' %>
|
||||||
|
parse_again_end
|
||||||
|
</div>
|
||||||
|
<div class="pagination pagination-centered">
|
||||||
|
<%= content_tag :div, paginate(@module_modal_templates), class: "pagination pagination-centered" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<%= form_for @module_modal_template, url: admin_module_modal_templates_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<%= render partial: 'form', locals: {f: f} %>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,72 @@
|
||||||
|
<% content_for :page_specific_javascript do %>
|
||||||
|
<%= 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;
|
||||||
|
}
|
||||||
|
</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_module_modal_template_related_path %>#module_modal_template_related_modal" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
|
||||||
|
<span><%= t("module_template.module_modal_template_related.module_modal_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="module_modal_template_relateds" class="table table-striped">
|
||||||
|
<%= render :partial => 'module_modal_template_related', :locals => {:@module_modal_template_relateds => @module_modal_template_relateds} %>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
parse_again_end
|
||||||
|
</div>
|
||||||
|
|
||||||
|
parse_again_start
|
||||||
|
<div>
|
||||||
|
<div style="display:none;" class="modal" id="module_modal_template_related_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$("#module_modal_template_relateds tbody").sortable({
|
||||||
|
update : function(){
|
||||||
|
var data = {};
|
||||||
|
$("#module_modal_template_relateds tbody tr").each(function(i){
|
||||||
|
data[$(this).data("type-id")] = i;
|
||||||
|
})
|
||||||
|
$.ajax({
|
||||||
|
url : "/admin/module_modal_template_relateds/update_order",
|
||||||
|
type : "post",
|
||||||
|
data : {"order" : data}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
parse_again_end
|
|
@ -0,0 +1,48 @@
|
||||||
|
<% if !@page.nil? %>
|
||||||
|
<form id="form_for_plugin_fields" action="">
|
||||||
|
<div class="form-inline">
|
||||||
|
<ul class="current-fields">
|
||||||
|
<% if @page.custom_array_field.blank? %>
|
||||||
|
<% @default_fields_to_show.each do |fs| %>
|
||||||
|
<li data-attrib-key="<%= fs %>" class="clearfix"><span class="field-value"><%= t("module_template.#{fs}") %></span><span class="remove-field"><i class="icon-remove-sign"></i></span></li>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<% @page.custom_array_field.each do |fs| %>
|
||||||
|
<li data-attrib-key="<%= fs %>" class="clearfix"><span class="field-value"><%= t("module_template.#{fs}") %></span><span class="remove-field"><i class="icon-remove-sign"></i></span></li>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-horizontal controls-row">
|
||||||
|
|
||||||
|
<div class="attr-type-wrap control-group">
|
||||||
|
<label class="attr control-label">Fields: </label>
|
||||||
|
<div class="attr controls">
|
||||||
|
<%= select_tag "fields_to_show_for_pp", options_for_select(@fields_to_show), prompt: "---Select something---" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a href="#" class="add-pp-field btn btn-info">Add Field</a>
|
||||||
|
<input type="hidden" name="plugin_key" value="<%= @page.module %>">
|
||||||
|
<input type="hidden" name="plugin_page_frontend_id" value="<%= @page.id.to_s %>">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(".current-fields").sortable();
|
||||||
|
var select = $("select#fields_to_show_for_pp");
|
||||||
|
$(".add-pp-field").on("click",function(){
|
||||||
|
var val = select.val(),
|
||||||
|
text = select.find("option:selected").text(),
|
||||||
|
li = null;
|
||||||
|
if(val != ""){
|
||||||
|
li = '<li class="clearfix" data-attrib-key="' + val + '"><span class="field-value">' + text + '</span><span class="remove-field"><i class="icon-remove-sign"></i></span></li>';
|
||||||
|
}
|
||||||
|
$("#modify_plugin_fields ul.current-fields").append(li);
|
||||||
|
})
|
||||||
|
$(document).on("click",".remove-field",function(){
|
||||||
|
$(this).parent().remove();
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<% else %>
|
||||||
|
<h3>Page not found.</h3>
|
||||||
|
<% end %>
|
|
@ -0,0 +1 @@
|
||||||
|
<%= render_view %>
|
|
@ -0,0 +1 @@
|
||||||
|
<%= render_view %>
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
||||||
|
|
||||||
|
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
||||||
|
ENGINE_PATH = File.expand_path('../../lib/personal_course/engine', __FILE__)
|
||||||
|
|
||||||
|
# Set up gems listed in the Gemfile.
|
||||||
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||||||
|
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
||||||
|
|
||||||
|
require 'rails/all'
|
||||||
|
require 'rails/engine/commands'
|
|
@ -0,0 +1,23 @@
|
||||||
|
en:
|
||||||
|
module_name:
|
||||||
|
personal_plugin_template: personal_plugin_template_translate
|
||||||
|
plugin_templates: personal_plugin_template_translate
|
||||||
|
plugin_template: personal_plugin_template_translate
|
||||||
|
personal_plugin_template:
|
||||||
|
extend_translate:
|
||||||
|
start_time: Start time
|
||||||
|
end_time: End time
|
||||||
|
start_date: Start date
|
||||||
|
end_date: End date
|
||||||
|
start_date_time: Start date & time
|
||||||
|
end_date_time: End date & time
|
||||||
|
start_year: Start year
|
||||||
|
end_year: End year
|
||||||
|
start_year_month: Start year/month
|
||||||
|
end_year_month: End year/month
|
||||||
|
total_number: Total number
|
||||||
|
select_class: "——select class——"
|
||||||
|
search_class: "search class:"
|
||||||
|
word_to_search: "word to search:"
|
||||||
|
graph_by: "Graph By"
|
||||||
|
col_name_translate_yaml
|
|
@ -0,0 +1,23 @@
|
||||||
|
zh_tw:
|
||||||
|
module_name:
|
||||||
|
personal_plugin_template: personal_plugin_template_translate
|
||||||
|
plugin_templates: personal_plugin_template_translate
|
||||||
|
plugin_template: personal_plugin_template_translate
|
||||||
|
personal_plugin_template:
|
||||||
|
extend_translate:
|
||||||
|
start_time: 開始時間
|
||||||
|
end_time: 結束時間
|
||||||
|
start_date: 開始日期
|
||||||
|
end_date: 結束日期
|
||||||
|
start_date_time: 開始日期時間
|
||||||
|
end_date_time: 結束日期時間
|
||||||
|
start_year: 開始年分
|
||||||
|
end_year: 結束年分
|
||||||
|
start_year_month: 開始年月
|
||||||
|
end_year_month: 結束年月
|
||||||
|
total_number: 總數量
|
||||||
|
select_class: "——選取分類——"
|
||||||
|
search_class: "搜尋類別:"
|
||||||
|
word_to_search: "關鍵字搜尋:"
|
||||||
|
graph_by: "Graph By"
|
||||||
|
col_name_translate_yaml
|
|
@ -0,0 +1,32 @@
|
||||||
|
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' => "module_modal_templates#setting"
|
||||||
|
resources :module_modal_templates do
|
||||||
|
collection do
|
||||||
|
get 'toggle_hide' => 'module_modal_templates#toggle_hide'
|
||||||
|
get 'analysis'
|
||||||
|
get 'analysis_report'
|
||||||
|
get "download_excel"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
resources :members do
|
||||||
|
collection do
|
||||||
|
scope '(:name-:uid)' do
|
||||||
|
resources :module_modal_templates do
|
||||||
|
collection do
|
||||||
|
get 'frontend_setting' => 'module_modal_templates#frontend_setting'
|
||||||
|
post 'update_frontend_setting' => 'module_modal_templates#update_frontend_setting'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
parse_again_start
|
||||||
|
resources :module_modal_relateds
|
||||||
|
parse_again_end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,4 @@
|
||||||
|
require "module_template/engine"
|
||||||
|
|
||||||
|
module ModuleTemplate
|
||||||
|
end
|
|
@ -0,0 +1,21 @@
|
||||||
|
module ModuleTemplate
|
||||||
|
class Engine < ::Rails::Engine
|
||||||
|
initializer "module_template" do
|
||||||
|
OrbitApp.registration "ModuleTemplate",:type=> 'ModuleApp' do
|
||||||
|
module_label 'module_key.module_modal_templates'
|
||||||
|
base_url File.expand_path File.dirname(__FILE__)
|
||||||
|
module :enable => true, :sort_number => '35', :app_name=>"ModuleModalTemplate", :intro_app_name=>"ModuleModalTemplateIntro",:path=>"/plugin/module_template/profile",:front_path=>"/profile",:admin_path=>"/admin/module_modal_templates/",:i18n=>'module_key.module_modal_templates', :module_app_name=>'ModuleModalTemplate', :one_line_title => enable_one_line_title, :field_modifiable => true, :analysis => true, :analysis_path => "/admin/module_modal_templates/analysis"
|
||||||
|
|
||||||
|
version "0.1"
|
||||||
|
desktop_enabled true
|
||||||
|
organization "Rulingcom"
|
||||||
|
author "RD dep"
|
||||||
|
intro "I am intro"
|
||||||
|
update_info 'some update_info'
|
||||||
|
frontend_enabled
|
||||||
|
icon_class_no_sidebar "icons-user"
|
||||||
|
data_count 1..10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,3 @@
|
||||||
|
module ModuleTemplate
|
||||||
|
VERSION = "0.0.1"
|
||||||
|
end
|
|
@ -0,0 +1,4 @@
|
||||||
|
# desc "Explaining what the task does"
|
||||||
|
# task :module_template do
|
||||||
|
# # Task goes here
|
||||||
|
# end
|
|
@ -0,0 +1,19 @@
|
||||||
|
$:.push File.expand_path("../lib", __FILE__)
|
||||||
|
|
||||||
|
# Maintain your gem's version:
|
||||||
|
require "module_template/version"
|
||||||
|
|
||||||
|
# Describe your gem and declare its dependencies:
|
||||||
|
Gem::Specification.new do |s|
|
||||||
|
s.name = "module_template"
|
||||||
|
s.version = ModuleTemplate::VERSION
|
||||||
|
s.authors = ["Bohung"]
|
||||||
|
s.email = ["bohung@rulingcom.com"]
|
||||||
|
s.homepage = "http://www.rulingcom.com"
|
||||||
|
s.summary = "module_template_description."
|
||||||
|
s.description = "module_template_description."
|
||||||
|
s.license = "MIT"
|
||||||
|
|
||||||
|
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
|
||||||
|
s.test_files = Dir["test/**/*"]
|
||||||
|
end
|
|
@ -0,0 +1,23 @@
|
||||||
|
<table class="table table-hover table-striped projects-index module_modal_templates-index dt-responsive nowrap">
|
||||||
|
<caption><h3>{{widget-title}}</h3></caption>
|
||||||
|
<thead>
|
||||||
|
<tr data-level="0" data-list="headers">
|
||||||
|
<th class="col-md-{{col}}">{{head-title}}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody data-level="0" data-list="module_modal_templates">
|
||||||
|
<tr data-level="1" data-list="jps">
|
||||||
|
<td>{{value}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{pagination_goes_here}}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('table.module_modal_templates-index').DataTable({
|
||||||
|
searching: false,
|
||||||
|
paging: false,
|
||||||
|
ordering: false,
|
||||||
|
info: false
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -0,0 +1,48 @@
|
||||||
|
<script type="text/javascript">
|
||||||
|
$( ".selectbox" ).ready(function() {
|
||||||
|
var option_len = $(".search-widget option").length
|
||||||
|
for (var i=0;i<option_len;i++){
|
||||||
|
if($(".search-widget option").eq(i).data('selected')=="selected"){
|
||||||
|
$(".search-widget option").eq(i).attr('selected','selected')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<h3>{{widget-title}}</h3>
|
||||||
|
<div class="search-widget">
|
||||||
|
<form action="{{url}}" method="get">
|
||||||
|
<input type="hidden" name="authenticity_token" value="{{csrf_value}}">
|
||||||
|
{{select_text}}
|
||||||
|
<select class="selectbox" name="selectbox" data-level="0" data-list="choice">
|
||||||
|
<option value={{choice_value}} data-selected='{{choice_select}}' >
|
||||||
|
{{choice_show}}</option>
|
||||||
|
</select>
|
||||||
|
{{search_text}}
|
||||||
|
<input name="keywords" placeholder="Keywords" type="text" value="{{search_value}}">
|
||||||
|
<button>Go</button>
|
||||||
|
<a id="filter" style="" href="{{url}}">Clear</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<table class="table table-hover table-striped module_modal_templates-index dt-responsive nowrap">
|
||||||
|
<caption style="display: none;"><h3>{{widget-title}}</h3></caption>
|
||||||
|
<thead>
|
||||||
|
<tr data-level="0" data-list="headers">
|
||||||
|
<th class="col-md-{{col}}">{{head-title}}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody data-level="0" data-list="module_modal_templates">
|
||||||
|
<tr data-level="1" data-list="jps">
|
||||||
|
<td>{{value}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{pagination_goes_here}}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('table.module_modal_templates-index').DataTable({
|
||||||
|
searching: false,
|
||||||
|
paging: false,
|
||||||
|
ordering: false,
|
||||||
|
info: false
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"frontend": [
|
||||||
|
{
|
||||||
|
"filename" : "index",
|
||||||
|
"name" : {
|
||||||
|
"zh_tw" : "1. 列表",
|
||||||
|
"en" : "1. List"
|
||||||
|
},
|
||||||
|
"thumbnail" : "thumb.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "index_search1",
|
||||||
|
"name" : {
|
||||||
|
"zh_tw" : "2. 列表(含搜尋)",
|
||||||
|
"en" : "2. List which includes search"
|
||||||
|
},
|
||||||
|
"thumbnail" : "thumb.png"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
<table class="table table-striped plugin-show-table">
|
||||||
|
<tbody data-list="plugin_datas" data-level="0">
|
||||||
|
<tr>
|
||||||
|
<th class="{{title_class}}">{{title}}</th>
|
||||||
|
<td class="{{value_class}}">{{value}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
|
@ -0,0 +1,28 @@
|
||||||
|
== README
|
||||||
|
|
||||||
|
This README would normally document whatever steps are necessary to get the
|
||||||
|
application up and running.
|
||||||
|
|
||||||
|
Things you may want to cover:
|
||||||
|
|
||||||
|
* Ruby version
|
||||||
|
|
||||||
|
* System dependencies
|
||||||
|
|
||||||
|
* Configuration
|
||||||
|
|
||||||
|
* Database creation
|
||||||
|
|
||||||
|
* Database initialization
|
||||||
|
|
||||||
|
* How to run the test suite
|
||||||
|
|
||||||
|
* Services (job queues, cache servers, search engines, etc.)
|
||||||
|
|
||||||
|
* Deployment instructions
|
||||||
|
|
||||||
|
* ...
|
||||||
|
|
||||||
|
|
||||||
|
Please feel free to use a different markup language if you do not plan to run
|
||||||
|
<tt>rake doc:app</tt>.
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||||
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||||
|
|
||||||
|
require File.expand_path('../config/application', __FILE__)
|
||||||
|
|
||||||
|
Rails.application.load_tasks
|
|
@ -0,0 +1,13 @@
|
||||||
|
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||||
|
// listed below.
|
||||||
|
//
|
||||||
|
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||||
|
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
||||||
|
//
|
||||||
|
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||||
|
// compiled file.
|
||||||
|
//
|
||||||
|
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
||||||
|
// about supported directives.
|
||||||
|
//
|
||||||
|
//= require_tree .
|
|
@ -0,0 +1,15 @@
|
||||||
|
/*
|
||||||
|
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||||
|
* listed below.
|
||||||
|
*
|
||||||
|
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
||||||
|
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
||||||
|
*
|
||||||
|
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
||||||
|
* compiled file so the styles you add here take precedence over styles defined in any styles
|
||||||
|
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
||||||
|
* file per style scope.
|
||||||
|
*
|
||||||
|
*= require_tree .
|
||||||
|
*= require_self
|
||||||
|
*/
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ApplicationController < ActionController::Base
|
||||||
|
# Prevent CSRF attacks by raising an exception.
|
||||||
|
# For APIs, you may want to use :null_session instead.
|
||||||
|
protect_from_forgery with: :exception
|
||||||
|
end
|
|
@ -0,0 +1,2 @@
|
||||||
|
module ApplicationHelper
|
||||||
|
end
|
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Dummy</title>
|
||||||
|
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
||||||
|
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
||||||
|
<%= csrf_meta_tags %>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<%= yield %>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||||||
|
load Gem.bin_path('bundler', 'bundle')
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
||||||
|
require_relative '../config/boot'
|
||||||
|
require 'rails/commands'
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
require_relative '../config/boot'
|
||||||
|
require 'rake'
|
||||||
|
Rake.application.run
|
|
@ -0,0 +1,4 @@
|
||||||
|
# This file is used by Rack-based servers to start the application.
|
||||||
|
|
||||||
|
require ::File.expand_path('../config/environment', __FILE__)
|
||||||
|
run Rails.application
|
|
@ -0,0 +1,23 @@
|
||||||
|
require File.expand_path('../boot', __FILE__)
|
||||||
|
|
||||||
|
require 'rails/all'
|
||||||
|
|
||||||
|
Bundler.require(*Rails.groups)
|
||||||
|
require "personal_course"
|
||||||
|
|
||||||
|
module Dummy
|
||||||
|
class Application < Rails::Application
|
||||||
|
# Settings in config/environments/* take precedence over those specified here.
|
||||||
|
# Application configuration should go into files in config/initializers
|
||||||
|
# -- all .rb files in that directory are automatically loaded.
|
||||||
|
|
||||||
|
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||||
|
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
||||||
|
# config.time_zone = 'Central Time (US & Canada)'
|
||||||
|
|
||||||
|
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
||||||
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
||||||
|
# config.i18n.default_locale = :de
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue