forked from saurabh/orbit4-5
Fix page edit form category_list tag_list stats_list
This commit is contained in:
parent
3f285d9c1e
commit
03baa31648
|
@ -129,11 +129,13 @@ var Items = function(){
|
||||||
var this_value = $(this).val(),
|
var this_value = $(this).val(),
|
||||||
categories_list = $("#categories_list")
|
categories_list = $("#categories_list")
|
||||||
tags_list = $("#tags_list"),
|
tags_list = $("#tags_list"),
|
||||||
|
status_list = $("#status_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("");
|
tags_list.html("");
|
||||||
|
status_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 %>",
|
||||||
|
@ -142,7 +144,6 @@ 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("<%= I18n.t(:category) %> :");
|
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' /> <%= I18n.t(:all) %> </label>");
|
var checkbox = $("<label class='checkbox'><input type='checkbox' value='all' name='page[categories][]' class='checkbox-all' /> <%= I18n.t(:all) %> </label>");
|
||||||
|
@ -170,6 +171,20 @@ var Items = function(){
|
||||||
tags_list.parent().find("label.control-label").text("");
|
tags_list.parent().find("label.control-label").text("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var controlDiv = $("<div class='controls'></div>");
|
||||||
|
if(data.role_status.length){
|
||||||
|
status_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' /> <%= I18n.t(:all) %> </label>");
|
||||||
|
controlDiv.append(checkbox);
|
||||||
|
$.each(data.role_status,function(i,category){
|
||||||
|
var checkbox = $("<label class='checkbox'><input type='checkbox' value='"+ category.id +"' name='page[categories][]' /> " + category.title + " </label>");
|
||||||
|
controlDiv.append(checkbox);
|
||||||
|
})
|
||||||
|
status_list.html(controlDiv);
|
||||||
|
}else{
|
||||||
|
status_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>"),
|
||||||
|
|
|
@ -140,25 +140,28 @@ class PagesController < ApplicationController
|
||||||
def get_categories
|
def get_categories
|
||||||
module_app = ModuleApp.find_by_key(params[:module]);
|
module_app = ModuleApp.find_by_key(params[:module]);
|
||||||
if module_app.key.eql?("member")
|
if module_app.key.eql?("member")
|
||||||
@categories = module_app.role_status.collect do |cat|
|
role_status = module_app.role_status.collect do |cat|
|
||||||
{
|
{
|
||||||
"title" => "#{cat.title} (#{cat.role.title})",
|
"title" => "#{cat.title} (#{cat.role.title})",
|
||||||
"id" => cat.id.to_s
|
"id" => cat.id.to_s
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@categories = module_app.categories.collect do |cat|
|
categories = module_app.categories.collect do |cat|
|
||||||
{
|
{
|
||||||
"title" => cat.title,
|
"title" => cat.title,
|
||||||
"id" => cat.id.to_s
|
"id" => cat.id.to_s
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
role_status = role_status.nil? ? [] : role_status
|
||||||
|
categories = categories.nil? ? [] : categories
|
||||||
|
|
||||||
if module_app.data_count.nil?
|
if module_app.data_count.nil?
|
||||||
render :json => {"categories" => @categories, "tags" => module_app.tags,"layouts" => (get_layouts module_app.key),"data_count" => {"present"=>false}}.to_json
|
render :json => {"categories" => categories, "tags" => module_app.tags,"role_status" => role_status,"layouts" => (get_layouts module_app.key),"data_count" => {"present"=>false}}.to_json
|
||||||
else
|
else
|
||||||
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
|
render :json => {"categories" => categories, "tags" => module_app.tags,"role_status" => role_status,"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
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<div class="view-page">
|
<div class="view-page">
|
||||||
<div class="nano">
|
<div class="nano">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<%= form_for :category, url: nil, remote: true do |f| %>
|
<%= form_for :category, url: nil, remote: true, :html=>{id: "category_form"} do |f| %>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<%= f.fields_for :title_translations do |f| %>
|
<%= f.fields_for :title_translations do |f| %>
|
||||||
<% @site_in_use_locales.each do |locale| %>
|
<% @site_in_use_locales.each do |locale| %>
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
$.each($('form input:text'),function(){
|
$.each($('#category_form input:text'),function(){
|
||||||
$(this).blur(function(){
|
$(this).blur(function(){
|
||||||
validate($(this));
|
validate($(this));
|
||||||
});
|
});
|
||||||
|
@ -66,7 +66,8 @@
|
||||||
|
|
||||||
$("#category_submit").click(function(){
|
$("#category_submit").click(function(){
|
||||||
var valid = true;
|
var valid = true;
|
||||||
$.each($("form input:text"),function(){
|
$.each($("#category_form input:text"),function(){
|
||||||
|
console.log(valid);
|
||||||
if(!validate($(this))) valid=false;
|
if(!validate($(this))) valid=false;
|
||||||
});
|
});
|
||||||
if(!valid) return false;
|
if(!valid) return false;
|
||||||
|
|
|
@ -69,9 +69,9 @@
|
||||||
</div>
|
</div>
|
||||||
</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="status_list">
|
||||||
<% if params[:action] == "edit" %>
|
<% if params[:action] == "edit" %>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<% if !@status.blank? %>
|
<% if !@status.blank? %>
|
||||||
|
@ -89,7 +89,8 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label"><%= t(:theme)+":" 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">
|
||||||
|
|
Loading…
Reference in New Issue