|
|
@@ -2,27 +2,27 @@
|
|
|
<main>
|
|
|
<LayoutContainer>
|
|
|
<UiForm
|
|
|
- ref="form"
|
|
|
- :model="Subdomain"
|
|
|
- :entity="subdomain"
|
|
|
- :submitActions="submitActions"
|
|
|
- :validation-pending="validationPending"
|
|
|
- :refresh-profile="true"
|
|
|
+ ref="form"
|
|
|
+ :model="Subdomain"
|
|
|
+ :entity="subdomain"
|
|
|
+ :submitActions="submitActions"
|
|
|
+ :validation-pending="validationPending"
|
|
|
+ :refresh-profile="true"
|
|
|
>
|
|
|
<v-container :fluid="true" class="container">
|
|
|
<v-row>
|
|
|
<v-col cols="12" sm="6">
|
|
|
- <div>{{ $t('pleaseEnterYourNewSubdomain')}} :</div>
|
|
|
+ <div>{{ $t('pleaseEnterYourNewSubdomain') }} :</div>
|
|
|
</v-col>
|
|
|
</v-row>
|
|
|
<v-row>
|
|
|
<v-col cols="12" sm="6">
|
|
|
<UiInputText
|
|
|
- v-model="subdomain.subdomain"
|
|
|
- field="subdomain"
|
|
|
- type="string"
|
|
|
- :rules="rules()"
|
|
|
- @update:modelValue="onSubdomainUpdate"
|
|
|
+ v-model="subdomain.subdomain"
|
|
|
+ field="subdomain"
|
|
|
+ type="string"
|
|
|
+ :rules="rules()"
|
|
|
+ @update:modelValue="onSubdomainUpdate"
|
|
|
/>
|
|
|
</v-col>
|
|
|
</v-row>
|
|
|
@@ -35,7 +35,6 @@
|
|
|
<v-icon>fa fa-check</v-icon>
|
|
|
<i class="ml-2">{{ $t('this_subdomain_is_available') }}</i>
|
|
|
</span>
|
|
|
-
|
|
|
</div>
|
|
|
</v-container>
|
|
|
|
|
|
@@ -49,18 +48,17 @@
|
|
|
</UiForm>
|
|
|
</LayoutContainer>
|
|
|
</main>
|
|
|
-
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import {useEntityManager} from "~/composables/data/useEntityManager";
|
|
|
-import Subdomain from "~/models/Organization/Subdomain";
|
|
|
-import {SUBMIT_TYPE} from "~/types/enum/enums";
|
|
|
-import {AnyJson} from "~/types/data";
|
|
|
-import SubdomainValidation from "~/services/validation/subdomainValidation";
|
|
|
-import {Ref} from "@vue/reactivity";
|
|
|
-import {useSubdomainValidation} from "~/composables/form/validation/useSubdomainValidation";
|
|
|
-import _ from "lodash";
|
|
|
+import { useEntityManager } from '~/composables/data/useEntityManager'
|
|
|
+import Subdomain from '~/models/Organization/Subdomain'
|
|
|
+import { SUBMIT_TYPE } from '~/types/enum/enums'
|
|
|
+import { AnyJson } from '~/types/data'
|
|
|
+import SubdomainValidation from '~/services/validation/subdomainValidation'
|
|
|
+import { Ref } from '@vue/reactivity'
|
|
|
+import { useSubdomainValidation } from '~/composables/form/validation/useSubdomainValidation'
|
|
|
+import _ from 'lodash'
|
|
|
|
|
|
const i18n = useI18n()
|
|
|
|
|
|
@@ -78,7 +76,7 @@ const submitActions = computed(() => {
|
|
|
return actions
|
|
|
})
|
|
|
|
|
|
-const form: Ref<HTMLCanvasElement | null> = ref(null);
|
|
|
+const form: Ref<HTMLCanvasElement | null> = ref(null)
|
|
|
const subdomainAvailable: Ref<boolean | null> = ref(null)
|
|
|
const validationPending: Ref<boolean> = ref(false)
|
|
|
|
|
|
@@ -92,7 +90,7 @@ const inputDelay = 600
|
|
|
* @param subdomain
|
|
|
*/
|
|
|
const checkAvailability = async (subdomain: string) => {
|
|
|
- subdomainAvailable.value = await subdomainValidation.isAvailable(subdomain);
|
|
|
+ subdomainAvailable.value = await subdomainValidation.isAvailable(subdomain)
|
|
|
validationPending.value = false
|
|
|
|
|
|
//@ts-ignore
|
|
|
@@ -103,12 +101,15 @@ const checkAvailability = async (subdomain: string) => {
|
|
|
* Version debounced de la fonction checkAvailability
|
|
|
* @see https://docs-lodash.com/v4/debounce/
|
|
|
*/
|
|
|
-const checkAvailabilityDebounced: _.DebouncedFunc<() => void> = _.debounce(async () => {
|
|
|
- if (subdomain.value.subdomain === null) {
|
|
|
- return
|
|
|
- }
|
|
|
- await checkAvailability(subdomain.value.subdomain);
|
|
|
-}, inputDelay)
|
|
|
+const checkAvailabilityDebounced: _.DebouncedFunc<() => void> = _.debounce(
|
|
|
+ async () => {
|
|
|
+ if (subdomain.value.subdomain === null) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ await checkAvailability(subdomain.value.subdomain)
|
|
|
+ },
|
|
|
+ inputDelay
|
|
|
+)
|
|
|
|
|
|
const onSubdomainUpdate = () => {
|
|
|
subdomainAvailable.value = null
|
|
|
@@ -120,19 +121,25 @@ const onSubdomainUpdate = () => {
|
|
|
* Règles de validation
|
|
|
*/
|
|
|
const rules = () => [
|
|
|
- (subdomain: string | null) => (subdomain !== null && subdomain.length > 0) || i18n.t('please_enter_a_value_for_the_subdomain'),
|
|
|
- (subdomain: string | null) => (subdomain !== null && subdomain.length >= 2 && subdomain.length <=60) || i18n.t('subdomain_need_to_have_0_to_60_cars'),
|
|
|
- (subdomain: string | null) => SubdomainValidation.isValid(subdomain) || i18n.t('subdomain_can_not_contain_spaces_or_special_cars'),
|
|
|
- async () => (subdomainAvailable.value !== false) || i18n.t('this_subdomain_is_already_in_use')
|
|
|
+ (subdomain: string | null) =>
|
|
|
+ (subdomain !== null && subdomain.length > 0) ||
|
|
|
+ i18n.t('please_enter_a_value_for_the_subdomain'),
|
|
|
+ (subdomain: string | null) =>
|
|
|
+ (subdomain !== null && subdomain.length >= 2 && subdomain.length <= 60) ||
|
|
|
+ i18n.t('subdomain_need_to_have_0_to_60_cars'),
|
|
|
+ (subdomain: string | null) =>
|
|
|
+ SubdomainValidation.isValid(subdomain) ||
|
|
|
+ i18n.t('subdomain_can_not_contain_spaces_or_special_cars'),
|
|
|
+ async () =>
|
|
|
+ subdomainAvailable.value !== false ||
|
|
|
+ i18n.t('this_subdomain_is_already_in_use'),
|
|
|
]
|
|
|
-
|
|
|
-
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
- .validationMessage {
|
|
|
- font-size: 13px;
|
|
|
- height: 20px;
|
|
|
- min-height: 20px;
|
|
|
- }
|
|
|
+.validationMessage {
|
|
|
+ font-size: 13px;
|
|
|
+ height: 20px;
|
|
|
+ min-height: 20px;
|
|
|
+}
|
|
|
</style>
|