From 4389f0cf28f472bb0249fc53a1bccb23cca6e71e Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 16 Feb 2012 12:18:27 +0800 Subject: [PATCH] Add new created files to previous commit --- app/views/admin/page_parts/_edit.html.erb | 19 +++++++++++++++++++ .../admin/page_parts/_module_widget.html.erb | 7 +++++++ .../admin/page_parts/_public_r_tag.html.erb | 7 +++++++ app/views/admin/page_parts/_text.html.erb | 8 ++++++++ .../admin/page_parts/reload_widgets.js.erb | 1 + config/initializers/dehumanize.rb | 11 +++++++++++ 6 files changed, 53 insertions(+) create mode 100644 app/views/admin/page_parts/_edit.html.erb create mode 100644 app/views/admin/page_parts/_module_widget.html.erb create mode 100644 app/views/admin/page_parts/_public_r_tag.html.erb create mode 100644 app/views/admin/page_parts/_text.html.erb create mode 100644 app/views/admin/page_parts/reload_widgets.js.erb create mode 100644 config/initializers/dehumanize.rb diff --git a/app/views/admin/page_parts/_edit.html.erb b/app/views/admin/page_parts/_edit.html.erb new file mode 100644 index 00000000..b5e298cb --- /dev/null +++ b/app/views/admin/page_parts/_edit.html.erb @@ -0,0 +1,19 @@ +<%= @part.inspect %>

+ +<%= form_for @part, :url => admin_page_part_path(@part) do |f| %> + + <% LIST[:page_part_kinds].each do |kind| %> + <%= f.radio_button :kind, kind, :class => 'part_kind' %> + <%= t(kind) %> + <% end %> + + <% LIST[:page_part_kinds].each do |kind| %> +
+ <%= render :partial => kind, :locals => {:f => f} %> +
+ <% end %> + +

+ <%= f.submit t(:update) %> <%= link_back %> +

+<% end %> \ No newline at end of file diff --git a/app/views/admin/page_parts/_module_widget.html.erb b/app/views/admin/page_parts/_module_widget.html.erb new file mode 100644 index 00000000..532cff53 --- /dev/null +++ b/app/views/admin/page_parts/_module_widget.html.erb @@ -0,0 +1,7 @@ + + <%= f.select :module_app, options_from_collection_for_select(@module_apps, :id, :title, :selected => @module_app.id), {}, {:rel => admin_page_parts_path} %> + + + + <%= f.select :widget_path, @module_app.widgets.collect{|widget| [widget.humanize, widget]}, :selected => @part.widget_path %> + \ No newline at end of file diff --git a/app/views/admin/page_parts/_public_r_tag.html.erb b/app/views/admin/page_parts/_public_r_tag.html.erb new file mode 100644 index 00000000..3f8170d7 --- /dev/null +++ b/app/views/admin/page_parts/_public_r_tag.html.erb @@ -0,0 +1,7 @@ + + <%= f.select :public_r_tag, LIST[:public_r_tags].collect{|tag| [t(tag), tag]}, :selected => @r_tag %> + + + + <%= f.select :public_r_tag_object_id, options_from_collection_for_select(@tag_objects, :id, :title, :selected => @part.public_r_tag_object_id) %> + \ No newline at end of file diff --git a/app/views/admin/page_parts/_text.html.erb b/app/views/admin/page_parts/_text.html.erb new file mode 100644 index 00000000..8cd03d58 --- /dev/null +++ b/app/views/admin/page_parts/_text.html.erb @@ -0,0 +1,8 @@ +<%= f.fields_for :i18n_variable, (@part.i18n_variable ? @part.i18n_variable : @part.build_i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> +
+ <%= I18nVariable.from_locale(locale) %> + <%= f.text_field locale %> +
+ <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/page_parts/reload_widgets.js.erb b/app/views/admin/page_parts/reload_widgets.js.erb new file mode 100644 index 00000000..646d4274 --- /dev/null +++ b/app/views/admin/page_parts/reload_widgets.js.erb @@ -0,0 +1 @@ +$('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|widget| [widget.humanize, widget]}) %>") \ No newline at end of file diff --git a/config/initializers/dehumanize.rb b/config/initializers/dehumanize.rb new file mode 100644 index 00000000..becdca77 --- /dev/null +++ b/config/initializers/dehumanize.rb @@ -0,0 +1,11 @@ +module ActiveSupport::Inflector + def dehumanize(the_string) + the_string.gsub(' ', '_').downcase + end +end + +class String + def dehumanize + ActiveSupport::Inflector.dehumanize(self) + end +end \ No newline at end of file