From 1b8ed53afb9b8d32f01accaacb768e1ddb147683 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Tue, 15 Dec 2015 15:55:30 -0500 Subject: [PATCH] Start of delete functionality for anime collection --- app/views/collection/cover.php | 10 ++++--- public/css/base.css | 8 +++++- public/css/base.myth.css | 4 ++- sonar-project.properties | 2 +- .../AnimeClient/Controller/Collection.php | 26 ++++++++++++++++++- .../AnimeClient/Model/AnimeCollection.php | 17 ++++++++++++ src/Aviat/AnimeClient/Model/DB.php | 2 +- 7 files changed, 60 insertions(+), 9 deletions(-) diff --git a/app/views/collection/cover.php b/app/views/collection/cover.php index b3162624..bd154cf7 100644 --- a/app/views/collection/cover.php +++ b/app/views/collection/cover.php @@ -24,12 +24,14 @@
+ is_authenticated()): ?> +
+ [">Edit] + [">Delete] +
+ - - is_authenticated()): ?> - [">Edit] - diff --git a/public/css/base.css b/public/css/base.css index 4107aa1f..f5ebd964 100644 --- a/public/css/base.css +++ b/public/css/base.css @@ -16,6 +16,7 @@ tbody > tr:nth-child(odd) { } .grow-1 { + -webkit-box-flex: 1; -webkit-flex-grow: 1; -ms-flex-positive: 1; flex-grow: 1; @@ -34,6 +35,7 @@ tbody > tr:nth-child(odd) { } .flex-align-end { + -webkit-box-align: end; -webkit-align-items: flex-end; -ms-flex-align: end; align-items: flex-end; @@ -58,6 +60,7 @@ tbody > tr:nth-child(odd) { } .flex { + display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; @@ -223,7 +226,9 @@ button { .anime .airing_status, .anime .user_rating, .anime .completion, -.anime .age_rating { +.anime .age_rating, +.anime .edit, +.anime .delete { background: none; text-align: center; } @@ -240,6 +245,7 @@ button { .manga .row { width: 100%; background: rgba(0, 0, 0, 0.45); + display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; diff --git a/public/css/base.myth.css b/public/css/base.myth.css index 8c8165d5..fa8235d4 100644 --- a/public/css/base.myth.css +++ b/public/css/base.myth.css @@ -178,7 +178,9 @@ button { .anime .airing_status, .anime .user_rating, .anime .completion, -.anime .age_rating { +.anime .age_rating, +.anime .edit, +.anime .delete { background: none; text-align:center; } diff --git a/sonar-project.properties b/sonar-project.properties index f2ac005c..81418be2 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,6 @@ sonar.projectKey=animeclient sonar.projectName=Anime Client -sonar.projectVersion=1.0 +sonar.projectVersion=2.0.0 sonar.sources=src sonar.php.coverage.reportPath=build/logs/clover.xml sonar.php.tests.reportPath=build/logs/junit.xml \ No newline at end of file diff --git a/src/Aviat/AnimeClient/Controller/Collection.php b/src/Aviat/AnimeClient/Controller/Collection.php index efb5c67b..e57c8a60 100644 --- a/src/Aviat/AnimeClient/Controller/Collection.php +++ b/src/Aviat/AnimeClient/Controller/Collection.php @@ -27,10 +27,16 @@ class Collection extends BaseController { /** * The anime collection model - * @var object $anime_collection_model + * @var AnimeCollectionModel $anime_collection_model */ private $anime_collection_model; + /** + * The anime API model + * @var AnimeModel $anime_model + */ + private $anime_model; + /** * Data to ve sent to all routes in this controller * @var array $base_data @@ -151,5 +157,23 @@ class Collection extends BaseController { $this->redirect("collection/view", 303); } + + /** + * Remove a collection item + * + * @return void + */ + public function delete() + { + $data = $this->request->post->get(); + if ( ! array_key_exists('id', $data)) + { + $this->redirect("collection/view", 303); + } + + $this->anime_collection_model->delete($data); + + $this->redirect("collection/view", 303); + } } // End of CollectionController.php \ No newline at end of file diff --git a/src/Aviat/AnimeClient/Model/AnimeCollection.php b/src/Aviat/AnimeClient/Model/AnimeCollection.php index 38d5f5d8..315220e4 100644 --- a/src/Aviat/AnimeClient/Model/AnimeCollection.php +++ b/src/Aviat/AnimeClient/Model/AnimeCollection.php @@ -261,6 +261,23 @@ class AnimeCollection extends DB { ->update('anime_set'); } + /** + * Remove a colleciton item + * @param array $data + * @return void + */ + public function delete($data) + { + // If there's no id to update, don't delete + if ( ! array_key_exists('hummingbird_id', $data)) + { + return; + } + + $this->db->where('hummingbird_id', $data['hummingbird_id']) + ->delete('anime_set'); + } + /** * Get the details of a collection item * diff --git a/src/Aviat/AnimeClient/Model/DB.php b/src/Aviat/AnimeClient/Model/DB.php index d2a66aaf..61b94ca6 100644 --- a/src/Aviat/AnimeClient/Model/DB.php +++ b/src/Aviat/AnimeClient/Model/DB.php @@ -39,7 +39,7 @@ class DB extends BaseModel { public function __construct(ContainerInterface $container) { parent::__construct($container); - $this->db_config = $this->config->get('database'); + $this->db_config = (array) $this->config->get('database'); } } // End of BaseDBModel.php \ No newline at end of file