Add link_to_edit for frontend

This commit is contained in:
manson 2014-08-05 14:39:47 +08:00
parent 951be509e5
commit f45ea12490
3 changed files with 67 additions and 64 deletions

View File

@ -58,7 +58,7 @@ class Admin::FaqsController < OrbitAdminController
@qa.create_user_id = current_user.id
@qa.update_user_id = current_user.id
@qa.save
redirect_to admin_faqs_path
redirect_to params['referer_url']
end
def edit
@ -76,7 +76,7 @@ class Admin::FaqsController < OrbitAdminController
@qa.update_attributes(create_params)
@qa.update_user_id = current_user.id
@qa.save
redirect_to admin_faqs_path
redirect_to params['referer_url']
end
def destroy

View File

@ -24,6 +24,9 @@ class FaqsController < ApplicationController
def show
params = OrbitHelper.params
faq = Qa.can_display.find_by_param(params[:uid])
url_to_edit = OrbitHelper.user_can_edit?(faq) ? "/admin/faqs/#{faq.id.to_s}/edit" : ""
faqs_files = faq.qa_files.collect do |f|
{
"file_url" => f.file.url,
@ -41,7 +44,8 @@ class FaqsController < ApplicationController
"extras" => {"question" => faq.title,"answer" => faq.answer},
"faqs_links" => faqs_links,
"faqs_files" => faqs_files,
"tags" => tags
"tags" => tags,
"url_to_edit" => url_to_edit
}
end

View File

@ -170,9 +170,8 @@
</div>
<!-- Form Actions -->
<div class="form-actions">
<input type="hidden" name="referer_url" value="<%= request.referer %>">
<%= 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" %>
</div>
</fieldset>