rejection and approval mods
This commit is contained in:
parent
ef5c330146
commit
d7fc2b9aaf
|
@ -57,7 +57,13 @@ class Admin::NewsController < OrbitAdminController
|
||||||
def approve_news_bulletin
|
def approve_news_bulletin
|
||||||
id = params[:id]
|
id = params[:id]
|
||||||
news_bulletin = NewsBulletin.find(id)
|
news_bulletin = NewsBulletin.find(id)
|
||||||
|
if params["approved"] == "true"
|
||||||
news_bulletin.approved = true
|
news_bulletin.approved = true
|
||||||
|
news_bulletin.rejected = false
|
||||||
|
else
|
||||||
|
news_bulletin.rejected = true
|
||||||
|
news_bulletin.rejection_reason = params["reason"]
|
||||||
|
end
|
||||||
news_bulletin.save
|
news_bulletin.save
|
||||||
redirect_to "/admin/news"
|
redirect_to "/admin/news"
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,6 +21,8 @@ class NewsBulletin
|
||||||
field :deadline , :type => DateTime
|
field :deadline , :type => DateTime
|
||||||
field :rss2_sn
|
field :rss2_sn
|
||||||
field :approved, :type => Boolean, :default => false
|
field :approved, :type => Boolean, :default => false
|
||||||
|
field :rejected, :type => Boolean, :default => false
|
||||||
|
field :rejection_reason
|
||||||
field :is_preview, :type => Boolean, :default => false
|
field :is_preview, :type => Boolean, :default => false
|
||||||
|
|
||||||
field :email_id
|
field :email_id
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
<style>
|
||||||
|
#approvalModal {
|
||||||
|
width: 90%;
|
||||||
|
height: 600px;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
margin: auto;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
#approvalModal .preview-iframe {
|
||||||
|
border: 0;
|
||||||
|
outline: none;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
#approvalModal .modal-body {
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 0;
|
||||||
|
max-height: none;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
#approvalModal .modal-left {
|
||||||
|
overflow: auto;
|
||||||
|
float: left;
|
||||||
|
width: 19.8%;
|
||||||
|
border-right: 1px solid #DFDFDF;
|
||||||
|
height: 100%;
|
||||||
|
padding: 1em;
|
||||||
|
margin: 0;
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
#approvalModal .modal-right {
|
||||||
|
float: right;
|
||||||
|
width: 80%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.approvalModal__form {
|
||||||
|
padding: 0 10px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
label.approvalModal__radio {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
label.control-label {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approvalModal__controls {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approvalModal__group {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
label.approvalModal__label {
|
||||||
|
display: inline-block;
|
||||||
|
margin: 0 4px 0 7px;
|
||||||
|
position: relative;
|
||||||
|
top: -1px;
|
||||||
|
}
|
||||||
|
.approvalModal__controls .approvalModal__privacy {
|
||||||
|
margin: 0 5px;
|
||||||
|
}
|
||||||
|
.approvalModal__controls .approvalModal__large {
|
||||||
|
}
|
||||||
|
#approvalModal .modal-footer {
|
||||||
|
text-align: left;
|
||||||
|
padding: 15px 10px 10px;
|
||||||
|
}
|
||||||
|
.approvalModal__group.confirm {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div id="approvalModal" class="modal hide fade" role="dialog">
|
||||||
|
<div class="modal-header">
|
||||||
|
<a class="close" data-dismiss="modal">×</a>
|
||||||
|
<h3>預覽</h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body clearfix">
|
||||||
|
<div class="modal-left">
|
||||||
|
<label for="____">寄送對象</label>
|
||||||
|
</div>
|
||||||
|
<div class="modal-right">
|
||||||
|
<iframe class="preview-iframe"></iframe>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<%= form_tag "/admin/news/approve_news_bulletin", :class=>"approvalModal__form" do %>
|
||||||
|
<div class="approvalModal__group">
|
||||||
|
<label class="control-label" for="bulletin_approval_stat">審核狀態</label>
|
||||||
|
<div class="approvalModal__controls">
|
||||||
|
<label class="approvalModal__radio">
|
||||||
|
<input class="approvalModal__privacy" id="bulletin_is_checked_true" name="approved" type="radio" value="true">已認可
|
||||||
|
</label>
|
||||||
|
<label class="approvalModal__radio">
|
||||||
|
<input checked="checked" class="approvalModal__privacy" id="bulletin_approved_false" name="approved" type="radio" value="false">拒絕
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="approvalModal__group group--reject">
|
||||||
|
<label class="approvalModal__label" for="is_checked_false_拒絕原因">拒絕原因</label>
|
||||||
|
<div class="approvalModal__controls">
|
||||||
|
<input class="approvalModal__large" id="bulletin_not_checked_reason" name="reason" size="30" type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="approvalModal__group confirm">
|
||||||
|
<input class="approvalModal__btn btn btn-primary" name="commit" type="submit" value="送出">
|
||||||
|
<input type="hidden" id="object_id" name="id" />
|
||||||
|
<button class="approvalModal__btn btn" data-dismiss="modal" aria-hidden="true">關閉</button>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -20,6 +20,8 @@
|
||||||
<td>
|
<td>
|
||||||
<% if b.expired? %>
|
<% if b.expired? %>
|
||||||
<%= b.title %> <span class='label'><%= t(:expired) %></span>
|
<%= b.title %> <span class='label'><%= t(:expired) %></span>
|
||||||
|
<% elsif b.rejected %>
|
||||||
|
<a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title %></a> <span class='label'><%= t(:rejected) %> : <%= b.rejection_reason rescue "" %></span>
|
||||||
<% elsif !b.approved? %>
|
<% elsif !b.approved? %>
|
||||||
<a href="<%=page_for_news_bulletin(b)%>" target="_blank"><%= b.title %></a> <span class='label'><%= t(:pending) %></span>
|
<a href="<%=page_for_news_bulletin(b)%>" target="_blank"><%= b.title %></a> <span class='label'><%= t(:pending) %></span>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
@ -32,7 +34,7 @@
|
||||||
<li><a href="/admin/news/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li>
|
<li><a href="/admin/news/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li>
|
||||||
<li><a href="#" class="delete text-error" rel="/admin/news/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
|
<li><a href="#" class="delete text-error" rel="/admin/news/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
|
||||||
<% if !b.approved && user_can_approve? %>
|
<% if !b.approved && user_can_approve? %>
|
||||||
<li><a href="<%= admin_news_approve_news_bulletin_path(:id => b.id.to_s) %>"><%= t("news.approve") %></a></li>
|
<li><a href="#" class="appoval_button" data-approve-link="<%= "/#{I18n.locale.to_s}/news/#{b.to_param}" %>" data-id="<%= b.id.to_s %>"><%= t("news.approve") %></a></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -4,3 +4,16 @@
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
|
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
|
||||||
|
|
||||||
|
<%= render :partial=> "approval_modal" %>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(".appoval_button").on("click",function(){
|
||||||
|
var url = $(this).data("approve-link"),
|
||||||
|
modal = $("#approvalModal");
|
||||||
|
modal.find("iframe").attr("src", url);
|
||||||
|
modal.find("#object_id").val($(this).data("id"));
|
||||||
|
modal.modal("show");
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
</script>
|
|
@ -29,6 +29,7 @@ zh_tw:
|
||||||
all_articles: 文章列表
|
all_articles: 文章列表
|
||||||
all: 全部類別
|
all: 全部類別
|
||||||
news: 新聞
|
news: 新聞
|
||||||
|
approve: 審核
|
||||||
admins: 單位設定
|
admins: 單位設定
|
||||||
append_note: 以下之附加連結與檔案,為使前台顯示名稱,建議您輸入註解。
|
append_note: 以下之附加連結與檔案,為使前台顯示名稱,建議您輸入註解。
|
||||||
approval_setting: 審核設定
|
approval_setting: 審核設定
|
||||||
|
|
|
@ -6,7 +6,7 @@ Rails.application.routes.draw do
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
post 'news/preview', to: 'news#preview'
|
post 'news/preview', to: 'news#preview'
|
||||||
get 'news/destroy_preview/:slug_title-:uid', to: 'news#destroy_preview'
|
get 'news/destroy_preview/:slug_title-:uid', to: 'news#destroy_preview'
|
||||||
get 'news/approve_news_bulletin', to: 'news#approve_news_bulletin'
|
post 'news/approve_news_bulletin', to: 'news#approve_news_bulletin'
|
||||||
get 'news_admins/get_departments' => "news_admins#get_departments"
|
get 'news_admins/get_departments' => "news_admins#get_departments"
|
||||||
resources :news
|
resources :news
|
||||||
resources :news_admins
|
resources :news_admins
|
||||||
|
|
Loading…
Reference in New Issue