new ui for faq and announcement status fixed.

This commit is contained in:
Harry Bomrah 2013-08-20 15:54:56 +08:00 committed by saurabhbhatia
parent 21a7b5da5c
commit 897ed49d2e
26 changed files with 369 additions and 632 deletions

View File

@ -307,6 +307,15 @@
$(this).parents('.start-line').hide(); $(this).parents('.start-line').hide();
} }
}); });
$(document).on('click',"*[data-toggle=buttons-checkbox] input",function(){
var d = $(this).parent().find("input[type=hidden]");
if($(this).is(":checked")){
d.val("1");
}else{
d.val("0");
}
})
}); });
</script> </script>
<% end %> <% end %>

View File

@ -1,104 +0,0 @@
class Panel::Faq::BackEnd::QaCategorysController < OrbitBackendController
before_filter :for_app_manager,:except => [:index]
include OrbitControllerLib::DivisionForDisable
def index
@qa_categorys = get_categories_for_index("QaCategory")
@qa_category = QaCategory.new(:display => 'List')
@url = panel_faq_back_end_qa_categorys_path
respond_to do |format|
format.html # index.html.erb
format.js
end
end
# GET /qas/1
# GET /qas/1.xml
def show
@qa_category = QaCategory.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.js
end
end
# GET /qas/new
# GET /qas/new.xml
def new
@qa_category = QaCategory.new(:display => 'List')
respond_to do |format|
format.html # new.html.erb
format.js
end
end
# GET /qas/1/edit
def edit
@qa_category = QaCategory.find(params[:id])
@url = panel_faq_back_end_qa_category_path(@qa_category)
respond_to do |format|
format.html
format.js
end
end
# POST /qas
# POST /qas.xml
def create
@qa_category = QaCategory.new(params[:qa_category])
respond_to do |format|
if @qa_category.save
format.html { redirect_to(panel_faq_back_end_qa_categorys_url, :notice => t('qa.create_qa_category_success')) }
format.js
else
format.html { render :action => "new" }
format.js { render action: "new" }
end
end
end
# PUT /qas/1
# PUT /qas/1.xml
def update
@qa_category = QaCategory.find(params[:id])
@url = panel_faq_back_end_qa_category_path(@qa_category)
respond_to do |format|
if @qa_category.update_attributes(params[:qa_category])
format.html { redirect_to(panel_faq_back_end_qa_categorys_url, :notice => t('qa.update_qa_category_success')) }
# format.xml { head :ok }
format.js
else
format.html { render :action => "edit" }
format.js { render :action => "edit" }
end
end
end
# DELETE /qas/1
# DELETE /qas/1.xml
def destroy
@qa_category = QaCategory.find(params[:id])
@qa_category.disable = @qa_category.disable ? false : true
if @qa_category.save!
respond_to do |format|
format.html { redirect_to(panel_faq_back_end_qa_categorys_url) }
# format.xml { head :ok }
format.js
end
else
flash[:error] = t("update.fail")
format.html { render :action => "index" }
end
end
end

View File

