This commit is contained in:
@@ -66,13 +66,14 @@ CURRENT TODOs
|
||||
|
||||
@@@@@@@@@@@ ROADMAP STAGE 2:
|
||||
|
||||
todo: add to attachment object at server if it's an image or not so that can handle without downloading to see (or is it in the content type already?)
|
||||
|
||||
todo: Image toolbar component handle attachments (this is a requirement because on a phone or other browsers you might not be able to drag and drop)
|
||||
todo: wiki emit input on change: currently it's manual but it should just either WATCH for changes or the replace text method should do the triggering since it's called for all ops
|
||||
|
||||
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 from attachments and have it added to wiki automatically.
|
||||
todo: Image toolbar component handle attachments (this is a requirement because on a phone or other browsers you might not be able to drag and drop)
|
||||
todo: handle dropped attachment that isn't an image with an alternate link style
|
||||
todo: wiki emit input on change: currently it's manual but it should just either WATCH for changes or the replace text method should do the triggering since it's called for all ops
|
||||
|
||||
|
||||
|
||||
todo: AFTER ATTACHMENTS WIKI IMAGES
|
||||
- Go back and finish off wiki image attachment UI and code
|
||||
|
||||
@@ -366,11 +366,8 @@ export default {
|
||||
///////////////////////////////////////////////
|
||||
// attempt to detect image extension name
|
||||
//
|
||||
isImageURI: function(uri) {
|
||||
if (!uri) {
|
||||
return false;
|
||||
}
|
||||
return this.iconForFile(uri, "") == "fa-file-image";
|
||||
isImageAttachment: function(fileName, mimeType) {
|
||||
return this.iconForFile(fileName, mimeType) == "fa-file-image";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -245,17 +245,14 @@
|
||||
<v-tab-item key="file"
|
||||
><div class="ma-6">
|
||||
<v-select
|
||||
@click="getAttachments"
|
||||
:label="$ay.t('Attachments')"
|
||||
v-model="selectedImageAttachment"
|
||||
:items="availableAttachments()"
|
||||
:items="attachments"
|
||||
item-text="name"
|
||||
item-value="id"
|
||||
return-object
|
||||
></v-select>
|
||||
<!--
|
||||
<v-file-input
|
||||
:label="$ay.t('AttachFile')"
|
||||
prepend-icon="fa-paperclip"
|
||||
></v-file-input> -->
|
||||
|
||||
<v-text-field
|
||||
v-model="imageText"
|
||||
@@ -385,14 +382,17 @@ export default {
|
||||
imageTab: null,
|
||||
imageUrl: "",
|
||||
imageText: "",
|
||||
attachments: [],
|
||||
selectedImageAttachment: null,
|
||||
|
||||
dropTest: null
|
||||
};
|
||||
},
|
||||
props: {
|
||||
value: String,
|
||||
readonly: Boolean,
|
||||
attachments: Array
|
||||
ayaType: Number,
|
||||
ayaId: Number,
|
||||
readonly: Boolean
|
||||
},
|
||||
watch: {
|
||||
value(value) {
|
||||
@@ -755,28 +755,35 @@ export default {
|
||||
case "image":
|
||||
//")
|
||||
{
|
||||
this.imageMenu = false;
|
||||
let url = null;
|
||||
if (ex == 1) {
|
||||
throw "Attachment mode TODO";
|
||||
//todo: ATTACHEDFILEMODE//attached file mode?
|
||||
//it's an attachment
|
||||
url = this.selectedImageAttachment.url;
|
||||
if (!this.imageText) {
|
||||
this.imageText = this.selectedImageAttachment.name;
|
||||
}
|
||||
} else {
|
||||
this.imageMenu = false;
|
||||
let url = this.imageUrl;
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
let txt = this.imageText;
|
||||
//force it to a full url so it doesn't attempt to open it as a SPA window
|
||||
if (!url.includes(":")) {
|
||||
url = "https://" + url;
|
||||
}
|
||||
//it's a url paste / manual entry
|
||||
url = this.imageUrl;
|
||||
}
|
||||
|
||||
if (txt) {
|
||||
this.replaceSelectedText(
|
||||
" \n' + txt //keep original selected text otherwise it will vanish
|
||||
);
|
||||
} else {
|
||||
this.replaceSelectedText("");
|
||||
}
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
|
||||
let txt = this.imageText;
|
||||
//force it to a full url so it doesn't attempt to open it as a SPA window
|
||||
if (!url.includes(":")) {
|
||||
url = "https://" + url;
|
||||
}
|
||||
|
||||
if (txt) {
|
||||
this.replaceSelectedText(
|
||||
" \n' + txt //keep original selected text otherwise it will vanish
|
||||
);
|
||||
} else {
|
||||
this.replaceSelectedText("");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -810,12 +817,38 @@ export default {
|
||||
this.imageMenu = true;
|
||||
});
|
||||
},
|
||||
availableAttachments() {
|
||||
return [
|
||||
{ id: 0, name: "Stub attachment one" },
|
||||
{ id: 1, name: "Stub attachment two" },
|
||||
{ id: 2, name: "Stub attachment three" }
|
||||
];
|
||||
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];
|
||||
|
||||
if (
|
||||
window.$gz.util.isImageAttachment(
|
||||
o.displayFileName,
|
||||
o.contentType
|
||||
)
|
||||
) {
|
||||
ret.push({
|
||||
id: o.id,
|
||||
url: window.$gz.api.downloadUrl(o.id, o.contentType),
|
||||
name: o.displayFileName
|
||||
});
|
||||
}
|
||||
}
|
||||
vm.attachments = ret;
|
||||
}
|
||||
})
|
||||
.catch(function handleGetListError(error) {
|
||||
window.$gz.errorHandler.handleFormError(error);
|
||||
});
|
||||
},
|
||||
|
||||
onDrop(ev) {
|
||||
@@ -829,7 +862,7 @@ export default {
|
||||
//maybe an url?
|
||||
let url = ev.dataTransfer.getData("text");
|
||||
let isImageUrl = false;
|
||||
console.log(ev.dataTransfer);
|
||||
//console.log(ev.dataTransfer);
|
||||
//todo: use alternate to "text" to look for url specifically
|
||||
//if not an url then can just drop as plain text
|
||||
//todo: handle both internal and external urls in the same block, because the only diff is the url itself, the rest is identical
|
||||
@@ -848,7 +881,7 @@ export default {
|
||||
}
|
||||
} else {
|
||||
//External url, sniff out if it's an image
|
||||
isImageUrl = window.$gz.util.isImageURI(url);
|
||||
isImageUrl = window.$gz.util.isImageAttachment(url);
|
||||
}
|
||||
if (url != null) {
|
||||
//insert into textarea
|
||||
|
||||
@@ -207,6 +207,8 @@
|
||||
|
||||
<v-col v-if="form().showMe(this, 'Wiki')" cols="12">
|
||||
<gz-wiki
|
||||
:ayaType="ayType"
|
||||
:ayaId="obj.id"
|
||||
ref="wiki"
|
||||
v-model="obj.wiki"
|
||||
:readonly="formState.readOnly"
|
||||
|
||||
Reference in New Issue
Block a user