@@ -12,7 +12,7 @@ function setSlotMisssion(mission, $slot) {
1212
1313 missionsText += $ ( '<span class="badge badge-secondary">' ) . text ( mission . type ? mission . type . name : 'mission' ) [ 0 ] . outerHTML ;
1414 missionsText += ' ' ;
15- missionsText += $ ( `<button type="button" class="btn btn-link" data-toggle="modal" data-target="#modal-mission " data-mission-id="${ mission . id } ">` ) . text ( mission . name ) [ 0 ] . outerHTML ;
15+ missionsText += $ ( `<button type="button" class="btn btn-link" data-toggle="modal" data-target="#modal-ajax " data-mission-id="${ mission . id } ">` ) . text ( mission . name ) [ 0 ] . outerHTML ;
1616
1717 $slot . addClass ( 'mission' ) . data ( 'mission-text' , missionsText ) ;
1818}
@@ -137,48 +137,42 @@ export function fetchMissions() {
137137 } ) ;
138138}
139139
140- export function initMissionsEvents ( ) {
141- $ ( '#modal-mission' )
140+ export function initMissionsPlanningEvents ( ) {
141+ $ ( '#modal-add- mission' )
142142 . on ( 'show.bs.modal' , function ( event ) {
143143 const $modal = $ ( this ) ;
144144 const $link = $ ( event . relatedTarget ) ;
145- const missionId = $link . data ( 'mission-id ' ) ;
145+ const url = $link . data ( 'href ' ) ;
146146
147- displayMissionModal ( $modal , missionId ) ;
147+ displayAjaxModal ( $modal , url ) ;
148148 } )
149149 . on ( 'hidden.bs.modal' , function ( ) {
150150 const $modal = $ ( this ) ;
151151 $modal . find ( '.loading' ) . show ( ) ;
152152 $modal . find ( '.content' ) . html ( '' ) ;
153153 } ) ;
154154
155- $ ( '#modal-add-mission' )
155+ $ ( document ) . on ( 'click' , '.mission-choose' , function ( ) {
156+ addUserToMission ( $ ( this ) . data ( 'href' ) ) ;
157+ } ) ;
158+ }
159+
160+ export function initMissionsEvents ( ) {
161+ $ ( '#modal-ajax' )
156162 . on ( 'show.bs.modal' , function ( event ) {
157163 const $modal = $ ( this ) ;
158164 const $link = $ ( event . relatedTarget ) ;
159- const url = $link . data ( 'href ' ) ;
165+ const missionId = $link . data ( 'mission-id ' ) ;
160166
161- displayAjaxModal ( $modal , url ) ;
167+ if ( ! missionId ) {
168+ return ;
169+ }
170+
171+ displayMissionModal ( $modal , missionId ) ;
162172 } )
163173 . on ( 'hidden.bs.modal' , function ( ) {
164174 const $modal = $ ( this ) ;
165175 $modal . find ( '.loading' ) . show ( ) ;
166176 $modal . find ( '.content' ) . html ( '' ) ;
167177 } ) ;
168-
169- $ ( document ) . on ( 'click' , '.mission-choose' , function ( ) {
170- addUserToMission ( $ ( this ) . data ( 'href' ) ) ;
171- } ) ;
172-
173- // Allow modals stacking
174- $ ( document ) . on ( 'show.bs.modal' , '.modal' , function ( ) {
175- const zIndex = 1040 + 10 * $ ( '.modal:visible' ) . length ;
176- $ ( this ) . css ( 'z-index' , zIndex ) ;
177- setTimeout ( function ( ) {
178- $ ( '.modal-backdrop' )
179- . not ( '.modal-stack' )
180- . css ( 'z-index' , zIndex - 1 )
181- . addClass ( 'modal-stack' ) ;
182- } ) ;
183- } ) ;
184178}
0 commit comments