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

MES 31-10-23 #1902

Merged
merged 20 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7a33fbd
COM-3592: fix bug on course creation
ulysseferreira Oct 17, 2023
33cb1c9
Merge pull request #1893 from sophiemoustard/COM-3592
sophiemoustard Oct 18, 2023
5648779
COM-3581: can get attendances
ulysseferreira Oct 19, 2023
2da4ba4
COM-3582: can get potential trainees
ulysseferreira Oct 19, 2023
926adab
COM-3581: sophie's review
ulysseferreira Oct 19, 2023
4c1336a
Merge pull request #1894 from sophiemoustard/COM-3581
sophiemoustard Oct 20, 2023
f020c0e
COM-3582: check if register in another group
ulysseferreira Oct 23, 2023
b5b668e
COM-3601: without trainer filter works
ulysseferreira Oct 23, 2023
d014748
COM-3582: sophie's review
ulysseferreira Oct 24, 2023
6de343d
COM-3601: simplify condition
ulysseferreira Oct 24, 2023
409cf44
COM-3582: minor changes
ulysseferreira Oct 24, 2023
b54093a
Merge pull request #1896 from sophiemoustard/COM-3582
sophiemoustard Oct 24, 2023
c33ce66
Merge pull request #1897 from sophiemoustard/COM-3601
manonpalin Oct 24, 2023
f5a8bdb
COM-3585: can upload intra_holding attendance sheet
ulysseferreira Oct 25, 2023
dff39bf
Merge pull request #1898 from sophiemoustard/COM-3585
sophiemoustard Oct 26, 2023
dd02416
COM-3584: can't add sheet if no companies
ulysseferreira Oct 27, 2023
05aebef
COM-3584: minor change
ulysseferreira Oct 30, 2023
d4b045d
Merge pull request #1899 from sophiemoustard/COM-3584
manonpalin Oct 30, 2023
3672bf6
COM-3584: hide bottom
ulysseferreira Oct 31, 2023
76c03a9
Merge pull request #1901 from sophiemoustard/COM-3584-2
manonpalin Oct 31, 2023
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
12 changes: 6 additions & 6 deletions src/core/components/courses/AttendanceSheetAdditionModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<template #title>
Ajouter une nouvelle <span class="text-weight-bold">feuille d'émargement</span>
</template>
<ni-select v-if="course.type === INTRA" :model-value="newAttendanceSheet.date" @blur="validations.date.$touch"
<ni-select v-if="course.type === INTER_B2B" :model-value="newAttendanceSheet.trainee"
:error="validations.trainee.$error" @update:model-value="update($event, 'trainee')" in-modal required-field
caption="Participant(e)" :options="traineeOptions" @blur="validations.trainee.$touch" />
<ni-select v-else :model-value="newAttendanceSheet.date" @blur="validations.date.$touch"
:error="validations.date.$error" @update:model-value="update($event, 'date')" :options="dateOptions"
required-field in-modal caption="Date" />
<ni-select v-else :model-value="newAttendanceSheet.trainee" @blur="validations.trainee.$touch"
:error="validations.trainee.$error" @update:model-value="update($event, 'trainee')" in-modal required-field
caption="Participant(e)" :options="traineeOptions" />
<ni-input in-modal caption="Feuille d'émargement" type="file" @blur="validations.file.$touch" last required-field
:model-value="newAttendanceSheet.file" @update:model-value="update($event, 'file')"
:extensions="[DOC_EXTENSIONS, IMAGE_EXTENSIONS]" :error="validations.file.$error" />
Expand All @@ -24,7 +24,7 @@ import Modal from '@components/modal/Modal';
import Select from '@components/form/Select';
import Input from '@components/form/Input';
import Button from '@components/Button';
import { INTRA, DOC_EXTENSIONS, IMAGE_EXTENSIONS, DD_MM_YYYY } from '@data/constants';
import { INTER_B2B, DOC_EXTENSIONS, IMAGE_EXTENSIONS, DD_MM_YYYY } from '@data/constants';
import { formatAndSortIdentityOptions } from '@helpers/utils';
import CompaniDate from '@helpers/dates/companiDates';

