From 9d8b3c27a2d0fdb0aaa4f3688a5025cbf5f1cd20 Mon Sep 17 00:00:00 2001 From: Sockenklaus Date: Mon, 11 Oct 2021 00:00:44 +0200 Subject: [PATCH] Refactored Schedule.vue contain more than one month. Started working on selecting cells. --- src/components/Schedule.vue | 249 ++++++++++++++++++++++++----------- src/types/schedule-data.d.ts | 13 +- src/views/Home.vue | 23 +--- 3 files changed, 184 insertions(+), 101 deletions(-) diff --git a/src/components/Schedule.vue b/src/components/Schedule.vue index 830a258..2d3d9f9 100644 --- a/src/components/Schedule.vue +++ b/src/components/Schedule.vue @@ -8,38 +8,43 @@ AddEmployeeModal( @emitResult="addEmployee($event)" ) -//- TODO: #3 Close Modal after successful input -table(class='table table-bordered table-sm' v-for="(row, rIndex) in scheduleData" :key="rIndex") - thead - tr - td.fw-bold(style="width: 150px") {{ format(startDate, "MMMM", {locale: de}) }} - td(v-for="(day, index) in weekdays" :key="index" :class="{'text-body text-opacity-50 bg-secondary bg-opacity-10' : row.dates[index] === null}") {{ day }} - tr - td.fw-bold {{ format(startDate, "y") }} - td(v-for="(date, dIndex) in row.dates" :key="dIndex" :class="{'bg-secondary bg-opacity-10' : row.dates[dIndex] === null}") - template(v-if="date !== null") {{ format(date, "dd.MM.")}} - tbody - tr(v-for="(employee, eIndex) in row.employees" :key="eIndex") - td - .row.justify-content-between.align-items-center.employee-wrapper - .col.text-start.ps-3 {{employee.handle}} - .col.text-end - button.btn( - @click="removeEmployee(rIndex, employee)" +.pt-5(v-for="(month, mIndex) in scheduleData" :key="mIndex") + table(class='table table-bordered table-sm' v-for="(row, rIndex) in month" :key="rIndex") + thead + tr + td.fw-bold(style="width: 150px") {{ format(startDates[mIndex], "MMMM", {locale: de}) }} + td(v-for="(day, index) in weekdays" :key="index" :class="{'text-body text-opacity-50 bg-secondary bg-opacity-10' : row.dates[index] === null}") {{ day }} + tr + td.fw-bold {{ format(startDates[mIndex], "y") }} + td(v-for="(date, dIndex) in row.dates" :key="dIndex" :class="{'bg-secondary bg-opacity-10' : row.dates[dIndex] === null}") + template(v-if="date !== null") {{ format(date, "dd.MM.")}} + tbody + tr(v-for="(employee, eIndex) in row.employees" :key="eIndex") + td + .row.justify-content-between.align-items-center.employee-wrapper + .col.text-start.ps-3 {{employee.handle}} + .col.text-end + button.btn( + @click="removeEmployee(mIndex, rIndex, employee)" + ) + i.bi-x-lg + td( + v-for="(date, dIndex) in row.dates" + :key="dIndex" + :class="{'bg-secondary bg-opacity-10' : row.dates[dIndex] === null, 'selected' : isSelected({mIndex, rIndex, eIndex, dIndex})}" + @click="select({mIndex, rIndex, eIndex, dIndex}, $event)" + )   + tr() + td.text-end + button( + class="btn" + @click="addEmployeeRow = rIndex; addEmployeeMonth = mIndex" + data-bs-toggle="modal" + :data-bs-target="'#'+modalId" ) - i.bi-x-lg - td(v-for="(date, dIndex) in row.dates" :key="dIndex" :class="{'bg-secondary bg-opacity-10' : row.dates[dIndex] === null}")   - tr() - td.text-end - button( - class="btn" - @click="addEmployeeRow = rIndex" - data-bs-toggle="modal" - :data-bs-target="'#'+modalId" - ) - i.bi.bi-plus-lg - td(v-for="(date, dIndex) in row.dates" :key="dIndex" :class="{'bg-secondary bg-opacity-10' : row.dates[dIndex] === null}")   + i.bi.bi-plus-lg + td(v-for="(date, dIndex) in row.dates" :key="dIndex" :class="{'bg-secondary bg-opacity-10' : row.dates[dIndex] === null}")   @@ -47,64 +52,124 @@ table(class='table table-bordered table-sm' v-for="(row, rIndex) in scheduleData