From 55cde1594bb90f3976ab08f9bfca345f8f53e62d Mon Sep 17 00:00:00 2001 From: Polonkai Gergely Date: Wed, 8 Aug 2012 22:15:51 +0200 Subject: [PATCH] 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 --- TODO | 17 +- app/AppKernel.php | 1 + .../Version20120801224509.php | 24 ++ .../Version20120801224533.php | 34 ++ .../Version20120806165106.php | 34 ++ .../Version20120806165716.php | 28 ++ .../Version20120808111846.php | 28 ++ app/Resources/views/main_template.html.twig | 52 +++ app/config/routing.yml | 3 + composer.json | 1 + .../FrontBundle/Controller/BookController.php | 135 ++++++++ src/KekRozsak/FrontBundle/Entity/Book.php | 299 ++++++++++++++++++ src/KekRozsak/FrontBundle/Entity/BookCopy.php | 165 ++++++++++ .../Resources/views/Book/ajaxData.html.twig | 63 ++++ .../Resources/views/Book/list.html.twig | 133 ++++++++ web/bundles/fosjsrouting/js/router.js | 13 + web/css/kekrozsak_front.css | 109 +++++++ web/images/no.png | Bin 0 -> 894 bytes web/js/jquery.tinyscrollbar.min.js | 1 + 19 files changed, 1128 insertions(+), 12 deletions(-) create mode 100644 app/DoctrineMigrations/Version20120801224509.php create mode 100644 app/DoctrineMigrations/Version20120801224533.php create mode 100644 app/DoctrineMigrations/Version20120806165106.php create mode 100644 app/DoctrineMigrations/Version20120806165716.php create mode 100644 app/DoctrineMigrations/Version20120808111846.php create mode 100644 src/KekRozsak/FrontBundle/Controller/BookController.php create mode 100644 src/KekRozsak/FrontBundle/Entity/Book.php create mode 100644 src/KekRozsak/FrontBundle/Entity/BookCopy.php create mode 100644 src/KekRozsak/FrontBundle/Resources/views/Book/ajaxData.html.twig create mode 100644 src/KekRozsak/FrontBundle/Resources/views/Book/list.html.twig create mode 100644 web/bundles/fosjsrouting/js/router.js create mode 100644 web/images/no.png create mode 100644 web/js/jquery.tinyscrollbar.min.js diff --git a/TODO b/TODO index 3ed8a5c..1afa2f0 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,5 @@ +PDF header fix + User FavouriteForumTopics @@ -28,7 +30,9 @@ PollAnswer Article check if public UserForumViewed - it should contain records that show the last viewed post in each forum topic + User + ForumTopic + timestamp of last visit BlogPost id @@ -55,17 +59,6 @@ ForumPost last edit reason edit count -Library - id - owner - author - title - year - borrowable - borrowed by - borrower returned - commentable - Event last edited by last edited timestamp diff --git a/app/AppKernel.php b/app/AppKernel.php index b915e32..f7a85e0 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -23,6 +23,7 @@ class AppKernel extends Kernel new Ivory\CKEditorBundle\IvoryCKEditorBundle(), new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), new Io\TcpdfBundle\IoTcpdfBundle(), + new FOS\JsRoutingBundle\FOSJsRoutingBundle(), // Own bundles new KekRozsak\FrontBundle\KekRozsakFrontBundle(), new KekRozsak\SecurityBundle\KekRozsakSecurityBundle(), diff --git a/app/DoctrineMigrations/Version20120801224509.php b/app/DoctrineMigrations/Version20120801224509.php new file mode 100644 index 0000000..4899b4a --- /dev/null +++ b/app/DoctrineMigrations/Version20120801224509.php @@ -0,0 +1,24 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("CREATE TABLE books (id INT AUTO_INCREMENT NOT NULL, author VARCHAR(100) NOT NULL, title VARCHAR(100) NOT NULL, year INT NOT NULL, commentable TINYINT(1) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB"); + $this->addSql("CREATE TABLE book_copies (id INT AUTO_INCREMENT NOT NULL, book_id INT NOT NULL, owner_id INT NOT NULL, borrower_id INT DEFAULT NULL, owner_comment LONGTEXT NOT NULL, borrowable TINYINT(1) NOT NULL, borrower_returned TINYINT(1) NOT NULL, INDEX IDX_F0A8D81116A2B381 (book_id), INDEX IDX_F0A8D8117E3C61F9 (owner_id), UNIQUE INDEX UNIQ_F0A8D81111CE312B (borrower_id), UNIQUE INDEX UNIQ_F0A8D8117E3C61F916A2B381 (owner_id, book_id), PRIMARY KEY(id)) ENGINE = InnoDB"); + $this->addSql("ALTER TABLE book_copies ADD CONSTRAINT FK_F0A8D81116A2B381 FOREIGN KEY (book_id) REFERENCES books (id)"); + $this->addSql("ALTER TABLE book_copies ADD CONSTRAINT FK_F0A8D8117E3C61F9 FOREIGN KEY (owner_id) REFERENCES users (id)"); + $this->addSql("ALTER TABLE book_copies ADD CONSTRAINT FK_F0A8D81111CE312B FOREIGN KEY (borrower_id) REFERENCES users (id)"); + } + + public function down(Schema $schema) + { + // this down() migration is autogenerated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("ALTER TABLE book_copies DROP FOREIGN KEY FK_F0A8D81116A2B381"); + $this->addSql("DROP TABLE books"); + $this->addSql("DROP TABLE book_copies"); + } +} diff --git a/app/DoctrineMigrations/Version20120806165106.php b/app/DoctrineMigrations/Version20120806165106.php new file mode 100644 index 0000000..14c2dec --- /dev/null +++ b/app/DoctrineMigrations/Version20120806165106.php @@ -0,0 +1,34 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("CREATE TABLE book_would_borrow (book_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_7ED804D216A2B381 (book_id), INDEX IDX_7ED804D2A76ED395 (user_id), PRIMARY KEY(book_id, user_id)) ENGINE = InnoDB"); + $this->addSql("CREATE TABLE book_would_buy (book_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_67D6BB5216A2B381 (book_id), INDEX IDX_67D6BB52A76ED395 (user_id), PRIMARY KEY(book_id, user_id)) ENGINE = InnoDB"); + $this->addSql("ALTER TABLE book_would_borrow ADD CONSTRAINT FK_7ED804D216A2B381 FOREIGN KEY (book_id) REFERENCES books (id) ON DELETE CASCADE"); + $this->addSql("ALTER TABLE book_would_borrow ADD CONSTRAINT FK_7ED804D2A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE"); + $this->addSql("ALTER TABLE book_would_buy ADD CONSTRAINT FK_67D6BB5216A2B381 FOREIGN KEY (book_id) REFERENCES books (id) ON DELETE CASCADE"); + $this->addSql("ALTER TABLE book_would_buy ADD CONSTRAINT FK_67D6BB52A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE"); + } + + public function down(Schema $schema) + { + // this down() migration is autogenerated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("DROP TABLE book_would_borrow"); + $this->addSql("DROP TABLE book_would_buy"); + } +} diff --git a/app/DoctrineMigrations/Version20120806165716.php b/app/DoctrineMigrations/Version20120806165716.php new file mode 100644 index 0000000..8a30627 --- /dev/null +++ b/app/DoctrineMigrations/Version20120806165716.php @@ -0,0 +1,28 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("ALTER TABLE book_copies ADD buyable TINYINT(1) NOT NULL"); + } + + public function down(Schema $schema) + { + // this down() migration is autogenerated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("ALTER TABLE book_copies DROP buyable"); + } +} diff --git a/app/DoctrineMigrations/Version20120808111846.php b/app/DoctrineMigrations/Version20120808111846.php new file mode 100644 index 0000000..85e5f86 --- /dev/null +++ b/app/DoctrineMigrations/Version20120808111846.php @@ -0,0 +1,28 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("ALTER TABLE book_copies CHANGE owner_comment owner_comment LONGTEXT DEFAULT NULL"); + } + + public function down(Schema $schema) + { + // this down() migration is autogenerated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("ALTER TABLE book_copies CHANGE owner_comment owner_comment LONGTEXT NOT NULL"); + } +} diff --git a/app/Resources/views/main_template.html.twig b/app/Resources/views/main_template.html.twig index 5482f8d..362cea4 100644 --- a/app/Resources/views/main_template.html.twig +++ b/app/Resources/views/main_template.html.twig @@ -11,14 +11,32 @@ + + + {% block additional_js %}{% endblock %} +
{% if app.user %} {% include ':Box:UserProfile.html.twig' %} {% include ':Box:Events.html.twig' %} + {% else %} {% include ':Box:Login.html.twig' %} {% endif %} @@ -120,6 +138,40 @@ } }); {% endif %} + jQuery.fn.center = function() { + this.css('top', Math.max(0, (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop()) + 'px'); + this.css('left', Math.max(0, (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft()) + 'px'); + return this; + }; + + $('#popup-close').click(function() { $('#popup-container').fadeOut(); }); + $('#popup-scrollable').tinyscrollbar(); + function doPopup(title, content, url, w, h, callback) + { + $('#popup-title').html(title); + $('#popup-content').html(content); + $('#popup-container').css('width', w + 'px'); + $('#popup-container').css('height', h + 'px'); + $('#popup-inside').css('width', (w - 8) + 'px'); + $('#popup-inside').css('height', (h - 8) + 'px'); + $('#popup-scrollable').css('width', (w - 8) + 'px'); + $('#popup-scrollable .viewport').css('width', (w - 28) + 'px'); + $('#popup-scrollable .viewport').css('height', (h - 54) + 'px'); + $('#popup-container').center(); + $('#popup-container').fadeIn(); + $.ajax({ + method: 'GET', + url: url + }).done(function(data) { + $('#popup-content').html(data); + $('#popup-scrollable').tinyscrollbar(); + $('.userdata').cluetip(); + if (callback != null) + callback(); + }).error(function() { + $('#popup-content').html('Nem sikerült betölteni a könyv adatait.'); + }); + } {% block bottomscripts %}{% endblock %} diff --git a/app/config/routing.yml b/app/config/routing.yml index 298d8e1..52078d1 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -1,3 +1,6 @@ +fos_js_routing: + resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml" + KekRozsakAdminBundle: resource: "@KekRozsakAdminBundle/Controller/" type: annotation diff --git a/composer.json b/composer.json index 68b6f95..5284ead 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "jms/di-extra-bundle": "1.0.*", "doctrine/doctrine-migrations-bundle": "dev-master", "egeloen/ckeditor-bundle": "dev-master", + "friendsofsymfony/jsrouting-bundle": "dev-master", "gergelypolonkai/tcpdfbundle": "dev-master" }, "scripts": { diff --git a/src/KekRozsak/FrontBundle/Controller/BookController.php b/src/KekRozsak/FrontBundle/Controller/BookController.php new file mode 100644 index 0000000..39fad41 --- /dev/null +++ b/src/KekRozsak/FrontBundle/Controller/BookController.php @@ -0,0 +1,135 @@ +getDoctrine()->getEntityManager()->createQuery('SELECT b FROM KekRozsakFrontBundle:Book b ORDER BY b.author ASC, b.title ASC, b.year ASC'); + + $books = $query->getResult(); + + return array( + 'books' => $books, + ); + } + + /** + * @Route("/konyvadat/{id}/ajax.{_format}", name="KekRozsakFrontBundle_bookAjaxData", defaults={"_format": "html"}, options={"expose": true}) + * @Template() + * @ParamConverter("book") + */ + public function ajaxDataAction(Book $book) + { + return array( + 'book' => $book, + ); + } + + /** + * @Route("/konyv/torles/{id}", name="KekRozsakFrontBundle_bookDeleteCopy", requirements={"id": "\d+"}, options={"expose": true}) + * @ParamConverter("book") + */ + public function ajaxDeleteBookAction(Book $book) + { + $copies = $book->getUsersCopies($this->get('security.context')->getToken()->getUser()); + $em = $this->getDoctrine()->getEntityManager(); + $copies->forAll(function($key, $copy) use ($book, $em) { + $book->removeCopy($copy); + $em->remove($copy); + }); + $em->persist($book); + $em->flush(); + + return new Response(); + } + + /** + * @Route("/konyv/ujpeldany/{id}", name="KekRozsakFrontBundle_bookAddCopy", requirements={"id": "\d+"}, options={"expose": true}) + * @ParamConverter("book") + */ + public function ajaxAddBookAction(Book $book) + { + $user = $this->get('security.context')->getToken()->getUser(); + $copies = $book->getUsersCopies($user); + if ($copies->count() == 0) + { + $copy = new BookCopy($book, $user); + $em = $this->getDoctrine()->getEntityManager(); + $em->persist($copy); + $em->flush(); + } + + return new Response(); + } + + /** + * @Route("/konyv/kolcsonozheto/{id}/{newValue}", name="KekRozsakFrontBundle_bookSetCopyBorrowable", requirements={"id": "\d+"}, options={"expose": true}) + * @ParamConverter("book") + */ + public function ajaxSetBookCopyBorrowableAction(Book $book, $newValue) + { + $user = $this->get('security.context')->getToken()->getUser(); + $copies = $book->getUsersCopies($user); + $em = $this->getDoctrine()->getEntityManager(); + $copies->forAll(function($key, $copy) use ($em, $newValue) { + $copy->setBorrowable($newValue); + $em->persist($copy); + }); + $em->flush(); + return new Response(); + } + + /** + * @Route("/konyv/megveheto/{id}/{newValue}", name="KekRozsakFrontBundle_bookSetCopyForSale", requirements={"id": "\d+"}, options={"expose": true}) + * @ParamConverter("book") + */ + public function ajaxSetBookCopyForSaleAction(Book $book, $newValue) + { + $user = $this->get('security.context')->getToken()->getUser(); + $copies = $book->getUsersCopies($user); + $em = $this->getDoctrine()->getEntityManager(); + $copies->forAll(function($key, $copy) use ($em, $newValue) { + $copy->setBuyable($newValue); + $em->persist($copy); + }); + $em->flush(); + return new Response(); + } + + /** + * @Route("/konyv/szeretnek/{id}/{wantToBuy}", name="KekRozsakFrontBundle_bookWantOne", requirements={"id": "\d+"}, options={"expose": true}) + * @ParamConverter("book") + */ + public function ajaxWantABookAction(Book $book, $wantToBuy) + { + $user = $this->get('security.context')->getToken()->getUser(); + if ($wantToBuy) + { + $book->addWouldBuy($user); + } + else + { + $book->addWouldBorrow($user); + } + $em = $this->getDoctrine()->getEntityManager(); + $em->persist($book); + $em->flush(); + return new Response(); + } +} + diff --git a/src/KekRozsak/FrontBundle/Entity/Book.php b/src/KekRozsak/FrontBundle/Entity/Book.php new file mode 100644 index 0000000..c5ef106 --- /dev/null +++ b/src/KekRozsak/FrontBundle/Entity/Book.php @@ -0,0 +1,299 @@ +copies = new ArrayCollection(); + $this->wouldBorrow = new ArrayCollection(); + $this->wouldBuy = new ArrayCollection(); + } + + /** + * @var integer $id + * + * @ORM\Id + * @ORM\GeneratedValue(strategy="AUTO") + * @ORM\Column(type="integer") + */ + protected $id; + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * @var Doctrine\Common\Collections\ArrayCollection $copies + * + * @ORM\OneToMany(targetEntity="BookCopy", mappedBy="book") + */ + protected $copies; + + /** + * Remove a copy + * + * @param KekRozsak\FrontBundle\Entity\BookCopy $copy + * @return Book + */ + public function removeCopy(BookCopy $copy) + { + $this->copies->removeElement($copy); + } + + /** + * Get copies + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getCopies() + { + return $this->copies; + } + + public function getCopiesBorrowed() + { + return $this->copies->filter(function($copy) { + return ($copy->getBorrower() !== null); + }); + } + + public function getCopiesBorrowedByUser(User $user) + { + return $this->copies->filter(function($copy) use ($user) { + return ($copy->getBorrower() == $user); + }); + } + + public function getCopiesBorrowedReturnedByUser(User $user) + { + return $this->copies->filter(function($copy) use ($user) { + return ($copy->getBorrower() == $user) && ($copy->isBorrowerReturned()); + }); + } + + public function getCopiesBorrowable() + { + return $this->copies->filter(function($copy) { + return $copy->isBorrowable(); + }); + } + + public function getUsersCopies(User $user) + { + return $this->copies->filter(function ($copy) use ($user) { + return ($copy->getOwner() == $user); + }); + } + + public function getUsersCopiesBorrowable(User $user) + { + return $this->copies->filter(function($copy) use ($user) { + return (($copy->getOwner() == $user) && $copy->isBorrowable()); + }); + } + + public function getUsersCopiesBuyable(User $user) + { + return $this->copies->filter(function($copy) use ($user) { + return (($copy->getOwner() == $user) && $copy->isBuyable()); + }); + } + + /** + * @var string $author + * + * @ORM\Column(type="string", length=100, nullable=false) + */ + protected $author; + + /** + * Set author + * + * @param string $author + * @return Book + */ + public function setAuthor($author) + { + $this->author = $author; + return $this; + } + + /** + * Get author + * + * @return string + */ + public function getAuthor() + { + return $this->author; + } + + /** + * @var string $title + * + * @ORM\Column(type="string", length=100, nullable=false) + */ + protected $title; + + /** + * Set title + * + * @param string $title + * @return Book + */ + public function setTitle($title) + { + $this->title = $title; + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * @var integer $year + * + * @ORM\Column(type="integer", nullable=false) + */ + protected $year; + + /** + * Set year + * + * @param integer $year + * @return Book + */ + public function setYear($year) + { + $this->year = $year; + return $this; + } + + /** + * Get year + * + * @return integer + */ + public function getYear() + { + return $this->year; + } + + /** + * @var boolean $commentable + * + * @ORM\Column(type="boolean", nullable=false) + */ + protected $commentable; + + /** + * @var Doctrine\Common\Collections\ArrayCollection $wouldBorrow + * + * @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User") + * @ORM\JoinTable(name="book_would_borrow") + */ + protected $wouldBorrow; + + /** + * Add a user for want-to-borrowers + * + * @param KekRozsak\SecurityBundle\Entity\User $user + * @return Book + */ + public function addWouldBorrow(User $user) + { + $this->wouldBorrow->add($user); + return $this; + } + + /** + * Get wouldBorrow list + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getWouldBorrow() + { + return $this->wouldBorrow; + } + + /** + * Check if specified user would borrow this book + * + * @param KekRozsak\SecurityBundle\Entity\User $user + * @return boolean + */ + public function userWouldBorrow(User $user) + { + return $this->wouldBorrow->contains($user); + } + + /** + * @var Doctrine\Common\Collections\ArrayCollection $wouldBuy + * + * @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User") + * @ORM\JoinTable(name="book_would_buy") + */ + protected $wouldBuy; + + /** + * Add a user for want-to-buyers + * + * @param KekRozsak\SecurityBundle\Entity\User $user + * @return Book + */ + public function addWouldBuy(User $user) + { + $this->wouldBuy->add($user); + return $this; + } + + /** + * Get wouldBuy list + * + * @return Doctrine\Common\Collections\ArrayCollection + */ + public function getWouldBuy() + { + return $this->wouldBuy; + } + + /** + * Check if specified user would buy this book + * + * @param KekRozsak\SecurityBundle\Entity\User $user + * @return boolean + */ + public function userWouldBuy(User $user) + { + return $this->wouldBuy->contains($user); + } +} diff --git a/src/KekRozsak/FrontBundle/Entity/BookCopy.php b/src/KekRozsak/FrontBundle/Entity/BookCopy.php new file mode 100644 index 0000000..c2c84e3 --- /dev/null +++ b/src/KekRozsak/FrontBundle/Entity/BookCopy.php @@ -0,0 +1,165 @@ +book = $book; + $this->owner = $owner; + $this->borrowable = false; + $this->buyable = false; + $this->borrower = null; + $this->borrowerReturned = true; + } + + /** + * @var integer $id + * + * @ORM\Id + * @ORM\GeneratedValue(strategy="AUTO") + * @ORM\Column(type="integer") + */ + protected $id; + + /** + * @var KekRozsak\FrontBundle\Entity\Book $book + * + * @ORM\ManyToOne(targetEntity="Book", inversedBy="copies") + * @ORM\JoinColumn(nullable=false) + */ + protected $book; + + /** + * @var KekRozsak\SecurityBundle\Entity\User $owner + * + * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") + * @ORM\JoinColumn(nullable=false) + */ + protected $owner; + + /** + * Get owner + * + * @return KekRozsak\SecurityBundle\Entity\User + */ + public function getOwner() + { + return $this->owner; + } + + /** + * @var string $ownerComment + * + * @ORM\Column(type="text", name="owner_comment", nullable=true) + */ + protected $ownerComment; + + /** + * @var boolean $borrowable + * + * @ORM\Column(type="boolean", nullable=false) + */ + protected $borrowable; + + /** + * Set borrowable + * + * @param boolean $borrowable + * @return BookCopy + */ + public function setBorrowable($borrowable) + { + $this->borrowable = $borrowable; + return $this; + } + + /** + * Get borrowable + * + * @return boolean + */ + public function isBorrowable() + { + return $this->borrowable; + } + + /** + * @var boolean $buyable + * + * @ORM\Column(type="boolean", nullable=false) + */ + protected $buyable; + + /** + * Set buyable + * + * @param boolean $buyable + * @return BookCopy + */ + public function setBuyable($buyable) + { + $this->buyable = $buyable; + return $this; + } + + /** + * Get borrowable + * + * @return boolean + */ + public function isBuyable() + { + return $this->buyable; + } + + /** + * @var KekRozsak\SecurityBundle\Entity\User $borrower + * + * @ORM\OneToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") + */ + protected $borrower; + + /** + * Get borrower + * + * @return KekRozsak\SecurityBundle\Entity\User + */ + public function getBorrower() + { + return $this->borrower; + } + + /** + * @var boolean $borrowerReturned + * + * @ORM\Column(type="boolean", nullable=false, name="borrower_returned") + */ + protected $borrowerReturned; + + /** + * Get borrowerReturned + * + * @return boolean + */ + public function isBorrowerReturned() + { + return $this->borrowerReturned(); + } +} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Book/ajaxData.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Book/ajaxData.html.twig new file mode 100644 index 0000000..56ffafd --- /dev/null +++ b/src/KekRozsak/FrontBundle/Resources/views/Book/ajaxData.html.twig @@ -0,0 +1,63 @@ +{# vim: ft=htmljinja +#} +

+ Szerző: {{ book.author }}
+ Cím: {{ book.title }}
+ Kiadás éve: {{ book.year }}
+

+

+ Nekem van {{ book.usersCopies(app.user)|length }}, ebből kölcsön van adva X.
+ A teljes közösségnek összesen {{ book.copies|length }} példánya van.
+ Kölcsönkérhető {{ book.copiesBorrowable|length }} példány, ebből {{ book.copiesBorrowedByUser(app.user)|length }} nálam van.
+

+

+{% if book.usersCopies(app.user)|length == 0 %} + [Nekem is van egy] +{% else %} + [Nincs már] +{# TODO + [Eladtam valakinek a körben] +#} +{% if book.usersCopiesBorrowable(app.user)|length == 0 %} + [Az enyém is kölcsönkérhető] +{% else %} + [Nem szeretném kölcsönadni] +{% endif %} +{% endif %} + +{% if book.usersCopies(app.user)|length > 0 %} +{% if book.usersCopiesBuyable(app.user)|length == 0 %} + [Az enyém eladó] +{% else %} + [Nem szeretném eladni] +{% endif %} +{% endif %} + +{% if book.copiesBorrowedByUser(app.user)|length == 0 and book.usersCopies(app.user)|length == 0 and not book.userWouldBorrow(app.user) %} + [Kérek egyet kölcsön] +{% endif %} + +{% if book.usersCopies(app.user)|length == 0 and not book.userWouldBuy(app.user) %} + [Vennék egyet] +{% endif %} +

+{% if book.wouldBuy|length > 0 %} +

+ Ők szeretnének egyet kölcsönkérni:
+

    +{% for user in book.wouldBorrow %} +
  • {{ user|userdataspan }}
  • +{% endfor %} +
+

+{% endif %} +{% if book.wouldBuy|length > 0 %} +

+ Ők szeretnének venni egyet:
+

    +{% for user in book.wouldBuy %} +
  • {{ user|userdataspan }}
  • +{% endfor %} +
+

+{% endif %} diff --git a/src/KekRozsak/FrontBundle/Resources/views/Book/list.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Book/list.html.twig new file mode 100644 index 0000000..da1068d --- /dev/null +++ b/src/KekRozsak/FrontBundle/Resources/views/Book/list.html.twig @@ -0,0 +1,133 @@ +{# vim: ft=htmljinja +#} +{% extends '::main_template.html.twig' %} +{% block title %} - Könyvtár{% endblock %} +{% block content %} +

Könyvtár

+[Saját könyveim] [Nálam lévő kölcsönzött könyvek] +{% if books|length > 0 %} + + + + + + + + + + + + + +{% for book in books %} + + + + + + + + + +{% endfor %} + +
SzerzőCímÉvÖsszesKölcsönözhetőSajátNálam (Vissza)
+{% endif %} +{% endblock %} +{% block bottomscripts %} + +{% endblock bottomscripts %} diff --git a/web/bundles/fosjsrouting/js/router.js b/web/bundles/fosjsrouting/js/router.js new file mode 100644 index 0000000..9e8e568 --- /dev/null +++ b/web/bundles/fosjsrouting/js/router.js @@ -0,0 +1,13 @@ +/** + * Portions of this code are from the Google Closure Library, + * received from the Closure Authors under the Apache 2.0 license. + * + * All other code is (C) 2011 FriendsOfSymfony and subject to the MIT license. + */ +(function() {var g=this;function i(a,b){var c=a.split("."),d=g;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)!c.length&&b!==void 0?d[e]=b:d=d[e]?d[e]:d[e]={}} +function k(a){var b=typeof a;if(b=="object")if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if(c=="[object Window]")return"object";if(c=="[object Array]"||typeof a.length=="number"&&typeof a.splice!="undefined"&&typeof a.propertyIsEnumerable!="undefined"&&!a.propertyIsEnumerable("splice"))return"array";if(c=="[object Function]"||typeof a.call!="undefined"&&typeof a.propertyIsEnumerable!="undefined"&&!a.propertyIsEnumerable("call"))return"function"}else return"null"; +else if(b=="function"&&typeof a.call=="undefined")return"object";return b};var l=/^[a-zA-Z0-9\-_.!~*'()]*$/;function m(a){a=""+a;return!l.test(a)?encodeURIComponent(a):a};var n=Array.prototype,p=n.forEach?function(a,b,c){n.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=typeof a=="string"?a.split(""):a,f=0;f1){if(c%2)throw Error("Uneven number of arguments");for(var d=0;d=0&&(a.push(b.substr(c)),a[0]=b=b.substr(0,c));c=b.indexOf("?");c<0?a[1]="?":c==b.length-1&&(a[1]=void 0)}return a.join("")}function v(a,b){for(var c in b){var d=c,e=b[c],f=a;if(k(e)=="array")for(var h=0;h0&&(f=u(v([f],e)));return this.d.c+f};i("fos.Router",w);i("fos.Router.setData",function(a){var b=w.f();b.i(a.base_url);b.g(a.routes)});w.getInstance=w.f;w.prototype.setRoutes=w.prototype.g;w.prototype.setBaseUrl=w.prototype.i;w.prototype.getBaseUrl=w.prototype.k;w.prototype.generate=w.prototype.j;window.Routing=w.f();})(); diff --git a/web/css/kekrozsak_front.css b/web/css/kekrozsak_front.css index b089307..459b3c2 100644 --- a/web/css/kekrozsak_front.css +++ b/web/css/kekrozsak_front.css @@ -137,6 +137,16 @@ body { padding: 5px; } +#konyvtar-gomb { + float: left; + padding: 5px; +} + +#konyvtar-gomb a { + color: inherit; + text-decoration: none; +} + #bottom-line { position: fixed; left: 0; @@ -358,3 +368,102 @@ td.uj-post p .kuldes-gomb { font-style: italic; } +#popup-container { + display: none; + position: fixed; + height: 300px; + width: 200px; + background: #ffffff; + z-index: 80; +} + +#popup-close { + position: absolute; + width: 16px; + height: 16px; + top: -5px; + right: -5px; + background-image: url('../images/no.png'); +} + +#popup-inside { + border: 1px solid black; + height: 292px; + width: 192px; + margin-left: auto; + margin-right: auto; + margin-top: 3px; +} + +#popup-title { + font-weight: bold; + padding: 5px; +} + +#popup-content { + padding: 3px; +} + +#popup-scrollable { + width: 192px; + clear: both; + margin: 20px 0 10px; +} + +#popup-scrollable .viewport { + width: 172px; + height: 246px; + overflow: hidden; + position: relative; +} + +#popup-scrollable .overview { + list-style: none; + position: absolute; + left: 0; + top: 0; +} + +#popup-scrollable .thumb .end, #popup-scrollable .thumb { + background-color: #003D5D; +} + +#popup-scrollable .scrollbar { + position: relative; + float: right; + width: 15px; +} + +#popup-scrollable .track { + background-color: #D8EEFD; + height: 100%; + width: 13px; + position: relative; + padding: 0 1px; +} + +#popup-scrollable .thumb { + height: 20px; + width: 13px; + cursor: pointer; + overflow: hidden; + position: absolute; + top: 0; +} + +#popup-scrollable .thumb .end { + overflow: hidden; + height: 5px; + width: 13px; +} + +#popup-scrollable .disable { + display: none; +} + +.gomb { + background-color: #cccccc; + color: black; + white-space: nowrap; +} + diff --git a/web/images/no.png b/web/images/no.png new file mode 100644 index 0000000000000000000000000000000000000000..7b263fbdc3eff0fedc4d0e6514ee95ab1bde19c9 GIT binary patch literal 894 zcmV-^1A+XBP)QK(@w+AQyARawUYWl4cfP;h^b2gxpIyd!bDbx91hopz zxn99~c!?w?GYDb0GIMWl{)oWd^^f9>-`9#kF-nkJ}p5~gR#{>$J%;GC_1$^m6Nu===!s-F8-O9!P`RfLN+5BK?T19@V z71jw9Mn3zR#K`*w@3|7@WRPcwBsp41>0_-VQ|fCEKHXgh4rCM=0f9o0$WW`-IBuRV3z1}sW}`vGK+Lm* zqARmSnYRFbZulaxc*&%)L<~e*H8K{W24bccy><^@%(M8SrIN1~|MyHk&AhZ6h|cwn z#0S+wI)=~~I%+T?E3-v8`b_<{_G)G_R6Y$wrvlNOiUa3LM%)8W<&$@IWuw3UU(j81 UEFk${^Z)<=07*qoM6N<$g3QpL<^TWy literal 0 HcmV?d00001 diff --git a/web/js/jquery.tinyscrollbar.min.js b/web/js/jquery.tinyscrollbar.min.js new file mode 100644 index 0000000..a2a96b5 --- /dev/null +++ b/web/js/jquery.tinyscrollbar.min.js @@ -0,0 +1 @@ +(function(a){a.tiny=a.tiny||{};a.tiny.scrollbar={options:{axis:"y",wheel:40,scroll:true,lockscroll:true,size:"auto",sizethumb:"auto"}};a.fn.tinyscrollbar=function(d){var c=a.extend({},a.tiny.scrollbar.options,d);this.each(function(){a(this).data("tsb",new b(a(this),c))});return this};a.fn.tinyscrollbar_update=function(c){return a(this).data("tsb").update(c)};function b(q,g){var k=this,t=q,j={obj:a(".viewport",q)},h={obj:a(".overview",q)},d={obj:a(".scrollbar",q)},m={obj:a(".track",d.obj)},p={obj:a(".thumb",d.obj)},l=g.axis==="x",n=l?"left":"top",v=l?"Width":"Height",r=0,y={start:0,now:0},o={},e=("ontouchstart" in document.documentElement)?true:false;function c(){k.update();s();return k}this.update=function(z){j[g.axis]=j.obj[0]["offset"+v];h[g.axis]=h.obj[0]["scroll"+v];h.ratio=j[g.axis]/h[g.axis];d.obj.toggleClass("disable",h.ratio>=1);m[g.axis]=g.size==="auto"?j[g.axis]:g.size;p[g.axis]=Math.min(m[g.axis],Math.max(0,(g.sizethumb==="auto"?(m[g.axis]*h.ratio):g.sizethumb)));d.ratio=g.sizethumb==="auto"?(h[g.axis]/m[g.axis]):(h[g.axis]-j[g.axis])/(m[g.axis]-p[g.axis]);r=(z==="relative"&&h.ratio<=1)?Math.min((h[g.axis]-j[g.axis]),Math.max(0,r)):0;r=(z==="bottom"&&h.ratio<=1)?(h[g.axis]-j[g.axis]):isNaN(parseInt(z,10))?r:parseInt(z,10);w()};function w(){var z=v.toLowerCase();p.obj.css(n,r/d.ratio);h.obj.css(n,-r);o.start=p.obj.offset()[n];d.obj.css(z,m[g.axis]);m.obj.css(z,m[g.axis]);p.obj.css(z,p[g.axis])}function s(){if(!e){p.obj.bind("mousedown",i);m.obj.bind("mouseup",u)}else{j.obj[0].ontouchstart=function(z){if(1===z.touches.length){i(z.touches[0]);z.stopPropagation()}}}if(g.scroll&&window.addEventListener){t[0].addEventListener("DOMMouseScroll",x,false);t[0].addEventListener("mousewheel",x,false)}else{if(g.scroll){t[0].onmousewheel=x}}}function i(A){var z=parseInt(p.obj.css(n),10);o.start=l?A.pageX:A.pageY;y.start=z=="auto"?0:z;if(!e){a(document).bind("mousemove",u);a(document).bind("mouseup",f);p.obj.bind("mouseup",f)}else{document.ontouchmove=function(B){B.preventDefault();u(B.touches[0])};document.ontouchend=f}}function x(B){if(h.ratio<1){var A=B||window.event,z=A.wheelDelta?A.wheelDelta/120:-A.detail/3;r-=z*g.wheel;r=Math.min((h[g.axis]-j[g.axis]),Math.max(0,r));p.obj.css(n,r/d.ratio);h.obj.css(n,-r);if(g.lockscroll||(r!==(h[g.axis]-j[g.axis])&&r!==0)){A=a.event.fix(A);A.preventDefault()}}}function u(z){if(h.ratio<1){if(!e){y.now=Math.min((m[g.axis]-p[g.axis]),Math.max(0,(y.start+((l?z.pageX:z.pageY)-o.start))))}else{y.now=Math.min((m[g.axis]-p[g.axis]),Math.max(0,(y.start+(o.start-(l?z.pageX:z.pageY)))))}r=y.now*d.ratio;h.obj.css(n,-r);p.obj.css(n,y.now)}}function f(){a(document).unbind("mousemove",u);a(document).unbind("mouseup",f);p.obj.unbind("mouseup",f);document.ontouchmove=document.ontouchend=null}return c()}}(jQuery)); \ No newline at end of file