This commit is contained in:
@@ -67,9 +67,9 @@ CURRENT TODOs
|
|||||||
@@@@@@@@@@@ ROADMAP STAGE 2:
|
@@@@@@@@@@@ ROADMAP STAGE 2:
|
||||||
|
|
||||||
|
|
||||||
todo: drag and drop files on to attachments and have them stored and added automatically
|
|
||||||
|
|
||||||
todo: drag and drop image file on to wiki and have it added as attachment then linked automatically
|
todo: drag and drop image file on to wiki and have it added as attachment then linked automatically
|
||||||
|
|
||||||
todo: Attachments control, sb minimized on parent form open and only do it's thing when expanded like wiki
|
todo: Attachments control, sb minimized on parent form open and only do it's thing when expanded like wiki
|
||||||
- i.e. don't bother fetching until the user expands it
|
- i.e. don't bother fetching until the user expands it
|
||||||
|
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ export default {
|
|||||||
return "height: " + this.height + "px;overflow-y:auto;";
|
return "height: " + this.height + "px;overflow-y:auto;";
|
||||||
},
|
},
|
||||||
upload() {
|
upload() {
|
||||||
|
//similar code in wiki-control
|
||||||
let vm = this;
|
let vm = this;
|
||||||
let at = {
|
let at = {
|
||||||
ayaId: vm.ayaId,
|
ayaId: vm.ayaId,
|
||||||
|
|||||||
@@ -384,8 +384,8 @@ export default {
|
|||||||
imageText: "",
|
imageText: "",
|
||||||
attachments: [],
|
attachments: [],
|
||||||
selectedImageAttachment: null,
|
selectedImageAttachment: null,
|
||||||
|
notes: null, //attachment upload notes
|
||||||
dropTest: null
|
uploadFiles: [] //attachment upload files
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@@ -853,61 +853,129 @@ export default {
|
|||||||
window.$gz.errorHandler.handleFormError(error);
|
window.$gz.errorHandler.handleFormError(error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
upload() {
|
||||||
|
//similar code in attachment-control upload
|
||||||
|
let vm = this;
|
||||||
|
let at = {
|
||||||
|
ayaId: vm.ayaId,
|
||||||
|
ayaType: vm.ayaType,
|
||||||
|
files: vm.uploadFiles,
|
||||||
|
notes: ""
|
||||||
|
};
|
||||||
|
|
||||||
|
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 (
|
||||||
|
// 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.downloadUrl(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
|
||||||
|
console.log("upload inserting found file:", atFile);
|
||||||
|
|
||||||
|
this.insertUrl(atFile.url, atFile.name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//finally, clear the upload files
|
||||||
|
vm.uploadFiles = [];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function handleUploadError(error) {
|
||||||
|
window.$gz.errorHandler.handleFormError(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
onDrop(ev) {
|
onDrop(ev) {
|
||||||
//Drop image file
|
//Drop image file
|
||||||
var files = Array.from(ev.dataTransfer.files);
|
var files = Array.from(ev.dataTransfer.files);
|
||||||
if (files.length > 0) {
|
if (files.length > 0) {
|
||||||
//handle file drop
|
//handle file drop
|
||||||
console.log("DROP:Possible files", files);
|
var files = Array.from(ev.dataTransfer.files);
|
||||||
|
if (files.length > 0) {
|
||||||
|
this.uploadFiles = files;
|
||||||
|
this.upload();
|
||||||
|
}
|
||||||
//if an image then put it directly in viewable, if not an image then make a link and keep as an attach
|
//if an image then put it directly in viewable, if not an image then make a link and keep as an attach
|
||||||
} else {
|
} else {
|
||||||
//maybe an url?
|
//maybe an url?
|
||||||
let url = ev.dataTransfer.getData("text");
|
let url = ev.dataTransfer.getData("text");
|
||||||
|
this.insertUrl(url);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
insertUrl(url, name) {
|
||||||
|
if (url) {
|
||||||
let isImageUrl = false;
|
let isImageUrl = false;
|
||||||
|
//Attachment?
|
||||||
if (url) {
|
if (url.includes("Attachment/download/")) {
|
||||||
//Attachment?
|
//it's an attachment url so fixup accordingly
|
||||||
if (url.includes("Attachment/download/")) {
|
//i paramter added by gzapi::downloadUrl function
|
||||||
//it's an attachment url so fixup accordingly
|
isImageUrl = url.includes("&i=");
|
||||||
//i paramter added by gzapi::downloadUrl function
|
let m = url.match(/Attachment\/download\/(.*)\?t=/);
|
||||||
isImageUrl = url.includes("&i=");
|
if (m.length > 1) {
|
||||||
let m = url.match(/Attachment\/download\/(.*)\?t=/);
|
url = "[ATTACH:" + m[1] + "]";
|
||||||
if (m.length > 1) {
|
} else {
|
||||||
url = "[ATTACH:" + m[1] + "]";
|
url = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//External url, sniff out if it's an image
|
||||||
|
isImageUrl = window.$gz.util.isImageAttachment(url);
|
||||||
|
}
|
||||||
|
if (url != null) {
|
||||||
|
//insert into textarea
|
||||||
|
let txt = this.getSelectedText();
|
||||||
|
if (!txt) {
|
||||||
|
txt = name;
|
||||||
|
}
|
||||||
|
if (txt) {
|
||||||
|
if (isImageUrl) {
|
||||||
|
this.replaceSelectedText(
|
||||||
|
" \n' + txt + "\n" //keep original selected text otherwise it will vanish
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
url = null;
|
//regular url not image
|
||||||
|
this.replaceSelectedText(
|
||||||
|
"[" + txt + "](" + url + ' "' + txt + '")\n'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//External url, sniff out if it's an image
|
//No selected text
|
||||||
isImageUrl = window.$gz.util.isImageAttachment(url);
|
if (isImageUrl) {
|
||||||
}
|
this.replaceSelectedText("\n");
|
||||||
if (url != null) {
|
|
||||||
//insert into textarea
|
|
||||||
let txt = this.getSelectedText();
|
|
||||||
if (txt) {
|
|
||||||
if (isImageUrl) {
|
|
||||||
this.replaceSelectedText(
|
|
||||||
" \n' + txt //keep original selected text otherwise it will vanish
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
//regular url not image
|
|
||||||
this.replaceSelectedText(
|
|
||||||
"[" + txt + "](" + url + ' "' + txt + '")\n'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
//No selected text
|
//regular no text non image url
|
||||||
if (isImageUrl) {
|
this.replaceSelectedText("<" + url + ">\n");
|
||||||
this.replaceSelectedText("\n");
|
|
||||||
} else {
|
|
||||||
//regular no text non image url
|
|
||||||
this.replaceSelectedText("<" + url + ">\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//handle accordingly
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//handle accordingly
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user