Revize 6c152ae0
Přidáno uživatelem Ondřej Drtina před téměř 4 roky(ů)
application/model/DB.php | ||
---|---|---|
648 | 648 |
} |
649 | 649 |
|
650 | 650 |
function remove(){ |
651 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_wordform ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
652 |
if (array_key_exists("id", $_POST) && $_POST['id'] != "") { |
|
653 |
$query = "DELETE FROM dd_wordform WHERE"; |
|
654 |
$query .= " id = :id ;"; |
|
655 |
$this->stmt = $this->pdo->prepare($query); |
|
656 |
$this->stmt->bindParam(':id', $_POST['id'], PDO::PARAM_INT); |
|
657 |
$this->stmt->execute(); |
|
658 |
} |
|
651 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_manuscript ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
652 |
if (array_key_exists("id", $_POST) && $_POST['id'] != "") { |
|
653 |
$query = "DELETE FROM dd_manuscript WHERE"; |
|
654 |
$query .= " wordform_id = :wordform_id ;"; |
|
655 |
$this->stmt = $this->pdo->prepare($query); |
|
656 |
$this->stmt->bindParam(':wordform_id', $_POST['id'], PDO::PARAM_INT); |
|
657 |
$this->stmt->execute(); |
|
658 |
} |
|
659 |
|
|
659 | 660 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_lemma ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
660 | 661 |
|
661 |
if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") { |
|
662 |
/*if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") {
|
|
662 | 663 |
$query = "DELETE FROM dd_lemma WHERE"; |
663 | 664 |
$query .= " id = :lemma_id ;"; |
664 | 665 |
$this->stmt = $this->pdo->prepare($query); |
665 | 666 |
$this->stmt->bindParam(':lemma_id', $lemma["id"], PDO::PARAM_INT); |
666 | 667 |
$this->stmt->execute(); |
667 |
} |
|
668 |
} TODO: fix lemma*/
|
|
668 | 669 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_tag ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
669 | 670 |
|
670 |
if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") { |
|
671 |
/*if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") {
|
|
671 | 672 |
$query = "DELETE FROM dd_tag WHERE"; |
672 | 673 |
$query .= " id = :tag_id ;"; |
673 | 674 |
$this->stmt = $this->pdo->prepare($query); |
674 | 675 |
$this->stmt->bindParam(':tag_id', $tag["id"], PDO::PARAM_INT); |
675 | 676 |
$this->stmt->execute(); |
676 |
} |
|
677 |
|
|
678 |
|
|
679 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_manuscript ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
|
680 |
|
|
681 |
if (array_key_exists("wordform_id", $_POST) && $_POST['wordform_id'] != "") { |
|
682 |
$query = "DELETE FROM dd_manuscript WHERE"; |
|
683 |
$query .= " wordform_id = :wordform_id ;"; |
|
684 |
$this->stmt = $this->pdo->prepare($query); |
|
685 |
$this->stmt->bindParam(':wordform_id', $_POST['wordform_id'], PDO::PARAM_INT); |
|
686 |
$this->stmt->execute(); |
|
687 |
} |
|
688 |
|
|
677 |
} TODO: fix tag */ |
|
689 | 678 |
|
690 | 679 |
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_wordform ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
691 | 680 |
if (array_key_exists("id", $_POST) && $_POST['id'] != "") { |
application/view/Index.php | ||
---|---|---|
8 | 8 |
// (A1) GET SEARCH TERM |
9 | 9 |
var data = new FormData(); |
10 | 10 |
//data.append("manuscript", "0,3"); //příklad pro filtraci manuscriptů, asi se ještě uprav |
11 |
data.append("page", "0"); |
|
11 |
/* data.append("page", "0");
|
|
12 | 12 |
data.append("items_per_page", "50"); |
13 | 13 |
data.append("lemma", "megaultranováLemma"); |
14 | 14 |
data.append("word", "novéWord2"); |
... | ... | |
24 | 24 |
data.append("positiondetail", "posdet"); |
25 | 25 |
data.append("prefix", "prefix"); |
26 | 26 |
data.append("suffix", "suffix"); |
27 |
data.append("id", 9); |
|
27 |
data.append("id", 9);*/ |
|
28 |
|
|
29 |
data.append("id", 4); |
|
30 |
data.append("wordform_id", 4); |
|
28 | 31 |
//data.append("lemma_id", 3686); |
29 | 32 |
//data.append("tag_id", 1219); |
30 |
data.append("pos", 6); |
|
33 |
/*data.append("pos", 6);
|
|
31 | 34 |
data.append("manuscript", [1,2,3,4,5]); |
32 | 35 |
data.append("wordform_id", 9); |
33 |
data.append("tag", "A---------"); |
|
36 |
data.append("tag", "A---------");*/
|
|
34 | 37 |
//data.append("finished", "false"); |
35 | 38 |
// data.append("tag_pos", "V"); |
36 | 39 |
// data.append("tag_verb_aspect", "P"); |
application/view/modals/removeModal.html | ||
---|---|---|
8 | 8 |
<div class="modal-body"> |
9 | 9 |
<div class="container"> |
10 | 10 |
<div class="row"> |
11 |
<p>Opravdu chcete odstranit zvolený záznam?</p>
|
|
11 |
<p id="mesBody"></p>
|
|
12 | 12 |
</div> |
13 | 13 |
</div> |
14 | 14 |
</div> |
15 | 15 |
<div class="modal-footer"> |
16 |
<button type="button" class="btn btn-default" data-dismiss="modal" onclick="removeSelectedItem()">Ano</button> |
|
16 |
<button type="button" class="btn btn-default" data-dismiss="modal" onclick="removeSelectedItem(document.getElementById('idToRemoveInput').value)">Ano</button>
|
|
17 | 17 |
<button type="button" class="btn btn-default" data-dismiss="modal">Ne</button> |
18 |
</div> |
|
18 |
<input type="hidden" id="idToRemoveInput" /> |
|
19 |
</div> |
|
19 | 20 |
</div> |
20 | 21 |
</div> |
21 | 22 |
</div> |
22 | 23 |
|
23 | 24 |
<script> |
24 |
$('#remove-modal').on('show.bs.modal', function (event){ |
|
25 |
$('#remove-modal').on('show.bs.modal', function (event){ //wait for modal to show
|
|
25 | 26 |
const button = $(event.relatedTarget); |
26 | 27 |
const pseudo_id = button.data('pseudo-id');//Extract info from data-* attributes |
27 | 28 |
|
28 | 29 |
const data_obj = data[pseudo_id]; |
29 | 30 |
let modal = $(this); |
30 | 31 |
|
31 |
alert("id: " + data_obj.id); |
|
32 |
modal.find('#mesBody').text("Opravdu chcete odstranit záznam týkající se slova \"" + data_obj.word + "\"?"); |
|
33 |
modal.find('#idToRemoveInput').val(data_obj.id); //assign id to delete to hidden input |
|
32 | 34 |
}); |
33 | 35 |
</script> |
application/view/searchContent.php | ||
---|---|---|
562 | 562 |
<h3 id="no-data-label" class="mx-auto text-center font-italic">Žádná data nebyla nalezena</h3> |
563 | 563 |
|
564 | 564 |
<script> |
565 |
function removeSelectedItem(){ |
|
565 |
function removeSelectedItem(idToDelete){
|
|
566 | 566 |
const data = new FormData(); //to pass ids, which we want to delete from DB |
567 |
data.append("id", ""+4); //id to delete from table dd_wordform |
|
568 |
data.append("wordform_id", ""+4); //id to delete from M:N table dd_manuscript (prolly the same as above...) |
|
567 |
data.append("id", ""+idToDelete); //id to delete from table dd_wordform |
|
569 | 568 |
|
570 | 569 |
let xhr = new XMLHttpRequest(); |
571 | 570 |
xhr.open("POST", "./controller/RemoveController.php"); |
572 |
xhr.onload = function(){ |
|
573 |
alert("loaded"); |
|
574 |
}; |
|
575 | 571 |
xhr.send(data); |
576 |
alert("removing item: 4");
|
|
572 |
fetchData(true); //reload data after item delete
|
|
577 | 573 |
} |
578 | 574 |
|
579 | 575 |
function checkValidItemsPerPage(){ |
Také k dispozici: Unified diff
funkční remove, ještě opravím drobnosti (err v console.log) - nicméně funguje