forked from saurabh/orbit4-5
Added tag in site structure
This commit is contained in:
parent
e00ec26409
commit
63270e2a79
|
@ -82,6 +82,14 @@ var Items = function(){
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
sidePanel.on("click","#tags_list input[type=checkbox]",function(){
|
||||||
|
if($(this).is(":checked") && $(this).hasClass("checkbox-all")){
|
||||||
|
$(".view-page .content #tags_list input[type=checkbox]").not($(this)).removeAttr("checked");
|
||||||
|
}else{
|
||||||
|
$(".view-page .content #tags_list input[type=checkbox].checkbox-all").removeAttr("checked");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
sidePanel.on("click","#enable-menu .main-enable-parent",function(e){
|
sidePanel.on("click","#enable-menu .main-enable-parent",function(e){
|
||||||
if(!$(this).is(":checked")){
|
if(!$(this).is(":checked")){
|
||||||
var parent = $(this).parent().parent();
|
var parent = $(this).parent().parent();
|
||||||
|
@ -108,10 +116,12 @@ var Items = function(){
|
||||||
sidePanel.on("change","select.module_select", function(){
|
sidePanel.on("change","select.module_select", function(){
|
||||||
var this_value = $(this).val(),
|
var this_value = $(this).val(),
|
||||||
categories_list = $("#categories_list")
|
categories_list = $("#categories_list")
|
||||||
|
tags_list = $("#tags_list"),
|
||||||
layouts_list = $("#layouts_list"),
|
layouts_list = $("#layouts_list"),
|
||||||
data_count_area = $("#data_count_area");
|
data_count_area = $("#data_count_area");
|
||||||
|
|
||||||
categories_list.html("");
|
categories_list.html("");
|
||||||
|
tags_list.html("");
|
||||||
if(this_value){
|
if(this_value){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : "<%= Rails.application.routes.url_helpers.pages_get_categories_path %>",
|
url : "<%= Rails.application.routes.url_helpers.pages_get_categories_path %>",
|
||||||
|
@ -120,9 +130,10 @@ var Items = function(){
|
||||||
dataType : "json"
|
dataType : "json"
|
||||||
}).done(function(data){
|
}).done(function(data){
|
||||||
var controlDiv = $("<div class='controls'></div>");
|
var controlDiv = $("<div class='controls'></div>");
|
||||||
|
|
||||||
if(data.categories.length){
|
if(data.categories.length){
|
||||||
categories_list.parent().find("label.control-label").text("Category List :");
|
categories_list.parent().find("label.control-label").text("<%= I18n.t(:category) %> :");
|
||||||
var checkbox = $("<label class='checkbox'><input type='checkbox' value='all' name='page[categories][]' class='checkbox-all' /> All </label>");
|
var checkbox = $("<label class='checkbox'><input type='checkbox' value='all' name='page[categories][]' class='checkbox-all' /> <%= I18n.t(:all) %> </label>");
|
||||||
controlDiv.append(checkbox);
|
controlDiv.append(checkbox);
|
||||||
$.each(data.categories,function(i,category){
|
$.each(data.categories,function(i,category){
|
||||||
var checkbox = $("<label class='checkbox'><input type='checkbox' value='"+ category.id +"' name='page[categories][]' /> " + category.title + " </label>");
|
var checkbox = $("<label class='checkbox'><input type='checkbox' value='"+ category.id +"' name='page[categories][]' /> " + category.title + " </label>");
|
||||||
|
@ -132,6 +143,21 @@ var Items = function(){
|
||||||
}else{
|
}else{
|
||||||
categories_list.parent().find("label.control-label").text("");
|
categories_list.parent().find("label.control-label").text("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var controlDiv = $("<div class='controls'></div>");
|
||||||
|
if(data.tags.length){
|
||||||
|
tags_list.parent().find("label.control-label").text("<%= I18n.t(:tags) %> :");
|
||||||
|
var checkbox = $("<label class='checkbox'><input type='checkbox' value='all' name='page[tags][]' class='checkbox-all' /> <%= I18n.t(:all) %> </label>");
|
||||||
|
controlDiv.append(checkbox);
|
||||||
|
$.each(data.tags,function(i,tag){
|
||||||
|
var checkbox = $("<label class='checkbox'><input type='checkbox' value='"+ tag.id +"' name='page[tags][]' /> " + tag.name + " </label>");
|
||||||
|
controlDiv.append(checkbox);
|
||||||
|
})
|
||||||
|
tags_list.html(controlDiv);
|
||||||
|
}else{
|
||||||
|
tags_list.parent().find("label.control-label").text("");
|
||||||
|
}
|
||||||
|
|
||||||
if(data.layouts.length){
|
if(data.layouts.length){
|
||||||
layouts_list.parent().find("label.control-label").text("Layout type:");
|
layouts_list.parent().find("label.control-label").text("Layout type:");
|
||||||
var controlDiv = $("<div class='controls'></div>"),
|
var controlDiv = $("<div class='controls'></div>"),
|
||||||
|
|
|
@ -742,13 +742,14 @@ class Admin::ImportController < OrbitAdminController
|
||||||
a = Asset.new
|
a = Asset.new
|
||||||
a.remote_data_url = link
|
a.remote_data_url = link
|
||||||
a.title_translations = {"en" => a.data.filename, "zh_tw" => a.data.filename}
|
a.title_translations = {"en" => a.data.filename, "zh_tw" => a.data.filename}
|
||||||
a.save!
|
if (a.save! rescue false)
|
||||||
@user.assets << a
|
@user.assets << a
|
||||||
@user.save
|
@user.save
|
||||||
@data = @data.sub(link, a.data.url)
|
@data = @data.sub(link, a.data.url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
@data
|
@data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ class PagePartsController < ApplicationController
|
||||||
app = ModuleApp.find_by_key(module_name) rescue nil
|
app = ModuleApp.find_by_key(module_name) rescue nil
|
||||||
app = OrbitWidget.find_by_key(module_name) if app.nil?
|
app = OrbitWidget.find_by_key(module_name) if app.nil?
|
||||||
@categories = app.categories rescue []
|
@categories = app.categories rescue []
|
||||||
|
@tags = app.tags rescue []
|
||||||
@widget_methods = app.get_registration.get_widget_methods
|
@widget_methods = app.get_registration.get_widget_methods
|
||||||
@widget_settings = app.get_registration.get_widget_settings
|
@widget_settings = app.get_registration.get_widget_settings
|
||||||
@data_count = nil
|
@data_count = nil
|
||||||
|
@ -93,6 +94,9 @@ class PagePartsController < ApplicationController
|
||||||
if final_params['categories'].nil?
|
if final_params['categories'].nil?
|
||||||
final_params['categories'] = []
|
final_params['categories'] = []
|
||||||
end
|
end
|
||||||
|
if final_params['tags'].nil?
|
||||||
|
final_params['tags'] = []
|
||||||
|
end
|
||||||
subpart.update_attributes(final_params)
|
subpart.update_attributes(final_params)
|
||||||
end
|
end
|
||||||
render :json => {"success"=>true}.to_json
|
render :json => {"success"=>true}.to_json
|
||||||
|
@ -119,6 +123,7 @@ class PagePartsController < ApplicationController
|
||||||
app = ModuleApp.find_by_key(module_name) rescue nil
|
app = ModuleApp.find_by_key(module_name) rescue nil
|
||||||
app = OrbitWidget.find_by_key(module_name) if app.nil?
|
app = OrbitWidget.find_by_key(module_name) if app.nil?
|
||||||
@categories = app.categories rescue []
|
@categories = app.categories rescue []
|
||||||
|
@tags = app.tags rescue []
|
||||||
@widget_methods = app.get_registration.get_widget_methods
|
@widget_methods = app.get_registration.get_widget_methods
|
||||||
@widget_settings = app.get_registration.get_widget_settings
|
@widget_settings = app.get_registration.get_widget_settings
|
||||||
@data_count = nil
|
@data_count = nil
|
||||||
|
|
|
@ -79,6 +79,7 @@ class PagesController < ApplicationController
|
||||||
OrbitHelper.set_site_locale locale
|
OrbitHelper.set_site_locale locale
|
||||||
OrbitHelper.set_this_module_app module_app.singularize
|
OrbitHelper.set_this_module_app module_app.singularize
|
||||||
OrbitHelper.set_page_categories page.categories || []
|
OrbitHelper.set_page_categories page.categories || []
|
||||||
|
OrbitHelper.set_page_tags page.tags || []
|
||||||
OrbitHelper.set_page_data_count page.data_count
|
OrbitHelper.set_page_data_count page.data_count
|
||||||
if params[:layout].kind_of?(String)
|
if params[:layout].kind_of?(String)
|
||||||
layout = to_bool(params[:layout])
|
layout = to_bool(params[:layout])
|
||||||
|
@ -155,9 +156,9 @@ class PagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if module_app.data_count.nil?
|
if module_app.data_count.nil?
|
||||||
render :json => {"categories" => @categories,"layouts" => (get_layouts module_app.key),"data_count" => {"present"=>false}}.to_json
|
render :json => {"categories" => @categories, "tags" => module_app.tags,"layouts" => (get_layouts module_app.key),"data_count" => {"present"=>false}}.to_json
|
||||||
else
|
else
|
||||||
render :json => {"categories" => @categories,"layouts" => (get_layouts module_app.key),"data_count" => {"present"=>true,"start"=>module_app.data_count.begin, "end" => module_app.data_count.end}}.to_json
|
render :json => {"categories" => @categories, "tags" => module_app.tags,"layouts" => (get_layouts module_app.key),"data_count" => {"present"=>true,"start"=>module_app.data_count.begin, "end" => module_app.data_count.end}}.to_json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -175,6 +176,7 @@ class PagesController < ApplicationController
|
||||||
@modules = ModuleApp.all.frontend_enabled
|
@modules = ModuleApp.all.frontend_enabled
|
||||||
@module_app = ModuleApp.find_by_key(@page.module) rescue nil
|
@module_app = ModuleApp.find_by_key(@page.module) rescue nil
|
||||||
@categories = @module_app.categories rescue []
|
@categories = @module_app.categories rescue []
|
||||||
|
@tags = @module_app.tags rescue []
|
||||||
if @module_app.key.eql?("member")
|
if @module_app.key.eql?("member")
|
||||||
@status = @module_app.role_status rescue []
|
@status = @module_app.role_status rescue []
|
||||||
else
|
else
|
||||||
|
@ -235,6 +237,8 @@ class PagesController < ApplicationController
|
||||||
OrbitHelper.set_widget_module_app subpart.module
|
OrbitHelper.set_widget_module_app subpart.module
|
||||||
OrbitHelper.set_widget_item_url subpart
|
OrbitHelper.set_widget_item_url subpart
|
||||||
OrbitHelper.set_widget_title subpart.title
|
OrbitHelper.set_widget_title subpart.title
|
||||||
|
OrbitHelper.set_widget_categories subpart.categories || []
|
||||||
|
OrbitHelper.set_widget_tags subpart.tags || []
|
||||||
custom_value = subpart.custom_string_field || subpart.custom_array_field rescue nil
|
custom_value = subpart.custom_string_field || subpart.custom_array_field rescue nil
|
||||||
if !custom_value.nil?
|
if !custom_value.nil?
|
||||||
OrbitHelper.set_widget_custom_value custom_value
|
OrbitHelper.set_widget_custom_value custom_value
|
||||||
|
@ -302,13 +306,13 @@ class PagesController < ApplicationController
|
||||||
page = Page.find(params[:page][:parent_page])
|
page = Page.find(params[:page][:parent_page])
|
||||||
page.url = page.url == "/" ? "" : page.url
|
page.url = page.url == "/" ? "" : page.url
|
||||||
@url = page.url + "/#{params[:page][:page_id]}"
|
@url = page.url + "/#{params[:page][:page_id]}"
|
||||||
p = params.require(:page).permit(:number, :page_type, :page_id, :module, :layout, :parent_page, :data_count, :enabled_for_mobile, enabled_for_sitemap: [], enabled_for: [], menu_enabled_for: [], categories: [], name_translations: [:en, :zh_tw],external_url_translations: [:en, :zh_tw])
|
p = params.require(:page).permit(:number, :page_type, :page_id, :module, :layout, :parent_page, :data_count, :enabled_for_mobile, enabled_for_sitemap: [], enabled_for: [], menu_enabled_for: [], categories: [], tags: [], name_translations: [:en, :zh_tw],external_url_translations: [:en, :zh_tw])
|
||||||
p["url"] = @url
|
p["url"] = @url
|
||||||
p
|
p
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_update_params
|
def page_update_params
|
||||||
p = params.require(:page).permit(:number, :page_type, :page_id, :module, :layout, :parent_page, :data_count, :enabled_for_mobile, enabled_for_sitemap: [], enabled_for: [],menu_enabled_for: [], categories: [], name_translations: [:en, :zh_tw], external_url_translations: [:en, :zh_tw])
|
p = params.require(:page).permit(:number, :page_type, :page_id, :module, :layout, :parent_page, :data_count, :enabled_for_mobile, enabled_for_sitemap: [], enabled_for: [],menu_enabled_for: [], categories: [], tags: [], name_translations: [:en, :zh_tw], external_url_translations: [:en, :zh_tw])
|
||||||
p["enabled_for"] = p["enabled_for"] || []
|
p["enabled_for"] = p["enabled_for"] || []
|
||||||
p["menu_enabled_for"] = p["menu_enabled_for"] || []
|
p["menu_enabled_for"] = p["menu_enabled_for"] || []
|
||||||
p["enabled_for_mobile"] = p["enabled_for_mobile"] || 0
|
p["enabled_for_mobile"] = p["enabled_for_mobile"] || 0
|
||||||
|
|
|
@ -7,6 +7,10 @@ module OrbitHelper
|
||||||
@categories = categories;
|
@categories = categories;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.set_page_tags(tags)
|
||||||
|
@tags = tags;
|
||||||
|
end
|
||||||
|
|
||||||
def self.set_page_data_count(data_count)
|
def self.set_page_data_count(data_count)
|
||||||
@data_count = data_count
|
@data_count = data_count
|
||||||
end
|
end
|
||||||
|
@ -30,6 +34,36 @@ module OrbitHelper
|
||||||
@categories
|
@categories
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.page_tags
|
||||||
|
@tags
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.page_for_tag(tag)
|
||||||
|
page_for_tag = nil
|
||||||
|
pages = Page.where(:module => @module_app.key)
|
||||||
|
|
||||||
|
pages.each do |page|
|
||||||
|
if page.tags.count ==1
|
||||||
|
if page.tags.include?(tag)
|
||||||
|
page_for_tag = page
|
||||||
|
end
|
||||||
|
end
|
||||||
|
break if !page_for_tag.nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
if page_for_tag.nil?
|
||||||
|
pages.each do |page|
|
||||||
|
if page.tags.include?(tag)
|
||||||
|
page_for_tag = page
|
||||||
|
end
|
||||||
|
break if !page_for_tag.nil?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
page_for_tag = pages.first if page_for_tag.nil?
|
||||||
|
'/'+I18n.locale.to_s+page_for_tag.url+'?tags[]='+tag.id.to_s
|
||||||
|
end
|
||||||
|
|
||||||
def self.this_module_app
|
def self.this_module_app
|
||||||
@module_app
|
@module_app
|
||||||
end
|
end
|
||||||
|
@ -62,6 +96,14 @@ module OrbitHelper
|
||||||
@widget_title
|
@widget_title
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.set_widget_tags(tags)
|
||||||
|
@tags = tags;
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.widget_tags
|
||||||
|
@tags
|
||||||
|
end
|
||||||
|
|
||||||
def self.params
|
def self.params
|
||||||
@params
|
@params
|
||||||
end
|
end
|
||||||
|
|
|
@ -63,21 +63,18 @@ module PagesHelper
|
||||||
controller = "#{controller_name.capitalize.pluralize}_controller".classify.constantize.new
|
controller = "#{controller_name.capitalize.pluralize}_controller".classify.constantize.new
|
||||||
OrbitHelper.set_current_widget_module controller_name
|
OrbitHelper.set_current_widget_module controller_name
|
||||||
data = controller.send("#{widget_method}")
|
data = controller.send("#{widget_method}")
|
||||||
keys = data.keys
|
|
||||||
wrap_elements = doc.css("*[data-list][data-level='0']")
|
wrap_elements = doc.css("*[data-list][data-level='0']")
|
||||||
htmls = parsing_repeats_again(wrap_elements,data,1)
|
htmls = parsing_repeats_again(wrap_elements,data,1)
|
||||||
html = doc.to_s
|
html = doc.to_s
|
||||||
htmls[0].each_with_index do |h,i|
|
htmls[0].each_with_index do |h,i|
|
||||||
html = html.gsub(h,htmls[1][i])
|
html = html.gsub(h,htmls[1][i])
|
||||||
end
|
end
|
||||||
if keys[1]
|
extras = data['extras'] || {}
|
||||||
extras = (data[keys[1]].kind_of?(Array) ? data[keys[0]] : data[keys[1]])
|
|
||||||
extras["widget-title"] = OrbitHelper.widget_title
|
extras["widget-title"] = OrbitHelper.widget_title
|
||||||
extras.each do |key,value|
|
extras.each do |key,value|
|
||||||
html = html.gsub("{{#{key}}}",value.to_s.html_safe)
|
html = html.gsub("{{#{key}}}",value.to_s.html_safe)
|
||||||
html = html.gsub("%7B%7B#{key}%7D%7D",value.to_s)
|
html = html.gsub("%7B%7B#{key}%7D%7D",value.to_s)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
html.html_safe
|
html.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Page
|
||||||
field :enabled_for_mobile, :type => Boolean, :default => true
|
field :enabled_for_mobile, :type => Boolean, :default => true
|
||||||
field :menu_enabled_for, type: Array, default: []
|
field :menu_enabled_for, type: Array, default: []
|
||||||
field :categories, type: Array, :default => []
|
field :categories, type: Array, :default => []
|
||||||
|
field :tags, type: Array, :default => []
|
||||||
field :enabled_for_sitemap, type: Array, :default => []
|
field :enabled_for_sitemap, type: Array, :default => []
|
||||||
field :rss2_id, type: String
|
field :rss2_id, type: String
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ class SubPart
|
||||||
field :content, localize: true
|
field :content, localize: true
|
||||||
field :data_count, type: Integer, default: 10
|
field :data_count, type: Integer, default: 10
|
||||||
field :categories, type: Array, :default => []
|
field :categories, type: Array, :default => []
|
||||||
|
field :tags, type: Array, :default => []
|
||||||
field :custom_string_field, type: String
|
field :custom_string_field, type: String
|
||||||
field :custom_array_field, type: Array, :default => []
|
field :custom_array_field, type: Array, :default => []
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<li class="metadata-tags">
|
<li class="metadata-tags">
|
||||||
<i class="fa fa-tags fa-fw"></i>
|
<i class="fa fa-tags fa-fw"></i>
|
||||||
<span data-list="tags" data-level="0">
|
<span data-list="tags" data-level="0">
|
||||||
<span class="tag">{{tag}}</span>
|
<a href="{{url}}"><span class="tag">{{tag}}</span></a>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
<div id="module_widget" class="tab-pane fade in <%= @subpart.kind == "module_widget" ? 'active' : '' rescue nil %>">
|
<div id="module_widget" class="tab-pane fade in <%= @subpart.kind == "module_widget" ? 'active' : '' rescue nil %>">
|
||||||
<% I18n.available_locales.each do |locale| %>
|
<% I18n.available_locales.each do |locale| %>
|
||||||
<div class="control-group input-content">
|
<div class="control-group input-content">
|
||||||
<label class="control-label muted">Widget name (<%= t(locale.to_s) %>) :</label>
|
<label class="control-label muted">Widget <%= t(:name) %>(<%= t(locale.to_s) %>) :</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input name="page_part[sub_parts_attributes][<%= @select_number %>][title_translations][<%= locale.to_s %>]" value="<%= @subpart.title_translations[locale.to_s] rescue nil %>" />
|
<input name="page_part[sub_parts_attributes][<%= @select_number %>][title_translations][<%= locale.to_s %>]" value="<%= @subpart.title_translations[locale.to_s] rescue nil %>" />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="control-group input-content">
|
<div class="control-group input-content">
|
||||||
<label class="control-label muted">Select Widget Type :</label>
|
<label class="control-label muted"><%= t('default_widget.select_widget_style') %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= select_tag("page_part[sub_parts_attributes][#{@select_number}][widget_type]",options_for_select(@widget_types, (@subpart.widget_type rescue nil))) %>
|
<%= select_tag("page_part[sub_parts_attributes][#{@select_number}][widget_type]",options_for_select(@widget_types, (@subpart.widget_type rescue nil))) %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
<% if @widget_settings['override_category_with'].nil? %>
|
<% if @widget_settings['override_category_with'].nil? %>
|
||||||
<% if !@categories.blank? %>
|
<% if !@categories.blank? %>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted">Category List :</label>
|
<label class="control-label muted"><%= t(:categories) %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<% @categories.each do |category| %>
|
<% @categories.each do |category| %>
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
|
@ -24,6 +24,23 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if !@tags.blank? %>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t(:tags) %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" <%= @subpart.tags.include?("all") ? "checked='checked'" : "" %> value="all" name="page_part[sub_parts_attributes][<%= @select_number %>][tags][]">
|
||||||
|
<%= t(:all) %>
|
||||||
|
</label>
|
||||||
|
<% @tags.each do |tag| %>
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" <%= @subpart.tags.include?(tag.id.to_s) ? "checked='checked'" : "" rescue nil %> value="<%= tag.id.to_s %>" name="page_part[sub_parts_attributes][<%= @select_number %>][tags][]">
|
||||||
|
<%= tag.name %>
|
||||||
|
</label>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if @multiselect %>
|
<% if @multiselect %>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
|
|
@ -18,22 +18,22 @@
|
||||||
<%= f.text_field :page_id %>
|
<%= f.text_field :page_id %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<label class="control-label">Module :</label>
|
<label class="control-label"><%= t(:module) %> :</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.select(:module, @modules.map{|m| [m.title,m.key]},{:include_blank => true},:class=>"module_select") %>
|
<%= f.select(:module, @modules.map{|m| [t(OrbitApp::Module::Registration.find_by_key(m.key).module_label),m.key]},{:include_blank => true},:class=>"module_select") %>
|
||||||
<%= f.hidden_field :parent_page, value: (params[:parent_page] || @page.parent_page_id) %>
|
<%= f.hidden_field :parent_page, value: (params[:parent_page] || @page.parent_page_id) %>
|
||||||
<%= f.hidden_field :page_type, value: "page" %>
|
<%= f.hidden_field :page_type, value: "page" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label"><%= "Category List :" if params[:action] == "edit" && !@categories.blank? %></label>
|
<label class="control-label"><%= t(:category)+" :" if params[:action] == "edit" && !@categories.blank? %></label>
|
||||||
<div id="categories_list">
|
<div id="categories_list">
|
||||||
<% if params[:action] == "edit" %>
|
<% if params[:action] == "edit" %>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<% if !@categories.blank? %>
|
<% if !@categories.blank? %>
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" value="all" class="checkbox-all" name="page[categories][]" <%= "checked='checked'" if (@page.categories.include? "all") %> >
|
<input type="checkbox" value="all" class="checkbox-all" name="page[categories][]" <%= "checked='checked'" if (@page.categories.include? "all") %> >
|
||||||
All
|
<%= t(:all) %>
|
||||||
</label>
|
</label>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% @categories.each do |category| %>
|
<% @categories.each do |category| %>
|
||||||
|
@ -46,6 +46,29 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label"><%= t(:tags)+" :" if params[:action] == "edit" && !@tags.blank? %></label>
|
||||||
|
<div id="tags_list">
|
||||||
|
<% if params[:action] == "edit" %>
|
||||||
|
<div class="controls">
|
||||||
|
<% if !@tags.blank? %>
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" value="all" class="checkbox-all" name="page[tags][]" <%= "checked='checked'" if (@page.tags.include? "all") %> >
|
||||||
|
<%= t(:all) %>
|
||||||
|
</label>
|
||||||
|
<% end %>
|
||||||
|
<% @tags.each do |tag| %>
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" name="page[tags][]" value="<%= tag.id.to_s %>" <%= "checked='checked'" if (@page.tags.include? tag.id.to_s) %> />
|
||||||
|
<%= tag.name %>
|
||||||
|
</label>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label"><%= "Category List :" if params[:action] == "edit" && !@status.blank? %></label>
|
<label class="control-label"><%= "Category List :" if params[:action] == "edit" && !@status.blank? %></label>
|
||||||
<div id="categories_list">
|
<div id="categories_list">
|
||||||
|
@ -54,7 +77,7 @@
|
||||||
<% if !@status.blank? %>
|
<% if !@status.blank? %>
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" value="all" class="checkbox-all" name="page[categories][]" <%= "checked='checked'" if (@page.categories.include? "all") %> >
|
<input type="checkbox" value="all" class="checkbox-all" name="page[categories][]" <%= "checked='checked'" if (@page.categories.include? "all") %> >
|
||||||
All
|
<%= t(:all) %>
|
||||||
</label>
|
</label>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% @status.each do |status| %>
|
<% @status.each do |status| %>
|
||||||
|
@ -68,7 +91,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label"><%= "Layout type :" if params[:action] == "edit" && !@layout_types.blank? %></label>
|
<label class="control-label"><%= t(:theme)+":" if params[:action] == "edit" && !@layout_types.blank? %></label>
|
||||||
<div id="layouts_list">
|
<div id="layouts_list">
|
||||||
<% if params[:action] == "edit" && !@layout_types.blank? %>
|
<% if params[:action] == "edit" && !@layout_types.blank? %>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
@ -101,7 +124,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group" id="enable-menu">
|
<div class="control-group" id="enable-menu">
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<label class="control-label">Activation :</label>
|
<label class="control-label"><%= t(:is_published) %> :</label>
|
||||||
<% I18n.available_locales.each do |locale| %>
|
<% I18n.available_locales.each do |locale| %>
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" name="page[enabled_for][]" value="<%= locale.to_s %>" class="main-enable-parent" for="<%= "checkbox_for_#{locale}" %>" <%= "checked" if @page.enabled_for.include? locale.to_s %> />
|
<input type="checkbox" name="page[enabled_for][]" value="<%= locale.to_s %>" class="main-enable-parent" for="<%= "checkbox_for_#{locale}" %>" <%= "checked" if @page.enabled_for.include? locale.to_s %> />
|
||||||
|
|
|
@ -20,6 +20,22 @@ module OrbitTag
|
||||||
self.where(:id.in=>result.map{|taggable| taggable.id})
|
self.where(:id.in=>result.map{|taggable| taggable.id})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def filter_by_tags(tags=[])
|
||||||
|
tags = OrbitHelper.page_tags if tags.blank?
|
||||||
|
tags = [tags].flatten.uniq
|
||||||
|
result = []
|
||||||
|
|
||||||
|
if tags.blank? or (tags.include?("all") rescue false)
|
||||||
|
self.all
|
||||||
|
else
|
||||||
|
self.all.each do |taggable|
|
||||||
|
result << taggable if (taggable.taggings.map{|t| t.tag.id.to_s } & tags).size > 0
|
||||||
|
end
|
||||||
|
self.where(:id.in=>result.map{|taggable| taggable.id})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def tags
|
def tags
|
||||||
|
|
Loading…
Reference in New Issue