This commit is contained in:
BoHung Chiu 2022-05-22 20:19:38 +08:00
parent 943ee2b35e
commit 1ab5631b2d
4 changed files with 18 additions and 16 deletions

View File

@ -20,29 +20,29 @@
if(window.scroll_top){ if(window.scroll_top){
$(window).scrollTop(window.scroll_top); $(window).scrollTop(window.scroll_top);
} }
window.archive_delete_ids = []; window.anncs_delete_ids = [];
$(".delete_archives_btn").addClass('hide'); $(".delete_anncs_btn").addClass('hide');
}); });
} }
$(document).on("click", ".select_delete", function(){ $(document).on("click", ".select_delete", function(){
var that = $(this); var that = $(this);
var id = that.data("id"); var id = that.data("id");
if(window.archive_delete_ids == undefined){ if(window.anncs_delete_ids == undefined){
window.archive_delete_ids = []; window.anncs_delete_ids = [];
} }
if(that.prop("checked")){ if(that.prop("checked")){
window.archive_delete_ids.push(id); window.anncs_delete_ids.push(id);
}else{ }else{
window.archive_delete_ids.delete(id); window.anncs_delete_ids.delete(id);
} }
if(window.archive_delete_ids.length == 0){ if(window.anncs_delete_ids.length == 0){
$(".delete_archives_btn").addClass('hide'); $(".delete_anncs_btn").addClass('hide');
}else{ }else{
$(".delete_archives_btn").removeClass('hide'); $(".delete_anncs_btn").removeClass('hide');
} }
}) })
function delete_archives(){ function delete_anncs(){
if(!window.archive_delete_ids || window.archive_delete_ids.length == 0){ if(!window.anncs_delete_ids || window.anncs_delete_ids.length == 0){
return null; return null;
} }
var data = new FormData(); var data = new FormData();
@ -55,7 +55,7 @@
if (csrf_token && csrf_param) { if (csrf_token && csrf_param) {
data.append(csrf_param, csrf_token); data.append(csrf_param, csrf_token);
} }
window.archive_delete_ids.forEach(function(val){ window.anncs_delete_ids.forEach(function(val){
data.append('ids[]', val); data.append('ids[]', val);
}); });
$.ajax({ $.ajax({
@ -78,10 +78,10 @@
} }
}) })
} }
$(document).on("click", ".delete_archives_btn", function(){ $(document).on("click", ".delete_anncs_btn", function(){
if(window.confirm("<%=t(:sure?)%>")){ if(window.confirm("<%=t(:sure?)%>")){
if(window.confirm("<%=t(:sure?)%>")){ if(window.confirm("<%=t(:sure?)%>")){
delete_archives(); delete_anncs();
} }
} }
}) })
@ -187,7 +187,7 @@
<%= <%=
content_tag :div, class: "bottomnav clearfix" do content_tag :div, class: "bottomnav clearfix" do
content_tag(:div, paginate(@bulletins), class: "pagination pagination-centered") + content_tag(:div, paginate(@bulletins), class: "pagination pagination-centered") +
content_tag(:div, link_to(t("archive.delete_selected"), "javascript:void(0)", :class=>"btn btn-primary"), class: "pull-right hide delete_archives_btn") + content_tag(:div, link_to(t("announcement.delete_selected"), "javascript:void(0)", :class=>"btn btn-primary"), class: "pull-right hide delete_anncs_btn") +
content_tag(:div, link_to(t(:new_),new_admin_announcement_path, :class=>"btn btn-primary"), class: "pull-right") content_tag(:div, link_to(t(:new_),new_admin_announcement_path, :class=>"btn btn-primary"), class: "pull-right")
end end
%> %>

View File

@ -3,6 +3,7 @@ en:
feed: Feed feed: Feed
import: Import import: Import
announcement: announcement:
delete_selected: "Delete Selected"
expired: This announcement has been expired. expired: This announcement has been expired.
go_back: Go back to the list of announcements. go_back: Go back to the list of announcements.
annc_dept: Department annc_dept: Department

View File

@ -4,6 +4,7 @@ zh_tw:
import: 匯入 import: 匯入
get_all_anncs_without_subannc: "選擇相關公告" get_all_anncs_without_subannc: "選擇相關公告"
announcement: announcement:
delete_selected: "刪除所選"
expired: 此則公告已過期 expired: 此則公告已過期
go_back: 回到公告列表 go_back: 回到公告列表
annc_dept: 公告單位 annc_dept: 公告單位

View File

@ -32,7 +32,7 @@ Rails.application.routes.draw do
patch 'announcement/updatesettings', to: 'announcements#updatesettings' patch 'announcement/updatesettings', to: 'announcements#updatesettings'
post 'announcement/import_from_wp', to: 'announcements#import_from_wp' post 'announcement/import_from_wp', to: 'announcements#import_from_wp'
post 'announcement/generate_iframe_url' => 'announcements#generate_iframe_url' post 'announcement/generate_iframe_url' => 'announcements#generate_iframe_url'
delete 'announcement/delete', to: 'announcements#delete' delete 'announcements/delete', to: 'announcements#delete'
resources :announcements resources :announcements
get 'announcements/:id/comment'=> 'announcements#comment' get 'announcements/:id/comment'=> 'announcements#comment'
get 'annc-comment-hidden/:id' => 'announcements#comment_hidden' get 'annc-comment-hidden/:id' => 'announcements#comment_hidden'