Add link_to_edit for frontend
This commit is contained in:
parent
38758160fe
commit
dfe9065916
|
@ -18,10 +18,10 @@ class Admin::PageContentsController < OrbitAdminController
|
|||
end
|
||||
|
||||
def create
|
||||
@page_content = PageContext.new(update_params)
|
||||
@page_content = PageContext.new(update_params)
|
||||
@page_content.update_user_id = current_user.id
|
||||
@page_content.save
|
||||
redirect_to admin_page_contents_path
|
||||
@page_content.save
|
||||
redirect_to params['referer_url']
|
||||
end
|
||||
|
||||
def view
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
class PageContentsController < OrbitAdminController
|
||||
def index
|
||||
params = OrbitHelper.params
|
||||
page = Page.where(:page_id => params[:page_id]).first
|
||||
{
|
||||
"html" => (page.page_contexts.last.content rescue "")
|
||||
}
|
||||
end
|
||||
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 ""),
|
||||
"url_to_edit" => url_to_edit
|
||||
}
|
||||
end
|
||||
end
|
|
@ -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>
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
<% data = action_data %>
|
||||
<%= data["html"].html_safe %>
|
||||
<%= 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 %>
|
Loading…
Reference in New Issue