update
This commit is contained in:
@@ -83,6 +83,8 @@ class CooperationMindStar(AbstractModel):
|
|||||||
coop_mind = models.ForeignKey(to="CooperationMind", to_field="id", verbose_name="脑图ID", on_delete=models.CASCADE)
|
coop_mind = models.ForeignKey(to="CooperationMind", to_field="id", verbose_name="脑图ID", on_delete=models.CASCADE)
|
||||||
coop_mind_name = models.CharField(verbose_name='脑图名称', max_length=128, null=False, blank=False)
|
coop_mind_name = models.CharField(verbose_name='脑图名称', max_length=128, null=False, blank=False)
|
||||||
|
|
||||||
|
# star_type = models.SmallIntegerField(verbose_name="收藏类型。1:根据主键收藏;2:根据分享收藏", null=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'cooperation_mind_star'
|
db_table = 'cooperation_mind_star'
|
||||||
indexes = [
|
indexes = [
|
||||||
|
|||||||
@@ -62,9 +62,8 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
|||||||
"""
|
"""
|
||||||
coop_mind_name = request.data.get('mind_name')
|
coop_mind_name = request.data.get('mind_name')
|
||||||
user = request.user
|
user = request.user
|
||||||
snapshot_data = SNAPSHOT_JSON_DATA
|
|
||||||
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_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)
|
||||||
mind.save()
|
mind.save()
|
||||||
return build_response(data=mind.id)
|
return build_response(data=mind.id)
|
||||||
|
|
||||||
@@ -130,6 +129,8 @@ class JsMindShareView(LoginRequiredJSONMixin, ListAPIView):
|
|||||||
share_uuid = request.GET.get('u')
|
share_uuid = request.GET.get('u')
|
||||||
coop_mind_id = request.GET.get('coop_mind_id')
|
coop_mind_id = request.GET.get('coop_mind_id')
|
||||||
user = request.user
|
user = request.user
|
||||||
|
if user.id is None:
|
||||||
|
return build_response(code=CODE_FAILED, msg="用户未登录")
|
||||||
#
|
#
|
||||||
if share_uuid_hash is not None and share_uuid is not None:
|
if share_uuid_hash is not None and share_uuid is not None:
|
||||||
share = CooperationMindShare.objects.filter(share_uuid_hash=share_uuid_hash, share_uuid=share_uuid).first()
|
share = CooperationMindShare.objects.filter(share_uuid_hash=share_uuid_hash, share_uuid=share_uuid).first()
|
||||||
@@ -199,3 +200,20 @@ class JsMindStarView(LoginRequiredJSONMixin, ListAPIView):
|
|||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def post(self, request):
|
||||||
|
user = request.user
|
||||||
|
post_body = request.POST
|
||||||
|
coop_mind_id = post_body.get('coop_mind_id')
|
||||||
|
if coop_mind_id is None:
|
||||||
|
return build_response(CODE_FAILED, msg="参数错误")
|
||||||
|
|
||||||
|
mind = CooperationMind.objects.filter(id=coop_mind_id).first()
|
||||||
|
if mind is None:
|
||||||
|
return build_response(CODE_FAILED, msg="导图不存在")
|
||||||
|
|
||||||
|
star = CooperationMindStar.objects.filter(user_id=user.id, coop_mind_id=coop_mind_id).first()
|
||||||
|
if star is None:
|
||||||
|
star = CooperationMindStar(user_id=user.id, coop_mind_id=coop_mind_id, coop_mind_name=mind.coop_mind_name)
|
||||||
|
star.save()
|
||||||
|
return build_response()
|
||||||
|
|||||||
+24
-3
@@ -35,6 +35,7 @@
|
|||||||
this.jm = null
|
this.jm = null
|
||||||
this.coop_mind_id = null
|
this.coop_mind_id = null
|
||||||
this.coop_mind_log_id = null
|
this.coop_mind_log_id = null
|
||||||
|
this.from_share = null
|
||||||
}
|
}
|
||||||
// prototype
|
// prototype
|
||||||
fetch.prototype = {
|
fetch.prototype = {
|
||||||
@@ -59,8 +60,9 @@
|
|||||||
let id = `{{ id }}`;
|
let id = `{{ id }}`;
|
||||||
let u = `{{ u }}`;
|
let u = `{{ u }}`;
|
||||||
let h = `{{ h }}`;
|
let h = `{{ h }}`;
|
||||||
const me = this;
|
const from_share = id.length === 0
|
||||||
const from_share = id.length === 0;
|
this.from_share = from_share
|
||||||
|
const me = this
|
||||||
const url = from_share ? `s_d?u=${u}&h=${h}` : 'd?id=' + id + `&s_p=b9b101e`;
|
const url = from_share ? `s_d?u=${u}&h=${h}` : 'd?id=' + id + `&s_p=b9b101e`;
|
||||||
$.get(url, function (resp) {
|
$.get(url, function (resp) {
|
||||||
if (resp.code === -1) {
|
if (resp.code === -1) {
|
||||||
@@ -143,6 +145,25 @@
|
|||||||
star: function () {
|
star: function () {
|
||||||
const coop_mind_id = this.coop_mind_id
|
const coop_mind_id = this.coop_mind_id
|
||||||
console.log(coop_mind_id)
|
console.log(coop_mind_id)
|
||||||
|
console.log(this.from_share)
|
||||||
|
|
||||||
|
// ajax start
|
||||||
|
$.ajax({
|
||||||
|
type: "post",
|
||||||
|
url: "star",
|
||||||
|
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||||
|
data: {'coop_mind_id': coop_mind_id},
|
||||||
|
dataType: "json",
|
||||||
|
success: function (resp) {
|
||||||
|
if (resp.code === 0) {
|
||||||
|
console.log(resp)
|
||||||
|
} else {
|
||||||
|
common_alert(resp.msg)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async: false
|
||||||
|
});
|
||||||
|
// ajax end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$(function () {
|
$(function () {
|
||||||
@@ -156,7 +177,7 @@
|
|||||||
<!-- -->
|
<!-- -->
|
||||||
<div style="position: absolute;top: 0px;z-index: 1000;cursor: pointer;" onclick="xxObj.collapse_all()"><span data-feather="folder-minus"></span><span class="un_selected">折叠</span></div>
|
<div style="position: absolute;top: 0px;z-index: 1000;cursor: pointer;" onclick="xxObj.collapse_all()"><span data-feather="folder-minus"></span><span class="un_selected">折叠</span></div>
|
||||||
<div style="position: absolute;top: 0px;left:80px;z-index: 1000;cursor: pointer;" onclick="xxObj.expand_all()"><span data-feather="folder-plus"></span><span class="un_selected">展开</span></div>
|
<div style="position: absolute;top: 0px;left:80px;z-index: 1000;cursor: pointer;" onclick="xxObj.expand_all()"><span data-feather="folder-plus"></span><span class="un_selected">展开</span></div>
|
||||||
<div style="position: absolute;top: 0px;left:160px;z-index: 1000;cursor: pointer;" onclick="xxObj.star()"><span data-feather="star"></span><span class="selected">收藏</span></div>
|
<div style="position: absolute;top: 0px;left:160px;z-index: 1000;cursor: pointer;" onclick="xxObj.star()"><span data-feather="star"></span><span class="un_selected">收藏</span></div>
|
||||||
<h3 id="h1" style="text-align: center;max-height: 40px;"></h3>
|
<h3 id="h1" style="text-align: center;max-height: 40px;"></h3>
|
||||||
<div id="jsmind_container"></div>
|
<div id="jsmind_container"></div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user