mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-09-19 01:58:00 +08:00
feat:实现自定义文档树的展开状态
This commit is contained in:
@@ -109,10 +109,17 @@ function openEditCatalogDialog($node) {
|
||||
var text = $node ? $node.text : '';
|
||||
var parentId = $node && $node.parent !== '#' ? $node.parent : 0;
|
||||
|
||||
|
||||
$then.find("input[name='doc_id']").val(doc_id);
|
||||
$then.find("input[name='parent_id']").val(parentId);
|
||||
$then.find("input[name='doc_name']").val(text);
|
||||
|
||||
if($node.a_attr && $node.a_attr.is_open){
|
||||
$then.find("input[name='is_open'][value='1']").prop("checked","checked");
|
||||
}else{
|
||||
$then.find("input[name='is_open'][value='0']").prop("checked","checked");
|
||||
}
|
||||
|
||||
for (var index in window.documentCategory){
|
||||
var item = window.documentCategory[index];
|
||||
if(item.id === doc_id){
|
||||
@@ -196,9 +203,11 @@ $("#btnAddDocument").on("click",function () {
|
||||
});
|
||||
//用于还原创建文档的遮罩层
|
||||
$("#addDocumentModal").on("hidden.bs.modal",function () {
|
||||
$(this).find("form").html(window.addDocumentModalFormHtml);
|
||||
// $(this).find("form").html(window.sessionStorage.getItem("addDocumentModal"));
|
||||
}).on("shown.bs.modal",function () {
|
||||
$(this).find("input[name='doc_name']").focus();
|
||||
}).on("show.bs.modal",function () {
|
||||
// window.sessionStorage.setItem("addDocumentModal",$(this).find("form").html())
|
||||
});
|
||||
|
||||
function showError($msg,$id) {
|
||||
@@ -344,7 +353,6 @@ $(function () {
|
||||
type : "post",
|
||||
data : { "attach_id" : $attach_id},
|
||||
success : function (res) {
|
||||
console.log(res);
|
||||
if(res.errcode === 0){
|
||||
$this.lists = $this.lists.filter(function ($item) {
|
||||
return $item.attachment_id != $attach_id;
|
||||
|
@@ -3,7 +3,7 @@ $(function () {
|
||||
js : window.katex.js,
|
||||
css : window.katex.css
|
||||
};
|
||||
window.addDocumentModalFormHtml = $(this).find("form").html();
|
||||
|
||||
window.editor = editormd("docEditor", {
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
@@ -256,7 +256,7 @@ $(function () {
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加顶级文档
|
||||
* 添加文档
|
||||
*/
|
||||
$("#addDocumentForm").ajaxForm({
|
||||
beforeSubmit: function () {
|
||||
@@ -269,11 +269,20 @@ $(function () {
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.errcode === 0) {
|
||||
var data = { "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 };
|
||||
var data = {
|
||||
"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 ,
|
||||
state: { opened: res.data.is_open == 1},
|
||||
a_attr: { is_open: res.data.is_open == 1}
|
||||
};
|
||||
|
||||
var node = window.treeCatalog.get_node(data.id);
|
||||
if (node) {
|
||||
window.treeCatalog.rename_node({ "id": data.id }, data.text);
|
||||
$("#sidebar").jstree(true).get_node(data.id).a_attr.is_open = data.state.opened;
|
||||
} else {
|
||||
window.treeCatalog.create_node(data.parent, data);
|
||||
window.treeCatalog.deselect_all();
|
||||
|
Reference in New Issue
Block a user