PageSourceSearch

https://appli.capiconsult.com/assets/js/pages/e-agreement/index-e5TJaGN.js

js capiconsult.com collected 2026-10-04 15:44:08 UTC 5,881 bytes, 152 lines download raw bytes

1import {presentConfirmationModal} from "utils";
2
3$(function () {
4    initTypeaheadStagiaire();
5});
6
7function createEmployeeCallback(data, me) {
8    const superContainerDialog = $(me).closest('.superContainerDialog');
9    const modalId = $(superContainerDialog).attr('id');
10    const $modal = $(`#${modalId}`).closest(`.modal`);
11
12    if (data.operationStatut === 'OK') {
13        LIST_DIALOG[modalId].modal('hide');
14        $('#form_stagiaires').append(data.viewEdit);
15        animateCSS('#stagiaire-' + data.idCapiUserStage, 'zoomIn');
16    } else {
17        if (data.duplicatedTrainee || data.duplicatedUser) {
18            presentConfirmationModal(
19                data.title,
20                data.content,
21                () => {
22                    $modal.find(`[name="ajout_stagiaire[askForDuplication]"]`).val(0);
23                    $modal
24                        .find(`[type="submit"]`)
25                        .trigger(`click`);
26
27                    return Promise.resolve();
28                },
29                {
30                    cancelCallback: () => {
31                        $modal.modal(`hide`);
32                    },
33                }
34            );
35        } else {
36            majView('#' + modalId, data.view);
37        }
38    }
39}
40
41export function selectEmployeeCallback(data, me) {
42    majView('#contSelectSalarie', data.view);
43    if (data.operationStatut === 'OK') {
44        $('#form_stagiaires').append(data.viewEdit);
45        animateCSS('#stagiaire-' + data.idCapiUserStage, 'zoomIn');
46
47    } else if (data.operationStatut === 'NOVALIDFORM') {
48        if (data.idDejaStagiaire > 0) {
49            animateCSS('#stagiaire-' + data.idDejaStagiaire, 'shake');
50        }
51    }
52    initTypeaheadStagiaire();
53}
54
55export function editEmployeeCallback(data, me) {
56    let contView = $(me).closest('.parentElementEdit');
57    let idContView = $(contView).attr('id');
58    majView('#' + idContView, data.view, true);
59}
60
61function initTypeaheadStagiaire() {
62    if (!$('#form_formSalarie').length) {
63        return;
64    }
65
66    const addTraineePath = $(`[name="addTraineePath"]`).val();
67    const mainEventId = $(`[name="mainEventId"]`).val();
68
69    let salaries = new Bloodhound({
70        datumTokenizer: datumTokenizerAvecAccent(['nom']),
71        queryTokenizer: queryTokenizerAvecAccent,
72        prefetch: {
73            url: Routing.generate('user_salaries_json', {
74                structure: ($('#form_formSalarie').data('type-entreprise') == 'entreprise' ? 'e' : 'a') + $('#form_formSalarie').data('id-entreprise'),
75                _csrf_token: $(`#form_formSalarie`).data(`csrf-users-json`),
76            }),
77            cache: false,
78        },
79    });
80
81    $('#form_formSalarie').tagsinput({
82        itemValue: 'id',
83        itemText: 'nom',
84        typeaheadjs: {
85            displayKey: 'nom',
86            source: salaries.ttAdapter(),
87            templates: {
88                suggestion: function (data) {
89                    let aRetourner = '<div><div>' + data.nom + '</div>';
90                    aRetourner += '<div class="color-gray">' + (data.email != '' ? data.email : 'Pas de mail') + '</div>';
91                    if (data.poste != null) {
92                        aRetourner += '<div class="color-gray"><i>' + data.poste + '</i></div></hr>';
93                    }
94                    aRetourner += '<hr/></div>';
95                    return aRetourner;
96                },
97                footer: function (data) {
98                    let aRetourner = `
99                        <div class="typeahead_contNotFound" style="padding: 3px 20px;">
100                            <div>Si le salarié n\'existe pas</div>
101                            <br/>
102                            <span class="btn btn-success text-white" 
103                                  onclick="ouvrirDialog(this)" 
104                                  data-titre="Créer un salarié" 
105                                  data-idcontaineur="dialogAjoutStagiaire${mainEventId}" 
106                                  data-url="${addTraineePath}" 
107                                  data-size="md"
108                            >
109                                Créer un salarié
110                            </span>
111                        </div>`;
112                    aRetourner += '</div>';
113                    return aRetourner;
114                },
115                notFound: function (data) {
116                    let aRetourner = `
117                        <div class="typeahead_contNotFound" style="padding: 3px 20px;">
118                            <div>Le salarié n\'existe pas.</div>
119                            <br/>
120                            <span class="btn btn-success text-white" 
121                                  onclick="ouvrirDialog(this)" 
122                                  data-titre="Créer un salarié" 
123                                  data-idcontaineur="dialogAjoutStagiaire${mainEventId}" 
124                                  data-url="${addTraineePath}" 
125                                  data-size="md"
126                            >
127                                Créer un salarié
128                            </span>
129                        </div>`;
130                    aRetourner += '</div>';
131                    return aRetourner;
132                }
133            }
134        },
135    });
136
137    $('#form_formSalarie').on('itemAdded itemRemoved', function () {
138        checkTagsInput();
139    });
140}
141
142function checkTagsInput() {
143    const tagContainer = document.querySelector('.bootstrap-tagsinput');
144    const submitBtn = document.getElementById('submitBtn');
145
146    // Si des tags sont présents, activer le bouton, sinon le désactiver
147    submitBtn.disabled = !(tagContainer && tagContainer.querySelectorAll('.tag').length > 0);
148}
149
150window.createEmployeeCallback = createEmployeeCallback;
151window.selectEmployeeCallback = selectEmployeeCallback;
152window.editEmployeeCallback = editEmployeeCallback;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.