Added code to the admin part of the site - still non-functional. Need to fix JSON streaming over HTTP such that native types (boolean, Date, int) are preserved for the DB; Need to finish the restore functionality & the hide/show of the edit, delete, and restore buttons on each editor page.
67 lines
2.4 KiB
HTML
67 lines
2.4 KiB
HTML
|
|
<div id="editDialog" class="modal fade" role="dialog">
|
|
<div class="modal-dialog">
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
<h4 class="modal-title">Edit Item</h4>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="form-group">
|
|
<label>Name</label>
|
|
<input type="text" class="form-control" name="name" id="editDialog_NameField" tabindex="0">
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Subcategory</label>
|
|
<div id="editDialog_subcategoryDropdown" style="position: relative;"></div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Default Price</label>
|
|
<input type="text" class="form-control" name="name" id="editDialog_DefaultPriceField" tabindex="0">
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Measures</label>
|
|
<input type="text" class="form-control" name="name" id="editDialog_MeasuresField" tabindex="0">
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-default btn-md" id="editDialog_SaveButton" tabindex="0">Save</button>
|
|
<button type="button" class="btn" data-dismiss="modal" tabindex="0">Cancel</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script language="JavaScript" type="text/javascript">
|
|
//# sourceURL=items/edit.html
|
|
$(function() {
|
|
$("#items #editButton").on("click", function(event) {
|
|
//debugger;
|
|
if(dataTable.getSelectedRow() != null) {
|
|
$('#editDialog_NameField').val(dataTable.getSelectedRow().data("model").name);
|
|
$('#editDialog_DefaultPriceField').val(dataTable.getSelectedRow().data("model").defaultPrice);
|
|
$('#editDialog_MeasuresField').val(dataTable.getSelectedRow().data("model").measures);
|
|
$("#items #editDialog").modal();
|
|
}
|
|
});
|
|
$("#items #editDialog_SaveButton").on("click", function(event) {
|
|
if(dataTable.getSelectedRow() != null) {
|
|
$.post("data/Item/edit", {
|
|
id: dataTable.getSelectedRow().data("model").id,
|
|
name: $("#items #editDialog_NameField").val(),
|
|
defaultPrice: $("#items #editDialog_DefaultPriceField").val(),
|
|
measures: $("#items #editDialog_MeasuresField").val()
|
|
}, function(data) {
|
|
if(data.result == "success") {
|
|
$("#items #editDialog").modal("hide");
|
|
dataTable.refresh();
|
|
}
|
|
else {
|
|
alert(data.result);
|
|
}
|
|
}, "json");
|
|
}
|
|
});
|
|
$("#items #editDialog").on('shown.bs.modal', function() {
|
|
$('#editDialog_NameField').focus().select();
|
|
});
|
|
});
|
|
</script> |