diff --git a/app/controllers/admin/ask_acknowledgements_controller.rb b/app/controllers/admin/ask_acknowledgements_controller.rb index 76bcad9..522380a 100644 --- a/app/controllers/admin/ask_acknowledgements_controller.rb +++ b/app/controllers/admin/ask_acknowledgements_controller.rb @@ -1,4 +1,5 @@ class Admin::AskAcknowledgementsController < OrbitAdminController + helper Admin::AsksHelper def initialize super @app_title = 'ask_acknowledgement' diff --git a/app/controllers/admin/asks_controller.rb b/app/controllers/admin/asks_controller.rb index 88fba21..2d2f3ed 100644 --- a/app/controllers/admin/asks_controller.rb +++ b/app/controllers/admin/asks_controller.rb @@ -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? diff --git a/app/controllers/asks_controller.rb b/app/controllers/asks_controller.rb index 6f18b99..c36df99 100644 --- a/app/controllers/asks_controller.rb +++ b/app/controllers/asks_controller.rb @@ -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'=>"#{@categories[0].title rescue ''}"+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'] = " + " + 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'] = "
#{text_field_tag(field_name,placeholder:t("#{tmp}.#{field}"))}
" + 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 \ No newline at end of file diff --git a/app/helpers/admin/asks_helper.rb b/app/helpers/admin/asks_helper.rb index 1560d77..641713a 100644 --- a/app/helpers/admin/asks_helper.rb +++ b/app/helpers/admin/asks_helper.rb @@ -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 "
#{t1}
".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' - "
+ tmp = value['datetime']['date'] rescue {} + readonly ? "#{tmp['0']}~#{tmp['1']}" : "
#{render_date_block(field_name,v,0,value)}
~
#{render_date_block(field_name,v,1,value)}
".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={}) diff --git a/app/models/ask_acknowledgement.rb b/app/models/ask_acknowledgement.rb index 454f408..30d00da 100644 --- a/app/models/ask_acknowledgement.rb +++ b/app/models/ask_acknowledgement.rb @@ -2,5 +2,5 @@ class AskAcknowledgement include Mongoid::Document include Mongoid::Timestamps - field :content, type: String + field :content, type: Hash,default:{} end \ No newline at end of file diff --git a/app/models/ask_question.rb b/app/models/ask_question.rb index 2f8356d..ce88b31 100644 --- a/app/models/ask_question.rb +++ b/app/models/ask_question.rb @@ -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 diff --git a/app/views/admin/ask_acknowledgements/index.html.erb b/app/views/admin/ask_acknowledgements/index.html.erb index e3aff30..498b5b2 100644 --- a/app/views/admin/ask_acknowledgements/index.html.erb +++ b/app/views/admin/ask_acknowledgements/index.html.erb @@ -1,10 +1,21 @@ +<% + set_input_name('ask_acknowledgement') +%> +
<%= form_for @ask_acknowledgements, url: @url, html: { class: 'form-horizontal' } do |f| %>
<%= f.label :content, t('ask.acknowledgements'), class: 'control-label' %> -
- <%= f.text_area :content, rows: 10 %> -
+ <%= + 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;'}) + %>
<%= f.submit t('submit'), class: 'btn btn-primary' %> diff --git a/app/views/admin/asks/_form.html.erb b/app/views/admin/asks/_form.html.erb index bb9528c..6abe0d4 100644 --- a/app/views/admin/asks/_form.html.erb +++ b/app/views/admin/asks/_form.html.erb @@ -32,6 +32,9 @@ <%= AskQuestion.human_attribute_name(:phone) %>:<%= @ask_question.phone %> + + <%= t('title') %>:<%= f.text_field :title %> + <%= AskQuestion.human_attribute_name(:appointment) %>:<%= @ask_question.appointment.strftime("%Y-%m-%d %H:%M") rescue nil %> @@ -51,11 +54,15 @@ <%= f.label :comment %>
<%= f.text_field :comment, style: 'width: 500px' %> + + <%= f.label :agree_show %><%= f.select :agree_show,[[t('ask.no'),false],[t('ask.yes'),true]] %> + <%= 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'] ] %> @@ -70,7 +77,7 @@ <%= ask_setting.custom_fields.collect do |k,v| required_pattern = v['required']=='true' ? '*' : '' "
- +
#{show_on_front(k,v,@ask_question.custom_values[k])}
@@ -78,8 +85,15 @@ end.join.html_safe %>
- +<% + 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 +%>
<%= 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' %>
diff --git a/app/views/admin/asks/_index.html.erb b/app/views/admin/asks/_index.html.erb index c75c7b0..2b630e6 100644 --- a/app/views/admin/asks/_index.html.erb +++ b/app/views/admin/asks/_index.html.erb @@ -2,7 +2,10 @@ <% @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 %> @@ -11,16 +14,17 @@ <% if b.situation == 'is_waiting' %> - <%= t('is_waiting') %> + <%= t('ask.is_waiting') %> <% elsif b.situation == 'is_processed' %> - <%= t('is_processed') %> + <%= t('ask.is_processed') %> <% elsif b.situation == 'is_referral' %> - <%= t('is_referral') %> + <%= t('ask.is_referral') %> + <% elsif b.situation == 'is_published' %> + <%= t('ask.is_published') %> <% end %> - <%= b.category.title %> - +
+ + + <% 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 %> + <%= b.name %> -
- -
- <%= b.phone %> - <%= b.appointment.strftime("%Y-%m-%d %H:%M") rescue nil %> + <% if @ask_setting.default_setting['phone'] %> + <%= b.phone %> + <% end %> + <% if @ask_setting.default_setting['appointment'] %> + <%= b.appointment.strftime("%Y-%m-%d %H:%M") rescue nil %> + <% end %> <% end %> diff --git a/app/views/asks/index.html.erb b/app/views/asks/index.html.erb index 493dbae..e30d2fe 100644 --- a/app/views/asks/index.html.erb +++ b/app/views/asks/index.html.erb @@ -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 %> <%# 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" %> \ No newline at end of file + +<% end %> \ No newline at end of file diff --git a/app/views/asks/published_index.erb b/app/views/asks/published_index.erb new file mode 100644 index 0000000..11b661e --- /dev/null +++ b/app/views/asks/published_index.erb @@ -0,0 +1,16 @@ + + + + + + + + + <% data['ask_questions'].each do |ask_question| %> + + + + + <% end %> + +
<%= t('categories') %><%= t('title') %>
<%= ask_question.category.title %><%= link_to ask_question.title,"#{data['url']}?item=#{ask_question.id}",title: ask_question.title %>
\ No newline at end of file diff --git a/app/views/asks/show.html.erb b/app/views/asks/show.html.erb new file mode 100644 index 0000000..23b6d82 --- /dev/null +++ b/app/views/asks/show.html.erb @@ -0,0 +1,83 @@ +<% ask = data['ask_question'] %> + +<%= stylesheet_link_tag "custom_field" %> + +
+
+
+ <%= label_tag nil,t('category'), :class=> 'control-label' %> +
+ <%= label_tag nil,(ask.category.title rescue nil), class: 'control-label' %> +
+
+
+ <%= label_tag nil,t('title'), :class=> 'control-label' %> +
+ <%= label_tag nil,ask.title, :class=> 'control-label' %> +
+
+ <%= ask_setting.custom_fields.collect do |k,v| + required_pattern = v['required']=='true' ? '*' : '' + "
+ +
+ #{show_on_front(k,v,ask.custom_values[k],true)} +
+
" + end.join.html_safe %> +
+ <%= label_tag nil,t('mongoid.attributes.ask_question.reply'), :class=> 'control-label' %> +
+ <%= ask.reply %> +
+
+
+
\ No newline at end of file diff --git a/app/views/asks/thank.html.erb b/app/views/asks/thank.html.erb index 1dea08e..f01d9ca 100644 --- a/app/views/asks/thank.html.erb +++ b/app/views/asks/thank.html.erb @@ -2,5 +2,10 @@
-

