This commit is contained in:
@@ -820,42 +820,42 @@ export default {
|
||||
this.imageMenu = true;
|
||||
});
|
||||
},
|
||||
getAttachments() {
|
||||
async getAttachments() {
|
||||
let vm = this;
|
||||
vm.attachments = [];
|
||||
window.$gz.api
|
||||
.get("attachment/list?ayatype=" + vm.ayaType + "&ayaid=" + vm.ayaId)
|
||||
.then(res => {
|
||||
if (res.error) {
|
||||
window.$gz.errorHandler.handleFormError(res.error);
|
||||
} else {
|
||||
let ret = [];
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
let o = res.data[i];
|
||||
try {
|
||||
vm.attachments = [];
|
||||
let res = await window.$gz.api.get(
|
||||
"attachment/list?ayatype=" + vm.ayaType + "&ayaid=" + vm.ayaId
|
||||
);
|
||||
if (res.error) {
|
||||
window.$gz.errorHandler.handleFormError(res.error);
|
||||
} else {
|
||||
let ret = [];
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
let o = res.data[i];
|
||||
|
||||
if (
|
||||
window.$gz.util.isImageAttachment(
|
||||
o.displayFileName,
|
||||
o.contentType
|
||||
)
|
||||
) {
|
||||
//attach url
|
||||
//
|
||||
ret.push({
|
||||
id: o.id,
|
||||
url: "[ATTACH:" + o.id + "]",
|
||||
name: o.displayFileName
|
||||
});
|
||||
}
|
||||
if (
|
||||
window.$gz.util.isImageAttachment(
|
||||
o.displayFileName,
|
||||
o.contentType
|
||||
)
|
||||
) {
|
||||
//attach url
|
||||
//
|
||||
ret.push({
|
||||
id: o.id,
|
||||
url: "[ATTACH:" + o.id + "]",
|
||||
name: o.displayFileName
|
||||
});
|
||||
}
|
||||
vm.attachments = ret;
|
||||
}
|
||||
})
|
||||
.catch(function handleGetListError(error) {
|
||||
window.$gz.errorHandler.handleFormError(error);
|
||||
});
|
||||
vm.attachments = ret;
|
||||
}
|
||||
} catch (error) {
|
||||
window.$gz.errorHandler.handleFormError(error);
|
||||
}
|
||||
},
|
||||
upload() {
|
||||
async upload() {
|
||||
//similar code in attachment-control upload
|
||||
let vm = this;
|
||||
let at = {
|
||||
@@ -864,53 +864,45 @@ export default {
|
||||
files: vm.uploadFiles,
|
||||
notes: ""
|
||||
};
|
||||
try {
|
||||
let res = await window.$gz.api.uploadAttachment(at);
|
||||
|
||||
window.$gz.api
|
||||
.uploadAttachment(at)
|
||||
.then(res => {
|
||||
if (res.error) {
|
||||
window.$gz.errorHandler.handleFormError(res.error);
|
||||
} else {
|
||||
let ret = [];
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
let o = res.data[i];
|
||||
if (res.error) {
|
||||
window.$gz.errorHandler.handleFormError(res.error);
|
||||
} else {
|
||||
let ret = [];
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
let o = res.data[i];
|
||||
|
||||
// if (
|
||||
// window.$gz.util.isImageAttachment(
|
||||
// o.displayFileName,
|
||||
// o.contentType
|
||||
// )
|
||||
// ) {
|
||||
//let them attach any file type to the wiki since it supports it anyway
|
||||
ret.push({
|
||||
id: o.id,
|
||||
url: window.$gz.api.attachmentDownloadUrl(o.id, o.contentType),
|
||||
name: o.displayFileName
|
||||
});
|
||||
//}
|
||||
}
|
||||
//put into attachments list
|
||||
vm.attachments = ret;
|
||||
//NOW iterate upload files list and insert into wiki based on attachments
|
||||
//insert into wiki
|
||||
for (let i = 0; i < vm.uploadFiles.length; i++) {
|
||||
let upFile = vm.uploadFiles[i];
|
||||
for (let j = 0; j < vm.attachments.length; j++) {
|
||||
let atFile = vm.attachments[j];
|
||||
if (upFile.name == atFile.name) {
|
||||
//found it
|
||||
this.insertUrl(atFile.url, atFile.name);
|
||||
break;
|
||||
}
|
||||
//let them attach any file type to the wiki since it supports it anyway
|
||||
ret.push({
|
||||
id: o.id,
|
||||
url: window.$gz.api.attachmentDownloadUrl(o.id, o.contentType),
|
||||
name: o.displayFileName
|
||||
});
|
||||
//}
|
||||
}
|
||||
//put into attachments list
|
||||
vm.attachments = ret;
|
||||
//NOW iterate upload files list and insert into wiki based on attachments
|
||||
//insert into wiki
|
||||
for (let i = 0; i < vm.uploadFiles.length; i++) {
|
||||
let upFile = vm.uploadFiles[i];
|
||||
for (let j = 0; j < vm.attachments.length; j++) {
|
||||
let atFile = vm.attachments[j];
|
||||
if (upFile.name == atFile.name) {
|
||||
//found it
|
||||
this.insertUrl(atFile.url, atFile.name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//finally, clear the upload files
|
||||
vm.uploadFiles = [];
|
||||
}
|
||||
})
|
||||
.catch(function handleUploadError(error) {
|
||||
window.$gz.errorHandler.handleFormError(error);
|
||||
});
|
||||
//finally, clear the upload files
|
||||
vm.uploadFiles = [];
|
||||
}
|
||||
} catch (error) {
|
||||
window.$gz.errorHandler.handleFormError(error);
|
||||
}
|
||||
},
|
||||
onDrop(ev) {
|
||||
//Drop image file
|
||||
|
||||
Reference in New Issue
Block a user