-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathSelectedLicenseDropdown.vue
74 lines (72 loc) · 2.04 KB
/
SelectedLicenseDropdown.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<template>
<div class="license-dropdown">
<b-field :label="this.$t('license-dropdown-label')">
<b-select placeholder="Creative Commons License"
v-model="currentLicense">
<option
v-for="license in this.licenseList"
:value="license"
:key="license">
{{ license }}
</option>
</b-select>
</b-field>
</div>
</template>
<script>
export default {
name: 'SelectedLicenseDropdown',
props: ['value'],
data() {
return {
licenseList: [
'CC0 1.0',
'CC BY 4.0',
'CC BY-SA 4.0',
'CC BY-ND 4.0',
'CC BY-NC 4.0',
'CC BY-NC-SA 4.0',
'CC BY-NC-ND 4.0'
]
}
},
methods: {
fullLicenseName(shortName) {
if (!shortName.includes('BY')) { return 'CC0 1.0 Universal' }
let base = 'Attribution'
if (shortName.includes('NC')) { base += '-NonCommercial' }
if (!shortName.includes('ND') && shortName.includes('SA')) {
base += '-ShareAlike'
} else if (shortName.includes('ND')) {
base += '-NoDerivatives'
}
base += ' 4.0 International'
return base
}
},
computed: {
currentLicense: {
get() {
return this.value.shortName
},
set(currentLicense) {
const fullLicenseName = this.fullLicenseName(currentLicense)
this.$emit('input', { ...this.$props.value, fullName: fullLicenseName, shortName: currentLicense })
}
}
}
}
</script>
<style lang="scss">
div.license-dropdown {
margin-top: 1rem;
label.label{
font-weight: normal;
opacity: 0.8;
font-size: 1em;
}
span.select, select {
width: 100%;
}
}
</style>