@ -1,44 +1,24 @@
class Panel::Faq::BackEnd::QasController < OrbitBackendController class Panel::Faq::BackEnd::QasController < OrbitBackendController
# before_filter :for_app_manager,:except => [:index,:show] # before_filter :for_app_manager,:except => [:index,:show]
include AdminHelper include AdminHelper
include OrbitControllerLib::DivisionForDisable # include OrbitControllerLib::DivisionForDisable
before_filter :force_order_for_visitor,:only=>[:index] before_filter :force_order_for_visitor,:only=>[:index]
before_filter :force_order_for_user,:except => [:index] before_filter :force_order_for_user,:except => [:index]
before_filter :for_app_sub_manager,:except => [:index] before_filter :for_app_sub_manager,:except => [:index]
before_filter :only => [ :new,:edit,:update,:create] do |controller| before_filter :only => [ :new, :create, :edit, :update ] do |controller|
controller.get_categorys('QaCategory') @categories = get_categories_for_form
end end
def index def index
get_categorys("QaCategory",params[:qa_category_id])
@filter = params[:filter]
new_filter = params[:new_filter]
if @filter && params[:clear]
@filter.delete(params[:type])
elsif @filter && new_filter
if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s)
@filter[new_filter[:type]].delete(new_filter[:id].to_s)
elsif @filter.has_key?(new_filter[:type])
@filter[new_filter[:type]] << new_filter[:id].to_s
else
@filter.merge!({new_filter[:type] => [new_filter[:id].to_s]})
end
elsif new_filter
@filter = {new_filter[:type] => [new_filter[:id].to_s]}
end
@qa_categories = get_categories_for_index("QaCategory")
@qa_category_ids = @qa_categories.collect{|t| t.id.to_s} + [nil]
# @qas = Qa.search(params[:category_id])
#@qas = (params[:sort] || @filter) ? get_sorted_and_filtered_qas : Qa.all.page(params[:page]).per(10)
@qas = (params[:sort] || @filter) ? get_sorted_and_filtered("qa",:qa_category_id.in => @qa_category_ids) : get_viewable("qa",:qa_category_id.in => @qa_category_ids)
@all_qas = @qas.page params[:page]
@tags = get_tags @tags = get_tags
@categories = get_categories_for_index
@statuses = get_statuses
category_ids = @categories.collect{|t| t.id}
@qas = get_sorted_and_filtered("qa", :category_id.in => category_ids)
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
format.xml { render :xml => @qas } format.xml { render :xml => @qas }
@ -61,7 +41,7 @@ class Panel::Faq::BackEnd::QasController < OrbitBackendController
def new def new
@qa = Qa.new @qa = Qa.new
@tags = get_tags @tags = get_tags
@statuses = get_statuses
respond_to do |format| respond_to do |format|
format.html # new.html.erb format.html # new.html.erb
format.xml { render :xml => @qa } format.xml { render :xml => @qa }
@ -71,6 +51,7 @@ class Panel::Faq::BackEnd::QasController < OrbitBackendController
# GET /qas/1/edit # GET /qas/1/edit
def edit def edit
@qa = Qa.find(params[:id]) @qa = Qa.find(params[:id])
@statuses = get_statuses
@tags = get_tags @tags = get_tags
end end
@ -97,14 +78,12 @@ class Panel::Faq::BackEnd::QasController < OrbitBackendController
# PUT /qas/1.xml # PUT /qas/1.xml
def update def update
@qa = Qa.find(params[:id]) @qa = Qa.find(params[:id])
@qa.update_user_id = current_user.id @qa.update_user_id = current_user.id
params[:qa][:tag_ids] ||=[]
respond_to do |format| respond_to do |format|
if @qa.update_attributes(params[:qa]) if @qa.update_attributes(params[:qa])
format.html { redirect_to(panel_faq_back_end_qas_url(:page => params[:page])) }
format.html { redirect_to(panel_faq_back_end_qas_path) }
format.js { render 'toggle_enable' } format.js { render 'toggle_enable' }
format.xml { head :ok } format.xml { head :ok }
else else

View File

@ -8,6 +8,7 @@ class Qa
include OrbitModel::LanguageRestrict include OrbitModel::LanguageRestrict
include OrbitModel::Status include OrbitModel::Status
include OrbitTag::Taggable include OrbitTag::Taggable
include OrbitCategory::Categorizable
field :title, localize: true field :title, localize: true
field :answer, localize: true field :answer, localize: true

View File

@ -1,27 +0,0 @@
# encoding: utf-8
class QaCategory
include Mongoid::Document
include Mongoid::Timestamps
include OrbitCoreLib::ObjectAuthable
include OrbitCoreLib::ObjectDisable
# include Mongoid::MultiParameterAttributes
AfterObjectAuthUrl = '/panel/page_content/back_end/page_contexts'
APP_NAME = 'faq'
ObjectAuthTitlesOptions = %W{edit}
field :key
field :title, localize: true
has_many :qas
def pp_object
title
end
def self.from_id(id)
QaCategory.find(id) rescue nil
end
end

