parent
6987ad0b4a
commit
919bb6eca3
|
@ -301,11 +301,14 @@ class Admin::PersonalPluginFieldsController < OrbitMemberController
|
||||||
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 = {}
|
plugin_template_sort_hash = {}
|
||||||
@personal_plugin_field.backend_fields[:sort_asc].to_a.each do |f|
|
@personal_plugin_field.backend_fields[:sort_asc].to_a.each do |f|
|
||||||
plugin_template_sort_hash[f] = 1
|
plugin_template_sort_hash[f.to_sym] = 1
|
||||||
end rescue nil
|
end rescue nil
|
||||||
@personal_plugin_field.backend_fields[:sort_desc].to_a.each do |f|
|
@personal_plugin_field.backend_fields[:sort_desc].to_a.each do |f|
|
||||||
plugin_template_sort_hash[f] = -1
|
plugin_template_sort_hash[f.to_sym] = -1
|
||||||
end rescue nil
|
end rescue nil
|
||||||
|
if @personal_plugin_field.backend_fields[:sort_desc].to_a.count != 0
|
||||||
|
plugin_template_sort_hash[:id] = -1
|
||||||
|
end
|
||||||
@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,
|
||||||
|
|
|
@ -5,66 +5,38 @@
|
||||||
<button type="button" class="select_all btn"><%=t("select_all")%></button>
|
<button type="button" class="select_all btn"><%=t("select_all")%></button>
|
||||||
<button type="button" class="de_select_all btn"><%=t("de_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}"%>">
|
<table class="table table-bordered" id="<%="#{root_name}_#{page_name}"%>">
|
||||||
<thead>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<% ths = [] %>
|
<% tds = [] %>
|
||||||
<% ii = -1 %>
|
<% ii = -1 %>
|
||||||
<% object.primary_modal_fields.each do |field_value| %>
|
<% object.primary_modal_fields.each do |field_value| %>
|
||||||
<% 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>" %>
|
<% content = check_box_tag("#{f.object_name}[]", field_value[:field_name] , (object.send(root_name)[page_name].include?(field_value[:field_name]) rescue false),:id=>nil,:class=>"#{page_name}_fields") %>
|
||||||
|
<% tds << "<td data-index=\"#{ii+=1}\">#{field_value[:translation_name][I18n.locale] rescue ""}-#{field_value[:field_name]}<hr class=\"border-hr\">#{content}</td>" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if !defined?(access_field_types) %>
|
<% 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| %>
|
||||||
<% ths << "<th data-index=\"#{ii+=1}\">#{related_modal_name}-#{field_value[:translation_name][I18n.locale] rescue ""}-#{field_value[:field_name]}</th>" %>
|
<% content = check_box_tag("#{f.object_name}[]", "#{related_modal_name+'.'+field_value[:field_name]}" , (object.send(root_name)[page_name].include?(related_modal_name+'.'+field_value[:field_name]) rescue false),:id=>nil,:class=>"#{page_name}_fields") %>
|
||||||
|
<% tds << "<td data-index=\"#{ii+=1}\">#{related_modal_name}-#{field_value[:translation_name][I18n.locale] rescue ""}-#{field_value[:field_name]}<hr class=\"border-hr\">#{content}</td>" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% author_name_translation = @personal_plugin_field.author_name_translations[locale] rescue ""
|
<% author_name_translation = @personal_plugin_field.author_name_translations[locale] rescue ""
|
||||||
author_name_translation = I18n.t("personal_plugins.author") if author_name_translation.blank? %>
|
author_name_translation = I18n.t("personal_plugins.author") if author_name_translation.blank? %>
|
||||||
<% ths << "<th data-index=\"#{ii+=1}\">#{author_name_translation}</th>" %>
|
<% content = check_box_tag("#{f.object_name}[]", "member_profile" , (object.send(root_name)[page_name].include?("member_profile") rescue false),:id=>nil) %>
|
||||||
|
<% tds << "<td data-index=\"#{ii+=1}\">#{author_name_translation}<hr class=\"border-hr\">#{content}</td>" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% fields_order = (0...ths.count).to_a
|
<% fields_order = (0...tds.count).to_a
|
||||||
if (object.fields_order["#{root_name}_#{page_name}"].present? rescue false)
|
if (object.fields_order["#{root_name}_#{page_name}"].present? rescue false)
|
||||||
object.fields_order["#{root_name}_#{page_name}"].to_a.each_with_index do |order,i|
|
object.fields_order["#{root_name}_#{page_name}"].to_a.each_with_index do |order,i|
|
||||||
fields_order[i] = order.to_i
|
fields_order[i] = order.to_i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
<% ths = ths.sort_by.with_index{|th,i| fields_order[i]}%>
|
|
||||||
<% ths.each do |th| %>
|
|
||||||
<%= th.html_safe %>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<% tds = [] %>
|
|
||||||
<%= f.fields_for root_name do |f| %>
|
|
||||||
<%= f.fields_for page_name do |f| %>
|
|
||||||
<% object.primary_modal_fields.each do |field_value| %>
|
|
||||||
<% 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) %>
|
|
||||||
<% end %>
|
|
||||||
<% if !defined?(access_field_types) %>
|
|
||||||
<% object.related_modal_name.each_with_index do |related_modal_name,i| %>
|
|
||||||
<% field_values = object.related_modal_fields[i].to_a %>
|
|
||||||
<% field_values.each do |field_value| %>
|
|
||||||
<% tds << check_box_tag("#{f.object_name}[]", "#{related_modal_name+'.'+field_value[:field_name]}" , (object.send(root_name)[page_name].include?(related_modal_name+'.'+field_value[:field_name]) rescue false),:id=>nil) %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
<% tds << check_box_tag("#{f.object_name}[]", "member_profile" , (object.send(root_name)[page_name].include?("member_profile") rescue false),:id=>nil) %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
<% tds = tds.sort_by.with_index{|td,i| fields_order[i]}%>
|
<% tds = tds.sort_by.with_index{|td,i| fields_order[i]}%>
|
||||||
<% tds.each do |td| %>
|
<% tds.each do |td| %>
|
||||||
<td><%= td.html_safe %></td>
|
<%= td.html_safe %>
|
||||||
<% end %>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<% fields_order.each do |order| %>
|
|
||||||
<%= hidden_field_tag "#{f.object_name}[fields_order][#{root_name}_#{page_name}][]",order,:id=>nil %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -50,6 +50,17 @@
|
||||||
.icons-list-2{
|
.icons-list-2{
|
||||||
cursor: all-scroll;
|
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>
|
</style>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(".select_all").click(function(){
|
$(".select_all").click(function(){
|
||||||
|
@ -76,11 +87,11 @@
|
||||||
$('#backend_fields_analysis').css( 'border','');
|
$('#backend_fields_analysis').css( 'border','');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
$( ".table thead th" ).each(function(i,v){
|
$( ".table tbody td" ).each(function(i,v){
|
||||||
$(v).attr("index",$(v).index());
|
$(v).attr("index",$(v).index());
|
||||||
$(v).html("<span class=\"brand ui-sortable-handle\"><i class=\"icons-list-2\"></i></span>" + $(v).html());
|
$(v).html("<span class=\"brand ui-sortable-handle\"><i class=\"icons-list-2\"></i></span>" + $(v).html());
|
||||||
})
|
})
|
||||||
$( ".table thead >" ).sortable({
|
$( ".table tbody >" ).sortable({
|
||||||
axis: "x",
|
axis: "x",
|
||||||
revert: true,
|
revert: true,
|
||||||
handle: ".brand",
|
handle: ".brand",
|
||||||
|
@ -94,14 +105,23 @@
|
||||||
ui.item.parent().find(">").eq(new_i).attr("index",new_i);
|
ui.item.parent().find(">").eq(new_i).attr("index",new_i);
|
||||||
ui.item.parent().parent().siblings("tbody").find("tr:eq(1) >").eq(org_i).val(new_i);
|
ui.item.parent().parent().siblings("tbody").find("tr:eq(1) >").eq(org_i).val(new_i);
|
||||||
}
|
}
|
||||||
var tds = ui.item.parent().parent().siblings("tbody").find("tr:eq(0) >")
|
var tds = ui.item.parent().parent().siblings("tbody").find("tr:eq(0) >");
|
||||||
if(new_index > old_index){ //向後移動
|
if(tds.length){
|
||||||
tds.eq(new_index).after(tds.eq(old_index))
|
if(new_index > old_index){ //向後移動
|
||||||
}
|
tds.eq(new_index).after(tds.eq(old_index))
|
||||||
else if(new_index < old_index){ //向前移動
|
}
|
||||||
tds.eq(new_index).before(tds.eq(old_index))
|
else if(new_index < old_index){ //向前移動
|
||||||
|
tds.eq(new_index).before(tds.eq(old_index))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$( ".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);
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -34,8 +34,8 @@ zh_tw:
|
||||||
index: Index 頁面
|
index: Index 頁面
|
||||||
show: Show 頁面
|
show: Show 頁面
|
||||||
member_show: 會員show頁面
|
member_show: 會員show頁面
|
||||||
slug_title: 頭銜標題
|
slug_title: "頭銜標題(show頁面會顯示於網址)"
|
||||||
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: 分析欄位只能選擇一個!
|
||||||
|
|
|
@ -9,24 +9,30 @@ 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(sort).page(params[:page]).per(10)
|
if params[:sort].present?
|
||||||
|
@plugin_templates = PluginTemplate.order_by(sort).page(params[:page]).per(10)
|
||||||
|
else
|
||||||
|
@plugin_templates = PluginTemplate.sort_hash.page(params[:page]).per(10)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def sort
|
def sort
|
||||||
unless params[:sort].blank?
|
case params[:sort]
|
||||||
case params[:sort]
|
when "status"
|
||||||
when "status"
|
@sort = [[:is_top, params[:order]],
|
||||||
@sort = [[:is_top, params[:order]],
|
[:is_hot, params[:order]],
|
||||||
[:is_hot, params[:order]],
|
[:is_hidden,params[:order]],
|
||||||
[:is_hidden,params[:order]]]
|
[:id,params[:order]]]
|
||||||
when "category"
|
when "category"
|
||||||
@sort = {:category_id=>params[:order]}
|
@sort = {:category_id=>params[:order]}.merge({:id=>params[:order]})
|
||||||
else
|
else
|
||||||
s = Sanitize.clean(params[:sort]).to_sym
|
if params[:sort].present?
|
||||||
@sort = {s=>params[:order]}
|
s = Sanitize.clean(params[:sort]).to_sym
|
||||||
end
|
@sort = {s=>params[:order]}.merge({:id=>params[:order]})
|
||||||
else
|
else
|
||||||
@sort = {:created_at=>'desc'}
|
@sort = {}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@sort
|
||||||
end
|
end
|
||||||
def new
|
def new
|
||||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class PersonalPluginTemplatesController < ApplicationController
|
class PersonalPluginTemplatesController < ApplicationController
|
||||||
def index
|
def index
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
plugin_templates = PluginTemplate.where(:is_hidden=>false).order_by(plugin_template_sort_hash)
|
plugin_templates = PluginTemplate.sort_for_frontend
|
||||||
fields_to_show = col_name_to_show_in_index_page
|
fields_to_show = col_name_to_show_in_index_page
|
||||||
if params[:keywords].present?
|
if params[:keywords].present?
|
||||||
plugin_templates = filter_keywords(plugin_templates,params[:selectbox],params[:keywords])
|
plugin_templates = filter_keywords(plugin_templates,params[:selectbox],params[:keywords])
|
||||||
|
|
|
@ -17,6 +17,7 @@ parse_again_end
|
||||||
field :rss2_id
|
field :rss2_id
|
||||||
belongs_to :member_profile
|
belongs_to :member_profile
|
||||||
|
|
||||||
|
scope :sort_hash, ->{ order_by(plugin_template_sort_hash) }
|
||||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(plugin_template_sort_hash) }
|
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(plugin_template_sort_hash) }
|
||||||
|
|
||||||
parse_again_start
|
parse_again_start
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
<%
|
<%
|
||||||
if has_access?
|
if has_access?
|
||||||
@plugin_templates = PluginTemplate.where(member_profile_id: @member.id).order_by(plugin_template_sort_hash).page(params[:page]).per(10)
|
@plugin_templates = PluginTemplate.where(member_profile_id: @member.id).sort_hash.page(params[:page]).per(10)
|
||||||
else
|
else
|
||||||
@plugin_templates = PluginTemplate.where(is_hidden: false, member_profile_id: @member.id).order_by(plugin_template_sort_hash).page(params[:page]).per(10)
|
@plugin_templates = PluginTemplate.where(is_hidden: false, member_profile_id: @member.id).sort_hash.page(params[:page]).per(10)
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue