From 42a7f1a19218b5a3c28501659077becb073e6af7 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 5 Dec 2014 18:08:10 +0800 Subject: [PATCH] customization log css modify --- .../admin/customization_logs_controller.rb | 9 +- app/models/site_log.rb | 1 + .../admin/customization_logs/_index.html.erb | 2 +- .../admin/customization_logs/get_log.html.erb | 89 ++++++++--------- .../admin/customization_logs/index.html.erb | 96 ++++++++++++++++--- config/routes.rb | 1 + 6 files changed, 137 insertions(+), 61 deletions(-) diff --git a/app/controllers/admin/customization_logs_controller.rb b/app/controllers/admin/customization_logs_controller.rb index 4a0bff2..8b64c8b 100644 --- a/app/controllers/admin/customization_logs_controller.rb +++ b/app/controllers/admin/customization_logs_controller.rb @@ -22,7 +22,7 @@ class Admin::CustomizationLogsController < OrbitAdminController def get_log @site = RegisteredSite.find(params[:id]) - @logs = @site.site_logs.desc(:created_at) + @logs = @site.site_logs.where(:archive.ne => true).desc(:created_at) render :layout => false end @@ -31,6 +31,13 @@ class Admin::CustomizationLogsController < OrbitAdminController @site = RegisteredSite.find(params[:id]) end + def archive + log = SiteLog.find(params[:id]) + log.archive = true + log.save + render :json => {"success" => true}.to_json + end + def update log = SiteLog.find(params[:id]) log.update_attributes(site_log_params) diff --git a/app/models/site_log.rb b/app/models/site_log.rb index cfe40c4..06470e1 100644 --- a/app/models/site_log.rb +++ b/app/models/site_log.rb @@ -4,6 +4,7 @@ class SiteLog field :title field :content + field :archive, type: Boolean, default: false field :create_user_id, type: BSON::ObjectId field :update_user_id, type: BSON::ObjectId diff --git a/app/views/admin/customization_logs/_index.html.erb b/app/views/admin/customization_logs/_index.html.erb index 1b9666d..62e733c 100644 --- a/app/views/admin/customization_logs/_index.html.erb +++ b/app/views/admin/customization_logs/_index.html.erb @@ -22,7 +22,7 @@ <% end %> - <% if !site.site_logs.blank? %> + <% if site.site_logs.where(:archive.ne => true).count > 0 %> View Log <% end %> Add Log diff --git a/app/views/admin/customization_logs/get_log.html.erb b/app/views/admin/customization_logs/get_log.html.erb index 9899886..1c20e57 100644 --- a/app/views/admin/customization_logs/get_log.html.erb +++ b/app/views/admin/customization_logs/get_log.html.erb @@ -1,46 +1,47 @@ <% @logs.each_with_index do |log, i| %> -
-
-
-
Author :
- <% user = User.find(log.create_user_id) %> -
<%= user.member_profile.nil? ? user.user_name : user.member_profile.name %>
-
-
-
Date :
-
<%= log.created_at %>
-
- <% if !log.update_user_id.nil? %> -
-
Updated by :
- <% user = User.find(log.update_user_id) %> -
<%= user.member_profile.nil? ? user.user_name : user.member_profile.name %>
-
- <% end %> -
-
Title :
-
<%= log.title %>
-
- <% if !log.site_log_files.blank? %> -
- <% log.site_log_files.each_with_index do |file,index| %> -
<%= index == 0 ? "Files" : "" %>
-
- <%= link_to (file.title.nil? || file.title == "" ? file.file_identifier : file.title), file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => file.file_identifier} %> -
- <% end %> -
- <% end %> -
-
Content :
-
<%= log.content.html_safe %>
-
-
-
-
- -
- <% if i != (@logs.length - 1) %> -
- <% end %> +
+
+
Author :
+ <% user = User.find(log.create_user_id) %> +
<%= user.member_profile.nil? ? user.user_name : user.member_profile.name %>
+
+
+
Date :
+
<%= log.created_at %>
+
+ <% if !log.update_user_id.nil? %> +
+
Updated by :
+ <% user = User.find(log.update_user_id) %> +
<%= user.member_profile.nil? ? user.user_name : user.member_profile.name %>
+
+ <% end %> +
+
Title :
+
<%= log.title %>
+
+ <% if !log.site_log_files.blank? %> +
+
Files :
+
+
    + <% log.site_log_files.each do |file| %> +
  • <%= link_to (file.title.nil? || file.title == "" ? file.file_identifier : file.title), file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => file.file_identifier} %>
  • + <% end %> +
+
+
+ <% end %> +
+
Content :
+
<%= log.content.html_safe %>
+
+
+ Edit + Archive +
+
+ <% if i != (@logs.length - 1) %> +
+ <% end %> <% end %> \ No newline at end of file diff --git a/app/views/admin/customization_logs/index.html.erb b/app/views/admin/customization_logs/index.html.erb index e138f19..3bf7a6d 100644 --- a/app/views/admin/customization_logs/index.html.erb +++ b/app/views/admin/customization_logs/index.html.erb @@ -2,22 +2,88 @@ <%= render 'index'%> - <%= render "log_modal" %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d752ce4..543c003 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,6 +9,7 @@ Rails.application.routes.draw do resources :customization_logs do member do get "get_log" => "customization_logs#get_log" + post "archive" => "customization_logs#archive" end end end