Add tile delete button

This commit is contained in:
Skylar Ittner 2017-12-01 22:55:00 -07:00
parent 735fbd3abe
commit c580cbdc11
4 changed files with 21 additions and 4 deletions

View File

@ -120,6 +120,14 @@ switch ($VARS['action']) {
$database->insert('tiles', $data);
}
exit(json_encode(["status" => "OK"]));
case "deltile":
header("Content-Type: application/json");
if (!$database->has('tiles', ['tileid' => $VARS['tileid']])) {
die(json_encode(["status" => "ERROR", "msg" => lang("invalid tileid", false)]));
}
$database->delete('tiles', ["tileid" => $VARS['tileid']]);
exit(json_encode(["status" => "OK"]));
case "signout":
session_destroy();
header('Location: index.php');

Binary file not shown.

View File

@ -71,6 +71,7 @@ if ($pub === false) {
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger btn-xs" id="edit-tile-del-btn"><?php lang("delete"); ?></button>
<button type="button" class="btn btn-default" data-dismiss="modal"><?php lang("close"); ?></button>
<button type="button" class="btn btn-primary" id="edit-tile-save-btn" data-tile=""><?php lang("save"); ?></button>
</div>

View File

@ -1,7 +1,3 @@
$("#new_tile_btn").click(function () {
// TODO
});
$(".edit-btn").click(function () {
var tileid = $(this).data("tile");
$("#tile-" + tileid + "-content .tile-html").summernote({
@ -117,6 +113,18 @@ $("#edit-tile-save-btn").click(function () {
$("#tile-options-modal").modal('hide');
});
$("#edit-tile-del-btn").click(function () {
var tileid = $("#edit-tile-save-btn").data("tile");
$("#tile-" + tileid).css("display", "none");
$.post("action.php", {
action: "deltile",
tileid: tileid
}, function (d) {
safeReload();
});
$("#tile-options-modal").modal('hide');
});
$("#new-tile-save-btn").click(function () {
var style = $("#newstyle").val();
var width = $("#newwidth").val();