我們已經收到您的預約,期待您的蒞臨,謝謝

+

+ <% text = AskAcknowledgement.first.content[I18n.locale] rescue t('ask.thank_text') + text = t('ask.thank_text') if text.to_s.empty? + %> + <%= text.html_safe %> +

\ No newline at end of file diff --git a/ask.gemspec b/ask.gemspec index edc13f9..dfef73c 100644 --- a/ask.gemspec +++ b/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" diff --git a/config/locales/en.yml b/config/locales/en.yml index ce9988b..40d1c17 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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 \ No newline at end of file + 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? \ No newline at end of file diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 54a2692..acdc07a 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -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: 是否回信 \ No newline at end of file + send_email: 是否回信 + agree_show: 是否同意您提出之需求及回覆內容以不呈現發問者資訊方式刊載於網站供他人參考? \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 2989470..74e8da4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,8 +15,7 @@ Rails.application.routes.draw do resources :ask_acknowledgements resources :ask_admins end - - resources :asks #fronted + resources :asks #fronted end end diff --git a/lib/ask/engine.rb b/lib/ask/engine.rb index bf5c7cd..9803bc7 100644 --- a/lib/ask/engine.rb +++ b/lib/ask/engine.rb @@ -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 diff --git a/modules/ask/_ask_widget_form.html.erb b/modules/ask/_ask_widget_form.html.erb new file mode 100644 index 0000000..04e2573 --- /dev/null +++ b/modules/ask/_ask_widget_form.html.erb @@ -0,0 +1,91 @@ +
+ + + + + +

+ {{widget-title}} +

+
+
+ {{token_tag}} +
+
+ {{label}} +
+ {{content}} +
+
+
+
+ + {{submit_tag}} + {{close_tag}} +
+
+
+
\ No newline at end of file diff --git a/modules/ask/_ask_widget_list.html.erb b/modules/ask/_ask_widget_list.html.erb new file mode 100644 index 0000000..03687c0 --- /dev/null +++ b/modules/ask/_ask_widget_list.html.erb @@ -0,0 +1,17 @@ +
+

+ {{widget-title}} +

+ + + + + + + + + + + +
{{td}}
{{content}}
+
\ No newline at end of file diff --git a/modules/ask/info.json b/modules/ask/info.json new file mode 100644 index 0000000..9dd7c12 --- /dev/null +++ b/modules/ask/info.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/modules/ask/thumbs/thumb.png b/modules/ask/thumbs/thumb.png new file mode 100644 index 0000000..266af56 Binary files /dev/null and b/modules/ask/thumbs/thumb.png differ