Ask Module for New UI

This commit is contained in:
saurabhbhatia committed 2013-08-27 12:38:06 +08:00
1 parent b970ea1e0e
commit 5591b06ee6
105 files changed
+2038 -50

No files matched your search

@@ -2,6 +2,8 @@ class Panel::Ask::BackEnd::AskAcknowledgementsController < OrbitBackendControlle
include AdminHelper
include OrbitControllerLib::DivisionForDisable
before_filter :for_app_manager
def initialize
super
@app_title = 'ask_acknowledgement'
@@ -3,6 +3,8 @@ class Panel::Ask::BackEnd::AskAdminsController < OrbitBackendController
include AdminHelper
include OrbitControllerLib::DivisionForDisable
before_filter :for_app_manager
def initialize
super
@app_title = 'ask_admins'
@@ -3,6 +3,8 @@ class Panel::Ask::BackEnd::AskCategoriesController < OrbitBackendController
include AdminHelper
include OrbitControllerLib::DivisionForDisable
before_filter :for_app_manager
def initialize
super
@app_title = 'ask_categories'
@@ -2,8 +2,9 @@ require 'csv'
class Panel::Ask::BackEnd::AskQuestionsController < OrbitBackendController
include AdminHelper
include OrbitControllerLib::DivisionForDisable
before_filter :only => [ :new, :create, :edit, :update ] do |controller|
@categories = get_categories_for_form
end
def initialize
super
@@ -11,8 +12,8 @@ class Panel::Ask::BackEnd::AskQuestionsController < OrbitBackendController
end
def index
@ask_questions = (params[:sort]) ? get_sorted_and_filtered('ask_questions') : get_viewable('ask_questions')
@all_ask_questions = @ask_questions.page params[:page]
@ask_questions = AskQuestion.all
respond_to do |format|
format.html
format.js
@@ -3,6 +3,8 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController
include AdminHelper
include OrbitControllerLib::DivisionForDisable
before_filter :for_app_manager
def initialize
super
@app_title = 'ask_replies'
@@ -13,16 +13,34 @@ class Panel::Ask::FrontEnd::AskQuestionsController < OrbitWidgetController
def create
@ask_question = AskQuestion.new(params[:ask_question])
if verify_recaptcha model: @ask_question, private_key: '6Lfl7OESAAAAAD4rl5S16-zjt5yiKNYJ6jsqdwmL'
if gotcha_valid? && @ask_question.save
@acknowledgement = AskAcknowledgement.last
@ask_acknowledgement = AskAcknowledgement.first || AskAcknowlegement.new
@ask_question.save
#@ask_question.save
#redirect_to root_path
AskAdmin.all.each do |ask_admin|
AskMailer.notice(ask_admin, @ask_question).deliver
Resque.enqueue(SendAskNoticeMail, ask_admin.id, @ask_question.id)
end
end
respond_to do |format|
format.js
# redirect_to panel_ask_front_end_thank_you_path
respond_to do |format|
format.js
# format.js { render :thank_you, notice: 'Your question has been successfully sent.' }
end
end
end
def thank_you
@acknowledgement = AskAcknowledgement.last
@item = Page.find(params[:page_id]) rescue nil
if @item
if @item.frontend_data_count
@page_num = @item.frontend_data_count
else
@page_num = 15
end
@frontend_style = @item.frontend_style
end
@item = Page.find(params[:page_id]) rescue nil
end
end
+1 -1
View File
@@ -1,6 +1,6 @@
class AskMailer < ActionMailer::Base
default from: 'orbit_test@rulingcom.com'
def reply(ask_question)
@ask_question = ask_question
mail(:to => @ask_question.email, :subject => "#{t('ask.reply')}:#{@ask_question.title}")
+7 -3
View File
@@ -1,7 +1,13 @@
class AskQuestion
include Mongoid::Document
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
include OrbitCategory::Categorizable
include OrbitModel::Approval
include Mongoid::Document
include Mongoid::Timestamps
include OrbitCoreLib::ObjectDisable
field :name, type: String
field :identity, type: String
@@ -13,8 +19,6 @@ class AskQuestion
validates_presence_of :name, :identity, :email, :title, :content
belongs_to :ask_category
has_one :ask_reply, dependent: :destroy
paginates_per 10
end
@@ -5,7 +5,7 @@
</head>
<body>
<p>
<%= @ask_question.ask_reply.content %>
<%= @ask_question.content %>
</p>
<p>此為系統自動發信,請勿直接回覆</p>
</body>
@@ -5,9 +5,7 @@
<td>
<%= ask_question.ask_reply ? ask_question.ask_reply.status : t('ask.pending') %>
</td>
<td>
<%= ask_question.ask_category.name %>
</td>
<td>
<%= ask_question.title %>
<div class="quick-edit">
@@ -1,14 +1,11 @@
<%= render 'filter' %>
<table class="table main-list">
<thead>
<tr>
<th class="span1"></th>
<th class="span1"></th>
<th class="span1"></th>
<th class="span3"></th>
<th class="span1"></th>
<th class="span1"></th>
<th class="span1"><%= t('ask.status') %></th>
<th class="span1"><%= t('ask.question') %></th>
<th class="span1"><%= t('ask.sender') %></th>
<th class="span3"><%= t('ask.created_at') %></th>
</tr>
</thead>
<tbody id="tbody_surveys" class="sort-holder">
@@ -18,6 +15,5 @@
<div class="form-actions form-fixed pagination-right">
<div id="ask_questions_pagination" class="paginationFixed">
<%= paginate @all_ask_questions %>
</div>
</div>
@@ -1,11 +1 @@
<% if @ask_question.errors.empty? %>
$('html,body').scrollTop(0);
$('#acknowledgement')
.html('<%= j simple_format(@ask_acknowledgement.content) %>')
.fadeIn(600)
.delay(3000)
.fadeOut(600);
<% else %>
alert('<%= @ask_question.errors.full_messages.join('\n') %>');
Recaptcha.reload()
<% end %>
window.location.href= "<%= panel_ask_front_end_thank_you_path %>"
@@ -1,8 +1,37 @@
<link href='/assets/ask.css' rel='stylesheet' type='text/css' />
<style type="text/css">
.spinner {
position: fixed;
top: 50%;
left: 50%;
margin-left: -50px; /* half width of the spinner gif */
margin-top: -50px; /* half height of the spinner gif */
text-align:center;
z-index:1234;
overflow: auto;
width: 100px; /* width of the spinner gif */
height: 102px; /*hight of the spinner gif +2px to fix IE8 issue */
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("#spinner").bind("ajaxSend", function() {
$(this).show();
}).bind("ajaxStop", function() {
$(this).hide();
}).bind("ajaxError", function() {
$(this).hide();
});
});
</script>
<div id="spinner" class="spinner" style="display:none;">
Sending Mail <%= image_tag 'loading.gif', :id => "img-spinner"%>
</div>
<div id="new-ask-question" class="ask-question">
<div id="acknowledgement"></div>
<%= form_for @ask_question, url: panel_ask_front_end_ask_questions_path(standalone: true), remote: true,
html: {class: 'form-horizontal'} do |f| %>
<%= form_for @ask_question, url: panel_ask_front_end_ask_questions_path(standalone: true), html: {class: 'form-horizontal'} do |f| %>
<div class="control-group">
<%= f.label :ask_category_id, class: 'control-label required' %>
<div class="controls">
@@ -55,17 +84,26 @@
<%= f.text_area :content, rows: 8, class: 'input-xlarge' %>
</div>
</div>
<div class="control-group">
<div class="control-group">
<div class="controls">
<%= recaptcha_tags ajax: true, public_key: '6Lfl7OESAAAAAKdxTSSmWSOWlL__04A9AqQzD7_z' %>
<%= gotcha_error %>
<%= gotcha%>
</div>
</div>
<div class="form-actions">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= f.submit t('submit'), class: 'btn btn-primary', :id => 'button-mail' %>
<%= f.button t('cancel'), type: 'reset', class: 'btn' %>
</div>
<% end %>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#button-mail').click(function() {
$('#spinner').show();
});
});
</script>
<script type="text/javascript">
$(function() {
$('#new-ask-question .required').each(function() {
@@ -77,4 +115,4 @@
return false;
});
});
</script>
</script>
@@ -1 +1 @@
<h3>Thank you for your email, we will get back to you soon.</h3>
<h3><%= @acknowledgement.content.html_safe%></h3>
+1
View File
@@ -18,6 +18,7 @@ Rails.application.routes.draw do
end
namespace :front_end do
match "ask_questions/thank_you" => "ask_questions#thank_you", :as => 'thank_you'
resources :ask_questions
end
end
+17 -7
View File
@@ -14,33 +14,43 @@ module Ask
app_page 'ask_questions' do
frontend_i18n 'ask.ask'
end
app_page 'thank_you' do
frontend_i18n "ask.thank_you"
end
end
widgets do
default_widget do
end
categories_query 'Category.all'
end
authorizable
approvable
categorizable
side_bar do
head_label_i18n 'ask.ask', icon_class: 'icons-light-bulb'
available_for [:admin,:manager,:sub_manager]
active_for_controllers ({:private=>['ask_questions', 'ask_admins', 'ask_ackowledgements']})
active_for_controllers({ private: ['ask_questions'] })
head_link_path "panel_ask_back_end_ask_questions_path"
context_link 'categories', link_path: 'panel_ask_back_end_ask_categories_path',
priority: 1,
active_for_action: {:ask_categories=>:index},
available_for: [:all]
context_link 'announcement.categories',
:link_path=>"admin_module_app_categories_path(get_module_app)" ,
:priority=>3,
:active_for_category => 'Ask',
:available_for => [:admin]
context_link 'ask.acknowledgement', link_path: 'panel_ask_back_end_ask_acknowledgements_path',
context_link 'ask.acknowledgement', link_path: 'panel_ask_back_end_ask_acknowledgements_path',
priority: 1,
available_for: [:all]
context_link 'ask.admin', link_path: 'panel_ask_back_end_ask_admins_path',
context_link 'ask.admin', link_path: 'panel_ask_back_end_ask_admins_path',
priority: 1,
available_for: [:all]
context_link 'ask.export', link_path: 'export_panel_ask_back_end_ask_questions_path',
context_link 'ask.export', link_path: 'export_panel_ask_back_end_ask_questions_path',
priority: 1,
available_for: [:all]
end