diff --git a/app/controllers/admin/personal_plugin_fields_controller.rb b/app/controllers/admin/personal_plugin_fields_controller.rb index f0ad69a..6d70263 100644 --- a/app/controllers/admin/personal_plugin_fields_controller.rb +++ b/app/controllers/admin/personal_plugin_fields_controller.rb @@ -98,8 +98,8 @@ class Admin::PersonalPluginFieldsController < OrbitAdminController "<%= link_to #{plugin_template}.#{field_name}, page_for_#{plugin_template}(#{plugin_template}), target: \"blank\" %>\r\n " + "
\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 diff --git a/template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb b/template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb index 312a64a..6adc52a 100644 --- a/template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb +++ b/template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb @@ -1,5 +1,5 @@ <% @plugin_templates.each do |plugin_template| %> - + <% parse_again_start %> backend_index_fields_contents <% parse_again_end %> diff --git a/template_generator/app/views/admin/plugin_templates/edit.html.erb b/template_generator/app/views/admin/plugin_templates/edit.html.erb index 49924b7..edba45c 100644 --- a/template_generator/app/views/admin/plugin_templates/edit.html.erb +++ b/template_generator/app/views/admin/plugin_templates/edit.html.erb @@ -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| %>
<%= render partial: 'form', locals: {f: f} %>