Add link_to_edit for frontend
This commit is contained in:
parent
38758160fe
commit
dfe9065916
|
@ -21,7 +21,7 @@ class Admin::PageContentsController < OrbitAdminController
|
||||||
@page_content = PageContext.new(update_params)
|
@page_content = PageContext.new(update_params)
|
||||||
@page_content.update_user_id = current_user.id
|
@page_content.update_user_id = current_user.id
|
||||||
@page_content.save
|
@page_content.save
|
||||||
redirect_to admin_page_contents_path
|
redirect_to params['referer_url']
|
||||||
end
|
end
|
||||||
|
|
||||||
def view
|
def view
|
||||||
|
|
|
@ -2,8 +2,10 @@ class PageContentsController < OrbitAdminController
|
||||||
def index
|
def index
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
page = Page.where(:page_id => params[:page_id]).first
|
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
|
||||||
end
|
end
|
|
@ -33,6 +33,7 @@
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<%= f.hidden_field :page_id, :value=>@page.id.to_s %>
|
<%= f.hidden_field :page_id, :value=>@page.id.to_s %>
|
||||||
<%= f.hidden_field :version, :value=>((@page.page_contexts.last.version + 1) rescue 1)%>
|
<%= 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" %>
|
<%= f.submit t("save"), :class=> "btn btn-primary bt-form-save" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
<% data = action_data %>
|
<% 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