Parcourir la source

Updated delete route to be POST method
Added js confirmation popup

Tom Wor il y a 8 ans
Parent
commit
2822faa21d
2 fichiers modifiés avec 4 ajouts et 2 suppressions
  1. 1 1
      src/routes/asset.php
  2. 3 1
      templates/edit_asset.phtml

+ 1 - 1
src/routes/asset.php

@@ -239,7 +239,7 @@ $app->post('/asset/{id:[0-9]+}/support_level', function ($request, $response, $a
 /*
  * Delete asset from library
  */
-$app->get('/asset/{id:[0-9]+}/delete', function ($request, $response, $args) {
+$app->post('/asset/{id:[0-9]+}/delete', function ($request, $response, $args) {
 
     $body = $request->getParsedBody();
 

+ 3 - 1
templates/edit_asset.phtml

@@ -25,7 +25,9 @@
 
                 <div class="form-group">
                     <div class="col-md-4 col-md-push-9 align-right">
-                        <a href="<?php echo raw($basepath) ?>/asset/<?php echo url($data['asset_id']) ?>/delete" id="delete" class="btn btn-danger">Delete asset from library</a>
+                        <form action="<?php echo raw($basepath) ?>/asset/<?php echo url($data['asset_id']) ?>/delete" method="POST">
+                            <input type="submit" id="delete" class="btn btn-danger" onclick="javascript:if(window.confirm('Do you really want to delete this asset?')){ return true; }else{ return false; }" value="Delete asset from library">
+                        </form>
                     </div>
                 </div>
         </fieldset>