文件操作权限

This commit is contained in:
Van 2014-11-06 16:51:59 +08:00
parent 338f16b262
commit 10a60be62d
3 changed files with 31 additions and 9 deletions

View File

@ -36,7 +36,9 @@
}
.ztree li > a > span.button,
.ztree li > a > span.button.ico-ztree-dir {
.ztree li > a > span.button.ico-ztree-dir,
.ztree li > a > span.button.ico-ztree-dir-api,
.ztree li > a > span.button.ico-ztree-dir-workspace {
margin-right: 2px;
}

View File

@ -79,11 +79,19 @@ var tree = {
}
return false;
},
newFile: function () {
newFile: function (it) {
if ($(it).hasClass("disabled")) {
return false;
}
$("#dirRMenu").hide();
$("#dialogNewFilePrompt").dialog("open");
},
newDir: function () {
if ($(it).hasClass("disabled")) {
return false;
}
$("#dirRMenu").hide();
$("#dialogNewDirPrompt").dialog("open");
},
@ -94,7 +102,7 @@ var tree = {
}
} else {
// 直接调用时,如果为 api 及其子目录或者 workspace 则不能进行删除
if (wide.curNode.iconSkin === 'ico-ztree-dir-workspace ') {
if (!wide.curNode.removable) {
return false;
}
}
@ -141,6 +149,12 @@ var tree = {
tree.fileTree.selectNode(treeNode);
if (!tree.isDir()) { // 如果右击了文件
if (wide.curNode.removable) {
$("#fileRMenu .remove").removeClass("disabled");
} else {
$("#fileRMenu .remove").addClass("disabled");
}
$("#fileRMenu").show();
fileRMenu.css({
@ -149,10 +163,16 @@ var tree = {
"display": "block"
});
} else { // 右击了目录
if (wide.curNode.iconSkin === "ico-ztree-dir-workspace ") {
$("#dirRMenu .remove").addClass("disabled");
} else {
if (wide.curNode.removable) {
$("#dirRMenu .remove").removeClass("disabled");
} else {
$("#dirRMenu .remove").addClass("disabled");
}
if (wide.curNode.creatable) {
$("#dirRMenu .create").removeClass("disabled");
} else {
$("#dirRMenu .create").addClass("disabled");
}
$("#dirRMenu").show();

View File

@ -131,8 +131,8 @@
<!-- 目录右键菜单 -->
<div id="dirRMenu" class="frame">
<ul>
<li onclick="tree.newFile();">{{.i18n.create_file}}</li>
<li onclick="tree.newDir();">{{.i18n.create_dir}}</li>
<li class="create" onclick="tree.newFile(this);">{{.i18n.create_file}}</li>
<li class="create" onclick="tree.newDir(this);">{{.i18n.create_dir}}</li>
<li class="remove" onclick="tree.removeIt(this);">{{.i18n.delete}}</li>
</ul>
</div>
@ -140,7 +140,7 @@
<!-- 文件右键菜单 -->
<div id="fileRMenu" class="frame">
<ul>
<li onclick="tree.removeIt(this);">{{.i18n.delete}}</li>
<li class="remove" onclick="tree.removeIt(this);">{{.i18n.delete}}</li>
</ul>
</div>
</div>