diff --git a/app/config/routes.php b/app/config/routes.php index 76c2601a..1fa3bb13 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -60,6 +60,11 @@ return [ 'id' => '[a-z0-9\-]+' ] ], + 'anime.delete' => [ + 'path' => '/anime/delete', + 'action' => 'delete', + 'verb' => 'post' + ], // --------------------------------------------------------------------- // Manga Routes // --------------------------------------------------------------------- diff --git a/app/views/anime/edit.php b/app/views/anime/edit.php index 6b1f7015..1e42608a 100644 --- a/app/views/anime/edit.php +++ b/app/views/anime/edit.php @@ -2,88 +2,104 @@

Edit Anime List Item

- - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
-

html($item['anime']['title']) ?>

- -

html($item['anime']['alternate_title']) ?>

- -
-
- img($item['anime']['image']); ?> -
-
- checked="checked" - /> -
- -
- / 10 -
- - 0): ?> - / + + + + - - - - - - - - - - - - - - - - - -
+

html($item['anime']['title']) ?>

+ +

html($item['anime']['alternate_title']) ?>

- -
- checked="checked" - /> -
- -
- -
  - - - -
+ +
+
+ img($item['anime']['image']); ?> +
+
+ checked="checked" + /> +
+ +
+ / 10 +
+ + 0): ?> + / + +
+ checked="checked" + /> +
+ +
+ +
  + + + +
+
+ Danger Zone +
+ + + + + + + + +
+
\ No newline at end of file diff --git a/public/css/base.css b/public/css/base.css index 0887a1c9..b53d8ab7 100644 --- a/public/css/base.css +++ b/public/css/base.css @@ -152,6 +152,19 @@ h1 a { margin: 0 auto; } +.danger { + background-color: #ff4136; + border-color: #924949; + color: #fff; +} + +.danger:hover, +.danger:active { + background-color: #924949; + border-color: #ff4136; + color: #fff; +} + /* ----------------------------------------------------------------------------- CSS loading icon ------------------------------------------------------------------------------*/ diff --git a/public/css/base.myth.css b/public/css/base.myth.css index 23e86327..1b55dc26 100644 --- a/public/css/base.myth.css +++ b/public/css/base.myth.css @@ -88,6 +88,18 @@ a:hover, a:active { margin:0 auto; } +.danger { + background-color: #ff4136; + border-color: #924949; + color:#fff; +} + +.danger:hover, .danger:active { + background-color: #924949; + border-color: #ff4136; + color:#fff; +} + /* ----------------------------------------------------------------------------- CSS loading icon ------------------------------------------------------------------------------*/ diff --git a/public/js/base/events.js b/public/js/base/events.js index 541238c1..fae002f5 100644 --- a/public/js/base/events.js +++ b/public/js/base/events.js @@ -10,4 +10,14 @@ ac.hide(this); }); + // Confirm deleting of list or library items + ac.on('form.js-danger', 'submit', function (event) { + let proceed = confirm("Are you ABSOLUTELY SURE you want to delete this item?"); + + if (proceed === false) { + event.preventDefault(); + event.stopPropagation(); + } + }); + })(AnimeClient); \ No newline at end of file diff --git a/src/Aviat/AnimeClient/Controller/Anime.php b/src/Aviat/AnimeClient/Controller/Anime.php index 8c1c0a8f..40bba49b 100644 --- a/src/Aviat/AnimeClient/Controller/Anime.php +++ b/src/Aviat/AnimeClient/Controller/Anime.php @@ -1,5 +1,4 @@ 'manga', 'config' => $this->config, ]); - + $this->cache = $container->get('cache'); } @@ -100,7 +99,7 @@ class Anime extends BaseController { '' => 'cover', 'list' => 'list' ]; - + $data = ($type != 'all') ? $this->cache->get($this->model, 'get_list', ['status' => $model_map[$type]]) : $this->cache->get($this->model, 'get_all_lists', []); @@ -154,7 +153,7 @@ class Anime extends BaseController { $result = $this->model->update($data); - if ($result['statusCode'] == 201) + if (intval($result['statusCode']) === 201) { $this->set_flash_message('Added new anime to list', 'success'); $this->cache->purge(); @@ -262,15 +261,25 @@ class Anime extends BaseController { */ public function delete() { - $response = $this->model->update($this->request->getParsedBody()); - $this->cache->purge(); - $this->outputJSON($response['body'], $response['statusCode']); + $response = $this->model->delete($this->request->getParsedBody()); + + if ($response['body'] == TRUE) + { + $this->set_flash_message("Successfully deleted anime", 'success'); + $this->cache->purge(); + } + else + { + $this->set_flash_message('Failed to delete anime.', 'error'); + } + + $this->session_redirect(); } /** * View details of an anime * - * @param string anime_id + * @param string $anime_id * @return void */ public function details($anime_id) @@ -284,5 +293,4 @@ class Anime extends BaseController { } } - // End of AnimeController.php \ No newline at end of file