rejection and approval mods
This commit is contained in:
parent
be4592ee99
commit
8770d7d8ca
|
@ -69,7 +69,13 @@ class Admin::AnnouncementsController < OrbitAdminController
|
|||
def approve_bulletin
|
||||
id = params[:id]
|
||||
bulletin = Bulletin.find(id)
|
||||
bulletin.approved = true
|
||||
if params["approved"] == "true"
|
||||
bulletin.approved = true
|
||||
bulletin.rejected = false
|
||||
else
|
||||
bulletin.rejected = true
|
||||
bulletin.rejection_reason = params["reason"]
|
||||
end
|
||||
bulletin.save
|
||||
redirect_to admin_announcements_path
|
||||
end
|
||||
|
|
|
@ -19,6 +19,8 @@ class Bulletin
|
|||
field :deadline , :type => DateTime
|
||||
field :rss2_sn
|
||||
field :approved, :type => Boolean, :default => false
|
||||
field :rejected, :type => Boolean, :default => false
|
||||
field :rejection_reason
|
||||
field :is_preview, :type => Boolean, :default => false
|
||||
|
||||
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/announcement/approve_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>
|
||||
<% if b.expired? %>
|
||||
<%= 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? %>
|
||||
<a href="<%=page_for_bulletin(b)%>" target="_blank"><%= b.title %></a> <span class='label'><%= t(:pending) %></span>
|
||||
<% else %>
|
||||
|
@ -32,7 +34,7 @@
|
|||
<li><a href="/admin/announcements/<%=b.id.to_s%>/edit"><%= t(:edit) %></a></li>
|
||||
<li><a href="#" class="delete text-error" rel="/admin/announcements/<%=b.id.to_s%>"><%= t(:delete_) %></a></li>
|
||||
<% if !b.approved && user_can_approve? %>
|
||||
<li><a href="<%= admin_announcement_approve_bulletin_path(:id => b.id.to_s) %>"><%= t("announcement.approve") %></a></li>
|
||||
<li><a href="#" class="appoval_button" data-approve-link="<%= "/#{I18n.locale.to_s}/announcement/#{b.to_param}" %>" data-id="<%= b.id.to_s %>"><%= t("announcement.approve") %></a></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
|
|
@ -3,4 +3,17 @@
|
|||
<%= render 'index'%>
|
||||
</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>
|
|
@ -8,7 +8,7 @@ zh_tw:
|
|||
sub_title: 副標題
|
||||
category: 類別
|
||||
add_new: 新建
|
||||
approve: 通過
|
||||
approve: 審核
|
||||
tag_cloud: 標籤雲
|
||||
all_articles: 文章列表
|
||||
announcement: 公告
|
||||
|
|
|
@ -6,7 +6,7 @@ Rails.application.routes.draw do
|
|||
namespace :admin do
|
||||
post 'announcement/preview', to: 'announcements#preview'
|
||||
get 'announcement/destroy_preview/:slug_title-:uid', to: 'announcements#destroy_preview'
|
||||
get 'announcement/approve_bulletin', to: 'announcements#approve_bulletin'
|
||||
post 'announcement/approve_bulletin', to: 'announcements#approve_bulletin'
|
||||
resources :announcements
|
||||
end
|
||||
|
||||
|
|
Reference in New Issue