First push.

This commit is contained in:
BoHung Chiu 2022-10-24 17:05:06 +08:00
commit b379b6e0ff
95 changed files with 2762 additions and 0 deletions

8
.gitignore vendored Normal file
View File

@ -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

14
Gemfile Normal file
View File

@ -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'

20
MIT-LICENSE Normal file
View File

@ -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.

3
README.rdoc Normal file
View File

@ -0,0 +1,3 @@
= PersonalTechnique
This project rocks and uses MIT-LICENSE.

34
Rakefile Normal file
View File

@ -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 = 'PersonalTechnique'
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

View File

@ -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 .

View File

@ -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
*/

View File

@ -0,0 +1,43 @@
class Admin::TechniqueStatusesController < OrbitMemberController
def index
end
def new
@technique_status = TechniqueStatus.new
@url = admin_technique_statuses_path
end
def edit
@technique_status = TechniqueStatus.find(params[:id])
@url = admin_technique_status_path(@technique_status)
end
def create
technique_status = TechniqueStatus.create(technique_status_params)
@technique_statuses = TechniqueStatus.all
end
def update
technique_status = TechniqueStatus.find(params[:id]) rescue nil
if !technique_status.nil?
technique_status.update_attributes(technique_status_params)
end
@technique_statuses = TechniqueStatus.all
end
def destroy
technique_status = TechniqueStatus.find(params[:id]) rescue nil
if !technique_status.nil?
technique_status.destroy
end
@technique_statuses = TechniqueStatus.all
end
private
def technique_status_params
params.require(:technique_status).permit!
end
end

View File

@ -0,0 +1,150 @@
class Admin::TechniquesController < OrbitMemberController
include Admin::TechniquesHelper
layout "member_plugin"
before_action :set_technique, 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?
@techniques = Technique.order_by(sort).page(params[:page]).per(10)
else
@techniques = Technique.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
@technique = Technique.new
end
def create
technique = Technique.create(technique_params)
redirect_to params[:referer_url]
end
def show
end
def analysis
end
def analysis_report
role = params[:role_id]
issue_date_start = params[:issue_date_start]
issue_date_end = params[:issue_date_end]
graph_by = params[:graph_by]
@data = get_chart_data(issue_date_start,issue_date_end,role,params[:graph_by],params[:time_zone])
render :layout => false
end
def download_excel
issue_date_start = params[:issue_date_start]
issue_date_end = params[:issue_date_end]
@data = get_data_for_excel(issue_date_start,issue_date_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="techniques.xlsx"'
}
end
end
def edit
end
def destroy
@technique.destroy
redirect_to admin_techniques_path(:page => params[:page])
end
def update
@technique.update_attributes(technique_params)
@technique.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 = TechniqueIntro.find_by(:member_profile_id=>@member.id) rescue nil
@intro = @intro.nil? ? TechniqueIntro.new({:member_profile_id=>@member.id}) : @intro
end
def update_frontend_setting
@member = MemberProfile.find(intro_params['member_profile_id']) rescue nil
@intro = TechniqueIntro.find_by(:member_profile_id=>@member.id) rescue nil
@intro = @intro.nil? ? TechniqueIntro.new({:member_profile_id=>@member.id}) : @intro
@intro.update_attributes(intro_params)
@intro.save
redirect_to URI.encode('/admin/members/'+@member.to_param+'/Technique')
end
def toggle_hide
if params[:ids]
@projects = Technique.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 technique_params
params.require(:technique).permit!
end
def intro_params
params.require(:technique_intro).permit! rescue nil
end
def get_settings
@technique_statuses = TechniqueStatus.all
end
def set_plugin
@plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'Technique'}.first
end
def set_technique
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
@technique = Technique.find_by(:uid => uid) rescue Technique.find(params[:id])
end
end

View File

