Rename ItemPriceController to ItemController. #780
This commit is contained in:
parent
01e4baa8c4
commit
80b9f90324
11 changed files with 373 additions and 61 deletions
|
|
@ -662,18 +662,18 @@ catalyst_auth:
|
||||||
- id: item_type.delete
|
- id: item_type.delete
|
||||||
label: Delete
|
label: Delete
|
||||||
|
|
||||||
- id: item_price
|
- id: item
|
||||||
label: Item Price
|
label: Item
|
||||||
acls:
|
acls:
|
||||||
- id: item_price.menu
|
- id: item.menu
|
||||||
label: Menu
|
label: Menu
|
||||||
- id: item_price.list
|
- id: item.list
|
||||||
label: List
|
label: List
|
||||||
- id: item_price.add
|
- id: item.add
|
||||||
label: Add
|
label: Add
|
||||||
- id: item_price.update
|
- id: item.update
|
||||||
label: Update
|
label: Update
|
||||||
- id: item_price.delete
|
- id: item.delete
|
||||||
label: Delete
|
label: Delete
|
||||||
- id: item_pricing
|
- id: item_pricing
|
||||||
label: Item Pricing
|
label: Item Pricing
|
||||||
|
|
|
||||||
|
|
@ -297,7 +297,7 @@ catalyst_menu:
|
||||||
acl: item.menu
|
acl: item.menu
|
||||||
label: Item Management
|
label: Item Management
|
||||||
icon: fa fa-boxes
|
icon: fa fa-boxes
|
||||||
order: 10
|
order: 10
|
||||||
- id: price_tier_list
|
- id: price_tier_list
|
||||||
acl: price_tier.list
|
acl: price_tier.list
|
||||||
label: Price Tiers
|
label: Price Tiers
|
||||||
|
|
@ -306,7 +306,7 @@ catalyst_menu:
|
||||||
acl: item_pricing.update
|
acl: item_pricing.update
|
||||||
label: Item Pricing
|
label: Item Pricing
|
||||||
parent: item
|
parent: item
|
||||||
- id: item_price_list
|
- id: item_list
|
||||||
acl: item_price.list
|
acl: item.list
|
||||||
label: Items
|
label: Items
|
||||||
parent: item
|
parent: item
|
||||||
|
|
|
||||||
34
config/routes/item.yaml
Normal file
34
config/routes/item.yaml
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
item_list:
|
||||||
|
path: /items
|
||||||
|
controller: App\Controller\ItemController::index
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
item_rows:
|
||||||
|
path: /items/rowdata
|
||||||
|
controller: App\Controller\ItemController::datatableRows
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
item_add_form:
|
||||||
|
path: /items/newform
|
||||||
|
controller: App\Controller\ItemController::addForm
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
item_add_submit:
|
||||||
|
path: /items
|
||||||
|
controller: App\Controller\ItemController::addSubmit
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
item_update_form:
|
||||||
|
path: /items/{id}
|
||||||
|
controller: App\Controller\ItemController::updateForm
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
item_update_submit:
|
||||||
|
path: /items/{id}
|
||||||
|
controller: App\Controller\ItemController::updateSubmit
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
item_delete:
|
||||||
|
path: /items/{id}
|
||||||
|
controller: App\Controller\ItemController::deleteSubmit
|
||||||
|
methods: [DELETE]
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
item_price_list:
|
|
||||||
path: /items
|
|
||||||
controller: App\Controller\ItemPriceController::index
|
|
||||||
methods: [GET]
|
|
||||||
|
|
||||||
item_price_rows:
|
|
||||||
path: /items/rowdata
|
|
||||||
controller: App\Controller\ItemPriceController::datatableRows
|
|
||||||
methods: [POST]
|
|
||||||
|
|
||||||
item_price_add_form:
|
|
||||||
path: /items/newform
|
|
||||||
controller: App\Controller\ItemPriceController::addForm
|
|
||||||
methods: [GET]
|
|
||||||
|
|
||||||
item_price_add_submit:
|
|
||||||
path: /items
|
|
||||||
controller: App\Controller\ItemPriceController::addSubmit
|
|
||||||
methods: [POST]
|
|
||||||
|
|
||||||
item_price_update_form:
|
|
||||||
path: /items/{id}
|
|
||||||
controller: App\Controller\ItemPriceController::updateForm
|
|
||||||
methods: [GET]
|
|
||||||
|
|
||||||
item_price_update_submit:
|
|
||||||
path: /items/{id}
|
|
||||||
controller: App\Controller\ItemPriceController::updateSubmit
|
|
||||||
methods: [POST]
|
|
||||||
|
|
||||||
item_price_delete:
|
|
||||||
path: /items/{id}
|
|
||||||
controller: App\Controller\ItemPriceController::deleteSubmit
|
|
||||||
methods: [DELETE]
|
|
||||||
|
|
@ -14,31 +14,31 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
|
||||||
|
|
||||||
use App\Entity\ItemType;
|
use App\Entity\ItemType;
|
||||||
use App\Entity\ItemPrice;
|
use App\Entity\Item;
|
||||||
use App\Entity\Battery;
|
use App\Entity\Battery;
|
||||||
use App\Entity\ServiceOffering;
|
use App\Entity\ServiceOffering;
|
||||||
|
|
||||||
use Catalyst\MenuBundle\Annotation\Menu;
|
use Catalyst\MenuBundle\Annotation\Menu;
|
||||||
|
|
||||||
class ItemPriceController extends Controller
|
class ItemController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Menu(selected="item_price_list")
|
* @Menu(selected="item_list")
|
||||||
* @IsGranted("item_price.list")
|
* @IsGranted("item.list")
|
||||||
*/
|
*/
|
||||||
public function index ()
|
public function index ()
|
||||||
{
|
{
|
||||||
return $this->render('item-price/list.html.twig');
|
return $this->render('item/list.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @IsGranted("item_price.list")
|
* @IsGranted("item.list")
|
||||||
*/
|
*/
|
||||||
public function datatableRows(Request $req)
|
public function datatableRows(Request $req)
|
||||||
{
|
{
|
||||||
// get query builder
|
// get query builder
|
||||||
$qb = $this->getDoctrine()
|
$qb = $this->getDoctrine()
|
||||||
->getRepository(ItemPrice::class)
|
->getRepository(Item::class)
|
||||||
->createQueryBuilder('q');
|
->createQueryBuilder('q');
|
||||||
|
|
||||||
// get datatable params
|
// get datatable params
|
||||||
|
|
@ -118,6 +118,8 @@ class ItemPriceController extends Controller
|
||||||
|
|
||||||
protected function setQueryFilters($datatable, QueryBuilder $query)
|
protected function setQueryFilters($datatable, QueryBuilder $query)
|
||||||
{
|
{
|
||||||
|
// TODO: add filter for item type.
|
||||||
|
// TODO: fix filter for name since name is with the associated entity
|
||||||
if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) {
|
if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) {
|
||||||
$query->where('q.name LIKE :filter')
|
$query->where('q.name LIKE :filter')
|
||||||
->setParameter('filter', '%' . $datatable['query']['data-rows-search'] . '%');
|
->setParameter('filter', '%' . $datatable['query']['data-rows-search'] . '%');
|
||||||
|
|
@ -6,10 +6,10 @@ use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="item_price")
|
* @ORM\Table(name="item")
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ItemPrice
|
class Item
|
||||||
{
|
{
|
||||||
// unique id
|
// unique id
|
||||||
/**
|
/**
|
||||||
|
|
@ -20,14 +20,14 @@ class ItemPrice
|
||||||
protected $id;
|
protected $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="PriceTier", inversedBy="item_prices")
|
* @ORM\ManyToOne(targetEntity="PriceTier", inversedBy="items")
|
||||||
* @ORM\JoinColumn(name="price_tier_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="price_tier_id", referencedColumnName="id")
|
||||||
*/
|
*/
|
||||||
protected $price_tier;
|
protected $price_tier;
|
||||||
|
|
||||||
// item type
|
// item type
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="ItemType", inversedBy="item_prices")
|
* @ORM\ManyToOne(targetEntity="ItemType", inversedBy="items")
|
||||||
* @ORM\JoinColumn(name="item_type_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="item_type_id", referencedColumnName="id")
|
||||||
*/
|
*/
|
||||||
protected $item_type;
|
protected $item_type;
|
||||||
|
|
@ -62,6 +62,17 @@ class ItemPrice
|
||||||
return $this->price_tier;
|
return $this->price_tier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setItemType(ItemType $item_type)
|
||||||
|
{
|
||||||
|
$this->item_type = $item_type;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getItemType()
|
||||||
|
{
|
||||||
|
return $this->item_type;
|
||||||
|
}
|
||||||
|
|
||||||
public function setItemID($item_id)
|
public function setItemID($item_id)
|
||||||
{
|
{
|
||||||
$this->item_id = $item_id;
|
$this->item_id = $item_id;
|
||||||
|
|
@ -35,6 +35,12 @@ class ItemType
|
||||||
*/
|
*/
|
||||||
protected $code;
|
protected $code;
|
||||||
|
|
||||||
|
// items under an item type
|
||||||
|
/**
|
||||||
|
* @ORM\OneToMany(targetEntity="Item", mappedBy="item_type")
|
||||||
|
*/
|
||||||
|
protected $items;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->code = '';
|
$this->code = '';
|
||||||
|
|
@ -66,4 +72,9 @@ class ItemType
|
||||||
{
|
{
|
||||||
return $this->code;
|
return $this->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getItems()
|
||||||
|
{
|
||||||
|
return $this->items;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,14 @@ class PriceTier
|
||||||
|
|
||||||
// items under a price tier
|
// items under a price tier
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToMany(targetEntity="ItemPrice", mappedBy="price_tier")
|
* @ORM\OneToMany(targetEntity="Item", mappedBy="price_tier")
|
||||||
*/
|
*/
|
||||||
protected $item_prices;
|
protected $items;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->supported_areas = new ArrayCollection();
|
$this->supported_areas = new ArrayCollection();
|
||||||
$this->item_prices = new ArrayCollection();
|
$this->items = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getID()
|
public function getID()
|
||||||
|
|
@ -80,9 +80,9 @@ class PriceTier
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getItemPrices()
|
public function getItems()
|
||||||
{
|
{
|
||||||
return $this->item_prices;
|
return $this->items;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
142
templates/item/form.html.twig
Normal file
142
templates/item/form.html.twig
Normal file
|
|
@ -0,0 +1,142 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<!-- BEGIN: Subheader -->
|
||||||
|
<div class="m-subheader">
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<div class="mr-auto">
|
||||||
|
<h3 class="m-subheader__title">Item Types</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- END: Subheader -->
|
||||||
|
<div class="m-content">
|
||||||
|
<!--Begin::Section-->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xl-6">
|
||||||
|
<div class="m-portlet m-portlet--mobile">
|
||||||
|
<div class="m-portlet__head">
|
||||||
|
<div class="m-portlet__head-caption">
|
||||||
|
<div class="m-portlet__head-title">
|
||||||
|
<span class="m-portlet__head-icon">
|
||||||
|
<i class="la la-industry"></i>
|
||||||
|
</span>
|
||||||
|
<h3 class="m-portlet__head-text">
|
||||||
|
{% if mode == 'update' %}
|
||||||
|
Edit Item Type
|
||||||
|
<small>{{ obj.getName() }}</small>
|
||||||
|
{% else %}
|
||||||
|
New Item Type
|
||||||
|
{% endif %}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form id="row-form" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="post" action="{{ mode == 'update' ? url('item_type_update_submit', {'id': obj.getId()}) : url('item_type_add_submit') }}">
|
||||||
|
<div class="m-portlet__body">
|
||||||
|
<div class="form-group m-form__group row no-border">
|
||||||
|
<label class="col-lg-3 col-form-label" data-field="name">
|
||||||
|
Name:
|
||||||
|
</label>
|
||||||
|
<div class="col-lg-9">
|
||||||
|
<input type="text" name="name" class="form-control m-input" value="{{ obj.getName() }}">
|
||||||
|
<div class="form-control-feedback hide" data-field="name"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row no-border">
|
||||||
|
<label class="col-lg-3 col-form-label" data-field="code">
|
||||||
|
Code:
|
||||||
|
</label>
|
||||||
|
<div class="col-lg-9">
|
||||||
|
<input type="text" name="code" class="form-control m-input" value="{{ obj.getCode() }}">
|
||||||
|
<div class="form-control-feedback hide" data-field="code"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="m-portlet__foot m-portlet__foot--fit">
|
||||||
|
<div class="m-form__actions m-form__actions--solid m-form__actions--right">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<button type="submit" class="btn btn-success">Submit</button>
|
||||||
|
<a href="{{ url('item_type_list') }}" class="btn btn-secondary">Back</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script>
|
||||||
|
$(function() {
|
||||||
|
$("#row-form").submit(function(e) {
|
||||||
|
var form = $(this);
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
method: "POST",
|
||||||
|
url: form.prop('action'),
|
||||||
|
data: form.serialize()
|
||||||
|
}).done(function(response) {
|
||||||
|
// remove all error classes
|
||||||
|
removeErrors();
|
||||||
|
swal({
|
||||||
|
title: 'Done!',
|
||||||
|
text: 'Your changes have been saved!',
|
||||||
|
type: 'success',
|
||||||
|
onClose: function() {
|
||||||
|
window.location.href = "{{ url('item_type_list') }}";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).fail(function(response) {
|
||||||
|
if (response.status == 422) {
|
||||||
|
var errors = response.responseJSON.errors;
|
||||||
|
var firstfield = false;
|
||||||
|
|
||||||
|
// remove all error classes first
|
||||||
|
removeErrors();
|
||||||
|
|
||||||
|
// display errors contextually
|
||||||
|
$.each(errors, function(field, msg) {
|
||||||
|
var formfield = $("[name='" + field + "']");
|
||||||
|
var label = $("label[data-field='" + field + "']");
|
||||||
|
var msgbox = $(".form-control-feedback[data-field='" + field + "']");
|
||||||
|
|
||||||
|
// add error classes to bad fields
|
||||||
|
formfield.addClass('form-control-danger');
|
||||||
|
label.addClass('has-danger');
|
||||||
|
msgbox.html(msg).addClass('has-danger').removeClass('hide');
|
||||||
|
|
||||||
|
// check if this field comes first in DOM
|
||||||
|
var domfield = formfield.get(0);
|
||||||
|
|
||||||
|
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
|
||||||
|
firstfield = domfield;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// focus on first bad field
|
||||||
|
firstfield.focus();
|
||||||
|
|
||||||
|
// scroll to above that field to make it visible
|
||||||
|
$('html, body').animate({
|
||||||
|
scrollTop: $(firstfield).offset().top - 200
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// remove all error classes
|
||||||
|
function removeErrors() {
|
||||||
|
$(".form-control-danger").removeClass('form-control-danger');
|
||||||
|
$("[data-field]").removeClass('has-danger');
|
||||||
|
$(".form-control-feedback[data-field]").addClass('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
146
templates/item/list.html.twig
Normal file
146
templates/item/list.html.twig
Normal file
|
|
@ -0,0 +1,146 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<!-- BEGIN: Subheader -->
|
||||||
|
<div class="m-subheader">
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<div class="mr-auto">
|
||||||
|
<h3 class="m-subheader__title">
|
||||||
|
Items
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- END: Subheader -->
|
||||||
|
<div class="m-content">
|
||||||
|
<!--Begin::Section-->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xl-12">
|
||||||
|
<div class="m-portlet m-portlet--mobile">
|
||||||
|
<div class="m-portlet__body">
|
||||||
|
<div class="m-form m-form--label-align-right m--margin-top-20 m--margin-bottom-30">
|
||||||
|
<div class="row align-items-center">
|
||||||
|
<div class="col-xl-8 order-2 order-xl-1">
|
||||||
|
<div class="form-group m-form__group row align-items-center">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="m-input-icon m-input-icon--left">
|
||||||
|
<input type="text" class="form-control m-input m-input--solid" placeholder="Search..." id="data-rows-search">
|
||||||
|
<span class="m-input-icon__icon m-input-icon__icon--left">
|
||||||
|
<span><i class="la la-search"></i></span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-xl-4 order-1 order-xl-2 m--align-right">
|
||||||
|
<a href="{{ url('item_add_form') }}" class="btn btn-focus m-btn m-btn--custom m-btn--icon m-btn--air m-btn--pill">
|
||||||
|
<span>
|
||||||
|
<i class="la la-industry"></i>
|
||||||
|
<span>New Item</span>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<div class="m-separator m-separator--dashed d-xl-none"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--begin: Datatable -->
|
||||||
|
<div id="data-rows"></div>
|
||||||
|
<!--end: Datatable -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script>
|
||||||
|
$(function() {
|
||||||
|
var options = {
|
||||||
|
data: {
|
||||||
|
type: 'remote',
|
||||||
|
source: {
|
||||||
|
read: {
|
||||||
|
url: '{{ url("item_rows") }}',
|
||||||
|
method: 'POST'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
saveState: {
|
||||||
|
cookie: false,
|
||||||
|
webstorage: false
|
||||||
|
},
|
||||||
|
pageSize: 10,
|
||||||
|
serverPaging: true,
|
||||||
|
serverFiltering: true,
|
||||||
|
serverSorting: true
|
||||||
|
},
|
||||||
|
layout: {
|
||||||
|
scroll: true
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
field: 'id',
|
||||||
|
title: 'ID',
|
||||||
|
width: 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: 'Name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'Actions',
|
||||||
|
width: 110,
|
||||||
|
title: 'Actions',
|
||||||
|
sortable: false,
|
||||||
|
overflow: 'visible',
|
||||||
|
template: function (row, index, datatable) {
|
||||||
|
var actions = '';
|
||||||
|
|
||||||
|
if (row.meta.update_url != '') {
|
||||||
|
actions += '<a href="' + row.meta.update_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" data-id="' + row.name + '" title="Edit"><i class="la la-edit"></i></a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (row.meta.delete_url != '') {
|
||||||
|
actions += '<a href="' + row.meta.delete_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-danger m-btn--icon m-btn--icon-only m-btn--pill btn-delete" data-id="' + row.name + '" title="Delete"><i class="la la-trash"></i></a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return actions;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
],
|
||||||
|
search: {
|
||||||
|
onEnter: false,
|
||||||
|
input: $('#data-rows-search'),
|
||||||
|
delay: 400
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var table = $("#data-rows").mDatatable(options);
|
||||||
|
|
||||||
|
$(document).on('click', '.btn-delete', function(e) {
|
||||||
|
var url = $(this).prop('href');
|
||||||
|
var id = $(this).data('id');
|
||||||
|
var btn = $(this);
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
swal({
|
||||||
|
title: 'Confirmation',
|
||||||
|
html: 'Are you sure you want to delete <strong>' + id + '</strong>?',
|
||||||
|
type: 'warning',
|
||||||
|
showCancelButton: true
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.value) {
|
||||||
|
$.ajax({
|
||||||
|
method: "DELETE",
|
||||||
|
url: url
|
||||||
|
}).done(function(response) {
|
||||||
|
table.row(btn.parents('tr')).remove();
|
||||||
|
table.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
</label>
|
</label>
|
||||||
<div class="col-lg-9">
|
<div class="col-lg-9">
|
||||||
{% if sets.areas is empty %}
|
{% if sets.areas is empty %}
|
||||||
No supported areas.
|
No available supported areas.
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="m-checkbox-list">
|
<div class="m-checkbox-list">
|
||||||
{% for id, label in sets.areas %}
|
{% for id, label in sets.areas %}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue