Skip to content

Commit

Permalink
Merge branch 'master' into fix/4273-allow-parentheses-in-hyperlink
Browse files Browse the repository at this point in the history
  • Loading branch information
connoratrug authored Oct 25, 2024
2 parents 0188306 + 81252f2 commit 6cce356
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 65 deletions.
78 changes: 39 additions & 39 deletions apps/molgenis-components/src/components/forms/InputEmail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
:name="name"
:value="modelValue"
@input="
//@ts-ignore
emit('update:modelValue', $event.target?.value)
$emit('update:modelValue', ($event.target as HTMLInputElement).value)
"
type="text"
class="form-control"
Expand All @@ -27,49 +26,50 @@
</FormGroup>
</template>

<script setup lang="ts">
import { computed } from "vue";
<script lang="ts">
import constants from "../constants";
import FormGroup from "./FormGroup.vue";
import InputGroup from "./InputGroup.vue";
import BaseInputProps from "./baseInputs/BaseInputProps";
import BaseInput from "./baseInputs/BaseInput.vue";
let props = defineProps({
...BaseInputProps,
modelValue: {
type: String,
default: null,
export default {
name: "InputEmail",
components: { FormGroup, InputGroup },
extends: BaseInput,
props: {
stringLength: {
type: Number,
default: 255,
},
additionalValidValidationStrings: {
type: Array,
default: [],
},
},
stringLength: {
type: Number,
default: 255,
computed: {
stringError() {
if (typeof this.modelValue === "string") {
if (this.modelValue.length > this.stringLength) {
return `Please limit to ${this.stringLength} characters.`;
} else if (!this.validateEmail(this.modelValue)) {
return `Please enter a valid email address`;
} else {
return this.errorMessage;
}
} else {
return this.errorMessage;
}
},
},
additionalValidValidationStrings: {
type: Array,
default: [],
methods: {
validateEmail(email: string) {
return (
this.additionalValidValidationStrings.includes(email) ||
email?.match(constants.EMAIL_REGEX)
);
},
},
});
const emit = defineEmits(["update:modelValue"]);
function validateEmail(email: string) {
return (
props.additionalValidValidationStrings.includes(email) ||
email?.match(constants.EMAIL_REGEX)
);
}
const stringError = computed(() => {
if (typeof props.modelValue === "string") {
if (props.modelValue.length > props.stringLength) {
return `Please limit to ${props.stringLength} characters.`;
} else if (!validateEmail(props.modelValue)) {
return `Please enter a valid email address`;
} else {
return props.errorMessage;
}
}
});
};
</script>

<style scoped>
Expand Down Expand Up @@ -111,7 +111,7 @@ span:hover .hoverIcon {
id="input-email5"
v-model="value"
:stringLength="8"
label="maximum stringLength (4)"
label="maximum stringLength (8)"
/>
</div>
</template>
Expand Down
51 changes: 25 additions & 26 deletions apps/molgenis-components/src/components/forms/InputHyperlink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
:value="modelValue"
@input="
//@ts-ignore
emit('update:modelValue', $event.target?.value)
$emit('update:modelValue', $event.target?.value)
"
type="text"
class="form-control"
Expand All @@ -27,36 +27,35 @@
</FormGroup>
</template>
<script setup lang="ts">
import { computed } from "vue";
<script lang="ts">
import BaseInput from "./baseInputs/BaseInput.vue";
import FormGroup from "./FormGroup.vue";
import InputGroup from "./InputGroup.vue";
import BaseInputProps from "./baseInputs/BaseInputProps";
import constants from "../constants";
let props = defineProps({
...BaseInputProps,
modelValue: {
type: String,
default: null,
export default {
name: "InputHyperlink",
components: { FormGroup, InputGroup },
extends: BaseInput,
computed: {
stringError() {
if (typeof this.modelValue === "string") {
if (!this.validateHyperlink(this.modelValue)) {
return `Please enter a valid hyperlink`;
} else {
return this.errorMessage;
}
} else {
return this.errorMessage;
}
},
},
});
const emit = defineEmits(["update:modelValue"]);
const stringError = computed(() => {
if (typeof props.modelValue === "string") {
if (!validateHyperlink(props.modelValue)) {
return `Please enter a valid hyperlink`;
} else {
return props.errorMessage;
}
}
});
function validateHyperlink(hyperlink: string) {
return hyperlink?.match(constants.HYPERLINK_REGEX);
}
methods: {
validateHyperlink(hyperlink: string) {
return hyperlink?.match(constants.HYPERLINK_REGEX);
},
},
};
</script>
<style scoped>
Expand Down

0 comments on commit 6cce356

Please sign in to comment.