11<script setup lang="ts">
2- import { BAlert , BFormGroup , BFormInput , BFormSelect , BFormTextarea } from " bootstrap-vue" ;
2+ import { BAlert } from " bootstrap-vue" ;
33import { ref } from " vue" ;
44
55import { submitToolRequest } from " @/api/toolRequestForm" ;
66import { errorMessageAsString } from " @/utils/simple-error" ;
77
88import GModal from " @/components/BaseComponents/GModal.vue" ;
9+ import FormElement from " @/components/Form/FormElement.vue" ;
910
1011const props = defineProps <{
1112 show: boolean ;
@@ -22,15 +23,34 @@ const scientificDomain = ref("");
2223const requestedVersion = ref (" " );
2324const condaAvailable = ref <boolean | null >(null );
2425const testDataAvailable = ref <boolean | null >(null );
25- const requesterName = ref (" " );
26- const requesterEmail = ref (" " );
2726const requesterAffiliation = ref (" " );
2827
2928const submitting = ref (false );
3029const successMessage = ref (" " );
3130const errorMessage = ref (" " );
31+ const urlError = ref (" " );
3232
33- const formValid = () => !! (toolName .value .trim () && description .value .trim () && requesterName .value .trim ());
33+ const formValid = () => !! (toolName .value .trim () && description .value .trim ());
34+
35+ function validateUrl(): boolean {
36+ const url = toolUrl .value .trim ();
37+ if (! url ) {
38+ urlError .value = " " ;
39+ return true ;
40+ }
41+ try {
42+ const parsed = new URL (url );
43+ if (parsed .protocol !== " https:" ) {
44+ urlError .value = " Only https:// URLs are allowed." ;
45+ return false ;
46+ }
47+ } catch {
48+ urlError .value = " Please enter a valid URL (e.g. https://example.com)." ;
49+ return false ;
50+ }
51+ urlError .value = " " ;
52+ return true ;
53+ }
3454
3555function resetForm() {
3656 toolName .value = " " ;
@@ -40,10 +60,9 @@ function resetForm() {
4060 requestedVersion .value = " " ;
4161 condaAvailable .value = null ;
4262 testDataAvailable .value = null ;
43- requesterName .value = " " ;
44- requesterEmail .value = " " ;
4563 requesterAffiliation .value = " " ;
4664 errorMessage .value = " " ;
65+ urlError .value = " " ;
4766 successMessage .value = " " ;
4867}
4968
@@ -58,6 +77,10 @@ async function submit() {
5877 return ;
5978 }
6079
80+ if (! validateUrl ()) {
81+ return ;
82+ }
83+
6184 submitting .value = true ;
6285 errorMessage .value = " " ;
6386 successMessage .value = " " ;
@@ -71,8 +94,6 @@ async function submit() {
7194 requested_version: requestedVersion .value .trim () || undefined ,
7295 conda_available: condaAvailable .value ?? undefined ,
7396 test_data_available: testDataAvailable .value ?? undefined ,
74- requester_name: requesterName .value .trim (),
75- requester_email: requesterEmail .value .trim () || undefined ,
7697 requester_affiliation: requesterAffiliation .value .trim () || undefined ,
7798 });
7899
@@ -115,102 +136,86 @@ async function submit() {
115136
116137 <h6 v-localize class =" font-weight-bold mb-2" >Tool Information</h6 >
117138
118- <BFormGroup label =" Tool Name *" label-for =" tool-request-name" >
119- <BFormInput
120- id =" tool-request-name"
121- v-model =" toolName"
122- placeholder =" e.g. FastQC"
123- :disabled =" submitting"
124- required />
125- </BFormGroup >
126-
127- <BFormGroup label =" Homepage / Repository URL" label-for =" tool-request-url" >
128- <BFormInput
129- id =" tool-request-url"
130- v-model =" toolUrl"
131- placeholder =" e.g. https://github.com/..."
132- :disabled =" submitting" />
133- </BFormGroup >
134-
135- <BFormGroup label =" Description *" label-for =" tool-request-description" >
136- <BFormTextarea
137- id =" tool-request-description"
138- v-model =" description"
139- placeholder =" Describe the tool and its scientific use case"
140- rows =" 3"
141- :disabled =" submitting"
142- required />
143- </BFormGroup >
144-
145- <BFormGroup label =" Scientific Domain" label-for =" tool-request-domain" >
146- <BFormInput
147- id =" tool-request-domain"
148- v-model =" scientificDomain"
149- placeholder =" e.g. Genomics, Proteomics, AI/ML"
150- :disabled =" submitting" />
151- </BFormGroup >
152-
153- <BFormGroup label =" Requested Version" label-for =" tool-request-version" >
154- <BFormInput
155- id =" tool-request-version"
156- v-model =" requestedVersion"
157- placeholder =" e.g. 1.2.0"
158- :disabled =" submitting" />
159- </BFormGroup >
139+ <FormElement
140+ id =" tool-request-name"
141+ v-model =" toolName"
142+ type =" text"
143+ title =" Tool Name"
144+ help =" e.g. FastQC"
145+ :attributes =" { optional: false }" />
146+
147+ <FormElement
148+ id =" tool-request-url"
149+ v-model =" toolUrl"
150+ type =" text"
151+ title =" Homepage / Repository URL"
152+ help =" e.g. https://github.com/..."
153+ :error =" urlError" />
154+
155+ <FormElement
156+ id =" tool-request-description"
157+ v-model =" description"
158+ type =" text"
159+ title =" Description"
160+ help =" Describe the tool and its scientific use case"
161+ :attributes =" { area: true, optional: false }" />
162+
163+ <FormElement
164+ id =" tool-request-domain"
165+ v-model =" scientificDomain"
166+ type =" text"
167+ title =" Scientific Domain"
168+ help =" e.g. Genomics, Proteomics, AI/ML" />
169+
170+ <FormElement
171+ id =" tool-request-version"
172+ v-model =" requestedVersion"
173+ type =" text"
174+ title =" Requested Version"
175+ help =" e.g. 1.2.0" />
160176
161177 <div class =" d-flex gap-3 mb-3" >
162- <BFormGroup label =" Conda package available?" label-for =" tool-request-conda" class =" flex-fill mb-0" >
163- <BFormSelect
164- id =" tool-request-conda"
165- v-model =" condaAvailable"
166- :options =" [
167- { value: null, text: 'Not specified' },
168- { value: true, text: 'Yes' },
169- { value: false, text: 'No' },
170- ]"
171- :disabled =" submitting" />
172- </BFormGroup >
173-
174- <BFormGroup label =" Test data available?" label-for =" tool-request-test-data" class =" flex-fill mb-0" >
175- <BFormSelect
176- id =" tool-request-test-data"
177- v-model =" testDataAvailable"
178- :options =" [
179- { value: null, text: 'Not specified' },
180- { value: true, text: 'Yes' },
181- { value: false, text: 'No' },
182- ]"
183- :disabled =" submitting" />
184- </BFormGroup >
178+ <FormElement
179+ id =" tool-request-conda"
180+ v-model =" condaAvailable"
181+ type =" select"
182+ title =" Conda package available?"
183+ class =" flex-fill"
184+ :attributes =" {
185+ data: [
186+ { label: 'Not specified', value: null },
187+ { label: 'Yes', value: true },
188+ { label: 'No', value: false },
189+ ],
190+ }" />
191+
192+ <FormElement
193+ id =" tool-request-test-data"
194+ v-model =" testDataAvailable"
195+ type =" select"
196+ title =" Test data available?"
197+ class =" flex-fill"
198+ :attributes =" {
199+ data: [
200+ { label: 'Not specified', value: null },
201+ { label: 'Yes', value: true },
202+ { label: 'No', value: false },
203+ ],
204+ }" />
185205 </div >
186206
187207 <h6 v-localize class =" font-weight-bold mb-2 mt-3" >Requester Information</h6 >
188208
189- <BFormGroup label =" Name *" label-for =" tool-request-requester-name" >
190- <BFormInput
191- id =" tool-request-requester-name"
192- v-model =" requesterName"
193- placeholder =" Your name"
194- :disabled =" submitting"
195- required />
196- </BFormGroup >
197-
198- <BFormGroup label =" Email (for follow-up)" label-for =" tool-request-requester-email" >
199- <BFormInput
200- id =" tool-request-requester-email"
201- v-model =" requesterEmail"
202- type =" email"
203- placeholder =" your@email.com"
204- :disabled =" submitting" />
205- </BFormGroup >
206-
207- <BFormGroup label =" Affiliation / Lab" label-for =" tool-request-requester-affiliation" >
208- <BFormInput
209- id =" tool-request-requester-affiliation"
210- v-model =" requesterAffiliation"
211- placeholder =" Your institution or lab"
212- :disabled =" submitting" />
213- </BFormGroup >
209+ <p class =" mb-2 text-muted small" >
210+ Your account name and email will be automatically included in the request.
211+ </p >
212+
213+ <FormElement
214+ id =" tool-request-requester-affiliation"
215+ v-model =" requesterAffiliation"
216+ type =" text"
217+ title =" Affiliation / Lab"
218+ help =" Your institution or lab" />
214219 </div >
215220 </GModal >
216221</template >
0 commit comments