Projekt

Obecné

Profil

Stáhnout (1.73 KB) Statistiky
| Větev: | Revize:
1
<div id="remove-modal" class="modal fade" role="dialog">
2
	<div class="modal-dialog modal-dialog-centered" role="document">
3
		<div class="modal-content">
4
			 <div class="modal-header">
5
					<h4 class="modal-title">Potvrdit odstranění</h4>
6
					<button type="button" class="close" data-dismiss="modal">&times;</button>
7
			 </div>
8
			 <div class="modal-body">
9
				<div class="container">
10
					<div class="row">
11
                        <p id="mesBody"></p>
12
                    </div>
13
				</div>
14
			 </div>
15
			 <div class="modal-footer">
16
                <button type="button" class="btn btn-default" data-dismiss="modal" onclick="removeUser(document.getElementById('idToRemoveInput').value)">Ano</button>
17
                <button type="button" class="btn btn-default" data-dismiss="modal">Ne</button>
18
				<input type="hidden" id="idToRemoveInput" />
19
			</div>
20
		</div>
21
	</div>
22
</div>
23

    
24
<script>
25
    $('#remove-modal').on('show.bs.modal', function (event){ //wait for modal to show 
26
        const button = $(event.relatedTarget);
27
        const pseudo_id = button.data('pseudo-id');//Extract info from data-* attributes
28

    
29
        const data_obj = users[pseudo_id];
30
        let modal = $(this);
31

    
32
		modal.find('#mesBody').text("Opravdu chcete odstranit uživatele  \"" + data_obj.username + "\"?");
33
		modal.find('#idToRemoveInput').val(data_obj.id); //assign id to delete to hidden input
34
    });
35

    
36
	function removeUser(id){
37
		const data = new FormData(); //to pass ids, which we want to delete from DB
38
		data.append("userId", ""+id); //id to delete from table dd_wordform
39

    
40
		let xhr = new XMLHttpRequest();
41
		xhr.open("POST", "./controller/DeleteUserController.php");
42
		xhr.send(data);
43
		setTimeout(function(){
44
			fetchUsers(); //reload data after item delete
45
		}, 500);
46
	}
47
</script>
(9-9/10)