删除恢复功能
This commit is contained in:
@@ -25,6 +25,7 @@ urlpatterns = [
|
|||||||
path('d', JsMindView.as_view()), # 获得导图详情
|
path('d', JsMindView.as_view()), # 获得导图详情
|
||||||
path('s_d', JsMindShareView.as_view()), # 获得导图详情
|
path('s_d', JsMindShareView.as_view()), # 获得导图详情
|
||||||
path('delete', JsMindView.as_view()), # 删除思维导图
|
path('delete', JsMindView.as_view()), # 删除思维导图
|
||||||
|
path('delete_cancel', JsMindView.as_view()), # 思维导图恢复
|
||||||
path('share', JsMindShareView.as_view()), # 分享思维导图,查询等
|
path('share', JsMindShareView.as_view()), # 分享思维导图,查询等
|
||||||
path('star', JsMindStarView.as_view()), # 收藏思维导图
|
path('star', JsMindStarView.as_view()), # 收藏思维导图
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,14 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
|||||||
"""
|
"""
|
||||||
创建思维导图
|
创建思维导图
|
||||||
"""
|
"""
|
||||||
|
user = request.user
|
||||||
coop_mind_name = request.data.get('mind_name')
|
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
|
user = request.user
|
||||||
data_format = 'node_tree'
|
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)
|
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
|
post_body = request.POST
|
||||||
# 思维导图id
|
# 思维导图id
|
||||||
coop_mind_id = post_body.get('coop_mind_id')
|
coop_mind_id = post_body.get('coop_mind_id')
|
||||||
# 操作类型
|
|
||||||
op_type = post_body.get('op_type')
|
|
||||||
if coop_mind_id is None:
|
if coop_mind_id is None:
|
||||||
return build_response(CODE_FAILED, msg="参数错误")
|
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 = CooperationMindStar(operator_user_id=user.id, coop_mind_id=coop_mind_id, coop_mind_name=mind.coop_mind_name)
|
||||||
star.save()
|
star.save()
|
||||||
return build_response()
|
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()
|
||||||
|
|||||||
@@ -100,7 +100,6 @@
|
|||||||
let idx = 0
|
let idx = 0
|
||||||
let row = $(`<div class="row"></row>`)
|
let row = $(`<div class="row"></row>`)
|
||||||
|
|
||||||
|
|
||||||
results.forEach(function (item) {
|
results.forEach(function (item) {
|
||||||
const uuid = me.get_uu_id()
|
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>
|
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>`
|
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.fetch_share_info(${item.id})">查看分享链接</a>`
|
||||||
} else if (page_tag === 'star') {
|
} 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}'>
|
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) {
|
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 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 = $(`<nav aria-label="Page navigation example"></nav>`)
|
||||||
const navigation_ul = $(`<ul class="pagination justify-content-center"></ul>`)
|
const navigation_ul = $(`<ul class="pagination justify-content-center"></ul>`)
|
||||||
|
|
||||||
@@ -231,6 +235,42 @@
|
|||||||
async: false
|
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) {
|
fetch_share_info: function (mind_id) {
|
||||||
const me = this
|
const me = this
|
||||||
|
|||||||
@@ -4,21 +4,22 @@ const modal = `
|
|||||||
<div class="modal-dialog modal-dialog-centered">
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<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">
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--qr_login Modal start-->
|
<!--qr_login Modal start
|
||||||
<div class="modal-body qr_login_group" style="height: 360px;">
|
<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">
|
<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>
|
</div>
|
||||||
|
-->
|
||||||
<!--qr_login Modal end-->
|
<!--qr_login Modal end-->
|
||||||
|
|
||||||
<!--register Modal start-->
|
<!--register Modal start-->
|
||||||
<form>
|
<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>
|
<h1 class="h3 mb-3 font-weight-normal">请输入用户名和密码</h1>
|
||||||
<label for="userName" class="sr-only"></label>
|
<label for="userName" class="sr-only"></label>
|
||||||
<input type="text" id="userName" class="form-control" placeholder="用户名" autocomplete="off" required autofocus>
|
<input type="text" id="userName" class="form-control" placeholder="用户名" autocomplete="off" required autofocus>
|
||||||
@@ -54,10 +55,10 @@ const modal = `
|
|||||||
<!--pw_login Modal end-->
|
<!--pw_login Modal end-->
|
||||||
|
|
||||||
<div class="modal-footer">
|
<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>
|
<span data-feather="grid"></span>
|
||||||
扫码登录
|
扫码登录
|
||||||
</a>
|
</a>-->
|
||||||
<a class="nav-link active" id="register_a" href="#">
|
<a class="nav-link active" id="register_a" href="#">
|
||||||
<span data-feather="check-circle"></span>
|
<span data-feather="check-circle"></span>
|
||||||
用户注册
|
用户注册
|
||||||
|
|||||||
Reference in New Issue
Block a user