Add link_to_edit for frontend

This commit is contained in:
manson 2014-08-05 14:45:30 +08:00
parent 38758160fe
commit dfe9065916
4 changed files with 18 additions and 11 deletions

View File

@ -21,7 +21,7 @@ class Admin::PageContentsController < OrbitAdminController
@page_content = PageContext.new(update_params)
@page_content.update_user_id = current_user.id
@page_content.save
redirect_to admin_page_contents_path
redirect_to params['referer_url']
end
def view

View File

@ -2,8 +2,10 @@ class PageContentsController < OrbitAdminController
def index
params = OrbitHelper.params
page = Page.where(:page_id => params[:page_id]).first
url_to_edit = OrbitHelper.user_can_edit?(page) ? "/admin/page_contents/new?page_id=#{page.id.to_s}" : ""
{
"html" => (page.page_contexts.last.content rescue "")
"html" => (page.page_contexts.last.content rescue ""),
"url_to_edit" => url_to_edit
}
end
end

View File

@ -33,6 +33,7 @@
<div class="form-actions">
<%= f.hidden_field :page_id, :value=>@page.id.to_s %>
<%= f.hidden_field :version, :value=>((@page.page_contexts.last.version + 1) rescue 1)%>
<input type="hidden" name="referer_url" value="<%= request.referer %>">
<%= f.submit t("save"), :class=> "btn btn-primary bt-form-save" %>
</div>
</div>

View File

@ -1,2 +1,6 @@
<% data = action_data %>
<%= data["html"].html_safe %>
<% if !data["url_to_edit"].blank? %>
<p class='admin-edit text-right'><a class='btn btn-primary' href='<%= data["url_to_edit"] %>'><i class='icon-edit'></i> <%= t(:edit) %></a></p>
<% end %>