View File

@ -1,30 +0,0 @@
<% # encoding: utf-8 %>
<%= form_for(@qa_category, :remote => true, :url => @url) do |f| %>
<h2><%= (@qa_category.new_record? ? t(:add) : t(:edit)) %></h2>
<div id="widget-title">
<%= f.label :key, t(:key) %>
<%= f.text_field :key %>
</div>
<div id="widget-title">
<%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group">
<%= label_tag "name-#{locale}", "#{t(:name)}-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge', :value => (@qa_category.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
<div class="form-actions">
<%= f.submit t(:submit), :class=>'btn btn-primary' %>
</div>
<% end %>

View File

@ -1,19 +0,0 @@
<tr id="<%= dom_id qa_category %>" class="with_action">
<td>
<%= qa_category.key %>
<%if at_least_module_manager %>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t(:edit), edit_panel_faq_back_end_qa_category_path(qa_category), :remote => true %></li>
<li><%= link_to show_toggle_archive_btn(qa_category), panel_faq_back_end_qa_category_path(qa_category), :confirm => t(:sure?), :method => :delete, :remote => true ,:class=> "archive_toggle"%></li>
<li><%#= show_qa_permission_link qa_category %></li>
</ul>
</div>
<% end -%>
</td>
<% @site_valid_locales.each do |locale| %>
<td><%= qa_category.title_translations[locale] rescue nil %></td>
<% end %>
</tr>

View File

@ -1,2 +0,0 @@
$('<%= j render :partial => 'qa_category', :collection => [@qa_category] %>').appendTo('#qa_categorys').hide().fadeIn();
$("#new_qa_category")[0].reset();

View File

@ -1 +0,0 @@
$("#<%= dom_id @qa_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@qa_category) %> ");

View File

@ -1 +0,0 @@
$("#form > form").replaceWith("<%= j render "form" %>");

View File

@ -1 +0,0 @@
$("#form > form").replaceWith("<%= j render "form" %>");

View File

@ -1 +0,0 @@
$("#form > form").replaceWith("<%= j render "form" %>");

View File

@ -1,39 +0,0 @@
<%= flash_messages %>
<div id="filter" class="subnav">
<div class="filters">
<div id="sort_headers" class="table-label">
<table class="table main-list">
<thead>
<tr>
<th class="span1-2"><%= t(:key) %></th>
<% @site_valid_locales.each do |locale| %>
<th class="span1-2"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></th>
<% end %>
</tr>
</thead>
</table>
</div>
</div>
</div>
<table id="qa_categorys" class="table main-list">
<thead>
<tr>
<th class="span1-2"></th>
<% @site_valid_locales.each do |locale| %>
<th class="span1-2"></th>
<% end %>
</tr>
</thead>
<tbody class="sort-holder">
<%= render :partial => 'qa_category', :collection => @qa_categorys %>
</tbody>
</table>
<div id="form"><%= render :partial => "form" if at_least_module_manager%></div>

View File

@ -1 +0,0 @@
$("#form > form").replaceWith("<%= j render "form" %>");

View File

@ -1 +0,0 @@
$("#form > form").replaceWith("<%= j render "form" %>");

View File

@ -1 +0,0 @@
$("#form > form").replaceWith("<%= j render "form" %>");

View File

@ -1,3 +0,0 @@
$.each($(".quick_edit"),function(obj){ $(this).remove(); });
$("#<%= dom_id @qa_category %>").append("<div class='quick_edit'><%= j render "form" %></div>");
//$("#form > form").replaceWith("<%= j render "form" %>");

View File

@ -1,4 +0,0 @@
$("#<%= dom_id @qa_category %>").replaceWith("<%= j render :partial => 'qa_category', :collection => [@qa_category] %>");
<% @qa_category = QaCategory.new(:display => 'List') # reset for new form %>
$(".edit_qa_category").replaceWith("<%= j render "form" %>")
$(".new_qa_category")[0].reset();

