Skip to content

Commit

Permalink
Add repository links
Browse files Browse the repository at this point in the history
  • Loading branch information
cchlanger committed May 26, 2023
1 parent a522b0c commit 845f3c4
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 2 deletions.
14 changes: 12 additions & 2 deletions front_end/src/components/forms/addDatasetForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<md-option value="url">
Import from URL
</md-option>
<md-option value="url">
<md-option value="encode">
ENCODE
</md-option>
<md-option
Expand Down Expand Up @@ -157,6 +157,14 @@
updateComponentValidity
"
/>
<formURLEncode
v-else-if="form.fileSource === 'encode'"
:fileTypeMapping="fileTypeExtensions"
@input-changed="urlInputChanged"
@update-component-validity="
updateComponentValidity
"
/>
<formRepositoryInput
v-else
:fileTypeMapping="fileTypeExtensions"
Expand Down Expand Up @@ -242,6 +250,7 @@ import { apiMixin } from "../../mixins";
import formFileInput from "./formFileInput";
import formURLInput from "./formURLInput";
import formURLEncode from "./formURLEncode";
import formRepositoryInput from "./formRepositoryInput";
export default {
Expand All @@ -253,7 +262,8 @@ export default {
components: {
formFileInput,
formRepositoryInput,
formURLInput
formURLInput,
formURLEncode
},
data: () => ({
form: {
Expand Down
3 changes: 3 additions & 0 deletions front_end/src/components/forms/formRepositoryInput.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div class="md-layout-item md-layout md-gutter">
<a href="https://data.4dnucleome.org/browse/" target="_blank">
<md-icon>manage_search</md-icon>
</a>
<div class="md-layout-item md-small-size-100">
<md-field :class="validationSampleID()">
<label for="sampleID">Sample-ID</label>
Expand Down
168 changes: 168 additions & 0 deletions front_end/src/components/forms/formURLEncode.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<template>
<div class="md-layout-item md-layout md-gutter">
<a href="https://www.encodeproject.org/search/?type=Experiment" target="_blank">
<md-icon>manage_search</md-icon>
</a>
<div class="md-layout-item md-small-size-100">
<md-field :class="validationSourceURL">
<label for="sourceURL">URL</label>
<md-input
name="sourceURL"
id="sourceURL"
v-model="form.sourceURL"
required
@change="inputURLChanged"
/>
<span class="md-error" v-if="!$v.form.sourceURL.url"
>URL invalid! {{ urlErrorMsg }}</span
>
<span class="md-error" v-if="!$v.form.sourceURL.required"
>URL required!</span
>
</md-field>
</div>
<div class="md-layout-item md-small-size-100">
<md-field :class="validationFileType">
<label for="fileType">File type</label>
<md-select
id="fileType"
name="fileType"
v-model="form.fileType"
required
@md-selected="inputFileTypeChanged"
>
<md-option
v-for="fileType in fileTypes"
:key="fileType"
:value="fileType"
>
{{ fileType }}
</md-option>
</md-select>

<span class="md-error" v-if="!$v.form.fileType.url"
>Filetype is required</span
>
</md-field>
</div>
</div>
</template>
<script>
import { validationMixin } from "vuelidate";
import { required, url } from "vuelidate/lib/validators";
export default {
name: "formURLInput",
props: ["fileTypeMapping"],
emits: ["input-changed", "update-component-validity"],
mixins: [validationMixin],
data: () => ({
form: {
sourceURL: null,
fileType: null
},
componentValid: false
}),
validations() {
let outputObject = {
form: {
sourceURL: {
// TODO validate URL properly
required,
url
},
fileType: {
required
}
}
};
return outputObject;
},
methods: {
inputFileTypeChanged: function(event) {
this.$v.form.fileType.$touch();
if (
this.$v.form.fileType.$dirty &&
this.$v.form.fileType.$invalid
) {
console.log("filetype invalid");
return;
}
this.checkFormValid();
return;
},
inputURLChanged: function(event) {
this.$v.form.sourceURL.$touch();
if (
this.$v.form.sourceURL.$dirty &&
this.$v.form.sourceURL.$invalid
) {
console.log("sourceurl invalid");
return;
}
this.checkFormValid();
return;
},
checkFormValid: function() {
if (
!this.$v.form.sourceURL.$dirty ||
!this.$v.form.fileType.$dirty
) {
return;
}
this.$v.$touch();
// emit validity value
if (this.componentValid != this.$v.$dirty && !this.$v.$invalid) {
this.componentValid = this.$v.$dirty && !this.$v.$invalid;
this.$emit("update-component-validity", this.componentValid);
console.log(
"update-component-validity, " + this.componentValid
);
}
if (!this.componentValid) {
return;
}
this.$emit(
"input-changed",
this.form.sourceURL,
this.form.fileType
);
}
},
computed: {
fileTypes: function() {
let fileTypesLC = Object.keys(this.fileTypeMapping).map(type =>
type.toLowerCase()
);
let fileTypes = [...new Set(fileTypesLC)];
return fileTypes;
},
validationSourceURL: function() {
return {
"md-invalid":
this.$v.form.sourceURL.$dirty &&
this.$v.form.sourceURL.$invalid
};
},
validationFileType: function() {
return {
"md-invalid":
this.$v.form.fileType.$dirty &&
this.$v.form.fileType.$invalid
};
},
urlErrorMsg: function() {
let url = this.form.sourceURL.toLowerCase();
if (!url.startsWith("https://") && !url.startsWith("http://")) {
return "Add protocol in front (e.g. https://)";
}
return "";
}
}
};
</script>

0 comments on commit 845f3c4

Please sign in to comment.