Skip to content
Snippets Groups Projects
Commit 2a75d13e authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Add URL metadata type

parent c548c3a3
No related branches found
No related tags found
1 merge request!1044Add URL metadata type
......@@ -272,7 +272,8 @@ export const METADATA_TYPES = {
date: 'icon-date',
location: 'icon-globe',
reference: 'icon-bookmark',
numeric: 'icon-number'
numeric: 'icon-number',
url: 'icon-link'
}
export const NOTIFICATION_TYPES = {
......
......@@ -280,6 +280,13 @@ export default {
this.formErrors.value = 'Value may not be empty'
}
if (this.selectedMetadata.type === 'date' && !this.validDate) this.formErrors.value = 'This date is invalid'
if (this.selectedMetadata.type === 'url') {
try {
if (!['http:', 'https:'].includes(new URL(this.selectedMetadata.value).protocol)) this.formErrors.value = 'Only HTTP and HTTPS URLs are allowed'
} catch (err) {
this.formErrors.value = err.message
}
}
return isEmpty(this.formErrors)
},
async updateMetadata () {
......
......@@ -15,7 +15,12 @@
:raw-date="data.value"
/>
</strong>
<strong v-else>{{ data.value }}</strong>
<strong v-else>
<a :href="data.value" target="_blank" v-if="data.type === 'url'">
{{ data.value }}
</a>
<template v-else>{{ data.value }}</template>
</strong>
</span>
<MetadataActions
class="is-actions is-hidden"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment