Browse Source

add input checkbox

Olivier Massot 2 years ago
parent
commit
75db82098a

+ 16 - 6
components/Layout/Parameters/PreferencesTab/GeneralParameters.vue

@@ -37,10 +37,18 @@
 
     <v-row>
       <v-col cols="6">
-        <v-checkbox :label="$t('show_adherents_list_and_their_coordinates') + ' *'"></v-checkbox>
+        <UiInputCheckbox
+            v-model="parameters.showAdherentList"
+            field="showAdherentList"
+            label="show_adherents_list_and_their_coordinates"
+        />
       </v-col>
       <v-col cols="6">
-        <v-checkbox :label="$t('students_are_also_association_members') + ' *'"></v-checkbox>
+        <UiInputCheckbox
+            v-model="parameters.studentsAreAdherents"
+            field="showAdherentList"
+            label="students_are_also_association_members"
+        />
       </v-col>
     </v-row>
 
@@ -60,13 +68,15 @@ import Parameters from "~/models/Organization/Parameters";
 
 const props = defineProps({
   parameters: {
-    type: Object as PropType<Parameters>
+    type: Object as PropType<Parameters>,
+    required: true
   }
 })
 
-const activitySeasonStartDate: Ref<Date> = ref(new Date())
-const coursesStartDate: Ref<Date> = ref(new Date())
-const coursesEndDate: Ref<Date> = ref(new Date())
+//
+// studentsAreAdherents
+// timezone
+
 </script>
 
 <style scoped lang="scss">

+ 21 - 11
components/Ui/Input/Checkbox.vue

@@ -10,12 +10,13 @@ Case à cocher
     fluid
   >
     <v-checkbox
-      v-model="data"
-      :value="data"
+      :model-value="modelValue"
+      :value="modelValue"
       :label="$t(fieldLabel)"
       :disabled="readonly"
-      :error="error || !!violation"
-      :error-messages="errorMessage || violation ? $t(violation) : ''"
+      :error="error || !!fieldViolations"
+      :error-messages="errorMessage || fieldViolations ? $t(fieldViolations) : ''"
+      @update:model-value="onUpdate($event)"
       @change="onChange($event)"
     />
   </v-container>
@@ -25,6 +26,10 @@ Case à cocher
 import {useFieldViolation} from "~/composables/form/useFieldViolation";
 
 const props = defineProps({
+  modelValue: {
+    type: Boolean,
+    required: false
+  },
   field: {
     type: String,
     required: false,
@@ -35,10 +40,6 @@ const props = defineProps({
     required: false,
     default: null
   },
-  data: {
-    type: Boolean,
-    required: false
-  },
   readonly: {
     type: Boolean,
     required: false
@@ -54,11 +55,20 @@ const props = defineProps({
   }
 })
 
-const { emit } = useNuxtApp()
+const {fieldViolations, updateViolationState} = useFieldViolation(props.field)
+
+const fieldLabel: string = props.label ?? props.field
+
+const emit = defineEmits(['update:model-value', 'change'])
 
-const { violation, onChange } = useFieldViolation(props.field, emit)
+const onUpdate = (event: string) => {
+  emit('update:model-value', props.modelValue)
+}
 
-const fieldLabel = props.label ?? props.field
+const onChange = (event: Event | undefined) => {
+  updateViolationState(event)
+  emit('change', props.modelValue)
+}
 
 </script>