Add category and tag to pages
This commit is contained in:
parent
e40c76bf5f
commit
cf8d20dc84
app
controllers/admin
models
views/admin
lib/parsers
|
@ -11,7 +11,17 @@ class Admin::ModuleAppsController < ApplicationController
|
||||||
|
|
||||||
def reload_frontend_pages
|
def reload_frontend_pages
|
||||||
@module_app = ModuleApp.find(params[:id])
|
@module_app = ModuleApp.find(params[:id])
|
||||||
@categories = @module_app.key.eql?('announcement') ? BulletinCategory.all : nil
|
case @module_app.key
|
||||||
|
when 'announcement'
|
||||||
|
@categories = BulletinCategory.all
|
||||||
|
@tags = AnnouncementTag.all
|
||||||
|
when 'news'
|
||||||
|
@categories = NewsBulletinCategory.all
|
||||||
|
@tags = NewsTag.all
|
||||||
|
when 'web_resource'
|
||||||
|
@categories = WebLinkCategory.all
|
||||||
|
@tags = WebResourceTag.all
|
||||||
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js {}
|
format.js {}
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,10 +35,13 @@ class Admin::PagesController < ApplicationController
|
||||||
case @item.module_app.key
|
case @item.module_app.key
|
||||||
when 'announcement'
|
when 'announcement'
|
||||||
@categories = BulletinCategory.all
|
@categories = BulletinCategory.all
|
||||||
|
@tags = AnnouncementTag.all
|
||||||
when 'news'
|
when 'news'
|
||||||
@categories = NewsBulletinCategory.all
|
@categories = NewsBulletinCategory.all
|
||||||
|
@tags = NewsTag.all
|
||||||
when 'web_resource'
|
when 'web_resource'
|
||||||
@categories = WebLinkCategory.all
|
@categories = WebLinkCategory.all
|
||||||
|
@tags = WebResourceTag.all
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@categories = nil
|
@categories = nil
|
||||||
|
|
|
@ -3,6 +3,8 @@ class Page < Item
|
||||||
field :content
|
field :content
|
||||||
field :app_frontend_url
|
field :app_frontend_url
|
||||||
field :theme_id, :type => BSON::ObjectId, :default => nil
|
field :theme_id, :type => BSON::ObjectId, :default => nil
|
||||||
|
field :category
|
||||||
|
field :tag
|
||||||
|
|
||||||
belongs_to :design
|
belongs_to :design
|
||||||
belongs_to :module_app
|
belongs_to :module_app
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
$('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', @module_app.app_pages) %>");
|
$('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', @module_app.app_pages) %>");
|
||||||
$('#app_page_category').html("<%= escape_javascript(select 'page', 'category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}) if @categories %>");
|
$('#app_page_category').html("<%= j (select 'page', 'category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, {:include_blank => true}) if @categories %>");
|
||||||
|
$('#app_page_tag').html("<%= j (select 'page', 'tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, {:include_blank => true}) if @tags %>");
|
|
@ -45,6 +45,9 @@
|
||||||
<span id="app_page_category">
|
<span id="app_page_category">
|
||||||
<%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @item[:category], :include_blank => true ) rescue ''%>
|
<%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @item[:category], :include_blank => true ) rescue ''%>
|
||||||
</span>
|
</span>
|
||||||
|
<span id="app_page_tag">
|
||||||
|
<%= select('page','tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, :selected => @item[:tag], :include_blank => true ) rescue ''%>
|
||||||
|
</span>
|
||||||
<!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
|
<!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -164,10 +164,12 @@ module ParserCommon
|
||||||
public_r_tags = []
|
public_r_tags = []
|
||||||
body.css('.page_content').each do |content|
|
body.css('.page_content').each do |content|
|
||||||
ret = ''
|
ret = ''
|
||||||
|
category = params[:category_id].blank? ? page[:category] : params[:category_id]
|
||||||
|
tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id]
|
||||||
if (content["main"] == "true" && !page.module_app.nil?)
|
if (content["main"] == "true" && !page.module_app.nil?)
|
||||||
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}"
|
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}"
|
||||||
ret << "/#{params[:id]}" if params[:id] && !params[:id].eql?(page.id.to_s)
|
ret << "/#{params[:id]}" if params[:id] && !params[:id].eql?(page.id.to_s)
|
||||||
ret << "?inner=true&page_id=#{page.id}&category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}&preview=#{params[:preview]}&page_main=#{params[:page_main]}"
|
ret << "?inner=true&page_id=#{page.id}&category_id=#{category}&tag_id=#{tag}&preview=#{params[:preview]}&page_main=#{params[:page_main]}"
|
||||||
ret << "'></div>"
|
ret << "'></div>"
|
||||||
else
|
else
|
||||||
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
|
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
|
||||||
|
@ -183,7 +185,7 @@ module ParserCommon
|
||||||
ret << part.i18n_variable[I18n.locale] rescue ''
|
ret << part.i18n_variable[I18n.locale] rescue ''
|
||||||
when 'module_widget'
|
when 'module_widget'
|
||||||
url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
|
url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
|
||||||
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : params[:category_id]}&tag_id=#{!part[:tag].blank? ? part[:tag] : params[:tag_id]}&page=#{params[:page]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}"
|
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}"
|
||||||
ret << "<div class='dymanic_load' path='#{url + options}'></div>"
|
ret << "<div class='dymanic_load' path='#{url + options}'></div>"
|
||||||
when 'public_r_tag'
|
when 'public_r_tag'
|
||||||
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
|
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
|
||||||
|
|
Loading…
Reference in New Issue