-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathSelectedLicenseDropdown.vue
94 lines (92 loc) · 2.67 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<template>
<div class="license-dropdown">
<p
:class="'dropdown-instruction'">
If you already know which license you need, just select it in the dropdown below.</p>
<b-field label="Current selection">
<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 {
p.dropdown-instruction{
padding-bottom: 1.4rem;
text-align: center;
font-size: 0.875em;
opacity: 90%;
}
div.field {
display: grid;
grid-template-columns: 1fr 2fr;
grid-gap: 5px;
label.label {
font-style: normal;
font-weight: bold;
font-size: 20px;
line-height: 30px;
color: #333333;
}
div.control {
span.select {
width: 100%;
select {
width: 100%;
}
}
}
}
}
</style>