forked from saurabh/orbit4-5
Merge branch 'development' of gitlab.tp.rulingcom.com:saurabh/orbit4-5 into development
This commit is contained in:
commit
20350c4e14
|
@ -5,6 +5,8 @@ class PagePartsController < ApplicationController
|
||||||
@part.sub_parts.build
|
@part.sub_parts.build
|
||||||
@part_number = params[:part]
|
@part_number = params[:part]
|
||||||
@page_id = params[:page_id]
|
@page_id = params[:page_id]
|
||||||
|
page = Page.find(@page_id)
|
||||||
|
@child_page_count = (page.root? ? 0 : page.child_page.count) rescue 0
|
||||||
@modules = ModuleApp.widget_enabled
|
@modules = ModuleApp.widget_enabled
|
||||||
@modules = @modules.concat(OrbitWidget.all)
|
@modules = @modules.concat(OrbitWidget.all)
|
||||||
@no_orbit_bar = @no_side_bar = true
|
@no_orbit_bar = @no_side_bar = true
|
||||||
|
@ -19,6 +21,8 @@ class PagePartsController < ApplicationController
|
||||||
@part = parts.where(:part_id => params[:id]).first
|
@part = parts.where(:part_id => params[:id]).first
|
||||||
@part.sub_parts.build
|
@part.sub_parts.build
|
||||||
@page_id = params[:page_id]
|
@page_id = params[:page_id]
|
||||||
|
page = Page.find(@page_id)
|
||||||
|
@child_page_count = (page.root? ? 0 : page.child_page.count) rescue 0
|
||||||
@part_number = params[:id]
|
@part_number = params[:id]
|
||||||
@select_number = @part.sub_parts.count
|
@select_number = @part.sub_parts.count
|
||||||
@modules = ModuleApp.widget_enabled
|
@modules = ModuleApp.widget_enabled
|
||||||
|
@ -32,6 +36,7 @@ class PagePartsController < ApplicationController
|
||||||
@part = part_model.find(params[:part_id])
|
@part = part_model.find(params[:part_id])
|
||||||
@subpart = SubPart.find(params[:sub_part_id])
|
@subpart = SubPart.find(params[:sub_part_id])
|
||||||
@select_number = @part.sub_parts.index(@subpart)
|
@select_number = @part.sub_parts.index(@subpart)
|
||||||
|
@child_page_count = 0
|
||||||
@kind = @subpart.kind
|
@kind = @subpart.kind
|
||||||
@modules = ModuleApp.widget_enabled
|
@modules = ModuleApp.widget_enabled
|
||||||
@modules = @modules.concat(OrbitWidget.all)
|
@modules = @modules.concat(OrbitWidget.all)
|
||||||
|
@ -138,6 +143,7 @@ class PagePartsController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@part = part_model.new(part_params)
|
@part = part_model.new(part_params)
|
||||||
@part.save!
|
@part.save!
|
||||||
|
apply_to_sub_pages(part_params,nil,nil) if !params[:apply_to_subpage].nil? && !@part.page_id.nil?
|
||||||
render :json => {"success"=>true}.to_json
|
render :json => {"success"=>true}.to_json
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -145,11 +151,36 @@ class PagePartsController < ApplicationController
|
||||||
def update
|
def update
|
||||||
@part = part_model.find(params[:part_id])
|
@part = part_model.find(params[:part_id])
|
||||||
@part.update_attributes(part_params)
|
@part.update_attributes(part_params)
|
||||||
|
apply_to_sub_pages(part_params,params[:part_id],params[:page_id]) if !params[:apply_to_subpage].nil? && !@part.page_id.nil?
|
||||||
render :json => {"success"=>true}.to_json
|
render :json => {"success"=>true}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def apply_to_sub_pages(part_params,part_id=nil,page_id=nil)
|
||||||
|
page_id = part_params[:page_id] if page_id.nil?
|
||||||
|
page = Page.find(page_id) rescue nil
|
||||||
|
if !page.nil?
|
||||||
|
child_pages = page.child_page
|
||||||
|
child_pages.each do |cp|
|
||||||
|
temp = part_params
|
||||||
|
if part_id.nil?
|
||||||
|
partid = part_params[:part_id]
|
||||||
|
else
|
||||||
|
partid = part_model.find(part_id).part_id
|
||||||
|
end
|
||||||
|
page_part = cp.page_parts.where(:part_id => partid).first rescue nil
|
||||||
|
if page_part.nil?
|
||||||
|
temp[:page_id] = cp.id.to_s
|
||||||
|
part = part_model.new(temp)
|
||||||
|
part.save!
|
||||||
|
else
|
||||||
|
page_part.update_attributes(temp)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def get_widget_files(module_name)
|
def get_widget_files(module_name)
|
||||||
temp = []
|
temp = []
|
||||||
f = File.join("#{Rails.root}/app/templates/#{@key}/modules/#{module_name.downcase}/info.json")
|
f = File.join("#{Rails.root}/app/templates/#{@key}/modules/#{module_name.downcase}/info.json")
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
<h4><%= t(:groups) %></h4>
|
<h4><%= t(:groups) %></h4>
|
||||||
<%= content_tag :ul, :class => ("nav nav-list ") do -%>
|
<%= content_tag :ul, :class => ("nav nav-list ") do -%>
|
||||||
<%= content_tag :li, link_to((content_tag(:span, "My Groups")), admin_groups_path), :class => active_for_action('groups', 'index') %>
|
<%= content_tag :li, link_to((content_tag(:span, "My Groups")), admin_groups_path), :class => active_for_action('groups', 'index') %>
|
||||||
<%= content_tag :li, link_to((content_tag(:span, "Categories")), admin_groups_categories_path), :class => active_for_action('groups','group_category') %>
|
<%= content_tag :li, link_to((content_tag(:span, "Categories")), admin_groups_categories_path), :class => active_for_action('groups','categories') %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -62,6 +62,14 @@
|
||||||
<%= select_tag("page_part[sub_parts_attributes][#{@select_number}][module]", options_for_select(@modules.map{|m| [m.title,m.key]}, (@subpart.module rescue nil)),{:include_blank => true,"class" => "input-xlarge change module_name"}) %>
|
<%= select_tag("page_part[sub_parts_attributes][#{@select_number}][module]", options_for_select(@modules.map{|m| [m.title,m.key]}, (@subpart.module rescue nil)),{:include_blank => true,"class" => "input-xlarge change module_name"}) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% if @child_page_count > 0 %>
|
||||||
|
<div class="control-group input-content">
|
||||||
|
<label class="control-label muted">Apply to sub-pages :</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="checkbox" name="apply_to_subpage" value="1" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<div id="widgets_selection_area">
|
<div id="widgets_selection_area">
|
||||||
<% if params[:action] == "edit_sub_part" && @kind == "module_widget"%>
|
<% if params[:action] == "edit_sub_part" && @kind == "module_widget"%>
|
||||||
<%= render :partial => "widget_form" %>
|
<%= render :partial => "widget_form" %>
|
||||||
|
|
Loading…
Reference in New Issue