Expand All @@ -46,7 +46,7 @@ export default {
emits: ['hide', 'update:model-value', 'update:new-attendance-sheet', 'submit'],
data () {
return {
INTRA,
INTER_B2B,
DOC_EXTENSIONS,
IMAGE_EXTENSIONS,
};
Expand Down
19 changes: 16 additions & 3 deletions src/core/components/courses/CourseCell/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,24 @@
import { computed, toRefs } from 'vue';
import get from 'lodash/get';
import { useStore } from 'vuex';
import { FORTHCOMING, COMPLETED, IN_PROGRESS, TRAINER, ON_SITE, INTRA } from '@data/constants';
import {
FORTHCOMING,
COMPLETED,
IN_PROGRESS,
TRAINER,
ON_SITE,
INTRA,
ARCHIVED_COURSES,
UNARCHIVED_COURSES,
WITHOUT_TRAINER,
} from '@data/constants';
import { happened, composeCourseName } from '@helpers/courses';
import { formatQuantity } from '@helpers/utils';
import CompaniDate from '@helpers/dates/companiDates';
import CompaniDuration from '@helpers/dates/companiDurations';
import { useCourses } from '@composables/courses';
import ForthcomingSection from './ForthcomingSection';
import InProgressSection from './InProgressSection';
import { ARCHIVED_COURSES, UNARCHIVED_COURSES } from '../../../data/constants';

export default {
name: 'CourseDetail',
Expand Down Expand Up @@ -106,7 +115,11 @@ export default {
const isDisplayed = computed(() => {
if (selectedProgram.value && course.value.subProgram.program._id !== selectedProgram.value) return false;

if (selectedTrainer.value && get(course.value, 'trainer._id') !== selectedTrainer.value) return false;
if (selectedTrainer.value) {
const courseTrainer = get(course.value, 'trainer._id');
if (selectedTrainer.value === WITHOUT_TRAINER && courseTrainer) return false;
if (selectedTrainer.value !== WITHOUT_TRAINER && courseTrainer !== selectedTrainer.value) return false;
}

const companiesIds = course.value.companies.map(company => company._id);
if (selectedCompany.value && !companiesIds.includes(selectedCompany.value)) return false;
Expand Down
28 changes: 10 additions & 18 deletions src/core/components/courses/ElearningFollowUpTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<connected-dot v-else />
</template>
<template v-else>
<div :class="['name', canAccessTrainee(props.row) && 'clickable-name']"
@click="goToLearnerProfile(props.row, $event)">
{{ col.value }}
<div v-if="canAccessTrainee" class="name clickable-name" @click="$event.stopPropagation()">
<router-link :to="goToLearnerProfile(props.row)">{{ col.value }}</router-link>
</div>
<div v-else>{{ col.value }}</div>
</template>
</q-td>
</template>
Expand All @@ -44,16 +44,14 @@
<script>
import get from 'lodash/get';
import { computed, ref, toRefs } from 'vue';
import { useRouter } from 'vue-router';
import { useStore } from 'vuex';
import pick from 'lodash/pick';
import ExpandingTable from '@components/table/ExpandingTable';
import Progress from '@components/CourseProgress';
import { getStepTypeIcon } from '@helpers/courses';
import { sortStrings } from '@helpers/utils';
import { defineAbilitiesFor } from '@helpers/ability';
import { defineAbilitiesForCourse } from '@helpers/ability';
import { useCourses } from '@composables/courses';
import { useLearnersEdition } from '@composables/learnersEdition';
import ConnectedDot from './ConnectedDot';

export default {
Expand All @@ -69,13 +67,11 @@ export default {
isBlended: { type: Boolean, default: false },
},
setup (props) {
const $router = useRouter();
const $store = useStore();

const { isBlended } = toRefs(props);

const { isClientInterface } = useCourses();
const { canAccessTrainee } = useLearnersEdition();

const columns = ref([
{
Expand Down Expand Up @@ -108,35 +104,31 @@ export default {

const loggedUser = computed(() => $store.state.main.loggedUser);

const canReadLearnerInfo = computed(() => {
const ability = defineAbilitiesFor(pick(loggedUser.value, ['role', 'company', '_id', 'sector']));
const canAccessTrainee = computed(() => {
const ability = defineAbilitiesForCourse(pick(loggedUser.value, ['role']));

return ability.can('read', 'learner_info');
return ability.can('access', 'trainee');
});

const visibleColumns = computed(() => (isBlended.value
? ['name', 'connectionInfos', 'progress', 'expand']
: ['name', 'progress', 'expand']));

const goToLearnerProfile = (row, $event) => {
if (!canAccessTrainee(row)) return;

$event.stopPropagation();
const goToLearnerProfile = (row) => {
const name = isClientInterface ? 'ni courses learners info' : 'ni users learners info';
$router.push({ name, params: { learnerId: row._id }, query: { defaultTab: 'courses' } });
return { name, params: { learnerId: row._id }, query: { defaultTab: 'courses' } };
};

return {
// Data
columns,
pagination,
// Computed
canReadLearnerInfo,
visibleColumns,
canAccessTrainee,
// Methods
goToLearnerProfile,
getStepTypeIcon,
canAccessTrainee,
};
},
};
Expand Down
4 changes: 0 additions & 4 deletions src/core/components/courses/ProfileOrganization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,10 @@ export default {

const {
vendorRole,
isIntraCourse,
disableDocDownload,
pdfLoading,
isClientInterface,
isVendorInterface,
isIntraOrVendor,
isIntraOrIntraHoldingOrVendor,
followUpDisabled,
isArchived,
Expand Down Expand Up @@ -818,7 +816,6 @@ export default {
tmpContactId,
courseHistoryFeed,
tmpCourse,
isIntraCourse,
trainingContractTableLoading,
trainingContracts,
canUpdateInterlocutor,
Expand All @@ -837,7 +834,6 @@ export default {
disableSms,
traineesEmails,
contactOptions,
isIntraOrVendor,
isIntraOrIntraHoldingOrVendor,
disableDocDownload,
followUpDisabled,
Expand Down
6 changes: 3 additions & 3 deletions src/core/components/courses/ProfileTraineeFollowUp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div>
<div class="q-mt-lg q-mb-xl">
<p class="text-weight-bold">Émargements</p>
<div v-if="isIntraOrVendor" class="q-mb-md">
<div v-if="isIntraOrIntraHoldingOrVendor" class="q-mb-md">
<ni-banner v-if="followUpDisabled">
<template #message>
Il manque {{ formatQuantity('information', followUpMissingInfo.length ) }}
Expand Down Expand Up @@ -128,7 +128,7 @@ export default {
const {
isClientInterface,
pdfLoading,
isIntraOrVendor,
isIntraOrIntraHoldingOrVendor,
isArchived,
disableDocDownload,
followUpDisabled,
Expand Down Expand Up @@ -265,7 +265,7 @@ export default {
unsubscribedAttendances,
columns,
pagination,
isIntraOrVendor,
isIntraOrIntraHoldingOrVendor,
learners,
learnersLoading,
expectationsQuestionnaireId,
Expand Down
7 changes: 1 addition & 6 deletions src/core/components/courses/TraineeTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
:style="col.style" :class="[col.classes, { 'border': props.rowIndex === 0 && !hideHeader}]">
<template v-if="col.name === 'actions' && canUpdateTrainees">
<div>
<ni-button icon="edit" @click="openTraineeEditionModal(props.row)"
:disable="!canEditTrainee(props.row) || !!course.archivedAt" />
<ni-button icon="edit" @click="openTraineeEditionModal(props.row)" :disable="!!course.archivedAt" />
<ni-button icon="close" @click="validateTraineeDeletion(props.row._id)" :disable="!!course.archivedAt" />
</div>
</template>
Expand Down Expand Up @@ -54,7 +53,6 @@ import TraineeEditionModal from '@components/courses/TraineeEditionModal';
import ResponsiveTable from '@components/table/ResponsiveTable';
import { NotifyNegative, NotifyWarning, NotifyPositive } from '@components/popup/notify';
import { frPhoneNumber } from '@helpers/vuelidateCustomVal';
import { useLearnersEdition } from '@composables/learnersEdition';
import ConnectedDot from './ConnectedDot';

export default {
Expand All @@ -76,8 +74,6 @@ export default {
const $q = useQuasar();
const $store = useStore();

const { canEditTrainee } = useLearnersEdition();

const traineePagination = ref({ rowsPerPage: 0, sortBy: 'lastname' });
const traineeEditionModal = ref(false);
const traineeModalLoading = ref(false);
Expand Down Expand Up @@ -213,7 +209,6 @@ export default {
resetTraineeEditionForm,
updateTrainee,
validateTraineeDeletion,
canEditTrainee,
};
},
};
Expand Down
24 changes: 11 additions & 13 deletions src/core/components/learners/ProfileCourses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@
<q-icon :name="props.expand ? 'expand_less' : 'expand_more'" />
</template>
<template v-else-if="col.name === 'name'">
<div @click.stop="goToCourseProfile(props)"
:class="props.row.type !== INTRA_HOLDING && 'clickable-name'">
{{ col.value }}
<div @click="$event.stopPropagation()">
<router-link :to="goToCourseProfile(props)" class="clickable-name">{{ col.value }}</router-link>
</div>
</template>
<template v-else>{{ col.value }}</template>
Expand Down Expand Up @@ -115,7 +114,6 @@
<script>
import { useStore } from 'vuex';
import { computed, ref } from 'vue';
import { useRouter } from 'vue-router';
import get from 'lodash/get';
import has from 'lodash/has';
import uniqBy from 'lodash/uniqBy';
Expand All @@ -132,7 +130,6 @@ import {
DD_MM_YYYY,
MONTH,
DAY,
INTRA_HOLDING,
} from '@data/constants';
import CompaniDate from '@helpers/dates/companiDates';
import CompaniDuration from '@helpers/dates/companiDurations';
Expand All @@ -157,7 +154,6 @@ export default {
},
setup () {
const $store = useStore();
const $router = useRouter();

const { isVendorInterface, isClientInterface } = useCourses();
const { getCountsByMonth, monthAxisLabels } = useCharts();
Expand Down Expand Up @@ -237,24 +233,27 @@ export default {
: 'activité eLearning réalisée'));

const goToCourseProfile = (props) => {
if (props.row.type === INTRA_HOLDING) return;
if (!isVendorInterface && props.row.subProgram.isStrictlyELearning) {
return $router.push({ name: 'ni elearning courses info', params: { courseId: props.row._id } });
return { name: 'ni elearning courses info', params: { courseId: props.row._id } };
}

if (!isVendorInterface) {
return $router.push({ name: 'ni courses info', params: { courseId: props.row._id } });
return {
name: 'ni courses info',
params: { courseId: props.row._id },
query: { defaultTab: 'traineeFollowUp' },
};
}

if (props.row.subProgram.isStrictlyELearning) {
return $router.push({ name: 'ni management elearning courses info', params: { courseId: props.row._id } });
return { name: 'ni management elearning courses info', params: { courseId: props.row._id } };
}

$router.push({
return {
name: 'ni management blended courses info',
params: { courseId: props.row._id },
query: { defaultTab: 'traineeFollowUp' },
});
};
};

const getUserCourses = async () => {
Expand Down Expand Up @@ -356,7 +355,6 @@ export default {
monthAxisLabels,
DD_MM_YYYY,
SHORT_DURATION_H_MM,
INTRA_HOLDING,
// Computed
userProfile,
eLearningCoursesOnGoing,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import get from 'lodash/get';
import useVuelidate from '@vuelidate/core';
import { required, requiredIf } from '@vuelidate/validators';
import AttendanceSheets from '@api/AttendanceSheets';
import { INTRA, INTER_B2B, DD_MM_YYYY } from '@data/constants';
import { INTER_B2B, DD_MM_YYYY } from '@data/constants';
import { formatIdentity, sortStrings } from '@helpers/utils';
import CompaniDate from '@helpers/dates/companiDates';
import { NotifyPositive, NotifyNegative, NotifyWarning } from '@components/popup/notify';
Expand Down Expand Up @@ -41,16 +41,16 @@ export const useAttendanceSheets = (
const attendanceSheetRules = computed(() => ({
newAttendanceSheet: {
file: { required },
trainee: { required: requiredIf(course.value.type !== INTRA) },
date: { required: requiredIf(course.value.type === INTRA) },
trainee: { required: requiredIf(course.value.type === INTER_B2B) },
date: { required: requiredIf(course.value.type !== INTER_B2B) },
},
}));

const v$ = useVuelidate(attendanceSheetRules, { newAttendanceSheet });

const attendanceSheetVisibleColumns = computed(() => (course.value.type === INTRA
? ['date', 'actions']
: ['trainee', 'actions']));
const attendanceSheetVisibleColumns = computed(() => (course.value.type === INTER_B2B
? ['trainee', 'actions']
: ['date', 'actions']));

const unsubscribedTrainees = computed(() => {
const traineesId = course.value.trainees.map(trainee => trainee._id);
Expand Down Expand Up @@ -105,6 +105,9 @@ export const useAttendanceSheets = (
if (course.value.archivedAt) {
return NotifyWarning('Vous ne pouvez pas ajouter de feuilles d\'émargement à une formation archivée.');
}
if (!course.value.companies.length) {
return NotifyWarning('Au moins une structure doit être rattachée à la formation.');
}

attendanceSheetAdditionModal.value = true;
};
Expand All @@ -117,7 +120,7 @@ export const useAttendanceSheets = (
const formatPayload = () => {
const { course: newAttendanceSheetCourse, file, trainee, date } = newAttendanceSheet.value;
const form = new FormData();
course.value.type === INTRA ? form.append('date', date) : form.append('trainee', trainee);
course.value.type === INTER_B2B ? form.append('trainee', trainee) : form.append('date', date);
form.append('course', newAttendanceSheetCourse);
form.append('file', file);

Expand Down
Loading