|
@@ -68,12 +68,13 @@ var blockLibObj = {
|
|
|
}
|
|
|
},
|
|
|
cloneType: null,
|
|
|
+ initialShareTip: '',
|
|
|
|
|
|
buildSheet: async function () {
|
|
|
$.bootstrapLoading.start();
|
|
|
let me = this;
|
|
|
let namesAndLib = await ajaxPost('/blockLib/getLibNamesAndFirstLib',
|
|
|
- {userID: userID, userName: $("#link_userName").text(), compilationID: projectObj.project.projectInfo.compilation});
|
|
|
+ {userID: userID, compilationID: projectObj.project.projectInfo.compilation});
|
|
|
function getLibNamesHtml(libsArr) {
|
|
|
let result = '';
|
|
|
for (let lib of libsArr) {
|
|
@@ -83,6 +84,10 @@ var blockLibObj = {
|
|
|
};
|
|
|
let html = getLibNamesHtml(namesAndLib.libNames);
|
|
|
$("#select_block_lib_names").html(html);
|
|
|
+ this.initialShareTip = namesAndLib.shareList && namesAndLib.shareList.length
|
|
|
+ ? namesAndLib.shareList.reduce((acc, user) => acc += ` ${user.real_name}`, '已分享给')
|
|
|
+ : '';
|
|
|
+ $('#btn_block_share').attr('data-original-title', this.initialShareTip);
|
|
|
await me.loadLib(namesAndLib.firstLib);
|
|
|
$.bootstrapLoading.end();
|
|
|
},
|
|
@@ -541,7 +546,7 @@ var blockLibObj = {
|
|
|
name: '删除',
|
|
|
icon: "delete",
|
|
|
disabled: function () {
|
|
|
-
|
|
|
+ return $("#select_block_lib_names option:selected").prop("index") !== 0;
|
|
|
},
|
|
|
visible: function(key, opt){
|
|
|
return true;
|
|
@@ -660,13 +665,31 @@ $(document).ready(function(){ // 这里不需要处理异步:因为不需
|
|
|
});
|
|
|
|
|
|
$("#select_block_lib_names").change(function() {
|
|
|
+ const index = $("#select_block_lib_names option:selected").prop("index");
|
|
|
+ if (index !== 0) {
|
|
|
+ // 只读
|
|
|
+ $('#btn_block_newFolder').hide();
|
|
|
+ $('#btn_block_reName').hide();
|
|
|
+ $('#btn_block_share').prop('disabled', true);
|
|
|
+ } else {
|
|
|
+ $('#btn_block_newFolder').show();
|
|
|
+ $('#btn_block_reName').show();
|
|
|
+ $('#btn_block_share').prop('disabled', false);
|
|
|
+ }
|
|
|
async function getLib(){
|
|
|
let libID = $("#select_block_lib_names").val();
|
|
|
let lib = await ajaxPost('/blockLib/getLib', {libID: libID});
|
|
|
blockLibObj.loadLib(lib);
|
|
|
+ if (userID === lib.userID) {
|
|
|
+ $('#btn_block_share').attr('data-original-title', blockLibObj.initialShareTip);
|
|
|
+ }
|
|
|
};
|
|
|
$.bootstrapLoading.start();
|
|
|
getLib();
|
|
|
$.bootstrapLoading.end();
|
|
|
});
|
|
|
+
|
|
|
+ $('#btn_block_share').click(function () {
|
|
|
+ SHARE_TO.initModal(SHARE_TO.Mode.BLOCK_LIB);
|
|
|
+ })
|
|
|
});
|