|
153 | 153 | self.editing_group = null |
154 | 154 | self._scheduledUpdate = false |
155 | 155 |
|
156 | | - // init semantic UI elements + setup multi-select behaviour |
157 | 156 | const initUI = () => { |
158 | 157 | try { $('.ui.checkbox', self.root).checkbox() } catch(e) {} |
159 | 158 | try { $('.ui.dropdown', self.root).dropdown() } catch(e) {} |
|
220 | 219 | self.markdown_editor = create_easyMDE(self.refs.terms) |
221 | 220 | self.markdown_editor_whitelist = create_easyMDE(self.refs.whitelist_emails, false, false, '200px') |
222 | 221 |
|
223 | | - // Si un event competition_loaded est arrivé avant le mount, l'appliquer maintenant |
224 | 222 | try { |
225 | 223 | if (self._pending_competition && self._pending_competition.terms) { |
226 | 224 | try { |
|
408 | 406 | try { $(self.refs.group_modal).modal('hide') } catch(e) { self.refs.group_modal.style.display = 'none' } |
409 | 407 | } |
410 | 408 |
|
411 | | - // submit create / update group (Form POST instead of JSON) |
412 | 409 | self.submit_group = () => { |
413 | 410 | const name = (self.refs.group_name && self.refs.group_name.value || '').trim() |
414 | 411 | if (!name) { |
|
446 | 443 | let url = '/competitions/' + pk + '/groups/create/' |
447 | 444 | if (self.editing_group && self.editing_group.id) url = '/competitions/' + pk + '/groups/' + self.editing_group.id + '/update/' |
448 | 445 |
|
449 | | - // Build FormData (classic Django POST format) |
450 | 446 | const form = new FormData() |
451 | 447 | form.append('name', name) |
452 | 448 | if (queue_id) form.append('queue_id', queue_id) |
|
500 | 496 | }) |
501 | 497 | } |
502 | 498 |
|
503 | | - // delete group (POST form-style) |
504 | 499 | self.delete_group = (group) => { |
505 | 500 | if (!confirm('Supprimer le groupe "' + group.name + '" ?')) return |
506 | 501 | const pk = compPk() |
507 | 502 | if (!pk) return |
508 | 503 | const url = '/competitions/' + pk + '/groups/' + group.id + '/delete/' |
509 | 504 |
|
510 | | - // Use an empty FormData (server only expects POST; no body required but consistent) |
511 | 505 | const form = new FormData() |
512 | 506 | form.append('dummy', '1') |
513 | 507 |
|
|
522 | 516 | if (!resp.ok) throw resp |
523 | 517 | return resp.json() |
524 | 518 | }).then(data => { |
525 | | - // remove from UI |
526 | 519 | self.available_groups = self.available_groups.filter(x => x.id !== group.id) |
527 | 520 | self.selected_group_ids = self.selected_group_ids.filter(x => x !== group.id) |
528 | 521 |
|
|
544 | 537 | } |
545 | 538 | } catch(e){ console.warn('setting checkboxes failed', e) } |
546 | 539 |
|
547 | | - // Si l'éditeur est prêt, appliquer tout de suite, sinon stocker en attente pour mount |
548 | 540 | try { |
549 | 541 | if (self.markdown_editor && self.markdown_editor.codemirror && typeof self.markdown_editor.codemirror.refresh === 'function') { |
550 | 542 | try { |
|
558 | 550 | } catch(e){ console.warn('apply competition_loaded to editors failed', e) } |
559 | 551 | return |
560 | 552 | } |
561 | | - } catch(e){ /* ignore */ } |
| 553 | + } catch(e){ |
| 554 | + } |
562 | 555 |
|
563 | | - // stocker la compétition pour l'appliquer lorsque mount aura créé les éditeurs |
564 | 556 | self._pending_competition = competition |
565 | 557 | }) |
566 | 558 |
|
|
0 commit comments