Add sortable.
This commit is contained in:
parent
6dc3bba750
commit
b2f3e2e9c2
|
@ -299,6 +299,13 @@ class Admin::PersonalPluginFieldsController < OrbitMemberController
|
||||||
period_fields = primary_modal_fields.select{|f| (f[:periodic_time] == "1" rescue false)}.map{|f| f[:field_name]}
|
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]}
|
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("\r\n")
|
before_save_codes = ""#time_fields.map{|f| "self.#{f} = parse_time(self.#{f}.strftime('%H:%M'))"}.join("\r\n")
|
||||||
|
plugin_template_sort_hash = {}
|
||||||
|
@personal_plugin_field.backend_fields[:sort_asc].to_a.each do |f|
|
||||||
|
plugin_template_sort_hash[f] = 1
|
||||||
|
end rescue nil
|
||||||
|
@personal_plugin_field.backend_fields[:sort_desc].to_a.each do |f|
|
||||||
|
plugin_template_sort_hash[f] = -1
|
||||||
|
end rescue nil
|
||||||
@match_pattern = {"personal_plugin_template" => personal_plugin_template,
|
@match_pattern = {"personal_plugin_template" => personal_plugin_template,
|
||||||
"plugin_template" => plugin_template,
|
"plugin_template" => plugin_template,
|
||||||
"plugin_template_related" => plugin_template_related,
|
"plugin_template_related" => plugin_template_related,
|
||||||
|
@ -311,7 +318,7 @@ class Admin::PersonalPluginFieldsController < OrbitMemberController
|
||||||
"col_related_fields" => col_related_fields,
|
"col_related_fields" => col_related_fields,
|
||||||
"plugin_template_file" => plugin_template_related_files,
|
"plugin_template_file" => plugin_template_related_files,
|
||||||
"plugin_template_link" => plugin_template_related_links,
|
"plugin_template_link" => plugin_template_related_links,
|
||||||
"plugin_template_sort_hash" => "nil",
|
"plugin_template_sort_hash" => plugin_template_sort_hash.to_s,
|
||||||
"col_name_to_show_in_index_page_arr" => col_name_to_show_in_index_page,
|
"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" => related_backend_index_fields,
|
||||||
"related_backend_index_fields_contents" => related_backend_index_fields_contents,
|
"related_backend_index_fields_contents" => related_backend_index_fields_contents,
|
||||||
|
@ -353,6 +360,7 @@ class Admin::PersonalPluginFieldsController < OrbitMemberController
|
||||||
copy_templates("#{cp_template_dir_path}modules/#{@personal_plugin_field.module_name}/")
|
copy_templates("#{cp_template_dir_path}modules/#{@personal_plugin_field.module_name}/")
|
||||||
#render :html => @logs#@match_pattern#@logs.join("<br>").html_safe#@match_pattern
|
#render :html => @logs#@match_pattern#@logs.join("<br>").html_safe#@match_pattern
|
||||||
@personal_plugin_field.update(:log_text=>"")
|
@personal_plugin_field.update(:log_text=>"")
|
||||||
|
@personal_plugin_field.update(:finished=>true)
|
||||||
add_plugin("downloaded_extensions.rb",@personal_plugin_field.module_name)
|
add_plugin("downloaded_extensions.rb",@personal_plugin_field.module_name)
|
||||||
bundle_install
|
bundle_install
|
||||||
render :json => {:success=>true,:url=>"/admin/#{plugin_template.pluralize}/",:name=>@personal_plugin_field.title}
|
render :json => {:success=>true,:url=>"/admin/#{plugin_template.pluralize}/",:name=>@personal_plugin_field.title}
|
||||||
|
@ -362,6 +370,7 @@ class Admin::PersonalPluginFieldsController < OrbitMemberController
|
||||||
replace_dirs(dirs,false)
|
replace_dirs(dirs,false)
|
||||||
error = e.backtrace.join("<br>")
|
error = e.backtrace.join("<br>")
|
||||||
@personal_plugin_field.update(:log_text=>error)
|
@personal_plugin_field.update(:log_text=>error)
|
||||||
|
@personal_plugin_field.update(:finished=>false)
|
||||||
render :json => {:success=>false,:error=>error}
|
render :json => {:success=>false,:error=>error}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,6 +15,7 @@ class PersonalPluginField
|
||||||
field :log_text, :type => String, :default => ""
|
field :log_text, :type => String, :default => ""
|
||||||
field :fields_order, :type => Hash, :default => {}
|
field :fields_order, :type => Hash, :default => {}
|
||||||
field :copy_id
|
field :copy_id
|
||||||
|
field :finished, :type => Boolean, :default => false
|
||||||
before_save :change_extensions,:check_modal_name,:auto_add_display_fields
|
before_save :change_extensions,:check_modal_name,:auto_add_display_fields
|
||||||
after_destroy do
|
after_destroy do
|
||||||
delete_plugin("downloaded_extensions.rb",self.module_name)
|
delete_plugin("downloaded_extensions.rb",self.module_name)
|
||||||
|
@ -81,12 +82,12 @@ class PersonalPluginField
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def auto_add_display_fields
|
def auto_add_display_fields
|
||||||
change_primary_fields = self.primary_modal_fields.map{|f| f["field_name"]} - self.primary_modal_fields_was.map{|f| f["field_name"]}
|
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 = []
|
change_related_fields = []
|
||||||
self.related_modal_fields.each_with_index do |field_values,i|
|
self.related_modal_fields.each_with_index do |field_values,i|
|
||||||
old_field_values = self.related_modal_fields_was[i].to_a rescue []
|
old_field_values = self.related_modal_fields_was[i].to_a rescue []
|
||||||
related_modal_name = self.related_modal_name[i].to_s
|
related_modal_name = self.related_modal_name[i].to_s
|
||||||
change_related_fields = change_related_fields + (field_values.map{|f| f["field_name"]} - old_field_values.map{|f| f["field_name"]}).select{|f| f.present?}.map{|f| "#{related_modal_name}.#{f}"}
|
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
|
end
|
||||||
change_fields = change_primary_fields + change_related_fields
|
change_fields = change_primary_fields + change_related_fields
|
||||||
change_fields = change_fields.select{|f| f.present?}
|
change_fields = change_fields.select{|f| f.present?}
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
<% @personal_plugin_fields.each do |personal_plugin_field| %>
|
<% @personal_plugin_fields.each do |personal_plugin_field| %>
|
||||||
<tr id="<%= dom_id personal_plugin_field %>" class="with_action">
|
<tr id="<%= dom_id personal_plugin_field %>" class="with_action">
|
||||||
<td><%= personal_plugin_field.title %></td>
|
<td>
|
||||||
|
<% title = personal_plugin_field.title %>
|
||||||
|
<% if personal_plugin_field.finished %>
|
||||||
|
<a href="/admin/<%=personal_plugin_field.primary_modal_name.pluralize%>" title="<%= title %>"><%= title %></a>
|
||||||
|
<% else %>
|
||||||
|
<%= title %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
<td><%= personal_plugin_field.module_name %></td>
|
<td><%= personal_plugin_field.module_name %></td>
|
||||||
<td><%= link_to t(:edit) ,edit_admin_personal_plugin_field_path(personal_plugin_field.id),:class=> "btn btn-primary" %>
|
<td><%= link_to t(:edit) ,edit_admin_personal_plugin_field_path(personal_plugin_field.id),:class=> "btn btn-primary" %>
|
||||||
<%= link_to thead_field('fields_display_setting') ,admin_personal_plugin_field_fields_setting_path(personal_plugin_field.id),:class=> "btn btn-primary" %>
|
<%= link_to thead_field('fields_display_setting') ,admin_personal_plugin_field_fields_setting_path(personal_plugin_field.id),:class=> "btn btn-primary" %>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<% next if (!access_field_types.include?(field_value[:field_type]) rescue false) %>
|
<% next if (!access_field_types.include?(field_value[:field_type]) rescue false) %>
|
||||||
<% ths << "<th data-index=\"#{ii+=1}\">#{field_value[:translation_name][I18n.locale] rescue ""}-#{field_value[:field_name]}</th>" %>
|
<% ths << "<th data-index=\"#{ii+=1}\">#{field_value[:translation_name][I18n.locale] rescue ""}-#{field_value[:field_name]}</th>" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if page_name != "analysis" %>
|
<% if !defined?(access_field_types) %>
|
||||||
<% f.object.related_modal_name.each_with_index do |related_modal_name,i| %>
|
<% 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 = f.object.related_modal_fields[i].to_a %>
|
||||||
<% field_values.each do |field_value| %>
|
<% field_values.each do |field_value| %>
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
<% next if (!access_field_types.include?(field_value[:field_type]) rescue false) %>
|
<% next if (!access_field_types.include?(field_value[:field_type]) rescue false) %>
|
||||||
<% tds << check_box_tag("#{f.object_name}[]", field_value[:field_name] , (object.send(root_name)[page_name].include?(field_value[:field_name]) rescue false),:id=>nil) %>
|
<% tds << check_box_tag("#{f.object_name}[]", field_value[:field_name] , (object.send(root_name)[page_name].include?(field_value[:field_name]) rescue false),:id=>nil) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if page_name != "analysis" %>
|
<% if !defined?(access_field_types) %>
|
||||||
<% object.related_modal_name.each_with_index do |related_modal_name,i| %>
|
<% object.related_modal_name.each_with_index do |related_modal_name,i| %>
|
||||||
<% field_values = object.related_modal_fields[i].to_a %>
|
<% field_values = object.related_modal_fields[i].to_a %>
|
||||||
<% field_values.each do |field_value| %>
|
<% field_values.each do |field_value| %>
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
<%= 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=>'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=>'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=>'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>
|
</div>
|
||||||
<h4><%= thead_field('frontend_page') %></h4>
|
<h4><%= thead_field('frontend_page') %></h4>
|
||||||
<div id="frontend_page">
|
<div id="frontend_page">
|
||||||
|
|
|
@ -48,3 +48,5 @@ en:
|
||||||
please_change_module_name: "Please change module name(This name already exist)."
|
please_change_module_name: "Please change module name(This name already exist)."
|
||||||
copy: Copy
|
copy: Copy
|
||||||
periodic_time: Periodic time
|
periodic_time: Periodic time
|
||||||
|
sort_asc: "Sort(Ascending)"
|
||||||
|
sort_desc: "Sort(Descending)"
|
|
@ -48,3 +48,5 @@ zh_tw:
|
||||||
please_change_module_name: "請更改模組名稱(此名稱已存在)"
|
please_change_module_name: "請更改模組名稱(此名稱已存在)"
|
||||||
copy: 複製
|
copy: 複製
|
||||||
periodic_time: 週期性時間
|
periodic_time: 週期性時間
|
||||||
|
sort_asc: "排序(升序)"
|
||||||
|
sort_desc: "排序(降序)"
|
|
@ -9,9 +9,25 @@ class Admin::PluginTemplatesController < OrbitMemberController
|
||||||
before_action :allow_admin_only, :only => [:index, :setting]
|
before_action :allow_admin_only, :only => [:index, :setting]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@plugin_templates = PluginTemplate.order_by(:created_at=>'desc').page(params[:page]).per(10)
|
@plugin_templates = PluginTemplate.order_by(sort).page(params[:page]).per(10)
|
||||||
|
end
|
||||||
|
def sort
|
||||||
|
unless params[:sort].blank?
|
||||||
|
case params[:sort]
|
||||||
|
when "status"
|
||||||
|
@sort = [[:is_top, params[:order]],
|
||||||
|
[:is_hot, params[:order]],
|
||||||
|
[:is_hidden,params[:order]]]
|
||||||
|
when "category"
|
||||||
|
@sort = {:category_id=>params[:order]}
|
||||||
|
else
|
||||||
|
s = Sanitize.clean(params[:sort]).to_sym
|
||||||
|
@sort = {s=>params[:order]}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@sort = {:created_at=>'desc'}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||||
@plugin_template = PluginTemplate.new
|
@plugin_template = PluginTemplate.new
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<table class="table main-list">
|
<table class="table main-list tablet footable-loaded">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr class="sort-header">
|
||||||
parse_again_start
|
parse_again_start
|
||||||
<th><%= t('personal_plugin_template.backend_index_fields') %></th>
|
<%= thead('personal_plugin_template.backend_index_fields') %>
|
||||||
parse_again_end
|
parse_again_end
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
Loading…
Reference in New Issue