Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Com 3874 #2098

Merged
merged 4 commits into from
Jan 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 86 additions & 44 deletions src/core/components/courses/SlotContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,71 @@
@blur="updateEstimatedStartDate" :disabled="course.archivedAt" />
</div>
<q-card class="q-pa-md">
<div v-for="(step, index) in stepList" :key="step.key" class="q-pb-sm">
<div :class="getStepClass(step)">
<div v-if="isStepToPlan(step)" class="to-plan-header">Créneaux à programmer</div>
<div class="row q-pa-md">
<div class="index">{{ index + 1 }}</div>
<div class="q-mx-md">
<div>{{ step.name }}</div>
<div class="type text-capitalize">{{ step.typeLabel }}</div>
<q-item-section @click="showStepDetails" class="slots cursor-pointer bg-copper-grey-50 copper-grey-700">
{{ showStepList ? 'Masquer' : 'Afficher' }} la liste des étapes de la formation
<q-icon size="xs" :name="showStepList ? 'expand_less' : 'expand_more'" color="copper-grey-700" />
</q-item-section>
<div v-if="showStepList" class="bg-copper-grey-50 q-px-md">
<q-item-section v-for="(step, index) in stepList" :key="step.key" class="q-pb-sm flex">
<div :class="getStepClass(step)">
<div v-if="isStepToPlan(step)" class="to-plan-header">Créneaux à programmer</div>
<div class="row q-pa-md">
<div class="index">{{ index + 1 }}</div>
<div class="q-mx-md">
<div>{{ step.name }}</div>
<div class="type text-capitalize">{{ step.typeLabel }}</div>
</div>
</div>
</div>
<div v-if="!isElearningStep(step)" class="slots-container">
<div v-for="day in Object.entries(omit(courseSlotsByStepAndDate[step.key], SLOTS_TO_PLAN_KEY))"
:key="day" class="row q-ml-xl q-my-sm">
<div class="text-weight-bold q-mr-md">{{ day[0] }}</div>
<div>
<div v-for="slot in day[1]" :key="slot._id" @click="openEditionModal(slot)"
:class="getSlotClass(step)">
<div class="q-mr-md">{{ formatSlotSchedule(slot) }}</div>
<div v-if="step.type === ON_SITE" class="q-mr-md">{{ getSlotAddress(slot) }}</div>
<div v-else class="q-mr-md ellipsis link-container">
<a class="link" :href="slot.meetingLink" target="_blank" @click="$event.stopPropagation()">
{{ slot.meetingLink }}
</a>
{{ !slot.meetingLink ? 'Lien vers la visio non renseigné' : '' }}
<div v-if="!isElearningStep(step)" class="slots-container">
<div v-for="day in Object.entries(omit(courseSlotsByStepAndDate[step.key], TO_PLAN_KEY))"
:key="day" class="row q-ml-xl q-my-sm">
<div class="text-weight-bold q-mr-md">{{ day[0] }}</div>
<div>
<div v-for="slot in day[1]" :key="slot._id" @click="openEditionModal(slot)"
:class="getSlotClass(step)">
<div class="q-mr-md">{{ formatSlotSchedule(slot) }}</div>
<div v-if="step.type === ON_SITE" class="q-mr-md">{{ getSlotAddress(slot) }}</div>
<div v-else class="q-mr-md ellipsis link-container">
<a class="link" :href="slot.meetingLink" target="_blank" @click="$event.stopPropagation()">
{{ slot.meetingLink }}
</a>
{{ !slot.meetingLink ? 'Lien vers la visio non renseigné' : '' }}
</div>
<q-icon v-if="canEdit" name="edit" size="12px" color="copper-grey-500" />
</div>
<q-icon v-if="canEdit" name="edit" size="12px" color="copper-grey-500" />
</div>
</div>
</div>
<div v-if="isStepToPlan(step) && !!get(courseSlotsByStepAndDate[step.key], SLOTS_TO_PLAN_KEY)"
class="to-plan-slot">
<div v-for="slot in Object.values(get(courseSlotsByStepAndDate[step.key], SLOTS_TO_PLAN_KEY)).flat()"
:key="slot._id" @click="openEditionModal(slot)"
:class="['row items-center q-ml-xl q-mb-md', canEdit && 'cursor-pointer hover-orange']">
<div class="clickable-name text-orange-500 q-mr-md">créneau à planifier</div>
<q-icon v-if="canEdit" name="edit" size="12px" color="copper-grey-500" />
<div v-if="isStepToPlan(step) && !!get(courseSlotsByStepAndDate[step.key], TO_PLAN_KEY)"
class="q-mx-lg bg-peach-100">
<q-item-section @click="() => showSlotToPlanDetails(step.key)" class="slots cursor-pointer">
<span class="text-orange-500">
{{ showSlotToPlan[step.key] ? 'Masquer' : 'Afficher' }}
{{ formatQuantity(
'créneau',
Object.values(get(courseSlotsByStepAndDate[step.key], TO_PLAN_KEY)).flat().length,
'x'
) }} à planifier
</span>
<q-icon :name="showSlotToPlan[step.key] ? 'expand_less' : 'expand_more'" size="20px"
class="q-ml-sm" />
</q-item-section>
<div v-if="showSlotToPlan[step.key]" class="to-plan-slot">
<div v-for="slot in
Object.values(get(courseSlotsByStepAndDate[step.key], TO_PLAN_KEY)).flat()"
:key="slot._id" @click="openEditionModal(slot)"
:class="['row items-center q-ml-lg q-pa-sm', canEdit && 'cursor-pointer hover-orange']">
<div class="clickable-name text-orange-500 q-mr-md">créneau à planifier</div>
<q-icon v-if="canEdit" name="edit" size="12px" color="copper-grey-500" />
</div>
</div>
</div>
<div class="q-mt-sm" v-if="canEdit && isRofOrVendorAdmin && isVendorInterface" align="right">
<ni-button label="Ajouter un créneau" color="primary" icon="add" @click="addDateToPlan(step.key)"
:disable="addDateToPlanLoading" />
</div>
</div>
<div class="q-mt-sm" v-if="canEdit && isRofOrVendorAdmin && isVendorInterface" align="right">
<ni-button label="Ajouter un créneau" color="primary" icon="add" @click="addDateToPlan(step.key)"
:disable="addDateToPlanLoading" />
</div>
</div>
</div>
</q-item-section>
</div>
</q-card>
</div>
Expand All @@ -71,7 +92,6 @@
@unplan-slot="unplanSlot" />
</div>
</template>