@ -0,0 +1,207 @@
class PersonalTechniquesController < ApplicationController
include Admin::TechniquesHelper
def index
params = OrbitHelper.params
techniques = Technique.sort_for_frontend
page = OrbitHelper.page rescue Page.where(page_id: params[:page_id]).first
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 = ["title", "member_profile", "issue_date", "newsletter", "vol_no", "isbn", "url", "technique_status.status"]
end
else
fields_to_show = ["issue_date", "title"]
end
if params[:keywords].present?
techniques = filter_keywords(techniques,params[:selectbox],params[:keywords])
end
techniques = techniques.page(params[:page_no]).per(OrbitHelper.page_data_count)
techniques_list = techniques.collect do |technique|
{'jps' => fields_to_show.map{|field| {"value"=> get_display_field(technique,field, title_is_paper_format)}}}
end
extras = {"th-title" => I18n.t("personal_technique.title"), "th-member_profile" => I18n.t("personal_technique.member_profile"), "th-issue_date" => I18n.t("personal_technique.issue_date"), "th-newsletter" => I18n.t("personal_technique.newsletter"), "th-vol_no" => I18n.t("personal_technique.vol_no"), "th-isbn" => I18n.t("personal_technique.isbn"), "th-url" => I18n.t("personal_technique.url"), "th-technique_status.status" => I18n.t("personal_technique.technique_status.status")}
choice_show = []
headers = []
fields_to_show.each do |fs|
col = 2
col = 3 if fs == 'title'
headers << {
'head-title' => t("personal_technique.#{fs}"),
'col' => col
}
choice_show << t("personal_technique.#{fs}")
end
choice_value = fields_to_show
choice_value.unshift('default')
choice_select = choice_value.map { |iter| iter == params[:selectbox] ? 'selected' : '' }
choice_select = choice_select.map { |value| { 'choice_select' => value } }
choice_value = choice_value.map { |value| { 'choice_value' => value } }
choice_default = t('personal_technique.extend_translate.select_class')
choice_show.unshift(choice_default)
choice_show = choice_show.map { |value| { 'choice_show' => value } }
choice = choice_value.zip(choice_show, choice_select)
choice = choice.map { |value| value.inject :merge }
select_text = t('personal_technique.extend_translate.search_class')
search_text = t('personal_technique.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_name.personal_technique")
{
"techniques" => techniques_list,
"headers" => headers,
"extras" => extras,
"total_pages" => techniques.total_pages,
'choice' => choice
}
end
def show
params = OrbitHelper.params
plugin = Technique.where(:is_hidden=>false).find_by(uid: params[:uid].to_s)
fields_to_show = ["title", "member_profile", "issue_date", "newsletter", "vol_no", "isbn", "url", "technique_status.status", "keywords", "note"]
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
end
def get_display_field(technique,field, title_is_paper_format=false)
text_only = false
value = technique.send(field) rescue ""
if field.include?(".")
value = technique
field.split(".").each{|f| value = value.send(f) rescue nil }
end
file_fields = []
link_fields = []
member_fields = []
if file_fields.include?(field)
files = technique.send(field.pluralize)
value = files.map do |file|
url = file.file.url
title = (file.title.blank? ? File.basename(file.file.path) : file.title)
"<li><a href='#{url}'' target='_blank'>#{title}</li>"
end
value = value.join("")
elsif link_fields.include?(field)
links = technique.send(field.pluralize)
value = links.map do |link|
url = link.url
title = (link.title.blank? ? url : link.title)
"<li><a href='#{url}'' target='_blank'>#{title}</li>"
end
value = value.join("")
elsif member_fields.include?(field)
members = technique.send(field.pluralize)
value = members.map{|m|
path = OrbitHelper.url_to_plugin_show(m.to_param, 'member') rescue '#'
((text_only rescue false) ? m.name : "<a href='#{path}'>#{m.name}</a>")
}
join_text = (text_only rescue false) ? "," : "<br>"
value = value.join(join_text)
elsif field == "member_profile" || field == "authors"
value = get_authors_show(technique)
end
strftime_hash = {"issue_date"=>"%Y/%m"}
if strftime_hash.keys.include?(field)
value = value.strftime(strftime_hash[field]) rescue value
end
if field == "title"
link = OrbitHelper.url_to_plugin_show(technique.to_param,'personal_technique')
tmp_title = (title_is_paper_format ? technique.create_link : value)
value = link == '#' ? tmp_title : "<a href='#{link}' target='_blank' title='#{tmp_title}'>#{tmp_title}</a>"
end
value
return value
end
def get_fields_for_index
@page = Page.find(params[:page_id]) rescue nil
@fields_to_show = ["title", "issue_date", "newsletter", "vol_no", "isbn", "url", "technique_status.status", "note", "keywords"]
@fields_to_show = @fields_to_show.map { |fs| [t("personal_technique.#{fs}"), fs] }
if @page.present? && @page.custom_string_field == 'table'
@default_fields_to_show = ["title", "member_profile", "issue_date", "newsletter", "vol_no", "isbn", "url", "technique_status.status"]
else
@default_fields_to_show = ["issue_date", "title"]
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(techniques,select_field,keywords)
member_fields = []
file_fields = []
link_fields = []
if select_field == "default"
techniques = techniques.where(:slug_title=>/#{gsub_invalid_character(keywords)}/)
elsif select_field == "member_profile"
ms = MemberProfile.all.select{|m| m.name.include?(keywords)}
techniques = techniques.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_techniques = techniques.select{|p| (p.send("#{select_field.singularize}_ids") & m_ids).count != 0}
techniques = techniques.where(:id.in=>tmp_techniques.map{|p| p.id})
elsif select_field.split(".").count > 1
relate_name = select_field.split(".").first
field_name = select_field.split(".").last
relate = relate_name.classify.constantize
relate_ids = relate.where(field_name=>/#{gsub_invalid_character(keywords)}/).pluck(:id)
techniques = techniques.where("#{relate_name.singularize}_id"=>{'$in'=>relate_ids})
elsif (Technique.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")
techniques = techniques.where(select_field=>{'$gte'=>start_time,'$lte'=>end_time})
end
elsif (Technique.fields[select_field].options[:type] == DateTime rescue false)
keywords = keywords.split(/[\/\-]/)
if keywords.count > 1
DateTime.parse(keywords.join("/"))
elsif keywords[0].include?(":")
tmp_techniques = techniques.select{|p| (p.send(select_field).strftime('%Y/%m/%d %H:%M').include?(keywords[0]) rescue false)}
techniques = techniques.where(:id.in=>tmp_techniques.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")
techniques = techniques.where(select_field=>{'$gte'=>start_time,'$lte'=>end_time})
end
elsif (Technique.fields[select_field].options[:type] == Integer rescue false)
tmp_techniques = techniques.select{|p| p.send(select_field).to_s.include?(keywords)}
techniques = techniques.where(:id.in=>tmp_techniques.map{|p| p.id})
elsif file_fields.include?(select_field)
file_field = select_field.classify.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_techniques = techniques.select{|p| (p.send("#{select_field}_ids") & ids).count != 0}
techniques = techniques.where(:id.in=>tmp_techniques.map{|p| p.id})
elsif link_fields.include?(select_field)
link_field = select_field.classify.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_techniques = techniques.select{|p| (p.send("#{select_field}_ids") & ids).count != 0}
techniques = techniques.where(:id.in=>tmp_techniques.map{|p| p.id})
else
techniques = techniques.where(select_field=>/#{gsub_invalid_character(keywords)}/)
end
return techniques
end
def gsub_invalid_character(text)
text.to_s.gsub(/(\/|\*|\\|\]|\[|\(|\)|\.|\+|\?|\!)/){|ff| "\\"+ff}
end
end

View File

@ -0,0 +1,188 @@
module Admin::TechniquesHelper
include OrbitBackendHelper
include OrbitFormHelper
alias :org_datetime_picker :datetime_picker
def get_authors_text(technique, is_to_sentence=false, locale=nil)
authors_text = Nokogiri::HTML(technique.authors.to_s).text
split_text = authors_text.match(/[、,,\/]/)
split_text = split_text.nil? ? '/' : split_text[0]
full_authors_names = get_member(technique).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(technique, is_to_sentence=false, locale=nil)
authors_text = Nokogiri::HTML(technique.authors.to_s).text
split_text = authors_text.match(/[、,,\/]/)
split_text = split_text.nil? ? '/' : split_text[0]
full_authors_names = []
full_authors = get_member(technique).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(technique)
Array(MemberProfile.where(:id.in=>Array(technique).collect(&:member_profile_id).flatten))
end
def get_member_show(technique)
get_member(technique).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_technique(technique_object)
page = Page.where(:module=>"personal_technique").first
("/#{I18n.locale}"+page.url+'/'+technique_object.to_param).gsub('//','/') rescue "#"
end
def get_data_for_excel(issue_date_start,issue_date_end,timezone)
issue_date_start = parse_date_time_field("issue_date",issue_date_start,timezone)
issue_date_end = parse_date_time_field("issue_date",issue_date_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(Technique, issue_date_start, issue_date_end, mps)
data << d
end
return data
end
def filter_data(data,issue_date_start,issue_date_end,mps = nil)
result = []
if @periodic
all_ids = data.all.pluck(:id) rescue []
out_of_range_ids1 = data.where(:issue_date_start.gt => issue_date_end).pluck(:id) rescue []
out_of_range_ids2 = data.where(:issue_date_end.lt => issue_date_start).pluck(:id) rescue []
result = data.where(:id.in=>(all_ids - out_of_range_ids1 - out_of_range_ids2)) rescue []
else
result = data.where(:issue_date.gte => issue_date_start, :issue_date.lte => issue_date_end) rescue []
end
result = result.where(:member_profile_id.in => mps) rescue [] unless mps.nil?
return result
end
def get_chart_data(issue_date_start,issue_date_end,role,type,timezone)
issue_date_start = parse_date_time_field("issue_date",issue_date_start,timezone)
issue_date_end = parse_date_time_field("issue_date",issue_date_end,timezone)
main_field_name = ""
time_fields = []
max_iterate = 20
iterate_step = 1.minute
iterate_count = ((issue_date_end - issue_date_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 = []
when "technique_status"
jls = TechniqueStatus.all
main_field_name = "status"
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(issue_date_start,issue_date_end,iterate_step) do |issue_date|
next_issue_date = issue_date + iterate_step
current_issue_date = issue_date
current_issue_date = issue_date.strftime("%H:%M") if time_fields.include?("issue_date")
next_issue_date = next_issue_date.strftime("%H:%M") if time_fields.include?("issue_date")
t = filter_data(jl.techniques, current_issue_date, next_issue_date, mps)
if current_issue_date.class == DateTime
current_issue_date = display_date_time(current_issue_date,timezone,iterate_step)
end
data["data"][current_issue_date.to_s] = t
end
finaldata << data
end
data = {"name" => "N/A", "data" => {}}
time_iterate(issue_date_start,issue_date_end,iterate_step) do |issue_date|
next_issue_date = issue_date + iterate_step
current_issue_date = issue_date
current_issue_date = issue_date.strftime("%H:%M") if time_fields.include?("issue_date")
next_issue_date = next_issue_date.strftime("%H:%M") if time_fields.include?("issue_date")
case type
when "default"
t = filter_data(Technique, current_issue_date, next_issue_date, mps).count rescue 0
when "technique_status"
t = filter_data(Technique, current_issue_date, next_issue_date, mps).where(:technique_status_id => nil).count rescue 0
else
t = filter_data(Technique, current_issue_date, next_issue_date, mps).count rescue 0
end
current_issue_date = current_issue_date.new_offset(timezone) if current_issue_date.class == DateTime
if current_issue_date.class == DateTime
current_issue_date = display_date_time(current_issue_date,timezone,iterate_step)
end
data["data"][current_issue_date.to_s] = t
end
finaldata << data
finaldata
end
def parse_date_time_field(field,value,timezone="+08:00")
time_fields = []
type = Technique.fields[field].type rescue nil
if type.nil?
@periodic = true
type = Technique.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

207
app/models/technique.rb Normal file
View File

@ -0,0 +1,207 @@
class Technique
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include MemberHelper
include Admin::TechniquesHelper
include Slug
field :title, :type => String, :default => "", :localize => true, as: :slug_title
field :issue_date, :type => DateTime, :default => DateTime.now
field :newsletter, :type => String, :default => "", :localize => true
field :vol_no, :type => String, :default => ""
field :isbn, :type => String, :default => ""
field :url, :type => String, :default => ""
field :keywords, :type => String, :default => ""
field :note, :type => String, :default => ""
field :authors, :type => String, :default => "", :localize => true
belongs_to :technique_status
field :rss2_id
belongs_to :member_profile
index({:issue_date=>-1, :id=>-1}, { unique: false, background: false })
scope :sort_hash, ->{ order_by({:issue_date=>-1, :id=>-1}) }
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by({:issue_date=>-1, :id=>-1}) }
before_save do
end
def parse_time(time_str)
DateTime.parse("0000-01-01 " + time_str)
end
def create_link
title = ''
title += get_authors_text(self, true, :en) if self.authors.present? || self.member_profile_id.present?
title += ",\"#{self.title},\"" if self.title.present?
title += " #{self.newsletter}" if self.newsletter.present?
title += " #{self.vol_no}" if self.vol_no.present?
title += ", #{self.issue_date.strftime('%b. %Y')}" if self.issue_date.present?
title.sub(/^\s*,/,'').gsub(/,(\s*,)+/,',')
end
def self.get_plugin_datas_to_member(datas)
page = Page.where(:module => "personal_technique").first rescue nil
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 = ["title", "issue_date", "newsletter", "url"]
end
else
fields_to_show = ["issue_date", "title"]
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 [].include?(t)
fields_to_remove << t if (datas.select{|d| d.send(t) != " ~ " }.count == 0 rescue false)
else
fields_to_remove << t if (datas.where(t.to_sym.ne => nil).count == 0 rescue false)
end
pd_title << {
"plugin_data_title" => I18n.t("personal_technique.#{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
{
"pd_datas" => pd_data,
"type-sort" => (p.technique_status.sort_position.to_i rescue 1000),
"sort-index" => idx
}
end
plugin_datas = plugin_datas.sort_by{|pd| [pd["type-sort"], pd["sort-index"]]}
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)
technique = self
value = technique.send(field) rescue ""
if field.include?(".")
value = technique
field.split(".").each{|f| value = value.send(f) rescue nil }
end
file_fields = []
link_fields = []
member_fields = []
if file_fields.include?(field)
files = technique.send(field.pluralize)
value = files.map do |file|
url = file.file.url
title = (file.title.blank? ? File.basename(file.file.path) : file.title)
"<li><a href='#{url}'' target='_blank'>#{title}</li>"
end
value = value.join("")
elsif link_fields.include?(field)
links = technique.send(field.pluralize)
value = links.map do |link|
url = link.url
title = (link.title.blank? ? url : link.title)
"<li><a href='#{url}'' target='_blank'>#{title}</li>"
end
value = value.join("")
elsif member_fields.include?(field)
members = technique.send(field.pluralize)
value = members.map{|m|
path = OrbitHelper.url_to_plugin_show(m.to_param, 'member') rescue '#'
((text_only rescue false) ? m.name : "<a href='#{path}'>#{m.name}</a>")
}
join_text = (text_only rescue false) ? "," : "<br>"
value = value.join(join_text)
elsif field == "member_profile" || field == "authors"
value = get_authors_show(technique)
end
strftime_hash = {"issue_date"=>"%Y/%m"}
if strftime_hash.keys.include?(field)
value = value.strftime(strftime_hash[field]) rescue value
end
value
value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "<a href='#{value}' target='blank'>#{value}</a>" : value
{
"key"=>field,
"title_class"=>"technique-#{field.gsub('_','-')}-field",
"value_class"=>"technique-#{field.gsub('_','-')}-value",
"title"=>I18n.t('personal_technique.'+field),
"value"=>value
}
end
def display_field(field,text_only=false,title_is_paper_format=false)
technique = self
value = technique.send(field) rescue ""
if field.include?(".")
value = technique
field.split(".").each{|f| value = value.send(f) rescue nil }
end
file_fields = []
link_fields = []
member_fields = []
if file_fields.include?(field)
files = technique.send(field.pluralize)
value = files.map do |file|
url = file.file.url
title = (file.title.blank? ? File.basename(file.file.path) : file.title)
"<li><a href='#{url}'' target='_blank'>#{title}</li>"
end
value = value.join("")
elsif link_fields.include?(field)
links = technique.send(field.pluralize)
value = links.map do |link|
url = link.url
title = (link.title.blank? ? url : link.title)
"<li><a href='#{url}'' target='_blank'>#{title}</li>"
end
value = value.join("")
elsif member_fields.include?(field)
members = technique.send(field.pluralize)
value = members.map{|m|
path = OrbitHelper.url_to_plugin_show(m.to_param, 'member') rescue '#'
((text_only rescue false) ? m.name : "<a href='#{path}'>#{m.name}</a>")
}
join_text = (text_only rescue false) ? "," : "<br>"
value = value.join(join_text)
elsif field == "member_profile" || field == "authors"
value = get_authors_show(technique)
end
strftime_hash = {"issue_date"=>"%Y/%m"}
if strftime_hash.keys.include?(field)
value = value.strftime(strftime_hash[field]) rescue value
end
if field == "title"
link = OrbitHelper.url_to_plugin_show(technique.to_param,'personal_technique')
tmp_title = (title_is_paper_format ? technique.create_link : value)
value = link == '#' ? tmp_title : "<a href='#{link}' target='_blank' title='#{tmp_title}'>#{tmp_title}</a>"
end
value
end
end

View File

@ -0,0 +1,3 @@
class TechniqueIntro < PersonalPluginIntro
end

View File

@ -0,0 +1,9 @@
class TechniqueStatus
include Mongoid::Document
include Mongoid::Timestamps
field :status, :type => String, :default => "", :localize => true
field :sort_position, type: Integer, default: 0
has_many :techniques
end

View File

@ -0,0 +1,33 @@
<%= form_for(@technique_status, :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("personal_technique.technique_status.status") %></h3>
</div>
<div class="modal-body">
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.technique_status.status") %></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="status_<%=locale%>">
<%= f.fields_for :status_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_technique.technique_status.status"), value: (@technique_status.status_translations[locale] rescue nil) %>
<% end %>
</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="#status_<%=locale%>" data-toggle="tab"><%= t(locale) %></a>
<% end %>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div>
<% end %>

View File

@ -0,0 +1,2 @@
$("#technique_statuses").html("<%= j render :partial => '/admin/techniques/technique_status' %>");
$("#technique_status_modal").modal("hide");

View File

@ -0,0 +1,2 @@
$("#technique_statuses").html("<%= j render :partial => '/admin/techniques/technique_status' %>");
$("#technique_status_modal").modal("hide");

View File

@ -0,0 +1 @@
$('#technique_status_modal').html("<%= j render 'form' %>");

View File

@ -0,0 +1 @@
$('#technique_status_modal').html("<%= j render 'form' %>");

View File

@ -0,0 +1,2 @@
$("#technique_statuses").html("<%= j render :partial => '/admin/techniques/technique_status' %>");
$("#technique_status_modal").modal("hide");

View File

@ -0,0 +1,291 @@
<% # 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" : '' %>">
<!-- title -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_technique.title") %></label>
<div class="controls">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_technique.title"), value: (@technique.title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- newsletter -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_technique.newsletter") %></label>
<div class="controls">
<%= f.fields_for :newsletter_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_technique.newsletter"), value: (@technique.newsletter_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- authors -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_technique.authors") %></label>
<div class="controls">
<%= f.fields_for :authors_translations do |f| %>
<%= f.text_area locale, class: "input-block-level ckeditor", placeholder: t("personal_technique.authors"), value: (@technique.authors_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<% end %>
<!-- Link -->
<%
links_hash = {}
[].each do |link|
hash = {}
hash["html"] = add_attribute("form_link", f, link.pluralize.to_sym)
hash["count"] = @technique.send(link.pluralize).count rescue 0
links_hash[link] = hash
%>
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.#{link}") %></label>
<div class="controls">
<!-- Exist -->
<% if !@technique.new_record? && hash["count"] > 0 %>
<div class="exist">
<% @technique.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 = {}
[].each do |file|
hash = {}
hash["html"] = add_attribute("form_file", f, file.pluralize.to_sym)
hash["count"] = @technique.send(file.pluralize).count rescue 0
files_hash[file] = hash
%>
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.#{file}") %></label>
<div class="controls">
<!-- Exist -->
<% if !@technique.new_record? && hash["count"] > 0 %>
<div class="exist">
<% @technique.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("personal_technique.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("personal_technique.member_profile") %></label>
<div class="controls">
<% members = !@technique.member_profile.nil? ? @technique.member_profile.to_a : [] %>
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'technique[member_profile_id][]', email_members: members,index:'0',select_name:'member_profile_id'} %>
</div>
</div>
<% end %>
<!-- issue_date -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.issue_date") %></label>
<div class="controls">
<%= f.datetime_picker "issue_date",:format => "yyyy/MM", :no_label => true, :new_record => @technique.new_record? %>
</div>
</div>
<!-- vol_no -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.vol_no") %></label>
<div class="controls">
<%= f.text_field "vol_no", class: "input-block-level", placeholder: t("personal_technique.vol_no"), value: (@technique.vol_no rescue nil) %>
</div>
</div>
<!-- isbn -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.isbn") %></label>
<div class="controls">
<%= f.text_field "isbn", class: "input-block-level", placeholder: t("personal_technique.isbn"), value: (@technique.isbn rescue nil) %>
</div>
</div>
<!-- url -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.url") %></label>
<div class="controls">
<%= f.text_field "url", class: "input-block-level", placeholder: t("personal_technique.url"), value: (@technique.url rescue nil) %>
</div>
</div>
<!-- keywords -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.keywords") %></label>
<div class="controls">
<%= f.text_field "keywords", class: "input-block-level", placeholder: t("personal_technique.keywords"), value: (@technique.keywords rescue nil) %>
</div>
</div>
<!-- note -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_technique.note") %></label>
<div class="controls">
<%= f.text_area "note", class: "input-block-level ckeditor", placeholder: t("personal_technique.note"), value: (@technique.note rescue nil) %>
</div>
</div>
<!-- technique_status -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_technique.technique_status.status") %></label>
<div class="controls">
<%= f.select :technique_status_id, TechniqueStatus.all.collect {|t| [ t.status, t.id ]}, { include_blank: true } %>
</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 @technique.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>

View File

@ -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>

View File

@ -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>

View File

@ -0,0 +1,19 @@
<thead>
<tr>
<th><%= t("personal_technique.technique_status.status") %></th>
<th><%= t(:action) %></th>
</tr>
</thead>
<tbody>
<% @technique_statuses.each do |technique_status| %>
<tr id="<%= dom_id technique_status %>">
<td><%= technique_status.status %></td>
<td class="span2">
<a href="<%= edit_admin_technique_status_path(technique_status) %>#technique_status_modal" data-toggle="modal" data-remote="true" class="action">
<%= t(:edit) %>
</a>
<%= link_to t(:delete_), admin_technique_status_path(technique_status), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %>
</td>
</tr>
<% end %>
</tbody>

View File

@ -0,0 +1,16 @@
<% @techniques.each do |technique| %>
<tr id="<%= dom_id technique %>" class="with_action">
<td>
<%= link_to technique.title, page_for_technique(technique), target: "blank" %>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('edit'), edit_admin_technique_path(technique,:page => params[:page]) %></li>
<li><%= link_to t(:delete_), admin_technique_path(id: technique.id, :page => params[:page]), method: :delete, data: { confirm: 'Are you sure?' } %></li>
</ul>
</div>
</td>
<td> <%= technique.issue_date.strftime('%Y/%m') rescue "" %> </td>
<td> <%= technique.newsletter %> </td>
<td> <%= technique.display_field("member_profile").html_safe rescue "" %> </td>
</tr>
<% end %>

View File

@ -0,0 +1,116 @@
<% # 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 {