finish widget
This commit is contained in:
parent
5ca7593a05
commit
b44b181fc7
|
@ -1,4 +1,5 @@
|
|||
class Admin::AskAcknowledgementsController < OrbitAdminController
|
||||
helper Admin::AsksHelper
|
||||
def initialize
|
||||
super
|
||||
@app_title = 'ask_acknowledgement'
|
||||
|
|
|
@ -14,7 +14,7 @@ class Admin::AsksController < OrbitAdminController
|
|||
|
||||
def filter_fields(categories, tags)
|
||||
{
|
||||
:situation=>[{:title=>"is_waiting",:id=>"is_waiting"},{:title=>"is_processed",:id=>"is_processed"},{:title=>"is_referral",:id=>"is_referral"}],
|
||||
:situation=>[{:title=>"ask.is_waiting",:id=>"is_waiting"},{:title=>"ask.is_processed",:id=>"is_processed"},{:title=>"ask.is_referral",:id=>"is_referral"},{:title=>"ask.is_published",:id=>"is_published"}],
|
||||
:category=>categories.map{|c| {:title=>(c.title.blank? ? " " : c.title), :id=>c.id}},
|
||||
:identity=>tags.map{|tag| {:title=>(tag.name.blank? ? " " : tag.name), :id=>tag.id}}
|
||||
}
|
||||
|
@ -48,11 +48,13 @@ class Admin::AsksController < OrbitAdminController
|
|||
render :json => {key: ask_setting_index.key.to_i}
|
||||
end
|
||||
def index
|
||||
@ask_setting = AskSetting.first
|
||||
@ask_setting = AskSetting.create() if @ask_setting.nil?
|
||||
@tags = @module_app.tags
|
||||
@categories = @module_app.categories
|
||||
@filter_fields = filter_fields(@categories, @tags)
|
||||
# 列表欄位
|
||||
@table_fields = [:situation, :category, 'ask.name', 'ask.phone', 'ask.appointment']
|
||||
@table_fields = [:situation, :category, 'title' , 'ask.name', 'ask.phone', 'ask.appointment']
|
||||
# 列表排序
|
||||
# debugger
|
||||
if filter2("situation").blank? and filter2("identity").blank?
|
||||
|
|
|
@ -1,22 +1,163 @@
|
|||
class AsksController < ApplicationController
|
||||
class AsksController < ActionController::Base
|
||||
helper Admin::AsksHelper
|
||||
include Admin::AsksHelper
|
||||
include ActionView::Helpers::FormHelper
|
||||
include ActionView::Helpers::FormOptionsHelper
|
||||
helper ActionView::Helpers::UrlHelper
|
||||
include ActionController::RequestForgeryProtection
|
||||
def widget
|
||||
subpart = OrbitHelper.get_current_widget
|
||||
case subpart.widget_type
|
||||
when /.*_form/
|
||||
module_app = ModuleApp.where(:key => "ask").first
|
||||
categories = Array(Category.find(OrbitHelper.page_categories)) rescue ['all']
|
||||
categories = module_app.categories if categories.include? 'all'
|
||||
tags = module_app.tags
|
||||
ask_question = AskQuestion.new
|
||||
locale = I18n.locale
|
||||
ask_setting = AskSetting.first
|
||||
ask_setting = AskSetting.create() if ask_setting.nil?
|
||||
categories = Array(Category.find(OrbitHelper.widget_categories)) rescue ['all']
|
||||
categories = module_app.categories if categories.include? 'all'
|
||||
tmp = 'mongoid.attributes.ask_question'
|
||||
defalt_fields = [{'label'=>ask_label(t('title'),'true'),'content'=>text_field_tag('ask_question[title]',nil,placeholder: t('title'),required: true)}]
|
||||
if ask_setting.default_setting['ask_category_id']
|
||||
if categories.count > 1
|
||||
defalt_fields = defalt_fields + [{'label'=>ask_label(t("#{tmp}.ask_category_id"),'true'),'content'=>select_tag('ask_question[category_id]', options_for_select(categories.collect{|t| [ t.title, t.id ]}))}]
|
||||
else
|
||||
defalt_fields = defalt_fields + [{'label'=>ask_label(t("#{tmp}.ask_category_id"),'true'),'content'=>"<span>#{@categories[0].title rescue ''}</span>"+hidden_field_tag('ask_question[category_id]', (categories[0].id.to_s rescue ''))}]
|
||||
end
|
||||
else
|
||||
defalt_fields = defalt_fields + [{'label'=>'','content'=>hidden_field_tag('ask_question[category_id]', (categories[0].id.to_s rescue ''))}]
|
||||
end
|
||||
defalt_fields = defalt_fields + ['name','sex','mail','phone','appointment'].select{|v| ask_setting.default_setting[v]}.collect do |field|
|
||||
required = ['phone','appointment'].exclude?(field) ? 'true' : 'false'
|
||||
f1 = {'label'=>ask_label(t("#{tmp}.#{field}"),required)}
|
||||
field_name = "ask_question[#{field}]"
|
||||
case field
|
||||
when 'name'
|
||||
f1['content'] = text_field_tag(field_name,nil,data: {"fv-validation" => "required;", "fv-messages" => "必填欄位;"},required: true,placeholder:t("#{tmp}.#{field}"))
|
||||
when 'sex'
|
||||
f1['content'] = "<label class=\"radio-inline\">
|
||||
#{radio_button(field_name,'male')}#{I18n.t('users.male')}
|
||||
</label>
|
||||
<label class=\"radio-inline\">
|
||||
#{radio_button(field_name,'female')}#{I18n.t('users.female')}
|
||||
</label>"
|
||||
when 'mail'
|
||||
f1['content'] = text_field_tag(field_name,nil,data: {"fv-validation" => "required;check_email;", "fv-messages" => "必填欄位;Email不正確;"},required: true,placeholder:t("#{tmp}.#{field}"))
|
||||
when 'phone'
|
||||
f1['content'] = text_field_tag(field_name,nil,placeholder:t("#{tmp}.#{field}"))
|
||||
when 'appointment'
|
||||
f1['content'] = "<div class=\"default_picker\">#{text_field_tag(field_name,placeholder:t("#{tmp}.#{field}"))}</div>"
|
||||
end
|
||||
f1
|
||||
end
|
||||
defalt_fields = defalt_fields + ask_setting.custom_fields.collect{|k,v| {'label'=>ask_label(v['field'][I18n.locale],v['required']),'content'=>show_on_front(k,v)}}
|
||||
defalt_fields << {'label'=>ask_label(t("#{tmp}.agree_show")),'content'=>check_box_tag('ask_question[agree_show]')}
|
||||
request = OrbitHelper.request
|
||||
csrf_value = OrbitHelper.request.session[:_csrf_token] || SecureRandom.base64(32)
|
||||
{
|
||||
'fields' => defalt_fields,
|
||||
'extras'=>{
|
||||
'token_tag' => hidden_field_tag('authenticity_token',csrf_value),
|
||||
'form_url' => "/#{I18n.locale.to_s}/asks",
|
||||
'submit_tag' => submit_tag(t('submit'), :class=> 'btn btn-primary', :id => 'button-mail'),
|
||||
'close_tag' => button_tag(t('cancel'), type: 'reset', :class=> 'btn'),
|
||||
'referer_url' => ''
|
||||
}
|
||||
}
|
||||
else
|
||||
data_count = OrbitHelper.widget_data_count.to_i
|
||||
if data_count != 0
|
||||
ask_questions = AskQuestion.where(situation: 'is_published').page(1).per(data_count)
|
||||
else
|
||||
ask_questions = AskQuestion.where(situation: 'is_published')
|
||||
end
|
||||
ask_index_page = Page.where(:module=>'ask').first.url rescue nil
|
||||
ask_questions = ask_questions.collect do |v|
|
||||
url = ((ask_index_page+"?item=#{v.id}") rescue "javascript:alert('#{t('ask.no_index_page')}')")
|
||||
{'td'=> [
|
||||
{'content' =>v.category.title},
|
||||
{'content' => link_to(v.title,"#{url}",title: v.title)}
|
||||
]
|
||||
}
|
||||
end
|
||||
{
|
||||
'ask_questions' => ask_questions,
|
||||
'th'=>[{'td'=>t('categories')},{'td'=>t('title')}]
|
||||
}
|
||||
end
|
||||
end
|
||||
def get_layout_type
|
||||
@params = OrbitHelper.params
|
||||
page = Page.where(url:@params['url']).first
|
||||
@layout_type = 'index'
|
||||
if page.methods.include? 'select_option_items'.to_sym
|
||||
ModuleApp.all.select{|tmp| tmp.key.to_s=='ask'}.each do |modile_app|
|
||||
@show_option_items = modile_app.show_option_items rescue nil
|
||||
end
|
||||
page.select_option_items.each do |select_option_item|
|
||||
if !(@show_option_items.nil?) && select_option_item.field_name == @show_option_items.keys.first.to_s
|
||||
value = YAML.load(select_option_item.value)
|
||||
locale = I18n.default_locale
|
||||
I18n.with_locale(locale) do
|
||||
if value[locale] == t('ask.widget.index')
|
||||
@layout_type = 'index'
|
||||
elsif value[locale] == t('ask.is_published')
|
||||
@layout_type = 'published_index'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
def initialize
|
||||
super
|
||||
@app_title = 'ask'
|
||||
end
|
||||
|
||||
def show
|
||||
ask_question = AskQuestion.where(id: @params['item']).first
|
||||
puts ask_question.inspect
|
||||
{'ask_question' => ask_question,'layout_type'=>'show'}
|
||||
end
|
||||
def index
|
||||
module_app = ModuleApp.where(:key => "ask").first
|
||||
categories = Array(Category.find(OrbitHelper.page_categories)) rescue ['all']
|
||||
categories = module_app.categories if categories.include? 'all'
|
||||
tags = module_app.tags
|
||||
ask_question = AskQuestion.new
|
||||
{
|
||||
"ask_question" => ask_question,
|
||||
"categories" => categories,
|
||||
"tags" => tags,
|
||||
"module_app" => module_app
|
||||
}
|
||||
@params = OrbitHelper.params
|
||||
if @params['item'].to_s.empty?
|
||||
get_layout_type
|
||||
else
|
||||
@layout_type = 'show'
|
||||
end
|
||||
if @layout_type == 'index'
|
||||
module_app = ModuleApp.where(:key => "ask").first
|
||||
categories = Array(Category.find(OrbitHelper.page_categories)) rescue ['all']
|
||||
categories = module_app.categories if categories.include? 'all'
|
||||
tags = module_app.tags
|
||||
ask_question = AskQuestion.new
|
||||
{
|
||||
'layout_type' => 'index',
|
||||
'ask_question' => ask_question,
|
||||
'categories' => categories,
|
||||
'tags' => tags,
|
||||
'module_app' => module_app
|
||||
}
|
||||
elsif @layout_type == 'published_index'
|
||||
page_number = OrbitHelper.page_number.to_i
|
||||
page_number = 1 if page_number == 0
|
||||
page_data_count = OrbitHelper.page_data_count.to_i
|
||||
if page_data_count != 0
|
||||
ask_questions = AskQuestion.where(situation: 'is_published').page(page_number).per(page_data_count)
|
||||
else
|
||||
ask_questions = AskQuestion.where(situation: 'is_published')
|
||||
end
|
||||
{
|
||||
'layout_type' => 'published_index',
|
||||
'ask_questions' => ask_questions,
|
||||
'url' => @params['url']
|
||||
}
|
||||
else
|
||||
show
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -41,38 +182,37 @@ class AsksController < ApplicationController
|
|||
end
|
||||
|
||||
def build_email(email_er)
|
||||
email = Email.new
|
||||
email.save
|
||||
email_er.email_id = email.id
|
||||
email_er.save
|
||||
email = Email.new
|
||||
email.save
|
||||
email_er.email_id = email.id
|
||||
email_er.save
|
||||
|
||||
@group_mail = email_er.email_address
|
||||
@mail_sentdate = DateTime.now
|
||||
@group_mail = email_er.email_address
|
||||
@mail_sentdate = DateTime.now
|
||||
|
||||
email_er.email.update_attributes(
|
||||
:create_user=>current_user,
|
||||
:mail_sentdate=>@mail_sentdate,
|
||||
:module_app=>@module_app,
|
||||
:mail_to=>@group_mail,
|
||||
:mail_subject=>Site.first.title_translations["zh_tw"]+" #{t('ask.new_question')}:",
|
||||
:template=>'asks/email',
|
||||
:template_data=>{
|
||||
# "title" => email_er.title,
|
||||
"name" => email_er.name,
|
||||
"identity" => email_er[:identity],
|
||||
"mail" => email_er.mail,
|
||||
"phone" => email_er.phone,
|
||||
# "fax" => email_er.fax,
|
||||
# "content" => email_er.content
|
||||
"appointment" => email_er.appointment
|
||||
}
|
||||
)
|
||||
email_er.email.update_attributes(
|
||||
:create_user=>(current_user rescue nil),
|
||||
:mail_sentdate=>@mail_sentdate,
|
||||
:module_app=>@module_app,
|
||||
:mail_to=>@group_mail,
|
||||
:mail_subject=>Site.first.title_translations["zh_tw"]+" #{t('ask.new_question')}:",
|
||||
:template=>'asks/email',
|
||||
:template_data=>{
|
||||
# "title" => email_er.title,
|
||||
"name" => email_er.name,
|
||||
"identity" => email_er[:identity],
|
||||
"mail" => email_er.mail,
|
||||
"phone" => email_er.phone,
|
||||
# "fax" => email_er.fax,
|
||||
# "content" => email_er.content
|
||||
"appointment" => email_er.appointment
|
||||
}
|
||||
)
|
||||
|
||||
OrbitMailer.set_mail(email_er.email).deliver
|
||||
OrbitMailer.set_mail(email_er.email).deliver
|
||||
end
|
||||
|
||||
def create_params
|
||||
params.require(:ask_question).permit!
|
||||
end
|
||||
|
||||
end
|
|
@ -16,12 +16,20 @@ module Admin::AsksHelper
|
|||
end
|
||||
def multiple_lang_tag(index1,type_of_tag,field,value=nil,custom_options={},combine_element='',exteral_options={})
|
||||
content_tag(:div,{:class => "tab-panel"}.merge(exteral_options)) do
|
||||
all_field = (get_input_name + "[#{index1}][#{field}][parant]").gsub(/\[/,'_').gsub(/\]/,'')
|
||||
if !index1.nil?
|
||||
all_field = (get_input_name + "[#{index1}][#{field}][parant]").gsub(/\[/,'_').gsub(/\]/,'')
|
||||
else
|
||||
all_field = (get_input_name + "[#{field}][parant]").gsub(/\[/,'_').gsub(/\]/,'')
|
||||
end
|
||||
(I18n.available_locales.collect do |locale|
|
||||
active_flag = ((locale == I18n.locale) ? ' active' : '')
|
||||
content_tag(:div,:class => "tab-content#{active_flag}",:id=>"#{all_field}_#{locale}") do
|
||||
value_locale = value[locale.to_s] rescue nil
|
||||
self.__send__("#{type_of_tag}_tag","#{get_input_name}[#{index1}][#{field}][#{locale}]",value_locale,custom_options)
|
||||
if !index1.nil?
|
||||
self.__send__("#{type_of_tag}_tag","#{get_input_name}[#{index1}][#{field}][#{locale}]",value_locale,custom_options)
|
||||
else
|
||||
self.__send__("#{type_of_tag}_tag","#{get_input_name}[#{field}][#{locale}]",value_locale,custom_options)
|
||||
end
|
||||
end
|
||||
end.join + create_lang_panel(all_field)).html_safe + combine_element
|
||||
end
|
||||
|
@ -73,7 +81,7 @@ module Admin::AsksHelper
|
|||
"<div class=\"datetime_selector\">#{t1}</div>
|
||||
<script>
|
||||
jQuery(document).ready(function( $ ) {
|
||||
$(\"input[name='#{field_name}[datetime][date][#{i}]']\").ui_datepicker(dateFormat: 'yy-mm-dd');
|
||||
$(\"input[name='#{field_name}[datetime][date][#{i}]']\").ui_datepicker({dateFormat: 'yy-mm-dd'});
|
||||
})
|
||||
</script>".html_safe
|
||||
when 'format3'
|
||||
|
@ -96,45 +104,52 @@ module Admin::AsksHelper
|
|||
"
|
||||
end
|
||||
end
|
||||
def show_on_front(k,v,value=nil)
|
||||
def ask_label(value,required='false')
|
||||
label_tag(nil,value,{:class=>"control-label#{required=='true' ? ' required' : ''}"})
|
||||
end
|
||||
def show_on_front(k,v,value=nil,readonly=false)
|
||||
field_name = "#{get_input_name}[custom_values][#{k}]"
|
||||
begin
|
||||
case v['type']
|
||||
when 'text_field'
|
||||
text_field_tag(field_name,value,{:required => v['required']=='true',placeholder: v['prompt_word'][I18n.locale]})
|
||||
readonly ? value : text_field_tag(field_name,value,{:required => v['required']=='true',placeholder: v['prompt_word'][I18n.locale]})
|
||||
when 'select'
|
||||
prompt_hash = v['prompt_word'][I18n.locale].blank? ? {} : {prompt: v['prompt_word'][I18n.locale]}
|
||||
prompt_hash.merge(:required => v['required']=='true')
|
||||
select_tag(field_name,options_for_select(Array(v['options']).select{|index1,option| option['disabled'] != 'true'}.collect{|index1,option| [option[I18n.locale],index1]},selected: value),prompt_hash)
|
||||
readonly ? value : select_tag(field_name,options_for_select(Array(v['options']).select{|index1,option| option['disabled'] != 'true'}.collect{|index1,option| [option[I18n.locale],index1]},selected: value),prompt_hash)
|
||||
when 'date'
|
||||
if value.nil?
|
||||
value = {}
|
||||
end
|
||||
if v['range_flag']=='true'
|
||||
"<div style=\"display:inline-flex;flex-direction:column;\">
|
||||
tmp = value['datetime']['date'] rescue {}
|
||||
readonly ? "#{tmp['0']}~#{tmp['1']}" : "<div style=\"display:inline-flex;flex-direction:column;\">
|
||||
#{render_date_block(field_name,v,0,value)}
|
||||
<div style=\"display: inline-flex;align-items: center;writing-mode: tb-rl;padding: 0.3em;\">~</div>
|
||||
#{render_date_block(field_name,v,1,value)}
|
||||
</div>".html_safe
|
||||
else
|
||||
render_date_block(field_name,v,0,value)
|
||||
readonly ? value : render_date_block(field_name,v,0,value)
|
||||
end
|
||||
when 'text_area'
|
||||
text_area_tag(field_name,value,{:required => v['required']=='true',:placeholder=> v['prompt_word'][I18n.locale],:class=>'ckeditor'})
|
||||
readonly ? value : text_area_tag(field_name,value,{:required => v['required']=='true',:placeholder=> v['prompt_word'][I18n.locale],:class=>'ckeditor'})
|
||||
when 'radio_button'
|
||||
if value.nil?
|
||||
value = {}
|
||||
end
|
||||
Array(v['options']).select{|index1,option| option['disabled'] != 'true'}.collect do |index1,option|
|
||||
readonly ? v['options'][value.to_i] : Array(v['options']).select{|index1,option| option['disabled'] != 'true'}.collect do |index1,option|
|
||||
"#{radio_button_tag(field_name,index1,value==index1,{:required => v['required']=='true'})}#{option[I18n.locale]}"
|
||||
end.join
|
||||
when 'checkbox'
|
||||
if value.nil?
|
||||
value = {}
|
||||
end
|
||||
Array(v['options']).select{|index1,option| option['disabled'] != 'true'}.collect do |index1,option|
|
||||
readonly ? value.collect{|k1,v1| Array(v['options'])[v1.to_i][1][I18n.locale]}.join(', ') : Array(v['options']).select{|index1,option| option['disabled'] != 'true'}.collect do |index1,option|
|
||||
"#{check_box_tag("#{field_name}[#{index1}]",index1,value[index1]==index1)}#{option[I18n.locale]}"
|
||||
end.join
|
||||
end
|
||||
rescue => e
|
||||
debug e.inspect
|
||||
debug [e.inspect,e.backtrace]
|
||||
end
|
||||
end
|
||||
def custom_field_block(k,v={})
|
||||
|
|
|
@ -2,5 +2,5 @@ class AskAcknowledgement
|
|||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :content, type: String
|
||||
field :content, type: Hash,default:{}
|
||||
end
|
|
@ -22,6 +22,7 @@ class AskQuestion
|
|||
field :send_email, type: Boolean, default: false
|
||||
field :email_id
|
||||
field :custom_values, type: Hash,default: {}
|
||||
field :agree_show,type: Boolean,default: false
|
||||
# validates_presence_of :name, :identity, :mail, :title, :content
|
||||
|
||||
def email
|
||||
|
|
|
@ -1,10 +1,21 @@
|
|||
<%
|
||||
set_input_name('ask_acknowledgement')
|
||||
%>
|
||||
<style type="text/css">
|
||||
.tab-content{
|
||||
display: none;
|
||||
}
|
||||
.tab-content.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
<div id="ask-acknowledgements">
|
||||
<%= form_for @ask_acknowledgements, url: @url, html: { class: 'form-horizontal' } do |f| %>
|
||||
<div class="control-group">
|
||||
<%= f.label :content, t('ask.acknowledgements'), class: 'control-label' %>
|
||||
<div class="controls">
|
||||
<%= f.text_area :content, rows: 10 %>
|
||||
</div>
|
||||
<%=
|
||||
multiple_lang_tag(nil,'text_area','content',@ask_acknowledgements.content,{:class=>'ckeditor',placeholder: t('ask.acknowledgements'),rows:10},nil,{'class' => 'controls','style'=>'display: flex;flex-direction: column-reverse;'})
|
||||
%>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
<td><%= AskQuestion.human_attribute_name(:phone) %>:<%= @ask_question.phone %></td>
|
||||
<!-- <td><%= AskQuestion.human_attribute_name(:fax) %>:<%= @ask_question.fax %></td> -->
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5"><%= t('title') %>:<%= f.text_field :title %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5"><%= AskQuestion.human_attribute_name(:appointment) %>:<%= @ask_question.appointment.strftime("%Y-%m-%d %H:%M") rescue nil %></td>
|
||||
<!-- <td colspan="5"><%= AskQuestion.human_attribute_name(:name) %>:<%= @ask_question.name %></td> -->
|
||||
|
@ -51,11 +54,15 @@
|
|||
<%= f.label :comment %>
|
||||
<br/> <%= f.text_field :comment, style: 'width: 500px' %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5"><%= f.label :agree_show %><%= f.select :agree_show,[[t('ask.no'),false],[t('ask.yes'),true]] %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5"><%= f.label t('situation') %> <%= f.select :situation, [
|
||||
[t('is_waiting'), 'is_waiting'],
|
||||
[t('is_processed'), 'is_processed'],
|
||||
[t('is_referral'), 'is_referral']
|
||||
[t('ask.is_waiting'), 'is_waiting'],
|
||||
[t('ask.is_processed'), 'is_processed'],
|
||||
[t('ask.is_referral'), 'is_referral'],
|
||||
[t('ask.is_published'),'is_published']
|
||||
] %></td>
|
||||
</tr>
|
||||
|
||||
|
@ -70,7 +77,7 @@
|
|||
<%= ask_setting.custom_fields.collect do |k,v|
|
||||
required_pattern = v['required']=='true' ? '*' : ''
|
||||
"<div class=\"control-group\">
|
||||
<label class=\"control-label\" for=\"ask_question_mail\">#{required_pattern}#{v['field'][I18n.locale]}</label>
|
||||
<label class=\"control-label\">#{required_pattern}#{v['field'][I18n.locale]}</label>
|
||||
<div class=\"controls\">
|
||||
#{show_on_front(k,v,@ask_question.custom_values[k])}
|
||||
</div>
|
||||
|
@ -78,8 +85,15 @@
|
|||
end.join.html_safe %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%
|
||||
cancel_href = url_for(:back)
|
||||
if cancel_href == 'javascript:history.back()'
|
||||
now_ask_page = AskQuestion.order_by(:id).map(&:id).map.with_index.select{|v,i| v==@ask_question.id}[0][1] rescue nil
|
||||
now_ask_page = now_ask_page.nil? ? 1 : ((now_ask_page+1).to_f/10).ceil
|
||||
cancel_href = "/#{I18n.locale}/admin/asks?page=#{now_ask_page}"
|
||||
end
|
||||
%>
|
||||
<div class="form-actions">
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
<%= f.button t('cancel'), type: 'reset', class: 'btn' %>
|
||||
<%= link_to t('cancel'),cancel_href,title: t('cancel'),:class=> 'btn' %>
|
||||
</div>
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
<thead>
|
||||
<tr class="sort-header">
|
||||
<% @table_fields.each do |f| %>
|
||||
<%= thead(f) %>
|
||||
<% tmp = f.to_s.gsub(/ask\./,'') %>
|
||||
<% if @ask_setting.default_setting[tmp].nil? || @ask_setting.default_setting[tmp] %>
|
||||
<%= thead(f) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -11,16 +14,17 @@
|
|||
<tr>
|
||||
<td>
|
||||
<% if b.situation == 'is_waiting' %>
|
||||
<span class='label label-important'><%= t('is_waiting') %></span>
|
||||
<span class='label label-important'><%= t('ask.is_waiting') %></span>
|
||||
<% elsif b.situation == 'is_processed' %>
|
||||
<span class='label label-success'><%= t('is_processed') %></span>
|
||||
<span class='label label-warning'><%= t('ask.is_processed') %></span>
|
||||
<% elsif b.situation == 'is_referral' %>
|
||||
<span class='label'><%= t('is_referral') %></span>
|
||||
<span class='label'><%= t('ask.is_referral') %></span>
|
||||
<% elsif b.situation == 'is_published' %>
|
||||
<span class='label label-success'><%= t('ask.is_published') %></span>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= b.category.title %></td>
|
||||
<!-- <td>
|
||||
<%= b.title %>
|
||||
<td>
|
||||
<%= b.category.title %>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills">
|
||||
<% if can_edit_or_delete?(b) %>
|
||||
|
@ -28,21 +32,24 @@
|
|||
<li><a href="#" class="delete text-error" rel="/admin/asks/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</td> -->
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<% if b.situation == 'is_published' %>
|
||||
<%= link_to b.title,((Page.where(:module=>'ask').first.url+"?item=#{b.id}") rescue "javascript:alert('#{t('ask.no_index_page')}')") %>
|
||||
<% else %>
|
||||
<%= b.title %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<%= b.name %>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills">
|
||||
<% if can_edit_or_delete?(b) %>
|
||||
<li><a href="/admin/asks/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li>
|
||||
<li><a href="#" class="delete text-error" rel="/admin/asks/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<td><%= b.phone %></td>
|
||||
<td><%= b.appointment.strftime("%Y-%m-%d %H:%M") rescue nil %></td>
|
||||
<% if @ask_setting.default_setting['phone'] %>
|
||||
<td><%= b.phone %></td>
|
||||
<% end %>
|
||||
<% if @ask_setting.default_setting['appointment'] %>
|
||||
<td><%= b.appointment.strftime("%Y-%m-%d %H:%M") rescue nil %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
ask_setting = AskSetting.create() if ask_setting.nil?
|
||||
set_input_name('ask_question')
|
||||
%>
|
||||
<% if data['layout_type'] != 'index' %>
|
||||
<%= render template: "asks/#{data['layout_type']}",:locals => { :data => data, :ask_setting => ask_setting } %>
|
||||
<% else %>
|
||||
<style type="text/css">
|
||||
#new-ask-question .form-horizontal .control-group > *{
|
||||
font-size: 1.5em;
|
||||
|
@ -57,9 +60,9 @@
|
|||
}
|
||||
</style>
|
||||
<%# javascript_include_tag "/assets/lib/jquery-ui-1.12.1/jquery-ui.min" %>
|
||||
<%= stylesheet_link_tag "/assets/lib/jquery-ui-1.12.1/jquery-ui.min" %>
|
||||
<%# stylesheet_link_tag "/assets/lib/jquery-ui-1.12.1/jquery-ui.min" %>
|
||||
<%= stylesheet_link_tag "custom_field" %>
|
||||
<%= stylesheet_link_tag "jquery-ui-timepicker-addon" %>
|
||||
<%# stylesheet_link_tag "jquery-ui-timepicker-addon" %>
|
||||
<script type="text/javascript">
|
||||
var datepicker_fn = $.fn.datepicker
|
||||
var datepicker = $.datepicker
|
||||
|
@ -71,6 +74,12 @@
|
|||
<link href="/assets/ask/ask.css" media="screen" rel="stylesheet">
|
||||
<div id="new-ask-question" class="ask-question">
|
||||
<%= form_for @ask_question, url: asks_path, html: {class: 'form-horizontal'} do |f| %>
|
||||
<div class="control-group">
|
||||
<%= f.label nil,t('title'), class: 'control-label required' %>
|
||||
<div class="controls">
|
||||
<%= f.text_field :title,placeholder: t('title'),required: true %>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Category -->
|
||||
<% if ask_setting.default_setting['ask_category_id'] %>
|
||||
<div class="control-group">
|
||||
|
@ -169,7 +178,7 @@
|
|||
<%= ask_setting.custom_fields.collect do |k,v|
|
||||
required_pattern = v['required']=='true' ? '*' : ''
|
||||
"<div class=\"control-group\">
|
||||
<label class=\"control-label\" for=\"ask_question_mail\">#{required_pattern}#{v['field'][I18n.locale]}</label>
|
||||
<label class=\"control-label\">#{required_pattern}#{v['field'][I18n.locale]}</label>
|
||||
<div class=\"controls\">
|
||||
#{show_on_front(k,v)}
|
||||
</div>
|
||||
|
@ -184,6 +193,12 @@
|
|||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="control-group">
|
||||
<%= f.label :agree_show, class: 'control-label' %>
|
||||
<div class="controls">
|
||||
<%= f.check_box :agree_show %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<input type="hidden" name="referer_url" value="<%= request.original_url.split(request.env["HTTP_HOST"]).last %>">
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary', :id => 'button-mail' %>
|
||||
|
@ -230,4 +245,5 @@ $(function(){
|
|||
|
||||
// }
|
||||
})
|
||||
</script>
|
||||
</script>
|
||||
<% end %>
|
|
@ -0,0 +1,16 @@
|
|||
<table class="table">
|
||||
<thead>
|
||||
<tr class="bg-primary">
|
||||
<th><%= t('categories') %></th>
|
||||
<th><%= t('title') %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% data['ask_questions'].each do |ask_question| %>
|
||||
<tr>
|
||||
<td><%= ask_question.category.title %></td>
|
||||
<td><%= link_to ask_question.title,"#{data['url']}?item=#{ask_question.id}",title: ask_question.title %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
|
@ -0,0 +1,83 @@
|
|||
<% ask = data['ask_question'] %>
|
||||
<style type="text/css">
|
||||
.ask-question .form-horizontal .control-group > *{
|
||||
font-size: 1.5em;
|
||||
}
|
||||
.default_picker label{
|
||||
display: none;
|
||||
}
|
||||
.ask-question .control-group{
|
||||
flex-wrap: wrap;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
}
|
||||
.ask-question .controls > *{
|
||||
display: block;
|
||||
}
|
||||
.ask-question .controls > script{
|
||||
display: none;
|
||||
}
|
||||
.ask-question .form-horizontal .control-label{
|
||||
width: 24%;
|
||||
max-width: 15em;
|
||||
min-width: 14em;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
}
|
||||
.ask-question .form-horizontal .control-group .controls{
|
||||
margin: 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
min-width: 10em;
|
||||
max-width: 20em;
|
||||
padding-left: 0;
|
||||
width: 70%;
|
||||
padding: 0.5em;
|
||||
justify-content: center;
|
||||
}
|
||||
.ask-question .form-horizontal input[type="text"],.ask-question .form-horizontal select{
|
||||
width: 97%;
|
||||
max-width: 13.75em;
|
||||
}
|
||||
.ask-question .form-horizontal .form-actions{
|
||||
position: relative;
|
||||
padding: 1em 0 0 0;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<%= stylesheet_link_tag "custom_field" %>
|
||||
<link href="/assets/ask/ask.css" media="screen" rel="stylesheet">
|
||||
<div class="ask-question">
|
||||
<div class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<%= label_tag nil,t('category'), :class=> 'control-label' %>
|
||||
<div class="controls">
|
||||
<%= label_tag nil,(ask.category.title rescue nil), class: 'control-label' %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<%= label_tag nil,t('title'), :class=> 'control-label' %>
|
||||
<div class="controls">
|
||||
<%= label_tag nil,ask.title, :class=> 'control-label' %>
|
||||
</div>
|
||||
</div>
|
||||
<%= ask_setting.custom_fields.collect do |k,v|
|
||||
required_pattern = v['required']=='true' ? '*' : ''
|
||||
"<div class=\"control-group\">
|
||||
<label class=\"control-label\">#{required_pattern}#{v['field'][I18n.locale]}</label>
|
||||
<div class=\"controls\">
|
||||
#{show_on_front(k,v,ask.custom_values[k],true)}
|
||||
</div>
|
||||
</div>"
|
||||
end.join.html_safe %>
|
||||
<div class="control-group">
|
||||
<%= label_tag nil,t('mongoid.attributes.ask_question.reply'), :class=> 'control-label' %>
|
||||
<div class="controls">
|
||||
<%= ask.reply %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -2,5 +2,10 @@
|
|||
|
||||
<link href="/assets/ask/ask.css" media="screen" rel="stylesheet">
|
||||
<div class="form-horizontal">
|
||||
<h2>我們已經收到您的預約,期待您的蒞臨,謝謝</h2>
|
||||
<h2>
|
||||
<% text = AskAcknowledgement.first.content[I18n.locale] rescue t('ask.thank_text')
|
||||
text = t('ask.thank_text') if text.to_s.empty?
|
||||
%>
|
||||
<%= text.html_safe %>
|
||||
</h2>
|
||||
</div>
|
15
ask.gemspec
15
ask.gemspec
|
@ -2,7 +2,20 @@ $:.push File.expand_path("../lib", __FILE__)
|
|||
|
||||
# Maintain your gem's version:
|
||||
require "ask/version"
|
||||
|
||||
app_path = File.expand_path(__dir__)
|
||||
template_path = ENV['PWD'] + '/app/templates'
|
||||
all_template = Dir.glob(template_path+'/*/')
|
||||
puts 'copying ask module'
|
||||
all_template.each do |folder|
|
||||
if folder.split('/')[-1] != 'mobile'
|
||||
begin
|
||||
system ('cp -r '+ app_path + '/modules/ ' + folder)
|
||||
rescue
|
||||
puts 'error copy'
|
||||
end
|
||||
end
|
||||
end
|
||||
#syst
|
||||
# Describe your gem and declare its dependencies:
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "ask"
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
en:
|
||||
situation: Situation
|
||||
is_waiting: Pending
|
||||
is_processed: Processed
|
||||
is_referral: Rreferral
|
||||
sex: Sex
|
||||
ask:
|
||||
no_index_page: There are no page for ask module created at site struture.
|
||||
thank_text: We will reply as soon as posible,thank you.
|
||||
is_waiting: Pending
|
||||
is_processed: Processed
|
||||
is_referral: Rreferral
|
||||
is_published: Processed and Published
|
||||
'yes': 'Yes'
|
||||
'no': 'No'
|
||||
required: Required
|
||||
|
@ -56,4 +59,5 @@ en:
|
|||
content: Content
|
||||
comment: Comment
|
||||
status: Status
|
||||
send_email: Whether to reply email
|
||||
send_email: Whether to reply email
|
||||
agree_show: Do you agree on displaying your request and our reply on the webpage without your personal information?
|
|
@ -2,15 +2,18 @@ zh_tw:
|
|||
|
||||
situation: 狀況
|
||||
identity: 身份
|
||||
is_waiting: 待處理
|
||||
is_processed: 已處理
|
||||
is_referral: 轉介其他單位
|
||||
module_name:
|
||||
ask: 發問
|
||||
recaptcha:
|
||||
errors:
|
||||
verification_failed: 驗證碼錯誤
|
||||
ask:
|
||||
no_index_page: 前台頁面尚未被建立,請前往網站架構設定,謝謝。
|
||||
thank_text: 我們已經收到您的預約,期待您的蒞臨,謝謝
|
||||
is_waiting: 待處理
|
||||
is_processed: 已處理
|
||||
is_referral: 轉介其他單位
|
||||
is_published: 已處理並發佈網頁
|
||||
'yes': 是
|
||||
'no': 否
|
||||
required: 必填
|
||||
|
@ -24,7 +27,7 @@ zh_tw:
|
|||
field_name: 欄位名稱
|
||||
whether_open: 是否開啟
|
||||
setting: 設定
|
||||
name: 預約客戶
|
||||
name: 發問者
|
||||
appointment: 預約時間
|
||||
created_at: 發問時間
|
||||
phone: 聯絡電話
|
||||
|
@ -69,4 +72,5 @@ zh_tw:
|
|||
content: 內容
|
||||
comment: 備註
|
||||
status: 狀態
|
||||
send_email: 是否回信
|
||||
send_email: 是否回信
|
||||
agree_show: 是否同意您提出之需求及回覆內容以不呈現發問者資訊方式刊載於網站供他人參考?
|
|
@ -15,8 +15,7 @@ Rails.application.routes.draw do
|
|||
resources :ask_acknowledgements
|
||||
resources :ask_admins
|
||||
end
|
||||
|
||||
resources :asks #fronted
|
||||
resources :asks #fronted
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,29 @@
|
|||
module Ask
|
||||
class Engine < ::Rails::Engine
|
||||
initializer "ask" do
|
||||
locales = Site.first.in_use_locales rescue [:en,:zh_tw]
|
||||
begin
|
||||
t_data0 = locales.collect{|l| Dir["#{ENV['PWD']}/config/locales/#{l.to_s}.yml"]}.flatten.map{|yaml_file| YAML.load(File.read(yaml_file))}
|
||||
t_data1 = Dir["#{Ask::Engine.root}/config/locales/*.yml"].map{|yaml_file| YAML.load(File.read(yaml_file))}
|
||||
data_item = {}
|
||||
key_item1 = {}
|
||||
value_item1 = {}
|
||||
value_item2 = {}
|
||||
t_data0.each do |t_data|
|
||||
v = t_data.values
|
||||
k = t_data.keys[0]
|
||||
key_item1[k] = v[0]['theme']
|
||||
end
|
||||
t_data1.each do |t_data|
|
||||
v = t_data.values
|
||||
k = t_data.keys[0]
|
||||
value_item1[k] = v[0]['ask']['widget']['index']
|
||||
value_item2[k] = v[0]['ask']['is_published']
|
||||
end
|
||||
data_item[key_item1] = [value_item1,value_item2]
|
||||
rescue => e
|
||||
puts ['error in ask',e]
|
||||
end
|
||||
begin
|
||||
require File.expand_path('../../../app/models/ask_setting', __FILE__)
|
||||
require File.expand_path('../../../app/models/ask_setting_index', __FILE__)
|
||||
|
@ -16,9 +39,14 @@ module Ask
|
|||
OrbitApp.registration "Ask", :type => "ModuleApp" do
|
||||
module_label "ask.ask"
|
||||
base_url File.expand_path File.dirname(__FILE__)
|
||||
# widget_methods ["widget","widget1"]
|
||||
# widget_settings [{"data_count"=>10}]
|
||||
widget_methods ["widget"]
|
||||
widget_settings [{"data_count"=>10}]
|
||||
taggable "AskQuestion"
|
||||
begin
|
||||
show_option_items data_item
|
||||
rescue => e
|
||||
puts ['there_was_no_show_option_method',e]
|
||||
end
|
||||
categorizable
|
||||
authorizable
|
||||
frontend_enabled
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
<div class="widget-ask widget1">
|
||||
<style type="text/css">
|
||||
#new-ask-question .form-horizontal .control-group > *{
|
||||
font-size: 1.2em;
|
||||
}
|
||||
.default_picker label{
|
||||
display: none;
|
||||
}
|
||||
.ask-question .control-group{
|
||||
flex-wrap: wrap;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
}
|
||||
.ask-question .controls > *{
|
||||
display: block;
|
||||
}
|
||||
.ask-question .controls > script{
|
||||
display: none;
|
||||
}
|
||||
.ask-question .form-horizontal .control-label{
|
||||
width: 24%;
|
||||
max-width: 15em;
|
||||
min-width: 14em;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
}
|
||||
.ask-question .form-horizontal .control-group .controls{
|
||||
margin: 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
min-width: 10em;
|
||||
max-width: 20em;
|
||||
padding-left: 0;
|
||||
width: 70%;
|
||||
padding: 0.5em;
|
||||
justify-content: center;
|
||||
}
|
||||
.ask-question .form-horizontal input[type="text"],.ask-question .form-horizontal select{
|
||||
width: 97%;
|
||||
max-width: 13.75em;
|
||||
}
|
||||
.ask-question .form-horizontal .form-actions{
|
||||
position: relative;
|
||||
padding: 1em 0 0 0;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<link href="/assets/custom_field.css" media="screen" rel="stylesheet">
|
||||
<script src="/assets/validator"></script>
|
||||
<link href="/assets/ask/ask.css" media="screen" rel="stylesheet">
|
||||
<script type='text/javascript'>
|
||||
$('#new-ask-question .required').each(function() {
|
||||
$(this).text('*' + $(this).text());
|
||||
});
|
||||
$(function(){
|
||||
var fv = new FormValidator($("#new_ask_question"));
|
||||
fv.validate_functions.check_email = function(value){
|
||||
reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
|
||||
if (reg.test(value)) {
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<h3 class="widget-title">
|
||||
<span>{{widget-title}}</span>
|
||||
</h3>
|
||||
<div id="new-ask-question" class="ask-question">
|
||||
<form action="{{form_url}}" method="post" class="form-horizontal" accept-charset="UTF-8">
|
||||
{{token_tag}}
|
||||
<div data-level="0" data-list="fields">
|
||||
<div class="control-group">
|
||||
{{label}}
|
||||
<div class="controls">
|
||||
{{content}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<input type="hidden" name="referer_url" value="{{referer_url}}">
|
||||
{{submit_tag}}
|
||||
{{close_tag}}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,17 @@
|
|||
<div class="widget-asks widget1">
|
||||
<h3 class="widget-title">
|
||||
<span>{{widget-title}}</span>
|
||||
</h3>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr data-level="0" data-list="th" class="bg-primary">
|
||||
<th>{{td}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-level="0" data-list="ask_questions">
|
||||
<tr data-level="1" data-list="td">
|
||||
<td>{{content}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"widgets" : [
|
||||
{
|
||||
"filename" : "ask_widget_form",
|
||||
"name" : {
|
||||
"zh_tw" : "1. 模組標題、發問介面",
|
||||
"en" : "1. widget-title, question"
|
||||
},
|
||||
"thumbnail" : "thumb.png"
|
||||
},
|
||||
{
|
||||
"filename" : "ask_widget_list",
|
||||
"name" : {
|
||||
"zh_tw" : "2. 模組標題、 發佈回覆列表",
|
||||
"en" : "2. widget-title, published list"
|
||||
},
|
||||
"thumbnail" : "thumb.png"
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
Loading…
Reference in New Issue