This commit is contained in:
BoHung Chiu 2021-02-28 17:58:51 +08:00
parent d0641cd677
commit 231ac9c79f
3 changed files with 16 additions and 8 deletions

View File

@ -98,8 +98,8 @@ class Admin::PersonalPluginFieldsController < OrbitAdminController
"<%= link_to #{plugin_template}.#{field_name}, page_for_#{plugin_template}(#{plugin_template}), target: \"blank\" %>\r\n " +
"<div class=\"quick-edit\">
<ul class=\"nav nav-pills hide\">
<li><%= link_to t('edit'), edit_admin_#{plugin_template}_path(course,:page => params[:page]) %></li>
<li><%= link_to t(:delete_), admin_#{plugin_template}_path(id: course.id, :page => params[:page]), method: :delete, data: { confirm: 'Are you sure?' } %></li>
<li><%= link_to t('edit'), edit_admin_#{plugin_template}_path(#{plugin_template},:page => params[:page]) %></li>
<li><%= link_to t(:delete_), admin_#{plugin_template}_path(id: #{plugin_template}.id, :page => params[:page]), method: :delete, data: { confirm: 'Are you sure?' } %></li>
</ul>
</div>\r\n "
else
@ -149,7 +149,6 @@ class Admin::PersonalPluginFieldsController < OrbitAdminController
"plugin_template_sort_hash" => "nil",
"col_name_to_show_in_index_page_arr" => col_name_to_show_in_index_page,
"backend_index_fields" => backend_index_fields,
"slug_title" => slug_title,
"backend_index_fields_contents" => backend_index_fields_contents,
"plugin_template_related_files_text" => plugin_template_related_files_text,
"locale_fields" => locale_fields,
@ -181,12 +180,15 @@ class Admin::PersonalPluginFieldsController < OrbitAdminController
end
case field_type
when "year"
input_field = "<%= select_year((#{field_value_text} ? #{field_value_text}.to_i : DateTime.now.year), {:start_year => DateTime.now.year + 5, :end_year => 1930}, {:name => '#{plugin_template}[#{field_name}]',:class => 'span1'} ) %>"
input_field = datetime_picker_text(plugin_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 => '#{plugin_template}[#{field_name}]',:class => 'span1'} ) %>"
when "date"
input_field = datetime_picker_text(plugin_template,field_name_text, "yyyy/MM/dd")
when "time"
input_field = datetime_picker_text(plugin_template,field_name_text, "HH:mm",true)
when "date_time"
input_field = "<%= f.text_area #{field_name_text}, class: \"input-block-level ckeditor\", placeholder: t(\"#{personal_plugin_template}.#{field_name}\"), value: (#{field_value_text} rescue nil) %>"
input_field = datetime_picker_text(plugin_template,field_name_text)
when "text_editor"
input_field = "<%= f.text_area #{field_name_text}, class: \"input-block-level ckeditor\", placeholder: t(\"#{personal_plugin_template}.#{field_name}\"), value: (#{field_value_text} rescue nil) %>"
else #text_field
input_field = "<%= f.text_field #{field_name_text}, class: \"input-block-level\", placeholder: t(\"#{personal_plugin_template}.#{field_name}\"), value: (#{field_value_text} rescue nil) %>"
end
@ -195,6 +197,11 @@ class Admin::PersonalPluginFieldsController < OrbitAdminController
end
input_field
end
def datetime_picker_text(plugin_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 => @#{plugin_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_name].blank?
@ -214,7 +221,8 @@ class Admin::PersonalPluginFieldsController < OrbitAdminController
no_localize_types = ["date","time","date_time"]
field_text = "field :#{field_value[:field_name]}, :type => #{type}, :default => #{default}"
field_text += ", :localize => true" if field_value[:localize] && !no_localize_types.include?(field_value[:field_type])
field_text += ", as: :slug_title" if field_value[:slug_title]
field_text += ", as: :slug_title" if field_value[:slug_title] == "1"
field_text
end
fields_text.join("\r\n#{@blank_text}")
end

View File

@ -1,5 +1,5 @@
<% @plugin_templates.each do |plugin_template| %>
<tr id="<%= dom_id course %>" class="with_action">
<tr id="<%= dom_id plugin_template %>" class="with_action">
<% parse_again_start %>
<td> backend_index_fields_contents </td>
<% parse_again_end %>

View File

@ -1,4 +1,4 @@
<%= form_for @course, url: admin_course_path(@course), html: {class: "form-horizontal main-forms previewable"} do |f| %>
<%= form_for @plugin_template, url: admin_plugin_template_path(@plugin_template), html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>