Skip to content

Link: Fix link form category selection and ensure HTTPS default in URL - refs #4767 #6219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions assets/vue/components/links/LinkForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const resourceLinkList = ref(
const categories = ref([])

const formData = reactive({
url: "http://",
url: "https://",
title: "",
description: "",
category: null,
Expand Down Expand Up @@ -189,7 +189,7 @@ const fetchLink = async () => {
}

if (response.category) {
formData.category = parseInt(response.category["@id"].split("/").pop())
formData.category = response.category
}
} catch (error) {
console.error("Error fetching link:", error)
Expand Down Expand Up @@ -228,20 +228,27 @@ const submitForm = async () => {
if (props.linkId) {
await linkService.updateLink(props.linkId, postData)

const formDataImage = new FormData()
formDataImage.append("removeImage", formData.removeImage ? "true" : "false")
if (formData.showOnHomepage && (formData.removeImage || selectedFile.value instanceof File)) {
const formDataImage = new FormData()
formDataImage.append("removeImage", formData.removeImage ? "true" : "false")

if (selectedFile.value instanceof File) {
formDataImage.append("customImage", selectedFile.value)
}
if (selectedFile.value instanceof File) {
formDataImage.append("customImage", selectedFile.value)
}

await linkService.uploadImage(props.linkId, formDataImage)
await linkService.uploadImage(props.linkId, formDataImage)
}
} else {
const newLink = await linkService.createLink(postData)

if (selectedFile.value instanceof File) {
if (formData.showOnHomepage && (formData.removeImage || selectedFile.value instanceof File)) {
const formDataImage = new FormData()
formDataImage.append("customImage", selectedFile.value)
formDataImage.append("removeImage", formData.removeImage ? "true" : "false")

if (selectedFile.value instanceof File) {
formDataImage.append("customImage", selectedFile.value)
}

await linkService.uploadImage(newLink.iid, formDataImage)
}
}
Expand Down
2 changes: 1 addition & 1 deletion assets/vue/views/links/LinksList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ async function fetchLinks() {
try {
const data = await linkService.getLinks(params)
linksWithoutCategory.value = data.linksWithoutCategory || []
categories.value = data.categories || []
categories.value = Object.values(data.categories || {})
} catch (error) {
console.error("Error fetching links:", error)
notifications.showErrorNotification(t("Could not retrieve links"))
Expand Down
Loading