<script>
import { useStore } from 'vuex';
import { computed, ref, toRefs } from 'vue';
Expand Down Expand Up @@ -121,9 +141,11 @@ export default {
const modalLoading = ref(false);
const editedCourseSlot = ref({});
const editionModal = ref(false);
const SLOTS_TO_PLAN_KEY = 'toPlan';
const TO_PLAN_KEY = 'toPlan';
const isOnlySlot = ref(false);
const isPlannedSlot = ref(false);
const showStepList = ref(true);
const showSlotToPlan = ref([]);

const { isVendorInterface } = useCourses();
const { waitForFormValidation } = useValidations();
Expand Down Expand Up @@ -175,7 +197,7 @@ export default {
const slotsByStepAndDateList = Object.keys(slotsByStep)
.map(key => groupBy(
slotsByStep[key],
s => (s.startDate ? CompaniDate(s.startDate).format(DD_MM_YYYY) : SLOTS_TO_PLAN_KEY)
s => (s.startDate ? CompaniDate(s.startDate).format(DD_MM_YYYY) : TO_PLAN_KEY)
));

return Object.fromEntries(Object.keys(slotsByStep).map((key, index) => [key, slotsByStepAndDateList[index]]));
Expand Down Expand Up @@ -287,6 +309,7 @@ export default {
NotifyNegative('Erreur lors de l\'ajout de la date à planifier.');
} finally {
addDateToPlanLoading.value = false;
showSlotToPlan.value[stepId] = true;
}
};

Expand Down Expand Up @@ -357,7 +380,7 @@ export default {
const isElearningStep = step => step.type === E_LEARNING;

const isPlannedStep = step => !!courseSlotsByStepAndDate.value[step.key] &&
Object.keys(courseSlotsByStepAndDate.value[step.key]).every(date => date !== SLOTS_TO_PLAN_KEY);
Object.keys(courseSlotsByStepAndDate.value[step.key]).every(date => date !== TO_PLAN_KEY);

const isStepToPlan = step => !(isElearningStep(step) || isPlannedStep(step));

Expand All @@ -379,8 +402,16 @@ export default {
canEdit.value && `cursor-pointer hover-${isPlannedStep(step) ? 'blue' : 'orange'}`,
];

const showStepDetails = () => { showStepList.value = !showStepList.value; };

const showSlotToPlanDetails = (stepId) => {
showSlotToPlan.value[stepId] = !showSlotToPlan.value[stepId];
};

const created = async () => {
if (!course.value) emit('refresh');

showSlotToPlan.value = stepList.value.map(s => ({ [s.key]: false }));
};

created();
Expand All @@ -393,9 +424,11 @@ export default {
modalLoading,
editedCourseSlot,
editionModal,
SLOTS_TO_PLAN_KEY,
TO_PLAN_KEY,
isOnlySlot,
isPlannedSlot,
showStepList,
showSlotToPlanDetails,
// Computed
v$,
course,
Expand All @@ -421,6 +454,9 @@ export default {
getStepClass,
getSlotClass,
formatSlotSchedule,
showStepDetails,
showSlotToPlan,
formatQuantity,
};
},
};
Expand Down Expand Up @@ -453,8 +489,10 @@ export default {
padding: 8px 16px
border-radius: 15px 15px 0px 0px
color: $orange-900
.to-plan-slot
width: fit-content
.slots
flex-direction: row
justify-content: space-between
padding: 16px
.index
background-color: $copper-500
border-radius: 50%
Expand All @@ -480,4 +518,8 @@ export default {
text-decoration-color: $primary
.link-container
max-width: 14em
.to-plan-slot
width: fit-content
.q-item__section
margin-left: 0px
</style>
Loading