Added popup functionality and Library
* doPopup() JavaScript call creates a centered popup div with user defined width, height, title, content, and calls an optional callback function * Library with currently non-modifiable book list, and a popup with the books' details Signed-off-by: Gergely Polonkai <polesz@w00d5t0ck.info>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
{# vim: ft=htmljinja
|
||||
#}
|
||||
<p>
|
||||
<strong>Szerző:</strong> {{ book.author }}<br />
|
||||
<strong>Cím:</strong> {{ book.title }}<br />
|
||||
<strong>Kiadás éve:</strong> {{ book.year }}<br />
|
||||
</p>
|
||||
<p>
|
||||
Nekem van <strong>{{ book.usersCopies(app.user)|length }}</strong>, ebből kölcsön van adva <strong>X</strong>.<br />
|
||||
A teljes közösségnek összesen <strong>{{ book.copies|length }}</strong> példánya van.<br />
|
||||
Kölcsönkérhető <strong>{{ book.copiesBorrowable|length }}</strong> példány, ebből <strong>{{ book.copiesBorrowedByUser(app.user)|length }}</strong> nálam van.<br />
|
||||
</p>
|
||||
<p>
|
||||
{% if book.usersCopies(app.user)|length == 0 %}
|
||||
<span class="gomb add-copy-button" id="add-copy-button-{{ book.id }}">[Nekem is van egy]</span>
|
||||
{% else %}
|
||||
<span class="gomb delete-copy-button" id="delete-copy-button-{{ book.id }}">[Nincs már]</span>
|
||||
{# TODO
|
||||
<span class="gomb">[Eladtam valakinek a körben]</span>
|
||||
#}
|
||||
{% if book.usersCopiesBorrowable(app.user)|length == 0 %}
|
||||
<span class="gomb mine-is-borrowable-button" id="mine-is-borrowable-button-{{ book.id }}">[Az enyém is kölcsönkérhető]</span>
|
||||
{% else %}
|
||||
<span class="gomb mine-is-not-borrowable-button" id="mine-is-not-borrowable-button-{{ book.id }}">[Nem szeretném kölcsönadni]</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if book.usersCopies(app.user)|length > 0 %}
|
||||
{% if book.usersCopiesBuyable(app.user)|length == 0 %}
|
||||
<span class="gomb mine-is-for-sale-button" id="mine-is-for-sale-button-{{ book.id }}">[Az enyém eladó]</span>
|
||||
{% else %}
|
||||
<span class="gomb mine-is-not-for-sale-button" id="mine-is-not-for-sale-button-{{ book.id }}">[Nem szeretném eladni]</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if book.copiesBorrowedByUser(app.user)|length == 0 and book.usersCopies(app.user)|length == 0 and not book.userWouldBorrow(app.user) %}
|
||||
<span class="gomb want-to-borrow-button" id="want-to-borrow-button-{{ book.id }}">[Kérek egyet kölcsön]</span>
|
||||
{% endif %}
|
||||
|
||||
{% if book.usersCopies(app.user)|length == 0 and not book.userWouldBuy(app.user) %}
|
||||
<span class="gomb want-to-buy-button" id="want-to-buy-button-{{ book.id }}">[Vennék egyet]</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% if book.wouldBuy|length > 0 %}
|
||||
<p>
|
||||
Ők szeretnének egyet kölcsönkérni:<br />
|
||||
<ul>
|
||||
{% for user in book.wouldBorrow %}
|
||||
<li>{{ user|userdataspan }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if book.wouldBuy|length > 0 %}
|
||||
<p>
|
||||
Ők szeretnének venni egyet:<br />
|
||||
<ul>
|
||||
{% for user in book.wouldBuy %}
|
||||
<li>{{ user|userdataspan }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</p>
|
||||
{% endif %}
|
133
src/KekRozsak/FrontBundle/Resources/views/Book/list.html.twig
Normal file
133
src/KekRozsak/FrontBundle/Resources/views/Book/list.html.twig
Normal file
@@ -0,0 +1,133 @@
|
||||
{# vim: ft=htmljinja
|
||||
#}
|
||||
{% extends '::main_template.html.twig' %}
|
||||
{% block title %} - Könyvtár{% endblock %}
|
||||
{% block content %}
|
||||
<h3>Könyvtár</h3>
|
||||
[Saját könyveim] [Nálam lévő kölcsönzött könyvek]
|
||||
{% if books|length > 0 %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Szerző</td>
|
||||
<td>Cím</td>
|
||||
<td>Év</td>
|
||||
<td>Összes</td>
|
||||
<td>Kölcsönözhető</td>
|
||||
<td>Saját</td>
|
||||
<td>Nálam (Vissza)</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for book in books %}
|
||||
<tr class="book-row popup-opener" id="book-{{ book.id }}">
|
||||
<td class="popup-opener">{{ book.author }}</td>
|
||||
<td>{{ book.title }}</td>
|
||||
<td>{{ book.year }}</td>
|
||||
<td>{{ book.copies|length }}</td>
|
||||
<td>{{ book.copiesBorrowable|length }}</td>
|
||||
<td>{{ book.usersCopies(app.user)|length }}</td>
|
||||
<td>{{ book.copiesBorrowedByUser(app.user)|length }} ({{ book.copiesBorrowedReturnedByUser(app.user)|length }})</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block bottomscripts %}
|
||||
<script type="text/javascript">
|
||||
$('.book-row').click(function() {
|
||||
bookid = 0;
|
||||
if (!$(this).attr('id').match(/^book-\d+$/))
|
||||
return false;
|
||||
bookid = $(this).attr('id').replace(/^book-/, '');
|
||||
bookUrl = Routing.generate('KekRozsakFrontBundle_bookAjaxData', { id: bookid, _format: 'html' });
|
||||
bookCallback = function() {
|
||||
// TODO: Change alert() calls to HTML flashes
|
||||
$('.delete-copy-button').click(function() {
|
||||
bookid = 0;
|
||||
if (!$(this).attr('id').match(/^delete-copy-button-\d+$/))
|
||||
return false;
|
||||
bookid = $(this).attr('id').replace(/^delete-copy-button-/, '');
|
||||
url = Routing.generate('KekRozsakFrontBundle_bookDeleteCopy', { id: bookid });
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: url
|
||||
}).done(function() {
|
||||
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
|
||||
}).error(function() {
|
||||
alert('Nem sikerült törölni');
|
||||
});
|
||||
});
|
||||
|
||||
$('.add-copy-button').click(function() {
|
||||
bookid = 0;
|
||||
if (!$(this).attr('id').match(/^add-copy-button-\d+$/))
|
||||
return false;
|
||||
bookid = $(this).attr('id').replace(/^add-copy-button-/, '');
|
||||
url = Routing.generate('KekRozsakFrontBundle_bookAddCopy', { id: bookid });
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: url
|
||||
}).done(function() {
|
||||
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
|
||||
}).error(function() {
|
||||
alert('Nem sikerült bejegyezni ezt a példányt');
|
||||
});
|
||||
});
|
||||
|
||||
$('.mine-is-borrowable-button, .mine-is-not-borrowable-button').click(function() {
|
||||
bookid = 0;
|
||||
if (!$(this).attr('id').match(/^mine-is-(not-)?borrowable-button-\d+$/))
|
||||
return false;
|
||||
isBorrowable = ($(this).attr('id').match(/^mine-is-not-borrowable-button-\d+$/)) ? 0 : 1;
|
||||
bookid = $(this).attr('id').replace(/^mine-is-(not-)?borrowable-button-/, '');
|
||||
url = Routing.generate('KekRozsakFrontBundle_bookSetCopyBorrowable', { id: bookid, newValue: isBorrowable });
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: url
|
||||
}).done(function() {
|
||||
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
|
||||
}).error(function() {
|
||||
alert('Nem sikerült bejegyezni ezt a példányt');
|
||||
});
|
||||
});
|
||||
|
||||
$('.mine-is-for-sale-button, .mine-is-not-for-sale-button').click(function() {
|
||||
bookid = 0;
|
||||
if (!$(this).attr('id').match(/^mine-is-(not-)?for-sale-button-\d+$/))
|
||||
return false;
|
||||
isForSale = ($(this).attr('id').match(/^mine-is-not-for-sale-button-\d+$/)) ? 0 : 1;
|
||||
bookid = $(this).attr('id').replace(/^mine-is-(not-)?for-sale-button-/, '');
|
||||
url = Routing.generate('KekRozsakFrontBundle_bookSetCopyForSale', { id: bookid, newValue: isForSale });
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: url
|
||||
}).done(function() {
|
||||
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
|
||||
}).error(function() {
|
||||
alert('Nem sikerült bejegyezni ezt a példányt');
|
||||
});
|
||||
});
|
||||
|
||||
$('.want-to-buy-button, .want-to-borrow-button').click(function() {
|
||||
bookid = 0;
|
||||
if (!$(this).attr('id').match(/^want-to-(buy|borrow)-button-\d+$/))
|
||||
return false;
|
||||
toBuy = ($(this).attr('id').match(/^want-to-buy-button-\d+$/)) ? 1 : 0;
|
||||
bookid = $(this).attr('id').replace(/^want-to-(buy|borrow)-button-/, '');
|
||||
url = Routing.generate('KekRozsakFrontBundle_bookWantOne', { id: bookid, wantToBuy: toBuy });
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: url
|
||||
}).done(function() {
|
||||
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
|
||||
}).error(function() {
|
||||
alert('Nem sikerült bejegyezni a kérést');
|
||||
});
|
||||
});
|
||||
};
|
||||
doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback);
|
||||
});
|
||||
</script>
|
||||
{% endblock bottomscripts %}
|
Reference in New Issue
Block a user