Merge branch 'master' into 'master'

something for better user experience

* render edit button even if wiki_page has no html content
* redirect to referer_url after update wiki_page
* add direct link to front end wiki page
* add parent page for wiki page

See merge request !2
This commit is contained in:
EricTYL 2019-11-28 17:04:31 +08:00
commit 7c19c4d9a6
6 changed files with 51 additions and 7 deletions

View File

@ -57,6 +57,13 @@ class Admin::PageContentsController < OrbitAdminController
render :json => {"success" => true}.to_json
end
def wiki_parent
parent_page_id = params[:id]
@wiki_parent_page = Page.where(:id => parent_page_id).first
@table_fields = ["page_content.id", :name,:version,:update_at,:last_modified, :category]
@categories = @module_app.categories.enabled.authorized(current_user).collect{|c| [c.title, c.id]}
end
private
def update_params

View File

@ -53,7 +53,7 @@ class Admin::WikiPagesController < OrbitAdminController
def update
wiki = WikiPage.find(params[:id])
wiki.update_attributes(wiki_page_params)
redirect_to admin_wiki_pages_path(:page_id => wiki.page.id)
redirect_to params['referer_url']
end
private

View File

@ -0,0 +1,34 @@
<table class="table table-striped table-hover main-list">
<thead>
<tr class="sort-header">
<% @table_fields.each do |f| %>
<%= thead(f) %>
<% end %>
</tr>
</thead>
<tbody>
<tr>
<td><%= @wiki_parent_page.page_id%></td>
<td>
<a href="/<%= I18n.locale %><%= @wiki_parent_page.url %>" target="_blank"><%= @wiki_parent_page.name %></a>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(@wiki_parent_page) %>
<li><a href="/admin/page_contents/new?page_id=<%= @wiki_parent_page.id.to_s %>"><%= t(:edit) %></a></li>
<li><a href="/admin/wiki_pages/?page_id=<%= @wiki_parent_page.id.to_s %>"><%= t("page_content.wiki") %></a></li>
<% end %>
</ul>
</div>
</td>
<td><a href="/admin/page_contents/<%= @wiki_parent_page.id.to_s %>/view" ><%= @wiki_parent_page.page_contexts.last.version rescue nil %></a></td>
<td><%= format_value @wiki_parent_page.page_contexts.last.updated_at rescue nil %></td>
<td><%= User.find(@wiki_parent_page.page_contexts.last.update_user_id).user_name rescue nil %></td>
<td>
<% if can_edit_or_delete?(@wiki_parent_page) %>
<%= select_tag("category_id",options_for_select(@categories, (@wiki_parent_page.category_id.to_s rescue "")), prompt: t("select_category"), class: "category_select", style: "margin-bottom:0; width:150px;") %>
<button <%= !@wiki_parent_page.category_id.nil? ? "data-page-category-id=#{@wiki_parent_page.category_id.to_s}" : "" %> data-page-id="<%= @wiki_parent_page.id.to_s %>" class="btn btn-primary save_category hide">Save</button>
<% end %>
</td>
</tr>
</tbody>
</table>

View File

@ -10,7 +10,7 @@
<% @wikis.each do |page| %>
<tr>
<td>
<a href="" target="_blank"><%= page.title %></a>
<a href="/<%= I18n.locale %><%= @page.url + '/?wiki=' + page.uid.to_s %>" target="_blank"><%= page.title %></a>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(page.page) %>
@ -20,7 +20,9 @@
</div>
</td>
<td><%= format_value page.created_at rescue nil %></td>
<td><%= page.page.page_id rescue "" %></td>
<td>
<a href="<%= wiki_parent_admin_page_content_path(:id => page.page_id.to_s) %>" target="_blank"><%= page.page.page_id rescue "" %></a>
</td>
<td><%= User.find(page.update_user_id).user_name rescue nil %></td>
</tr>
<% end %>

View File

@ -6,7 +6,7 @@
</div>
<h3 class="page-module-title"><%= data["title"] %></h3>
<%= data["html"].html_safe %>
<%= data["html"].html_safe unless data["html"].nil? %>
<% 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>

View File

@ -7,6 +7,7 @@ Rails.application.routes.draw do
resources :page_contents do
member do
get "view" => "page_contents#view"
get "wiki_parent" => "page_contents#wiki_parent"
end
end
resources :wiki_pages