View File

@ -1,228 +1,233 @@
<div id= "poststuff"> <% content_for :page_specific_css do %>
<% # encoding: utf-8 %> <%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/modal-preview" %>
<%= javascript_include_tag "lib/file-type" %>
<% end %>
<%= f.error_messages %> <%= f.error_messages %>
<fieldset>
<!-- Input Area -->
<div class="input-area">
<!--Widget start--> <!-- Module Tabs -->
<div class="nav-name"><strong>Module</strong></div>
<ul class="nav nav-pills module-nav">
<li class="active">
<a href="#basic" data-toggle="tab">Basic</a>
</li>
<li>
<a href="#status" data-toggle="tab">Status</a>
</li>
<li>
<a href="#tag" data-toggle="tab">Tags</a>
</li>
</ul>
<div id="sub-wiget"> <!-- Module -->
<div class="tab-content module-area">
<div id="widget-status" class="widget-box widget-size-300"> <!-- Basic Module -->
<div class="widget-action clear tip" title="Setting the announcement state"> <div class="tab-pane fade in active" id="basic">
<a class="action"><i class="icon-exclamation-sign icon-white"></i></a>
</div> <!-- Category -->
<h3 class="widget-title"><i class="icons-star"></i><%= t(:status) %></h3> <div class="control-group">
<div class="widget-content clear"> <%= f.label :category ,t(:category), :class=>"control-label muted" %>
<div class="controls"> <div class="controls">
<%= content_tag :label,:class => "checkbox inline" do -%> <%= f.select :category_id, @categories.collect{|t| [ t.title, t.id ]} %>
<%= f.check_box :is_top %>
<%= t('top') %>
<% end -%>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= f.check_box :is_hot %>
<%= t('hot') %>
<% end -%>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= f.check_box :is_hidden %>
<%= t('hide') %>
<% end -%>
</div>
</div> </div>
</div> </div>
<div id="widget-tags" class="widget-box widget-size-300">
<div class="widget-action clear tip" title="Setting">
<a class="action"><i class="icon-cog icon-white"></i></a>
</div> </div>
<h3 class="widget-title"><i class="icons-tag"></i><%= t('nccu.tags') %></h3>
<div class="widget-content clear form-horizontal"> <!-- Status Module -->
<div class="tab-pane fade" id="status">
<!-- Status -->
<div class="control-group">
<label class="control-label muted">Status</label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @qa.is_top? %>">
<%= f.check_box :is_top %> <%= t(:top) %>
</label>
<label class="checkbox inline btn <%= 'active' if @qa.is_hot? %>">
<%= f.check_box :is_hot %> <%= t(:hot) %>
</label>
<label class="checkbox inline btn <%= 'active' if @qa.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
<!-- Tag Module -->
<div class="tab-pane fade" id="tag">
<!-- Tag -->
<div class="control-group">
<label class="control-label muted">Tag</label>
<div class="controls" data-toggle="buttons-checkbox">
<% @tags.each do |tag| %> <% @tags.each do |tag| %>
<%= content_tag :label,:class => "checkbox inline" do -%> <label class="checkbox inline btn <%= 'active' if @qa.tag_ids.include?(tag.id) %>">
<%= check_box_tag 'qa[tag_ids][]', tag.id, @qa.tag_ids.include?(tag.id)%> <%= check_box_tag 'qa[tag_ids][]', tag.id, @qa.tag_ids.include?(tag.id)%>
<%= tag.name %> <%= tag.name %>
<%= hidden_field_tag 'qa[tag_ids][]', '' %>
<% end %>
<% end %> <% end %>
</div> </div>
</div> </div>
</div> </div>
</div>
<!--Wiget End--> <!-- Language Tabs -->
<!--Post Start--> <div class="nav-name"><strong>Language</strong></div>
<ul class="nav nav-pills language-nav">
<div id="post-body">
<div id="post-body-content" class="clear">
<%= f.label :category ,t(:category)%>
<%= f.select :qa_category_id, @qa_categorys.collect {|t| [ t.title, t.id ]} %>
<ul class="nav nav-tabs">
<% @site_valid_locales.each_with_index do |locale, i| %> <% @site_valid_locales.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? "class=active" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li> <li <%= ( i == 0 ) ? "class=active" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %> <% end %>
</ul> </ul>
<div class="tab-content"> <!-- Language -->
<div class="tab-content language-area">
<% @site_valid_locales.each_with_index do |locale, i| %> <% @site_valid_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>"> <div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<div class="title"> <div class="control-group input-title">
<%= f.label :title , t('faq.question') %> <%= f.label :title , t('faq.question'), :class=>"control-label muted" %>
<div class="controls">
<%= f.fields_for :title_translations do |f| %> <%= f.fields_for :title_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title', :value => (@qa.title_translations[locale] rescue nil) %> <%= f.text_field locale, :class=>'post-title', :value => (@qa.title_translations[locale] rescue nil) %>
<% end %> <% end %>
</div> </div>
</div>
<div class="editor"> <div class="control-group input-content">
<%= f.label :answer ,t('faq.answer') %> <%= f.label :answer ,t('faq.answer'), :class => "control-label muted" %>
<%= f.fields_for :answer_translations do |f| %> <%= f.fields_for :answer_translations do |f| %>
<%= I18nVariable.from_locale(locale) %> <div class="controls">
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea', :value => (@qa.answer_translations[locale] rescue nil) %> <div class="textarea">
<%= f.text_area locale, :style=>"width:100%", :class => 'ckeditor input-block-level', :value => (@qa.answer_translations[locale] rescue nil) %>
</div>
</div>
<% end %> <% end %>
</div> </div>
</div> </div>
<% end %> <% end %>
<!-- Link -->
<div class="control-group">
<label class="control-label muted">Link</label>
<div class="controls add-input">
</div> <!-- Exist -->
<% if @qa && !@qa.qa_links.blank? %>
<div class="exist">
<div class="main-wiget">
<div id="widget-link" class="widget-box">
<div class="widget-action clear tip" title="Add a reference link">
<a class="action"><i class="icon-exclamation-sign icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-link"></i><%= t(:link) %></h3>
<div class="widget-content">
<div id='qa_links' class="qa_links_block">
<table class="table table-condensed">
<thead>
<tr>
<th><%= t('nccu.url') %></th>
<th><%= t('nccu.link_name') %></th>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td style="text-align:center" colspan="4">
<div id='add_qa_link' class="info_input qa_links_block">
<%= hidden_field_tag 'qa_link_field_count', @qa.qa_links.count %>
<a class="add"><span class="btn btn-primary btn-small"><i class="icon-plus icon-white"></i><%= t(:add) %></span></a>
</div>
</td>
</tr>
</tfoot>
<tbody>
<% @qa.qa_links.each_with_index do |qa_link, i| %> <% @qa.qa_links.each_with_index do |qa_link, i| %>
<%= f.fields_for :qa_links, qa_link do |f| %> <%= f.fields_for :qa_links, qa_link do |f| %>
<%= render :partial => 'form_qa_link', :object => qa_link, :locals => {:f => f, :i => i} %> <%= render :partial => 'form_qa_link', :object => qa_link, :locals => {:f => f, :i => i} %>
<% end %> <% end %>
<% end %> <% end %>
<hr>
</tbody>
</table>
</div> </div>
<% end %>
<!-- Add -->
<div class="add-target"></div>
<p class="add-btn">
<%= hidden_field_tag 'qa_link_field_count', @qa.qa_links.count %>
<a id="add_link" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div> </div>
</div> </div>
<div id="widget-file" class="widget-box">
<div class="widget-action clear tip" title="Added to the file">
<a class="action"><i class="icon-exclamation-sign icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-paperclip"></i><%= t('nccu.file') %></h3>
<div class="widget-content">
<div id='qa_files' class="qa_files_block"> <!-- File -->
<div class="control-group">
<label class="control-label muted">File</label>
<div class="controls">
<table class="table table-condensed"> <!-- Exist -->
<thead> <% if @qa && !@qa.qa_files.blank? %>
<tr> <div class="exist">
<th><%= t('nccu.selected_file') %></th>
<th><%= t('nccu.file_name') %></th>
<th><%= t('nccu.file_description') %></th>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td style="text-align:center" colspan="4">
<div id='add_qa_file' class="info_input qa_files_block">
<%= hidden_field_tag 'qa_file_field_count', @qa.qa_files.count %>
<a class="add"><span class="btn btn-primary btn-small"><i class="icon-plus icon-white"></i><%= t(:add) %></span></a>
<p><%= t("sys.limit_of_upload_file_size",:best_size => '3MB') %></p>
<p><%= t("sys.preview_only_for_img") %></p>
</div>
</td>
</tr>
</tfoot>
<tbody>
<% @qa.qa_files.each_with_index do |qa_file, i| %> <% @qa.qa_files.each_with_index do |qa_file, i| %>
<%= f.fields_for :qa_files, qa_file do |f| %> <%= f.fields_for :qa_files, qa_file do |f| %>
<%= render :partial => 'form_qa_file', :object => qa_file, :locals => {:f => f, :i => i} %> <%= render :partial => 'form_qa_file', :object => qa_file, :locals => {:f => f, :i => i} %>
<% end %> <% end %>
<% end %> <% end %>
<hr>
</tbody>
</table>
</div> </div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'qa_file_field_count', @qa.qa_files.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- Form Actions -->
<!--Post End-->
</div>
<div class="form-actions"> <div class="form-actions">
<%= hidden_field_tag 'page', params[:page] if !params[:page].blank? %> <%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= f.submit t('submit'), :class=>'btn btn-primary' %> <%= button_tag t("preview"), id: "button_for_preview", name: "commit", class: 'btn post_preview', type: :button, url: preview_panel_announcement_back_end_bulletins_path %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %> <%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div> </div>
</div>
</fieldset>
<% content_for :page_specific_javascript do %> <% content_for :page_specific_javascript do %>
<%= javascript_include_tag "faq/qa_form" %>
<%= javascript_include_tag "inc/jquery.imagesloaded.js" %>
<script> <script>
$(document).ready(function() { $(function() {
$(document).on('click', '#add_link', function(){
$('#add_qa_link a.add').live('click', function(){
var new_id = $(this).prev().attr('value'); var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_qa_links", "g"); var old_id = new RegExp("new_qa_links", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1); $(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_qa_link', f, :qa_links) %>").replace(old_id, new_id)); $(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_qa_link', f, :qa_links) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.tab-content').children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
formTip();
}); });
$('#add_qa_file a.add').live('click', function(){ $(document).on('click', '#add_file', function(){
var new_id = $(this).prev().attr('value'); var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_qa_files", "g"); var old_id = new RegExp("new_qa_files", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1); $(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_qa_file', f, :qa_files) %>").replace(old_id, new_id)); $(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_qa_file', f, :qa_files) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
}); });
$('.for_preview').popover({ html : true }); formTip();
});
$(document).on('click', '.delete_link', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
$(document).on('click',"*[data-toggle=buttons-checkbox] input",function(){
var d = $(this).parent().find("input[type=hidden]");
if($(this).is(":checked")){
d.val("1");
}else{
d.val("0");
}
})
}); });
</script> </script>
<% end %> <% end %>

