Commit a1605066 authored by Denis S. Valdenaire's avatar Denis S. Valdenaire

modif des listes simples en modal

parent 908f323d
......@@ -30,6 +30,9 @@ class Payment_Method extends Record {
return $payment_method;
}
// FIXME : hey you can't just delete like that
// if the payment method is used somewhere, that
// can't be done
public static function delete($id) {
// SQL SELECT payment_methods
$sql = " SELECT id
......
<div class="panel panel-default">
<div class="panel-heading">
<h4>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">
<span class="glyphicon glyphicon-list-alt" style="margin-right: 10px;" ></span>
{% if object.id %} Catégorie ESAR : {{ object.name }} {% else %} Nouvelle catégorie ESAR {% endif %}
</h4>
</h4>
</div>
<div class="panel-body">
<div class="modal-body">
<div class="form-group">
<label class="control-label col-sm-2" for="name">Nom</label>
<div class="col-sm-4">
......@@ -17,16 +18,19 @@
<input type="text" id="label" name="label" class="form-control" value="{{ object.label }}"/>
</div>
</div>
<div class="form-group">
<div class="col-sm-12" align="center">
<input type="button" class="btn btn-primary" id="back_button" value="&lt;&lt; Retour à la liste">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
{% if object.id != 0 %}
<input type="hidden" id="esar_category_id" value="{{ object.id }}">
<input type="submit" class="btn btn-success" id="save_button" value="Enregistrer les changements">
<input type="button" class="btn btn-danger" id="delete_button" value="Supprimer">
{% else %}
<input type="hidden" id="esar_category_id" value="0">
<input type="button" class="btn btn-success" id="save_button" value="Créer">
{% endif %}
</div>
</div>
</div>
<!-- end of panel -->
......@@ -40,9 +44,10 @@ $('#save_button').click(function(){
alert ("Vous n'avez pas saisi de nom !");
return false;
}
if($('#i').val() == 0) {
if($('#esar_category_id').val() == 0) {
$('#a').val('create');
} else {
$('#i').val($('#esar_category_id').val());
$('#a').val('update');
}
document.defaultform.submit();
......@@ -57,9 +62,4 @@ $('#delete_button').click(function(){
document.defaultform.submit();
}
});
$('#back_button').click(function(){
// TODO this function should verify that the object has not been modified
// and if yes, ask for confirmation from the user.
window.location.href='index.php?o=esar_categories&a=list';
});
</script>
{% extends "base.html" %}
{% block title %}Catalogue des jeux{% endblock %}
{% block title %}Catégories ESAR{% endblock %}
{% block content %}
<div class="panel panel-default">
<div class="panel-heading">
......@@ -8,10 +8,11 @@
Catégories ESAR
</span>
<span class="btn btn-success btn-md" style="float: right" id="new_button">
<i class="glyphicon glyphicon-plus"></i>
<span>Nouvelle catégorie...</span>
</span>
<button type="button" class="btn btn-success btn-md" style="float: right"
data-toggle="modal" data-target="#editModal" data-id="0">
<i class="glyphicon glyphicon-plus"></i>
<span>Nouvelle catégorie...</span>
</button>
</div>
</div>
......@@ -23,17 +24,28 @@
<tr>
<th>Label</th>
<th>Description</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for key, val in objects %}
<tr>
<td>
<a href="index.php?o=esar_categories&a=edit&i={{ val.id }}">{{ val.label }}</a>
{{ val.label }}
</td>
<td>
{{ val.name }}
</td>
<td align="center">
<button type="button" class="btn btn-success btn-xs"
data-toggle="modal" data-target="#editModal" data-id="{{ val.id }}">
<i class="glyphicon glyphicon-edit"></i>
</button>
<a onClick="if(confirm('Êtes vous sur ?')) { $('#a').val('delete'); $('i').val('{{ val.id }}'); defaultform.submit()}" href="#">
<button type="button" class="btn btn-danger btn-xs">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
</a>
</td>
</tr>
{% else %}
<tr>
......@@ -49,6 +61,14 @@
<!-- end of panel -->
</div>
</div>
<!-- edit modal skel -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModalLabel">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
<!-- end edit modal -->
<script>
$(document).ready(function() {
......@@ -58,11 +78,17 @@ $(document).ready(function() {
$(this).show();
}
});
$('#new_button').click(function(){
$('#a').val('new');
defaultform.submit();
});
$("#editModal").on("show.bs.modal", function(e) {
var button = $(e.relatedTarget);
if(button.data('id') == 0) {
$(this).find(".modal-content").load("index.php?o=esar_categories&a=new");
} else {
$(this).find(".modal-content").load("index.php?o=esar_categories&a=edit&i=" + button.data('id'));
}
}).on("hidden.bs.modal", function(e) {
$(this).find(".modal-content").empty();
});
});
/* FIXME : translation of the table
see https://datatables.net/plug-ins/i18n/French
......
{% for key, val in global['ihm_message'] %}
<div class="alert alert-{{ val.level }} alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
{{ val.msg }}
</div>
{% endfor %}
{% extends "base.html" %}
{% block title %}Catalogue des jeux{% endblock %}
{% block title %}{{ member.lastname }} {{ member.firstname }} - Adhésions{% endblock %}
{% block content %}
<div class="panel panel-default">
<div class="panel-heading">
......@@ -9,7 +9,7 @@
</span>
<span style="font-size: 150%; font-weight: bold">&nbsp;{{ member.lastname }} {{ member.firstname }} - Adhésions&nbsp;</span>
<button type="button" class="btn btn-success btm-md" style="float: right"
<button type="button" class="btn btn-success btn-md" style="float: right"
data-toggle="modal" data-target="#editModal" data-id="0">
<i class="glyphicon glyphicon-plus"></i>
<span>Nouvelle adhésion...</span>
......@@ -42,7 +42,7 @@
<td>{{ val.comments }}</td>
<td>
<button type="button" class="btn btn-success btm-md"
<button type="button" class="btn btn-success btn-sm"
data-toggle="modal" data-target="#editModal" data-id="{{ val.id }}">
<i class="glyphicon glyphicon-edit"></i>
</button>
......
......@@ -5,7 +5,7 @@
Types d'adhésion
</span>
<span class="btn btn-success btm-md" style="float: right" id="new_button">
<span class="btn btn-success btn-md" style="float: right" id="new_button">
<i class="glyphicon glyphicon-plus"></i>
<span>Nouveau type</span>
</span>
......@@ -29,7 +29,7 @@
<th>{{ val.name }}</th>
<td>{{ val.description }}</td>
<td>{{ val.price }}</td>
<td>
<td align="center">
<a href="index.php?o=membership_types&a=edit&i={{ val.id }}">
<button type="button" class="btn btn-default btn-sm">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span></button>
......
......@@ -161,4 +161,3 @@ $('#delete_button').click(function(){
}
});
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment