删除恢复功能

This commit is contained in:
chenyang
2022-07-23 17:36:27 +08:00
parent cf84ef8ae7
commit 55630678ce
4 changed files with 74 additions and 16 deletions
+1
View File
@@ -25,6 +25,7 @@ urlpatterns = [
path('d', JsMindView.as_view()), # 获得导图详情
path('s_d', JsMindShareView.as_view()), # 获得导图详情
path('delete', JsMindView.as_view()), # 删除思维导图
path('delete_cancel', JsMindView.as_view()), # 思维导图恢复
path('share', JsMindShareView.as_view()), # 分享思维导图,查询等
path('star', JsMindStarView.as_view()), # 收藏思维导图
+18 -2
View File
@@ -69,7 +69,14 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
"""
创建思维导图
"""
user = request.user
coop_mind_name = request.data.get('mind_name')
coop_mind_id = request.data.get('coop_mind_id')
op_type = request.data.get('op_type')
if op_type == "delete_cancel":
CooperationMind.objects.filter(id=coop_mind_id, creator_user_id=user.id).update(deleted=False)
return build_response()
else:
user = request.user
data_format = 'node_tree'
mind = CooperationMind(coop_mind_name=coop_mind_name, client_uuid='', mind_log_id=-1, creator_user_id=user.id, snapshot_data=SNAPSHOT_JSON_DATA, data_format=data_format)
@@ -219,8 +226,6 @@ class JsMindStarView(LoginRequiredJSONMixin, ListAPIView):
post_body = request.POST
# 思维导图id
coop_mind_id = post_body.get('coop_mind_id')
# 操作类型
op_type = post_body.get('op_type')
if coop_mind_id is None:
return build_response(CODE_FAILED, msg="参数错误")
@@ -233,3 +238,14 @@ class JsMindStarView(LoginRequiredJSONMixin, ListAPIView):
star = CooperationMindStar(operator_user_id=user.id, coop_mind_id=coop_mind_id, coop_mind_name=mind.coop_mind_name)
star.save()
return build_response()
def delete(self, request):
"""
取消收藏
"""
print('dlete')
post_body = request.POST
user = request.user
coop_mind_id = post_body.get('coop_mind_id')
CooperationMindStar.objects.filter(operator_user_id=user.id, coop_mind_id=coop_mind_id).delete()
return build_response()
+44 -4
View File
@@ -100,7 +100,6 @@
let idx = 0
let row = $(`<div class="row"></row>`)
results.forEach(function (item) {
const uuid = me.get_uu_id()
@@ -114,7 +113,9 @@
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_cancel(${item.id})">取消分享</a>
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.fetch_share_info(${item.id})">查看分享链接</a>`
} else if (page_tag === 'star') {
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="">取消收藏</a>`
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.un_star(${item.id})">取消收藏</a>`
} else if (page_tag === 'recycle') {
sub_btn = `<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_cancel(${item.id})">恢复</a>`
}
const content = `<div class="card col-2" style="margin: 6px; margin-left: 20px;" id='card_${uuid}'>
@@ -149,11 +150,14 @@
},
/**分页组件*/
init_pagination: function (count, page_size) {
const container = $('#pagination_div')
/**计算页数*/
if (count <= 0) return
if (count <= 0) {
container.empty()
return
}
const all_page = (count <= page_size) ? 1 : (count % page_size > 0) ? Math.floor(count / page_size) + 1 : Math.floor(count / page_size)
const container = $('#pagination_div')
const navigation = $(`<nav aria-label="Page navigation example"></nav>`)
const navigation_ul = $(`<ul class="pagination justify-content-center"></ul>`)
@@ -231,6 +235,42 @@
async: false
});
},
/** 删除恢复*/
del_cancel: function (mind_id) {
const me = this
$.ajax({
type: "post",
url: "delete_cancel",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'coop_mind_id': mind_id, 'op_type': 'delete_cancel'},
dataType: "json",
success: function (resp) {
common_alert(resp.msg)
if (me.is_success_resp(resp)) {
me.fetch_mind()
}
},
async: false
});
},
/** 取消收藏 */
un_star: function (mind_id) {
const me = this
$.ajax({
type: "delete",
url: "star",
headers: {"X-CSRFToken": $.cookie("csrftoken")},
data: {'coop_mind_id': mind_id},
dataType: "json",
success: function (resp) {
common_alert(resp.msg)
if (me.is_success_resp(resp)) {
me.fetch_mind()
}
},
async: false
});
},
/**获得分享信息*/
fetch_share_info: function (mind_id) {
const me = this
+6 -5
View File
@@ -4,21 +4,22 @@ const modal = `
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">扫码登录</h5>
<h5 class="modal-title">注册</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<!--qr_login Modal start-->
<!--qr_login Modal start
<div class="modal-body qr_login_group" style="height: 360px;">
<img src="https://img0.baidu.com/it/u=3881180510,1470858589&fm=253&fmt=auto&app=138&f=JPEG?w=200&h=200" height="300px">
</div>
-->
<!--qr_login Modal end-->
<!--register Modal start-->
<form>
<div class="modal-body register_group" style="display: none;height: 360px;">
<div class="modal-body register_group" style="height: 360px;">
<h1 class="h3 mb-3 font-weight-normal">请输入用户名和密码</h1>
<label for="userName" class="sr-only"></label>
<input type="text" id="userName" class="form-control" placeholder="用户名" autocomplete="off" required autofocus>
@@ -54,10 +55,10 @@ const modal = `
<!--pw_login Modal end-->
<div class="modal-footer">
<a class="nav-link active" href="#" id="s_login_a">
<!--<a class="nav-link active" href="#" id="s_login_a">
<span data-feather="grid"></span>
扫码登录
</a>
</a>-->
<a class="nav-link active" id="register_a" href="#">
<span data-feather="check-circle"></span>
用户注册