View File

@ -1,74 +1,55 @@
<% # encoding: utf-8 %>
<tr id="<%= "qa_file_#{form_qa_file.id}" if !form_qa_file.new_record? %>" class='list_item'>
<td>
<div class="control-group">
<div class="controls">
<%= f.file_field :file %>
<%= form_qa_file.file.file ? ( link_to t(:view), form_qa_file.file.url, {:class => 'btn', :target => '_blank', :title => t(:view)} ) : '' %>
</div>
</div>
</td>
<td>
<div class="tab-content">
<% @site_valid_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<%= f.fields_for :title_translations do |f| %>
<div class="control-group">
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls">
<%= f.text_field locale, :id => "link-#{locale}", :value => (form_qa_file.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
</div>
<% end %>
</div>
</td>
<td>
<div class="tab-content">
<% @site_valid_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<%= f.fields_for :description_translations do |f| %>
<div class="control-group">
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls">
<%= f.text_field locale, :id => "link-#{locale}", :value => (form_qa_file.description_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
</div>
<% end %>
</div>
</td>
<td>
<span class="action">
<% if form_qa_file.new_record? %> <% if form_qa_file.new_record? %>
<a class="delete"><i class="icon-remove"></i></a> <div class="fileupload fileupload-new start-line" data-provides="fileupload">
<% else %> <% else %>
<%= f.hidden_field :id %> <div class="fileupload fileupload-exist start-line" data-provides="fileupload">
<%= hidden_field_tag :tr, (dom_id form_qa_file) %> <% if form_qa_file.file.blank? %>
<a class="remove_existing_record"><i class="icon-remove"></i></a> <%= t(:no_file) %>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %> <% else %>
<%= link_to content_tag(:i) + form_qa_file.file_identifier, form_qa_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_qa_file.file_identifier} %>
<% end %>
<% end %>
<div class="input-prepend input-append">
<label>
<span class="add-on btn btn-file" title='<%= t(:file_) %>'>
<i class="icons-paperclip"></i>
<%= f.file_field :file %>
</span>
<div class="uneditable-input input-medium">
<i class="icon-file fileupload-exists"></i>
<span class="fileupload-preview"><%= (form_qa_file.new_record? || form_qa_file.file.blank?) ? t(:select_file) : t(:change_file) %></span>
</div>
</label>
<span class="add-on icons-pencil" title='<%= t(:alternative) %>'></span>
<span class="tab-content">
<% @site_valid_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_qa_file.title_translations[locale] rescue nil) %>
<% end %> <% end %>
</span> </span>
<% end %>
</td> </span>
</tr> <span class="add-on icons-pencil" title='<%= t(:description) %>'></span>
<span class="tab-content">
<% @site_valid_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :description_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:description), :value => (form_qa_file.description_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
</span>
<% if form_qa_file.new_record? %>
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>
</div>

View File

@ -1,48 +1,26 @@
<div class="input-prepend input-append start-line">
<tr id="<%= "qa_link_#{form_qa_link.id}" if !form_qa_link.new_record? %>" class='list_item'> <span class="add-on icons-link" title="<%= t(:url) %>"></span>
<%= f.text_field :url, class: "input-large", placeholder: t(:url) %>
<td> <span class="add-on icons-pencil" title="<%= t(:url_alt) %>"></span>
<div class="control-group"> <span class="tab-content">
<div class="controls">
<%= f.text_field :url %>
</div>
</div>
</td>
<td>
<div class="tab-content">
<% @site_valid_locales.each_with_index do |locale, i| %> <% @site_valid_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<%= f.fields_for :title_translations do |f| %> <%= f.fields_for :title_translations do |f| %>
<div class="control-group"> <%= f.text_field locale, :class => "input-large", placeholder: t(:url_alt), :value => (form_link.title_translations[locale] rescue nil) %>
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
<div class="controls">
<%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge", :value => (form_qa_link.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
</div>
<% end %>
</div>
</td>
<td>
<span class="action">
<% if form_qa_link.new_record? %>
<a class="delete"><i class="icon-remove"></i></a>
<% else %>
<%= f.hidden_field :id %>
<%= hidden_field_tag :tr, (dom_id form_qa_link) %>
<a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
<% end %> <% end %>
</span> </span>
</td> <% end %>
</tr> </span>
<% if form_qa_link.new_record? %>
<span class="delete_link add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class="remove_existing_record icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>

View File

@ -1,5 +1,5 @@
<h1><%= t('qa.editing_faq') %></h1> <h1><%= t('qa.editing_faq') %></h1>
<%= form_for @qa, :url => panel_faq_back_end_qa_path(@qa), :html => {:class => 'clear'} do |f| %> <%= form_for @qa, :url => panel_faq_back_end_qa_path(@qa), :html => {:class => 'form-horizontal main-forms'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %> <%= render :partial => 'form', :locals => {:f => f} %>
<% end %> <% end %>

View File

@ -1,22 +1,41 @@
<%= render 'filter' %> <% set_default_index do
<table class="table main-list"> objects @qas
<thead> quick_edit_link type: 'edit',
<tr> link: 'edit_panel_faq_back_end_qa_path'
<th class="span1"></th> quick_edit_link type: 'delete',
<th class="span1"></th> link: 'panel_faq_back_end_qa_path'
<th class="span2"></th> field type: 'status',
<th class="span3"></th> db_field: @statuses,
<th class="span2"></th> translation: 'status',
</tr> hide: 'phone',
</thead> sort: 'status'
<tbody id="tbody_qas" class="sort-holder"> field type: 'associated',
<%= render :partial => 'qa', :collection => @qas %> db_field: 'category',
</tbody> model_field: 'title',
</table> translation: 'category',
hide: 'phone',
sort: 'category'
field db_field: 'title',
translation: 'title',
sort: 'title',
display_option: 'link_to value, panel_faq_front_end_qa_path(object)',
quick_edit: true,
header_class: 'span5'
field type: 'tags',
hide: 'phone',
sort: 'tags'
filter_field type: 'array',
values: @statuses,
translation: 'status'
filter_field type: 'objects',
values: @categories,
translation: 'category',
object_field: 'title'
filter_field type: 'objects',
values: @tags,
translation: 'tags',
object_field: 'name'
footer link: 'new_panel_faq_back_end_qa_path'
end %>
<div class="form-actions form-fixed pagination-right"> <%= render 'admin/default_index/index' %>
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:add), new_panel_faq_back_end_qa_path, :class => 'btn btn-primary pull-right' if (is_manager? rescue nil) %>
<div id="qa_pagination" class="paginationFixed">
<%= paginate @all_qas, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>
</div>
</div>

View File

@ -2,7 +2,7 @@
<%= flash_messages %> <%= flash_messages %>
<div id="poststuff"> <div id="poststuff">
<h1><%= t('qa.new_faq') %></h1> <h1><%= t('qa.new_faq') %></h1>
<%= form_for @qa, :url => panel_faq_back_end_qas_path, :html => {:class => 'clear'} do |f| %> <%= form_for @qa, :url => panel_faq_back_end_qas_path, :html => {:class => 'form-horizontal main-forms'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %> <%= render :partial => 'form', :locals => {:f => f} %>
<% end %> <% end %>
</div> </div>

View File

@ -15,7 +15,6 @@ en:
read_more: Read More read_more: Read More
question: Question question: Question
answer: Answer answer: Answer
qa: qa:
create_qa_category_success: FAQ category was successfully created create_qa_category_success: FAQ category was successfully created
editing_web_resource: Editing FAQ editing_web_resource: Editing FAQ

View File

@ -20,6 +20,7 @@ module Faq
data_count 1..20 data_count 1..20
taggable taggable
categorizable
widgets do widgets do
default_widget do default_widget do
@ -62,9 +63,9 @@ module Faq
:available_for => [:sub_manager] :available_for => [:sub_manager]
context_link 'categories', context_link 'categories',
:link_path=>"panel_faq_back_end_qa_categorys_path" , :link_path=>"admin_module_app_categories_path(get_module_app)" ,
:priority=>3, :priority=>3,
:active_for_action=>{:qa_categorys=>:index}, :active_for_category => 'Qa',
:available_for => [:manager] :available_for => [:manager]
context_link 'tags', context_link 'tags',