Skip to content

Commit f7937c5

Browse files
committed
update the message field based on type
1 parent 554b85b commit f7937c5

File tree

1 file changed

+20
-41
lines changed

1 file changed

+20
-41
lines changed

src/components/ScreenStart.vue

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
</div>
1313

1414
<div id="form-content">
15+
<h2 class="question">
16+
What type of work does this CITATION.cff describe?
17+
<SchemaGuideLink anchor="#type" />
18+
</h2>
19+
<q-option-group
20+
type="radio"
21+
v-bind:model-value="type"
22+
v-bind:options="typeOptions"
23+
v-on:update:modelValue="[setType, setMessagePlaceHolder]"
24+
/>
1525
<h2 class="question">
1626
What is the title of the work?
1727
<SchemaGuideLink anchor="#title" />
@@ -35,43 +45,12 @@
3545
bg-color="white"
3646
label="message"
3747
outlined
48+
standout
3849
v-bind:class="[messageErrors.length > 0 ? 'has-error' : '']"
3950
v-bind:model-value="message"
4051
v-bind:error="messageErrors.length > 0"
4152
v-bind:error-message="messageErrors.join(', ')"
42-
v-on:new-value="setMessage"
4353
v-on:update:modelValue="setMessage"
44-
>
45-
<template v-slot:append>
46-
<q-btn-dropdown
47-
class="dropdown"
48-
flat
49-
>
50-
<q-list>
51-
<q-item
52-
clickable
53-
v-bind:key="messageOption"
54-
v-close-popup
55-
v-for="messageOption in messageOptions"
56-
v-on:click="setMessage(messageOption)"
57-
>
58-
<q-item-section>
59-
<q-item-label>{{ messageOption }}</q-item-label>
60-
</q-item-section>
61-
</q-item>
62-
</q-list>
63-
</q-btn-dropdown>
64-
</template>
65-
</q-input>
66-
<h2 class="question">
67-
What type of work does this CITATION.cff describe?
68-
<SchemaGuideLink anchor="#type" />
69-
</h2>
70-
<q-option-group
71-
type="radio"
72-
v-bind:model-value="type"
73-
v-bind:options="typeOptions"
74-
v-on:update:modelValue="setType"
7554
/>
7655
</div>
7756

@@ -105,14 +84,6 @@ export default defineComponent({
10584
})
10685
const { message, title, type, setMessage, setTitle, setType } = useCff()
10786
const { errors } = useValidation()
108-
const messageOptions = [
109-
'If you use this software, please cite it using the metadata from this file.',
110-
'Please cite this software using these metadata.',
111-
'Please cite this software using the metadata from \'preferred-citation\'.',
112-
'If you use this dataset, please cite it using the metadata from this file.',
113-
'Please cite this dataset using these metadata.',
114-
'Please cite this dataset using the metadata from \'preferred-citation\'.'
115-
]
11687
const messageErrors = computed(() => {
11788
return messageQueries
11889
.filter(byError(errors.value))
@@ -123,10 +94,17 @@ export default defineComponent({
12394
.filter(byError(errors.value))
12495
.map(query => query.replace.message)
12596
})
97+
const setMessagePlaceHolder = () => {
98+
// check if user modified the placeholder, if that is the case, do not update the message
99+
const messagePlaceHolderRegex = /^If you use this (?<cfftype>software|dataset), please cite it using the metadata from this file.$/igd
100+
const isMessageModifiedByApp = messagePlaceHolderRegex.exec(message.value)
101+
if (isMessageModifiedByApp) {
102+
setMessage(`If you use this ${type.value}, please cite it using the metadata from this file.`)
103+
}
104+
}
126105
return {
127106
message,
128107
messageErrors,
129-
messageOptions,
130108
title,
131109
titleErrors,
132110
type,
@@ -135,6 +113,7 @@ export default defineComponent({
135113
{ label: 'Dataset', value: 'dataset' }
136114
],
137115
setMessage,
116+
setMessagePlaceHolder,
138117
setTitle,
139118
setType
140119
}

0 commit comments

Comments
 (0)