Browse Source

add parameter to fixe benevole

tripeur 4 years ago
parent
commit
950a471b67
3 changed files with 35 additions and 11 deletions
  1. 22 4
      src/components/EditeurBenevole.vue
  2. 12 6
      src/models/Benevole.ts
  3. 1 1
      src/views/BenevoleManager.vue

+ 22 - 4
src/components/EditeurBenevole.vue

@@ -58,6 +58,19 @@
         :modelValue="benevole.phone"
         @input="inputListener($event, 'phone')"
       />
+      <styled-input
+        label="Commentaire"
+        id="comment"
+        type="textarea"
+        :modelValue="benevole.comment"
+        @input="inputListener($event, 'comment')"
+      />
+      <checkbox
+        label="Ne pas ajouter de créneau à ce bénévole"
+        :modelValue="benevole.isFixed"
+        help="Indique au solveur de ne pas changer les affectations de ce bénévole"
+        @input="checkboxListener($event, 'isFixed')"
+      />
       <h3 style="padding-bottom: 0.8rem">Propriétés</h3>
       <chips-input
         label="Préference & compétences"
@@ -75,15 +88,16 @@
 <script lang="ts">
 import Benevole from "@/models/Benevole";
 import Competence from "@/models/Competence";
-import styledInput from "./input.vue";
-import chipsInput from "./SelectChipInput.vue";
+import styledInput from "@/components/input.vue";
+import chipsInput from "@/components/SelectChipInput.vue";
+import checkbox from "@/components/checkBox.vue";
 import { defineComponent, PropType } from "vue";
 import { MutationTypes } from "@/store/Mutations";
 import AutocompleteOptions from "@/models/AutocompleteOptions";
 
 export default defineComponent({
   name: "EditeurBenevole",
-  components: { styledInput, chipsInput },
+  components: { styledInput, chipsInput, checkbox },
   props: { benevole: { type: Object as PropType<Benevole> } },
   data: function () {
     return {
@@ -92,7 +106,7 @@ export default defineComponent({
     };
   },
   watch: {
-    benevole: function (b: Benevole) {
+    benevole(b: Benevole) {
       this.competenceIdList = b.competenceIdList.map((s) => s.toString());
     },
     competenceIdList(val: Array<string>) {
@@ -121,6 +135,10 @@ export default defineComponent({
     inputListener(event: any, field: keyof Benevole) {
       this.updateBenevole(field, event.target.value);
     },
+    // eslint-disable-next-line @typescript-eslint/no-explicit-any
+    checkboxListener(event: any, field: keyof Benevole) {
+      this.updateBenevole(field, event.target.checked);
+    },
     updateBenevole<K extends keyof Benevole>(k: K, value: Benevole[K]) {
       if (this.benevole) {
         this.$store.commit(MutationTypes.editBenevole, {

+ 12 - 6
src/models/Benevole.ts

@@ -7,6 +7,7 @@ interface IBenevole {
   phone?: string;
   email?: string;
   comment?: string;
+  isFixed?: boolean;
   competenceIdList?: number[];
   creneauIdList?: string[];
 }
@@ -19,6 +20,7 @@ export default class Benevole {
   surname: string;
   phone: string;
   email: string;
+  isFixed: boolean;
   comment: string;
   competenceIdList: Array<number>;
   creneauIdList: Array<string>;
@@ -29,6 +31,7 @@ export default class Benevole {
     phone: string,
     email: string,
     comment: string,
+    isFixed: boolean,
     competenceIdList: number[],
     creneauIdList: string[]
   ) {
@@ -39,6 +42,7 @@ export default class Benevole {
     this.surname = surname;
     this.phone = phone;
     this.email = email;
+    this.isFixed = isFixed;
     this.comment = comment;
     this.competenceIdList = competenceIdList;
     this.creneauIdList = creneauIdList;
@@ -73,12 +77,13 @@ export default class Benevole {
     return new Benevole(
       id,
       obj.name,
-      obj.surname ? obj.surname : "",
-      obj.phone ? obj.phone : "",
-      obj.email ? obj.email : "",
-      obj.comment ? obj.comment : "",
-      obj.competenceIdList ? obj.competenceIdList : [],
-      obj.creneauIdList ? obj.creneauIdList : []
+      obj.surname ?? "",
+      obj.phone ?? "",
+      obj.email ?? "",
+      obj.comment ?? "",
+      obj.isFixed ?? false,
+      obj.competenceIdList ?? [],
+      obj.creneauIdList ?? []
     );
   }
 
@@ -90,6 +95,7 @@ export default class Benevole {
       phone: this.phone,
       email: this.email,
       comment: this.comment,
+      isFixed: this.isFixed,
       competenceIdList: this.competenceIdList,
       creneauIdList: this.creneauIdList,
     };

+ 1 - 1
src/views/BenevoleManager.vue

@@ -346,7 +346,7 @@ export default defineComponent({
 }
 @media (min-width: 1200px) {
   .page {
-    margin-top: 32px;
+    margin-top: 8px;
   }
 }
 </style>