From 943a01091f6505a8a2adf2713d70a0f698b0bfd7 Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Thu, 28 Nov 2019 16:30:45 +0800 Subject: [PATCH 1/7] render edit button even if wiki_page has no html content --- app/views/page_contents/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/page_contents/index.html.erb b/app/views/page_contents/index.html.erb index 3ccc552..5b5369c 100644 --- a/app/views/page_contents/index.html.erb +++ b/app/views/page_contents/index.html.erb @@ -6,8 +6,8 @@

<%= data["title"] %>

-<%= data["html"].html_safe %> +<%= data["html"].html_safe unless data["html"].nil? %> <% if !data["url_to_edit"].blank? %>

<%= t(:edit) %>

-<% end %> \ No newline at end of file +<% end %> From 20ca6213d1fcdc236c9b8be8c6cbf3da2d0ec394 Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Thu, 28 Nov 2019 16:35:40 +0800 Subject: [PATCH 2/7] redirect to referer_url after update --- app/controllers/admin/wiki_pages_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/wiki_pages_controller.rb b/app/controllers/admin/wiki_pages_controller.rb index 868a1f9..86f87cc 100644 --- a/app/controllers/admin/wiki_pages_controller.rb +++ b/app/controllers/admin/wiki_pages_controller.rb @@ -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 @@ -61,4 +61,4 @@ class Admin::WikiPagesController < OrbitAdminController def wiki_page_params params.require(:wiki_page).permit! end -end \ No newline at end of file +end From af163af3e74252b6b5d5f6e024944fd73bcb9e57 Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Thu, 28 Nov 2019 16:38:55 +0800 Subject: [PATCH 3/7] add link to wiki page --- app/views/admin/wiki_pages/_index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/wiki_pages/_index.html.erb b/app/views/admin/wiki_pages/_index.html.erb index cc221f9..ee11657 100644 --- a/app/views/admin/wiki_pages/_index.html.erb +++ b/app/views/admin/wiki_pages/_index.html.erb @@ -10,7 +10,7 @@ <% @wikis.each do |page| %> - <%= page.title %> + <%= page.title %>
- \ No newline at end of file + From 14fa1cc53485eee3961d7eccf9c0d06842ada9c4 Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Thu, 28 Nov 2019 16:40:59 +0800 Subject: [PATCH 4/7] add route for wiki parent page --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index 674fa2a..6d816ae 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 From 347000d139ba68ad34a7ba5cce5e95bdb9a64cb5 Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Thu, 28 Nov 2019 16:43:43 +0800 Subject: [PATCH 5/7] add wiki parent page action --- app/controllers/admin/page_contents_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/admin/page_contents_controller.rb b/app/controllers/admin/page_contents_controller.rb index 9c781b9..9842f5c 100644 --- a/app/controllers/admin/page_contents_controller.rb +++ b/app/controllers/admin/page_contents_controller.rb @@ -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 From e20ea408dc8bbafaad27123cef618fcfb998a9e3 Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Thu, 28 Nov 2019 16:45:46 +0800 Subject: [PATCH 6/7] add wiki parent page view --- .../admin/page_contents/wiki_parent.html.erb | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/views/admin/page_contents/wiki_parent.html.erb diff --git a/app/views/admin/page_contents/wiki_parent.html.erb b/app/views/admin/page_contents/wiki_parent.html.erb new file mode 100644 index 0000000..13213e0 --- /dev/null +++ b/app/views/admin/page_contents/wiki_parent.html.erb @@ -0,0 +1,34 @@ + + + + <% @table_fields.each do |f| %> + <%= thead(f) %> + <% end %> + + + + + + + + + + + + +
<%= @wiki_parent_page.page_id%> + <%= @wiki_parent_page.name %> +
+ +
+
<%= @wiki_parent_page.page_contexts.last.version rescue nil %><%= format_value @wiki_parent_page.page_contexts.last.updated_at rescue nil %><%= User.find(@wiki_parent_page.page_contexts.last.update_user_id).user_name rescue nil %> + <% 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;") %> + + <% end %> +
From 0e99dec8694cd9c8bcd8cabb1ca588c335fa087b Mon Sep 17 00:00:00 2001 From: Eric Tsai Date: Thu, 28 Nov 2019 16:50:21 +0800 Subject: [PATCH 7/7] add link to wiki parent page --- app/views/admin/wiki_pages/_index.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/admin/wiki_pages/_index.html.erb b/app/views/admin/wiki_pages/_index.html.erb index ee11657..ae73573 100644 --- a/app/views/admin/wiki_pages/_index.html.erb +++ b/app/views/admin/wiki_pages/_index.html.erb @@ -20,7 +20,9 @@ <%= format_value page.created_at rescue nil %> - <%= page.page.page_id rescue "" %> + + <%= page.page.page_id rescue "" %> + <%= User.find(page.update_user_id).user_name rescue nil %> <% end %>