Revize 9359b9a1
Přidáno uživatelem Ondřej Anděl před více než 3 roky(ů)
application/view/modals/editModal.html | ||
---|---|---|
25 | 25 |
</div> |
26 | 26 |
<div class="row my-1"> |
27 | 27 |
<div class="col-xs-12 col-sm-4"> |
28 |
<label for="manuscript-m">Rukopisy:</label> |
|
28 |
<label for="manuscript-m">Rukopisy: <b class="required">*</b></label>
|
|
29 | 29 |
</div> |
30 | 30 |
<div class="col-xs-12 col-sm-8"> |
31 | 31 |
<select id="manuscript-m" multiple> |
... | ... | |
331 | 331 |
modal.find('#submit-but').click(() => createData(modal)); |
332 | 332 |
|
333 | 333 |
enableSubmit(modal); |
334 |
manuChange(modal); |
|
334 | 335 |
modal.find("#lemma_edit").change(() => enableSubmit(modal)); |
335 | 336 |
modal.find("#word").change(() => enableSubmit(modal)); |
336 | 337 |
modal.find("#position").change(() => enableSubmit(modal)); |
337 | 338 |
modal.find("#wordclass").change(() => enableSubmit(modal)); |
339 |
modal.find("#manuscript-m").change(() => manuChange(modal)); |
|
338 | 340 |
} else { |
339 | 341 |
const data_obj = data[pseudo_id]; |
340 | 342 |
modal.find('#submit-but').text("Upravit"); |
... | ... | |
346 | 348 |
irregularMChange(modal); |
347 | 349 |
|
348 | 350 |
enableSubmit(modal); |
351 |
manuChange(modal); |
|
349 | 352 |
modal.find("#lemma_edit").change(() => enableSubmit(modal)); |
350 | 353 |
modal.find("#word").change(() => enableSubmit(modal)); |
351 | 354 |
modal.find("#position").change(() => enableSubmit(modal)); |
352 | 355 |
modal.find("#wordclass").change(() => enableSubmit(modal)); |
356 |
modal.find("#manuscript-m").change(() => manuChange(modal)); |
|
353 | 357 |
} |
354 | 358 |
}); |
355 | 359 |
|
... | ... | |
629 | 633 |
|
630 | 634 |
modal.find("#word").val(data.word); |
631 | 635 |
modal.find("#lemma_edit").val(data.lemma.lemma); |
632 |
modal.find("#manuscript-m").val(data.manuscript);//TODO not sure if this one works... kinda does what it wants
|
|
636 |
setManuscriptValue(modal, data.manuscript);
|
|
633 | 637 |
|
634 | 638 |
//dynamic setting |
635 | 639 |
const morphem = data.tag.tag; |
... | ... | |
663 | 667 |
} |
664 | 668 |
|
665 | 669 |
function enableSubmit(modal) { |
670 |
|
|
671 |
let ms_value = getManuscriptValue(modal); |
|
666 | 672 |
if ( |
667 | 673 |
modal.find("#lemma_edit")[0].value === "" || |
668 | 674 |
modal.find("#word")[0].value === "" || |
669 | 675 |
modal.find("#position")[0].value === "" || |
670 |
modal.find("#wordclass")[0].value === "" |
|
676 |
modal.find("#wordclass")[0].value === "" || |
|
677 |
ms_value === undefined || |
|
678 |
ms_value === null || |
|
679 |
ms_value.length === 0 |
|
671 | 680 |
) { |
672 | 681 |
modal.find("#submit-but").prop("disabled", true); |
673 | 682 |
} else { |
... | ... | |
705 | 714 |
formData.append("word", modal.find("#word")[0].value); |
706 | 715 |
formData.append("lemma", modal.find("#lemma_edit")[0].value); |
707 | 716 |
|
708 |
//this is to get data from manuscript --> possible better? |
|
709 |
var elements = modal.find("#manuscript-m").data('multiSelectContainer').find('input:checked'); |
|
710 |
let ms_value = []; |
|
711 |
Object.values(elements).forEach((item) => { |
|
712 |
if(item.value !== undefined){ |
|
713 |
ms_value.push(""+item.value); |
|
714 |
} |
|
715 |
}); |
|
717 |
//this is to get data from manuscript |
|
718 |
let ms_value = getManuscriptValue(modal); |
|
716 | 719 |
|
717 | 720 |
formData.append("manuscript", ms_value.join()); |
718 | 721 |
formData.append("context", modal.find("#context")[0].value); |
... | ... | |
759 | 762 |
return formData; |
760 | 763 |
} |
761 | 764 |
|
765 |
function getManuscriptValue(modal){ |
|
766 |
var elements = modal.find("#manuscript-m").data('multiSelectContainer').find('input:checked'); |
|
767 |
let ms_value = []; |
|
768 |
Object.values(elements).forEach((item) => { |
|
769 |
if(item.value !== undefined){ |
|
770 |
ms_value.push(""+item.value); |
|
771 |
} |
|
772 |
}); |
|
773 |
return ms_value; |
|
774 |
} |
|
775 |
|
|
776 |
function setManuscriptValue(modal, value){ |
|
777 |
var elements = modal.find("#manuscript-m").data('multiSelectContainer').find('input'); |
|
778 |
Object.values(elements).forEach((item) => { |
|
779 |
if(value.includes(parseInt(item.value))){ |
|
780 |
item.checked = true; |
|
781 |
} else { |
|
782 |
item.checked = false; |
|
783 |
} |
|
784 |
}); |
|
785 |
} |
|
786 |
|
|
787 |
function manuChange(modal){ |
|
788 |
var elements = modal.find("#manuscript-m").data('multiSelectContainer').find('input:checked'); |
|
789 |
let docCount = 0; |
|
790 |
Object.values(elements).forEach((item) => { |
|
791 |
if(item.value !== undefined){ |
|
792 |
docCount++; |
|
793 |
} |
|
794 |
}); |
|
795 |
|
|
796 |
let extra = ""; |
|
797 |
if(docCount === 1){ |
|
798 |
extra += " rukopis"; |
|
799 |
} else if(docCount < 5){ |
|
800 |
extra += " rukopisy"; |
|
801 |
} else { |
|
802 |
extra += " rukopisů"; |
|
803 |
} |
|
804 |
modal.find(".multi-select-button")[0].innerText = docCount+extra; |
|
805 |
|
|
806 |
enableSubmit(modal); |
|
807 |
} |
|
808 |
|
|
762 | 809 |
function moodMChange(modal) { |
763 | 810 |
if(modal.find("#mood")[0].value !== ""){ |
764 | 811 |
modal.find("#irregular").prop('disabled', true); |
Také k dispozici: Unified diff
Bug #8759: Opravit pole manuscriptu