Browse Source

various fixes

Olivier Massot 2 years ago
parent
commit
c1321cfb87

+ 34 - 33
components/Layout/Parameters/Website.vue

@@ -16,39 +16,40 @@
           <div class="mb-6">
             <div>{{ $t('subdomains_history') }} : </div>
             <UiLoadingPanel v-if="subdomainsPending" />
-            <v-table v-else class="my-2">
-              <tbody>
-                <tr
-                    v-for="subdomain in subdomains.items"
-                    :key="subdomain.id"
-                    :title="subdomain.subdomain"
-                    class="subdomainItem"
-                    @click="goToEditPage(subdomain.id)"
-                >
-                  <td>{{ subdomain.subdomain }}</td>
-                  <td>
-                      <span v-if="subdomain.active">
-                        <v-icon class="text-success icon">
-                          fa-solid fa-check
-                        </v-icon> {{ $t('active') }}
-                      </span>
-                  </td>
-
-                </tr>
-
-              </tbody>
-
-            </v-table>
-
+            <div v-else>
+              <v-table class="my-2">
+                <tbody>
+                  <tr
+                      v-for="subdomain in subdomains.items"
+                      :key="subdomain.id"
+                      :title="subdomain.subdomain"
+                      class="subdomainItem"
+                      @click="goToEditPage(subdomain.id)"
+                  >
+                    <td>{{ subdomain.subdomain }}</td>
+                    <td>
+                        <span v-if="subdomain.active">
+                          <v-icon class="text-success icon">
+                            fa-solid fa-check
+                          </v-icon> {{ $t('active') }}
+                        </span>
+                    </td>
+
+                  </tr>
+
+                </tbody>
+
+              </v-table>
+
+              <v-btn
+                  :disabled="!canAddNewSubdomain"
+                  class="my-2"
+                  @click="onAddSubdomainClick"
+              >
+                {{ $t('record_a_new_subdomain')}}
+              </v-btn>
+            </div>
           </div>
-
-          <v-btn
-              :disabled="!canAddNewSubdomain"
-              class="my-2"
-              @click="onAddSubdomainClick"
-          >
-            {{ $t('record_a_new_subdomain')}}
-          </v-btn>
         </v-col>
 
 
@@ -97,7 +98,7 @@ const { data: parameters, pending } = fetch(Parameters, organizationProfile.para
 
 const { data: subdomains, pending: subdomainsPending } = fetchCollection(Subdomain, null, ref({ 'organization' : organizationProfile.id }) )
 
-const canAddNewSubdomain: ComputedRef<boolean> = computed(() => subdomains.value.items.length < 3)
+const canAddNewSubdomain: ComputedRef<boolean> = computed(() => subdomains.value && subdomains.value.items.length < 3)
 
 
 

+ 15 - 2
components/Ui/Form.vue

@@ -127,10 +127,21 @@ const props = defineProps({
       return actions
     }
   },
+  /**
+   * La validation est en cours
+   */
   validationPending: {
     type: Boolean,
     required: false,
     default: false
+  },
+  /**
+   * Faut-il rafraichir le profil à la soumission du formulaire?
+   */
+  refreshProfile: {
+    type: Boolean,
+    required: false,
+    default: false
   }
 })
 
@@ -159,8 +170,6 @@ const isConfirmationDialogShowing: ComputedRef<boolean> = computed(() => {
   return useFormStore().showConfirmToLeave
 })
 
-
-
 /**
  * Ferme la fenêtre de confirmation
  */
@@ -191,6 +200,10 @@ const submit = async (next: string|null = null) => {
     // TODO: est-ce qu'il faut re-fetch l'entité après le persist?
     const updatedEntity = await em.persist(props.model, props.entity)
 
+    if (props.refreshProfile) {
+      await em.refreshProfile()
+    }
+
     usePageStore().addAlert(TYPE_ALERT.SUCCESS, ['saveSuccess'])
 
     // On retire l'état 'dirty'

+ 6 - 1
lang/fr.json

@@ -611,5 +611,10 @@
   "Not Found": "Données non trouvée",
   "subdomains_breadcrumbs": "Sous-domaines",
   "new_breadcrumbs": "Nouveau",
-  "validation_pending": "Validation en cours"
+  "validation_pending": "Validation en cours",
+  "The subdomain is already active": "Le sous-domaine est déjà actif",
+  "Not a valid subdomain": "Le sous-domaine est invalide",
+  "This organization can not register new subdomains": "Nombre maximum de sous-domaines enregistrés atteint",
+  "This subdomain is not available": "Ce sous-domaine n'est pas disponible",
+  "This subdomain is already registered": "Ce sous-domaine est déjà enregistré"
 }

+ 3 - 2
pages/parameters/subdomains/[id].vue

@@ -62,9 +62,10 @@
 
   const activationPending: Ref<boolean> = ref(false)
 
-  const activateAndQuit = () => {
+  const activateAndQuit = async () => {
     activationPending.value = true
-    em.patch(Subdomain, id, { active: true} )
+    await em.patch(Subdomain, id, { active: true} )
+    await em.refreshProfile()
     quit()
   }
 

+ 1 - 0
pages/parameters/subdomains/new.vue

@@ -7,6 +7,7 @@
           :entity="subdomain"
           :submitActions="submitActions"
           :validation-pending="validationPending"
+          :refresh-profile="true"
       >
         <v-container :fluid="true" class="container">
           <v-row>