Add review tag management views #730
This commit is contained in:
parent
e235026197
commit
562e96e32d
9 changed files with 630 additions and 1 deletions
|
|
@ -528,6 +528,20 @@ catalyst_auth:
|
||||||
- id: customer_tag.delete
|
- id: customer_tag.delete
|
||||||
label: Delete
|
label: Delete
|
||||||
|
|
||||||
|
- id: review_tag
|
||||||
|
label: Review Tags Access
|
||||||
|
acls:
|
||||||
|
- id: review_tag.menu
|
||||||
|
label: Menu
|
||||||
|
- id: review_tag.list
|
||||||
|
label: List
|
||||||
|
- id: review_tag.add
|
||||||
|
label: Add
|
||||||
|
- id: review_tag.update
|
||||||
|
label: Update
|
||||||
|
- id: review_tag.delete
|
||||||
|
label: Delete
|
||||||
|
|
||||||
- id: dealer
|
- id: dealer
|
||||||
label: Dealer Access
|
label: Dealer Access
|
||||||
acls:
|
acls:
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,10 @@ catalyst_menu:
|
||||||
acl: customer_tag.list
|
acl: customer_tag.list
|
||||||
label: '[menu.support.customertags]'
|
label: '[menu.support.customertags]'
|
||||||
parent: support
|
parent: support
|
||||||
|
- id: reviewtag_list
|
||||||
|
acl: review_tag.list
|
||||||
|
label: '[menu.support.reviewtags]'
|
||||||
|
parent: support
|
||||||
|
|
||||||
- id: service
|
- id: service
|
||||||
acl: service.menu
|
acl: service.menu
|
||||||
|
|
|
||||||
33
config/routes/review_tag.yaml
Normal file
33
config/routes/review_tag.yaml
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
reviewtag_list:
|
||||||
|
path: /review_tags
|
||||||
|
controller: App\Controller\ReviewTagController::index
|
||||||
|
|
||||||
|
reviewtag_rows:
|
||||||
|
path: /review_tags/rows
|
||||||
|
controller: App\Controller\ReviewTagController::rows
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
reviewtag_create:
|
||||||
|
path: /review_tags/create
|
||||||
|
controller: App\Controller\ReviewTagController::addForm
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
reviewtag_create_submit:
|
||||||
|
path: /review_tags/create
|
||||||
|
controller: App\Controller\ReviewTagController::addSubmit
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
reviewtag_update:
|
||||||
|
path: /review_tags/{id}
|
||||||
|
controller: App\Controller\ReviewTagController::updateForm
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
reviewtag_update_submit:
|
||||||
|
path: /review_tags/{id}
|
||||||
|
controller: App\Controller\ReviewTagController::updateSubmit
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
reviewtag_delete:
|
||||||
|
path: /review_tags/{id}
|
||||||
|
controller: App\Controller\ReviewTagController::destroy
|
||||||
|
methods: [DELETE]
|
||||||
267
src/Controller/ReviewTagController.php
Normal file
267
src/Controller/ReviewTagController.php
Normal file
|
|
@ -0,0 +1,267 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Entity\ReviewTag;
|
||||||
|
use App\Ramcar\ReviewTagType;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Query;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
|
||||||
|
use Catalyst\MenuBundle\Annotation\Menu;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
|
class ReviewTagController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Menu(selected="review_tag_list")
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('review_tag.list', null, 'No access.');
|
||||||
|
|
||||||
|
return $this->render('review-tag/list.html.twig');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rows(Request $req)
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('review_tag.list', null, 'No access.');
|
||||||
|
|
||||||
|
// get query builder
|
||||||
|
$qb = $this->getDoctrine()
|
||||||
|
->getRepository(ReviewTag::class)
|
||||||
|
->createQueryBuilder('q');
|
||||||
|
|
||||||
|
// get datatable params
|
||||||
|
$datatable = $req->request->get('datatable');
|
||||||
|
|
||||||
|
// count total records
|
||||||
|
$tquery = $qb->select('COUNT(q)');
|
||||||
|
$this->setQueryFilters($datatable, $tquery);
|
||||||
|
$total = $tquery->getQuery()
|
||||||
|
->getSingleScalarResult();
|
||||||
|
|
||||||
|
// get current page number
|
||||||
|
$page = $datatable['pagination']['page'] ?? 1;
|
||||||
|
|
||||||
|
$perpage = $datatable['pagination']['perpage'];
|
||||||
|
$offset = ($page - 1) * $perpage;
|
||||||
|
|
||||||
|
// add metadata
|
||||||
|
$meta = [
|
||||||
|
'page' => $page,
|
||||||
|
'perpage' => $perpage,
|
||||||
|
'pages' => ceil($total / $perpage),
|
||||||
|
'total' => $total,
|
||||||
|
'sort' => 'asc',
|
||||||
|
'field' => 'id'
|
||||||
|
];
|
||||||
|
|
||||||
|
// build query
|
||||||
|
$query = $qb->select('q');
|
||||||
|
$this->setQueryFilters($datatable, $query);
|
||||||
|
|
||||||
|
// check if sorting is present, otherwise use default
|
||||||
|
if (isset($datatable['sort']['field']) && !empty($datatable['sort']['field'])) {
|
||||||
|
$order = $datatable['sort']['sort'] ?? 'asc';
|
||||||
|
$query->orderBy('q.' . $datatable['sort']['field'], $order);
|
||||||
|
} else {
|
||||||
|
$query->orderBy('q.id', 'asc');
|
||||||
|
}
|
||||||
|
|
||||||
|
// get rows for this page
|
||||||
|
$obj_rows = $query->setFirstResult($offset)
|
||||||
|
->setMaxResults($perpage)
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
// process rows
|
||||||
|
$rows = [];
|
||||||
|
foreach ($obj_rows as $orow) {
|
||||||
|
// add row data
|
||||||
|
$row['id'] = $orow->getID();
|
||||||
|
$row['name'] = $orow->getName();
|
||||||
|
$row['type'] = ucfirst($orow->getType());
|
||||||
|
|
||||||
|
// add row metadata
|
||||||
|
$row['meta'] = [
|
||||||
|
'update_url' => '',
|
||||||
|
'delete_url' => ''
|
||||||
|
];
|
||||||
|
|
||||||
|
// add crud urls
|
||||||
|
if ($this->isGranted('review_tag.update'))
|
||||||
|
$row['meta']['update_url'] = $this->generateUrl('reviewtag_update', ['id' => $row['id']]);
|
||||||
|
if ($this->isGranted('review_tag.delete'))
|
||||||
|
$row['meta']['delete_url'] = $this->generateUrl('reviewtag_delete', ['id' => $row['id']]);
|
||||||
|
|
||||||
|
$rows[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $this->json([
|
||||||
|
'meta' => $meta,
|
||||||
|
'data' => $rows
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setQueryFilters($datatable, QueryBuilder $query)
|
||||||
|
{
|
||||||
|
if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) {
|
||||||
|
$query->where('q.name LIKE :filter')
|
||||||
|
->setParameter('filter', '%' . $datatable['query']['data-rows-search'] . '%');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Menu(selected="review_tag_list")
|
||||||
|
*/
|
||||||
|
public function addForm()
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('review_tag.add', null, 'No access.');
|
||||||
|
|
||||||
|
$params['obj'] = new ReviewTag();
|
||||||
|
$params['mode'] = 'create';
|
||||||
|
|
||||||
|
$params['types'] = ReviewTagType::getCollection();
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $this->render('review-tag/form.html.twig', $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addSubmit(Request $req, ValidatorInterface $validator)
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('review_tag.add', null, 'No access.');
|
||||||
|
|
||||||
|
// create new object
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$obj = new ReviewTag();
|
||||||
|
|
||||||
|
$obj->setName($req->request->get('name'))
|
||||||
|
->setType($req->request->get('type'));
|
||||||
|
|
||||||
|
// validate
|
||||||
|
$errors = $validator->validate($obj);
|
||||||
|
|
||||||
|
// initialize error list
|
||||||
|
$error_array = [];
|
||||||
|
|
||||||
|
// add errors to list
|
||||||
|
foreach ($errors as $error) {
|
||||||
|
$error_array[$error->getPropertyPath()] = $error->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if any errors were found
|
||||||
|
if (!empty($error_array)) {
|
||||||
|
// return validation failure response
|
||||||
|
return $this->json([
|
||||||
|
'success' => false,
|
||||||
|
'errors' => $error_array
|
||||||
|
], 422);
|
||||||
|
} else {
|
||||||
|
// validated! save the entity
|
||||||
|
$em->persist($obj);
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
// return successful response
|
||||||
|
return $this->json([
|
||||||
|
'success' => 'Changes have been saved!'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Menu(selected="review_tag_list")
|
||||||
|
*/
|
||||||
|
public function updateForm($id)
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('review_tag.update', null, 'No access.');
|
||||||
|
|
||||||
|
// get row data
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$obj = $em->getRepository(ReviewTag::class)->find($id);
|
||||||
|
|
||||||
|
// make sure this row exists
|
||||||
|
if (empty($obj))
|
||||||
|
throw $this->createNotFoundException('The item does not exist');
|
||||||
|
|
||||||
|
$params['obj'] = $obj;
|
||||||
|
$params['mode'] = 'update';
|
||||||
|
|
||||||
|
$params['types'] = ReviewTagType::getCollection();
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $this->render('review-tag/form.html.twig', $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateSubmit(Request $req, ValidatorInterface $validator, $id)
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('review_tag.update', null, 'No access.');
|
||||||
|
|
||||||
|
// get object data
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$obj = $em->getRepository(ReviewTag::class)->find($id);
|
||||||
|
|
||||||
|
// make sure this object exists
|
||||||
|
if (empty($obj))
|
||||||
|
throw $this->createNotFoundException('The item does not exist');
|
||||||
|
|
||||||
|
$obj->setName($req->request->get('name'))
|
||||||
|
->setType($req->request->get('type'));
|
||||||
|
|
||||||
|
// validate
|
||||||
|
$errors = $validator->validate($obj);
|
||||||
|
|
||||||
|
// initialize error list
|
||||||
|
$error_array = [];
|
||||||
|
|
||||||
|
// add errors to list
|
||||||
|
foreach ($errors as $error) {
|
||||||
|
$error_array[$error->getPropertyPath()] = $error->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if any errors were found
|
||||||
|
if (!empty($error_array)) {
|
||||||
|
// return validation failure response
|
||||||
|
return $this->json([
|
||||||
|
'success' => false,
|
||||||
|
'errors' => $error_array
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
// validated! save the entity
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
// return successful response
|
||||||
|
return $this->json([
|
||||||
|
'success' => 'Changes have been saved!'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('review_tag.delete', null, 'No access.');
|
||||||
|
|
||||||
|
// get object data
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$obj = $em->getRepository(ReviewTag::class)->find($id);
|
||||||
|
|
||||||
|
if (empty($obj))
|
||||||
|
throw $this->createNotFoundException('The item does not exist');
|
||||||
|
|
||||||
|
// delete this object
|
||||||
|
$em->remove($obj);
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
// response
|
||||||
|
$response = new Response();
|
||||||
|
$response->setStatusCode(Response::HTTP_OK);
|
||||||
|
$response->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
14
src/Ramcar/ReviewTagType.php
Normal file
14
src/Ramcar/ReviewTagType.php
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ramcar;
|
||||||
|
|
||||||
|
class ReviewTagType extends NameValue
|
||||||
|
{
|
||||||
|
const RIDER = 'rider';
|
||||||
|
const PARTNER = 'partner';
|
||||||
|
|
||||||
|
const COLLECTION = [
|
||||||
|
'rider' => 'Rider',
|
||||||
|
'partner' => 'Partner',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -49,7 +49,6 @@
|
||||||
Event Type
|
Event Type
|
||||||
</label>
|
</label>
|
||||||
<select class="form-control m-input" name="event_type">
|
<select class="form-control m-input" name="event_type">
|
||||||
<option value=""></option>
|
|
||||||
{% for key, event_type in event_types %}
|
{% for key, event_type in event_types %}
|
||||||
<option value="{{ key }}"{{ key == obj.getEventType ? ' selected' }}>{{ event_type }}</option>
|
<option value="{{ key }}"{{ key == obj.getEventType ? ' selected' }}>{{ event_type }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
||||||
149
templates/review-tag/form.html.twig
Normal file
149
templates/review-tag/form.html.twig
Normal file
|
|
@ -0,0 +1,149 @@
|
||||||
|
{% 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">Review Tags</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- END: Subheader -->
|
||||||
|
<div class="m-content">
|
||||||
|
<!--Begin::Section-->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xl-10">
|
||||||
|
<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="fa fa-tags"></i>
|
||||||
|
</span>
|
||||||
|
<h3 class="m-portlet__head-text">
|
||||||
|
{% if mode == 'update' %}
|
||||||
|
Edit Review Tag
|
||||||
|
<small>{{ obj.getName }}</small>
|
||||||
|
{% else %}
|
||||||
|
New Review Tag
|
||||||
|
{% 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('reviewtag_update_submit', {'id': obj.getId}) : url('reviewtag_create_submit') }}">
|
||||||
|
|
||||||
|
<div class="m-portlet__body">
|
||||||
|
<div class="form-group m-form__group row no-border">
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<label for="name" data-field="name">
|
||||||
|
Name
|
||||||
|
</label>
|
||||||
|
<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">
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<label for="name" data-field="name">
|
||||||
|
Type
|
||||||
|
</label>
|
||||||
|
<select class="form-control m-input" name="type">
|
||||||
|
{% for key, type in types %}
|
||||||
|
<option value="{{ key }}"{{ key == obj.getType ? ' selected' }}>{{ type }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<div class="form-control-feedback hide" data-field="type"></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('reviewtag_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('reviewtag_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 %}
|
||||||
|
|
||||||
148
templates/review-tag/list.html.twig
Normal file
148
templates/review-tag/list.html.twig
Normal file
|
|
@ -0,0 +1,148 @@
|
||||||
|
{% 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">
|
||||||
|
Review Tags
|
||||||
|
</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('reviewtag_create') }}" class="btn btn-focus m-btn m-btn--custom m-btn--icon m-btn--air m-btn--pill">
|
||||||
|
<span>
|
||||||
|
<i class="la la-star-o"></i>
|
||||||
|
<span>New Review Tag</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("reviewtag_rows") }}',
|
||||||
|
method: 'POST',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
saveState: {
|
||||||
|
cookie: false,
|
||||||
|
webstorage: false
|
||||||
|
},
|
||||||
|
pageSize: 10,
|
||||||
|
serverPaging: true,
|
||||||
|
serverFiltering: true,
|
||||||
|
serverSorting: true
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
field: 'id',
|
||||||
|
title: 'ID',
|
||||||
|
width: 250
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'type',
|
||||||
|
title: 'Type'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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 %}
|
||||||
|
|
||||||
|
|
@ -137,6 +137,7 @@ menu.support.warranty: 'Warranty'
|
||||||
menu.support.warrantyupload: 'Warranty Upload'
|
menu.support.warrantyupload: 'Warranty Upload'
|
||||||
menu.support.staticcontent: 'Static Content'
|
menu.support.staticcontent: 'Static Content'
|
||||||
menu.support.customertags: 'Customer Tags'
|
menu.support.customertags: 'Customer Tags'
|
||||||
|
menu.support.reviewtags: 'Review Tags'
|
||||||
|
|
||||||
menu.service: 'Other Services'
|
menu.service: 'Other Services'
|
||||||
menu.service.services: 'Services'
|
menu.service.services: 'Services'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue