From af6d41bc4d7022e021fedde84cbb860c86441e17 Mon Sep 17 00:00:00 2001 From: manson Date: Tue, 22 Jul 2014 16:48:46 +0800 Subject: [PATCH] fix structure page form and added missing module files in template --- app/assets/javascripts/lib/items/items.js.erb | 16 ++++++++--- app/controllers/pages_controller.rb | 12 ++++++--- .../modules/announcement/_widget.html.erb | 24 +++++++++++++++++ .../modules/announcement/index.html.erb | 26 ++++++++++++++++++ .../modules/faq/_widget.html.erb | 16 +++++++++++ .../modules/faq/index.html.erb | 16 +++++++++++ .../modules/gallery/_widget.html.erb | 18 +++++++++++++ .../modules/gallery/index.html.erb | 20 ++++++++++++++ .../modules/web_resource/_widget.html.erb | 13 +++++++++ .../modules/web_resource/index.html.erb | 17 ++++++++++++ app/views/pages/_form.html.erb | 27 ++++++++++--------- app/views/pages/edit.html.erb | 11 ++++---- app/views/pages/new.html.erb | 10 +++---- 13 files changed, 196 insertions(+), 30 deletions(-) create mode 100644 app/templates/orbit_bootstrap/modules/announcement/_widget.html.erb create mode 100644 app/templates/orbit_bootstrap/modules/announcement/index.html.erb create mode 100644 app/templates/orbit_bootstrap/modules/faq/_widget.html.erb create mode 100644 app/templates/orbit_bootstrap/modules/faq/index.html.erb create mode 100644 app/templates/orbit_bootstrap/modules/gallery/_widget.html.erb create mode 100644 app/templates/orbit_bootstrap/modules/gallery/index.html.erb create mode 100644 app/templates/orbit_bootstrap/modules/web_resource/_widget.html.erb create mode 100644 app/templates/orbit_bootstrap/modules/web_resource/index.html.erb diff --git a/app/assets/javascripts/lib/items/items.js.erb b/app/assets/javascripts/lib/items/items.js.erb index b97ceae..4fdf9ab 100755 --- a/app/assets/javascripts/lib/items/items.js.erb +++ b/app/assets/javascripts/lib/items/items.js.erb @@ -92,6 +92,14 @@ var Items = function(){ } }) + sidePanel.on("click","#status_list input[type=checkbox]",function(){ + if($(this).is(":checked") && $(this).hasClass("checkbox-all")){ + $(".view-page .content #status_list input[type=checkbox]").not($(this)).removeAttr("checked"); + }else{ + $(".view-page .content #status_list input[type=checkbox].checkbox-all").removeAttr("checked"); + } + }) + sidePanel.on("click","#enable-menu .main-enable-parent",function(e){ if(!$(this).is(":checked")){ var parent = $(this).parent().parent(); @@ -163,7 +171,7 @@ var Items = function(){ var controlDiv = $("
"); if(data.role_status.length){ - status_list.parent().find("label.control-label").text("<%= I18n.t(:category) %> :"); + status_list.parent().find("label.control-label").text("<%= I18n.t(:role) %> :"); var checkbox = $(""); controlDiv.append(checkbox); $.each(data.role_status,function(i,category){ @@ -265,9 +273,9 @@ function customOpenSlide() { $('#pageslide .parent').val(_parent); if(_id !== 'new') { $('#pageslide form').attr({ - 'action': $('#pageslide form').attr('action') + '/' + _id, - 'id': 'edit_' + _type + '_' + _id, - 'method': 'put' + // 'action': $('#pageslide form').attr('action') + '/' + _id, + // 'id': 'edit_' + _type + '_' + _id, + // 'method': 'put' }); setForm(element.data('form')); } else { diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 94c1167..0ab22a9 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -143,7 +143,7 @@ class PagesController < ApplicationController if module_app.key.eql?("member") role_status = module_app.role_status.collect do |cat| { - "title" => "#{cat.title} (#{cat.role.title})", + "title" => "#{cat.role.title} - #{cat.title}", "id" => cat.id.to_s } end @@ -156,7 +156,7 @@ class PagesController < ApplicationController end end - role_status = role_status.nil? ? [] : role_status + role_status = role_status.nil? ? [] : role_status.sort_by{|status| status['title']} categories = categories.nil? ? [] : categories if module_app.data_count.nil? @@ -187,7 +187,13 @@ class PagesController < ApplicationController @categories = @module_app.categories rescue [] @tags = @module_app.tags rescue [] if @module_app.key.eql?("member") - @status = @module_app.role_status rescue [] + @status = @module_app.role_status.collect do |cat| + { + "title" => "#{cat.role.title} - #{cat.title}", + "id" => cat.id.to_s + } + end + @status = @status.sort_by{|status| status['title']} else @status = [] end diff --git a/app/templates/orbit_bootstrap/modules/announcement/_widget.html.erb b/app/templates/orbit_bootstrap/modules/announcement/_widget.html.erb new file mode 100644 index 0000000..0f6a068 --- /dev/null +++ b/app/templates/orbit_bootstrap/modules/announcement/_widget.html.erb @@ -0,0 +1,24 @@ +
+

+ {{widget-title}} +

+
+
+
+
+ +
+
+ + {{status}} + + {{postdate}} +

+ {{title}} +

+

{{subtitle}} Read More »

+
+
+
+
+
\ No newline at end of file diff --git a/app/templates/orbit_bootstrap/modules/announcement/index.html.erb b/app/templates/orbit_bootstrap/modules/announcement/index.html.erb new file mode 100644 index 0000000..e374d1d --- /dev/null +++ b/app/templates/orbit_bootstrap/modules/announcement/index.html.erb @@ -0,0 +1,26 @@ +
+

+ {{widget-title}} +

+
+
+
+
+ +
+
+

+ {{title}} +

+ + {{status}} + + {{postdate}} +

{{subtitle}}

+ Read More » +
+
+
+
+
+{{pagination_goes_here}} \ No newline at end of file diff --git a/app/templates/orbit_bootstrap/modules/faq/_widget.html.erb b/app/templates/orbit_bootstrap/modules/faq/_widget.html.erb new file mode 100644 index 0000000..11695fd --- /dev/null +++ b/app/templates/orbit_bootstrap/modules/faq/_widget.html.erb @@ -0,0 +1,16 @@ +
+

+ {{widget-title}} +

+ +

+ More +

+
\ No newline at end of file diff --git a/app/templates/orbit_bootstrap/modules/faq/index.html.erb b/app/templates/orbit_bootstrap/modules/faq/index.html.erb new file mode 100644 index 0000000..5e8752c --- /dev/null +++ b/app/templates/orbit_bootstrap/modules/faq/index.html.erb @@ -0,0 +1,16 @@ +
+

+ {{widget-title}} +

+ +
+{{pagination_goes_here}} \ No newline at end of file diff --git a/app/templates/orbit_bootstrap/modules/gallery/_widget.html.erb b/app/templates/orbit_bootstrap/modules/gallery/_widget.html.erb new file mode 100644 index 0000000..2e4b3d6 --- /dev/null +++ b/app/templates/orbit_bootstrap/modules/gallery/_widget.html.erb @@ -0,0 +1,18 @@ + +<%= javascript_include_tag "plugin/jquery.cycle2.carousel.min"%> \ No newline at end of file diff --git a/app/templates/orbit_bootstrap/modules/gallery/index.html.erb b/app/templates/orbit_bootstrap/modules/gallery/index.html.erb new file mode 100644 index 0000000..43e8abd --- /dev/null +++ b/app/templates/orbit_bootstrap/modules/gallery/index.html.erb @@ -0,0 +1,20 @@ + +{{pagination_goes_here}} \ No newline at end of file diff --git a/app/templates/orbit_bootstrap/modules/web_resource/_widget.html.erb b/app/templates/orbit_bootstrap/modules/web_resource/_widget.html.erb new file mode 100644 index 0000000..88e4ed3 --- /dev/null +++ b/app/templates/orbit_bootstrap/modules/web_resource/_widget.html.erb @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/app/templates/orbit_bootstrap/modules/web_resource/index.html.erb b/app/templates/orbit_bootstrap/modules/web_resource/index.html.erb new file mode 100644 index 0000000..31d9f77 --- /dev/null +++ b/app/templates/orbit_bootstrap/modules/web_resource/index.html.erb @@ -0,0 +1,17 @@ + +{{pagination_goes_here}} \ No newline at end of file diff --git a/app/views/pages/_form.html.erb b/app/views/pages/_form.html.erb index 6bec136..55d869d 100644 --- a/app/views/pages/_form.html.erb +++ b/app/views/pages/_form.html.erb @@ -1,20 +1,18 @@ -<% if params[:action] == "edit" %> -

<%= @page.name %>

-<% end %>
<% if params[:action] == "new" %> - + <%= f.label :name, content_tag(:i, nil, :class => "icons-star") + t(:name) %>
- <%= f.text_field :page_id, data: {"fv-validation" => "required;nospace;pageid_validation;", "fv-messages" => "Cannot be empty.;Cannot have blank spaces.;Page id is already taken.;"} %> + <%= f.text_field :page_id, class:"input-xlarge change", data: {"fv-validation" => "required;nospace;pageid_validation;", "fv-messages" => "Cannot be empty.;Cannot have blank spaces.;Page id is already taken.;"} %> + <%= t("front_page.name_field_helper") %>
<% end %>
- <% I18n.available_locales.each do |locale| %> - + <% @site_in_use_locales.each do |locale| %> + <%= f.label :locale, "#{t(:title)} #{t(locale)}" %>
<%= f.fields_for :name_translations do |n| %> - <%= n.text_field locale, data: {"fv-validation" => "required;", "fv-messages" => "Cannot be empty.;"}, :value=>@page.name_translations[locale] rescue nil %> + <%= n.text_field locale, class:"input-xlarge change", data: {"fv-validation" => "required;", "fv-messages" => "Cannot be empty.;"}, :value=>@page.name_translations[locale] rescue nil %> <% end %>
<% end %> @@ -22,7 +20,7 @@
- <%= f.select(:module, @modules.map{|m| [t('module_name.'+m.key),m.key]},{:include_blank => true},:class=>"module_select", data: {"fv-validation" => "required;", "fv-messages" => "Cannot be empty.;"}) %> + <%= f.select(:module, @modules.map{|m| [t('module_name.'+m.key),m.key]},{:include_blank => true},:class=>"module_select input-xlarge change", data: {"fv-validation" => "required;", "fv-messages" => "Cannot be empty.;"}) %> <%= f.hidden_field :parent_page, value: (params[:parent_page] || @page.parent_page_id) %> <%= f.hidden_field :page_type, value: "page" %>
@@ -72,7 +70,7 @@
- +
<% if params[:action] == "edit" %>
@@ -84,8 +82,8 @@ <% end %> <% @status.each do |status| %> <% end %>
@@ -128,7 +126,7 @@
- <% I18n.available_locales.each do |locale| %> + <% @site_in_use_locales.each do |locale| %>
+ diff --git a/app/views/pages/edit.html.erb b/app/views/pages/edit.html.erb index 2a9125b..616384b 100644 --- a/app/views/pages/edit.html.erb +++ b/app/views/pages/edit.html.erb @@ -4,15 +4,16 @@ <% elsif params[:type] == "link" %> <%= render "form_link", {:f=> f} %> <% end %> -
-
- <% if params[:type] == "page" %> - <%= f.submit "Update Page", :class=>"btn btn-primary" %> + +
+ <% if params[:type] == "page" %> + <%= t(:cancel) %> + <%= f.submit t(:submit), class: 'btn btn-primary btn-small' %> <% elsif params[:type] == "link" %> <%= f.submit "Update Link", :class=>"btn btn-primary" %> <% end %> -
+ <% end %>