diff --git a/app/assets/javascripts/lib/items/items.js.erb b/app/assets/javascripts/lib/items/items.js.erb index 46cdc21..d9b9677 100755 --- a/app/assets/javascripts/lib/items/items.js.erb +++ b/app/assets/javascripts/lib/items/items.js.erb @@ -129,11 +129,13 @@ var Items = function(){ var this_value = $(this).val(), categories_list = $("#categories_list") tags_list = $("#tags_list"), + status_list = $("#status_list"), layouts_list = $("#layouts_list"), data_count_area = $("#data_count_area"); categories_list.html(""); tags_list.html(""); + status_list.html(""); if(this_value){ $.ajax({ url : "<%= Rails.application.routes.url_helpers.pages_get_categories_path %>", @@ -142,7 +144,6 @@ var Items = function(){ dataType : "json" }).done(function(data){ var controlDiv = $("
"); - if(data.categories.length){ categories_list.parent().find("label.control-label").text("<%= I18n.t(:category) %> :"); var checkbox = $(""); @@ -170,6 +171,20 @@ var Items = function(){ tags_list.parent().find("label.control-label").text(""); } + var controlDiv = $("
"); + if(data.role_status.length){ + status_list.parent().find("label.control-label").text("<%= I18n.t(:category) %> :"); + var checkbox = $(""); + controlDiv.append(checkbox); + $.each(data.role_status,function(i,category){ + var checkbox = $(""); + controlDiv.append(checkbox); + }) + status_list.html(controlDiv); + }else{ + status_list.parent().find("label.control-label").text(""); + } + if(data.layouts.length){ layouts_list.parent().find("label.control-label").text("Layout type:"); var controlDiv = $("
"), diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 7542d99..acdf7c0 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -140,25 +140,28 @@ class PagesController < ApplicationController def get_categories module_app = ModuleApp.find_by_key(params[:module]); 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})", "id" => cat.id.to_s } end else - @categories = module_app.categories.collect do |cat| + categories = module_app.categories.collect do |cat| { "title" => cat.title, "id" => cat.id.to_s } end end + + role_status = role_status.nil? ? [] : role_status + categories = categories.nil? ? [] : categories 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 - 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 diff --git a/app/views/admin/categories/index.html.erb b/app/views/admin/categories/index.html.erb index d583e88..e47f01e 100644 --- a/app/views/admin/categories/index.html.erb +++ b/app/views/admin/categories/index.html.erb @@ -12,7 +12,7 @@
- <%= form_for :category, url: nil, remote: true do |f| %> + <%= form_for :category, url: nil, remote: true, :html=>{id: "category_form"} do |f| %>
<%= f.fields_for :title_translations do |f| %> <% @site_in_use_locales.each do |locale| %> @@ -54,7 +54,7 @@ } $(function(){ - $.each($('form input:text'),function(){ + $.each($('#category_form input:text'),function(){ $(this).blur(function(){ validate($(this)); }); @@ -66,7 +66,8 @@ $("#category_submit").click(function(){ var valid = true; - $.each($("form input:text"),function(){ + $.each($("#category_form input:text"),function(){ + console.log(valid); if(!validate($(this))) valid=false; }); if(!valid) return false; diff --git a/app/views/pages/_form.html.erb b/app/views/pages/_form.html.erb index 3de7e8a..286b7a8 100644 --- a/app/views/pages/_form.html.erb +++ b/app/views/pages/_form.html.erb @@ -69,9 +69,9 @@
-
+
-
+
<% if params[:action] == "edit" %>
<% if !@status.blank? %> @@ -89,7 +89,8 @@
<% end %>
-
+
+