mirror of https://github.com/mindoc-org/mindoc.git
Merge pull request #147 from xunjianxiang/master
修改非文档库成员可看到返回编辑按钮的 bug 及优化销毁和发布文档时检测文档保存状态pull/176/head
commit
5bb61618fc
|
@ -42,12 +42,9 @@ func isReadable(identify, token string, c *DocumentController) *models.BookResul
|
|||
beego.Error(err)
|
||||
c.Abort("500")
|
||||
}
|
||||
if c.Member != nil && c.Member.IsAdministrator() {
|
||||
bookResult := book.ToBookResult()
|
||||
return bookResult
|
||||
}
|
||||
|
||||
//如果文档是私有的
|
||||
if book.PrivatelyOwned == 1 {
|
||||
if book.PrivatelyOwned == 1 && !c.Member.IsAdministrator() {
|
||||
|
||||
is_ok := false
|
||||
|
||||
|
|
|
@ -135,7 +135,6 @@ function pushDocumentCategory($node) {
|
|||
if(item.id === $node.id){
|
||||
|
||||
window.documentCategory[index] = $node;
|
||||
console.log( window.documentCategory[index]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,14 @@ $(function () {
|
|||
}
|
||||
};
|
||||
|
||||
window.editor.onchange = function () {
|
||||
// 判断内容是否改变
|
||||
if (window.source !== this.$txt.html()) {
|
||||
window.editor.menus.save.$domNormal.addClass('selected');
|
||||
} else {
|
||||
window.editor.menus.save.$domNormal.removeClass('selected');
|
||||
}
|
||||
};
|
||||
|
||||
window.editor.create();
|
||||
|
||||
|
@ -72,6 +80,8 @@ $(function () {
|
|||
window.isLoad = true;
|
||||
window.editor.clear();
|
||||
window.editor.$txt.html(res.data.content);
|
||||
// 将原始内容备份
|
||||
window.source = res.data.content;
|
||||
var node = { "id" : res.data.doc_id,'parent' : res.data.parent_id === 0 ? '#' : res.data.parent_id ,"text" : res.data.doc_name,"identify" : res.data.identify,"version" : res.data.version};
|
||||
pushDocumentCategory(node);
|
||||
window.selectNode = node;
|
||||
|
@ -136,6 +146,10 @@ $(function () {
|
|||
break;
|
||||
}
|
||||
}
|
||||
// 更新内容备份
|
||||
window.source = res.data.content;
|
||||
// 触发编辑器 onchange 回调函数
|
||||
window.editor.onchange();
|
||||
if(typeof callback === "function"){
|
||||
callback();
|
||||
}
|
||||
|
@ -253,7 +267,7 @@ $(function () {
|
|||
}).on('loaded.jstree', function () {
|
||||
window.treeCatalog = $(this).jstree();
|
||||
}).on('select_node.jstree', function (node, selected, event) {
|
||||
if($("#markdown-save").hasClass('change')) {
|
||||
if(window.editor.menus.save.$domNormal.hasClass('selected')) {
|
||||
if(confirm("编辑内容未保存,需要保存吗?")){
|
||||
saveDocument(false,function () {
|
||||
loadDocument(selected);
|
||||
|
@ -269,6 +283,11 @@ $(function () {
|
|||
|
||||
window.releaseBook = function () {
|
||||
if(Object.prototype.toString.call(window.documentCategory) === '[object Array]' && window.documentCategory.length > 0){
|
||||
if(window.editor.menus.save.$domNormal.hasClass('selected')) {
|
||||
if(confirm("编辑内容未保存,需要保存吗?")) {
|
||||
saveDocument();
|
||||
}
|
||||
}
|
||||
$.ajax({
|
||||
url : window.releaseURL,
|
||||
data :{"identify" : window.book.identify },
|
||||
|
|
|
@ -91,6 +91,12 @@ $(function () {
|
|||
});
|
||||
}else if(name === "release"){
|
||||
if(Object.prototype.toString.call(window.documentCategory) === '[object Array]' && window.documentCategory.length > 0){
|
||||
if($("#markdown-save").hasClass('change')) {
|
||||
var comfirm_result = confirm("编辑内容未保存,需要保存吗?")
|
||||
if(comfirm_result) {
|
||||
saveDocument();
|
||||
}
|
||||
}
|
||||
$.ajax({
|
||||
url : window.releaseURL,
|
||||
data :{"identify" : window.book.identify },
|
||||
|
|
|
@ -47,9 +47,11 @@
|
|||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="dLabel">
|
||||
{{if gt .Member.MemberId 0}}
|
||||
{{if gt .Model.RelationshipId 0}}
|
||||
{{if eq .Model.RoleId 0 1 2}}
|
||||
<li><a href="{{urlfor "DocumentController.Edit" ":key" .Model.Identify ":id" ""}}">返回编辑</a> </li>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<li><a href="{{urlfor "BookController.Index"}}">我的项目</a> </li>
|
||||
<li role="presentation" class="divider"></li>
|
||||
{{end}}
|
||||
|
|
Loading…
Reference in New Issue