Merge branch 'master' of gitlab.com:jankstudio/resq

This commit is contained in:
Kendrick Chan 2018-02-04 18:49:47 +08:00
commit 1961a86dfa
31 changed files with 639 additions and 683 deletions

View file

@ -0,0 +1,14 @@
$(function() {
$(document).ajaxError(function(event, response, ajaxSettings, thrownError) {
switch (response.status) {
case 500:
default:
swal({
title: 'Whoops!',
text: 'We encountered a problem. Please contact technical support.',
type: 'error'
});
break;
}
});
});

View file

@ -694,6 +694,7 @@
<!--end::Page Vendors -->
<!--begin::Page Snippets -->
<script src="/assets/app/js/dashboard.js" type="text/javascript"></script>
<script src="/assets/js/common.js" type="text/javascript"></script>
<!--end::Page Snippets -->
<!--begin::Extra Scripts -->

View file

@ -86,38 +86,40 @@
}
});
}).fail(function(response) {
var errors = response.responseJSON.errors;
var firstfield = false;
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// 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 + "']");
// 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');
// 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);
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// 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);
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -137,12 +137,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -86,38 +86,40 @@
}
});
}).fail(function(response) {
var errors = response.responseJSON.errors;
var firstfield = false;
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// 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 + "']");
// 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');
// 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);
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// 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);
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -137,12 +137,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -86,38 +86,40 @@
}
});
}).fail(function(response) {
var errors = response.responseJSON.errors;
var firstfield = false;
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// 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 + "']");
// 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');
// 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);
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// 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);
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -137,12 +137,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -32,183 +32,178 @@
</div>
</div>
</div>
<form id="row-form" class="m-form m-form--label-align-right" method="post" action="{{ mode == 'update' ? url('battery_update_submit', {'id': obj.getId()}) : url('battery_create_submit') }}">
<form id="row-form" class="m-form m-form--fit m-form--label-align-right" method="post" action="{{ mode == 'update' ? url('battery_update_submit', {'id': obj.getId()}) : url('battery_create_submit') }}">
<div class="m-portlet__body">
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#product-info">Product Information</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#vehicle-compatibility">Vehicle Compatibility</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="product-info" role="tabpanel">
<div class="m-form__section m-form__section--first">
<div class="m-form__heading">
<h3 class="m-form__heading-title">
Product Details
</h3>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<label data-field="prod_code">
Product Code
</label>
<input type="text" name="prod_code" class="form-control m-input" value="{{ obj.getProductCode() }}">
<div class="form-control-feedback hide" data-field="prod_code"></div>
</div>
<div class="col-lg-4">
<label data-field="sell_price">
Selling Price
</label>
<input type="text" name="sell_price" class="form-control m-input" value="{{ obj.getSellingPrice() }}">
<div class="form-control-feedback hide" data-field="sell_price"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<label data-field="manufacturer">
Manufacturer
</label>
<select class="form-control m-input" id="manufacturer" name="manufacturer">
<option value=""></option>
{% for manufacturer in bmfgs %}
<option value="{{ manufacturer.getID() }}"{{ obj.getManufacturer() and manufacturer.getID() == obj.getManufacturer().getID() ? ' selected' }}>{{ manufacturer.getName() }}</option>
{% endfor %}
</select>
<div class="form-control-feedback hide" data-field="manufacturer"></div>
</div>
<div class="col-lg-4">
<label data-field="model">
Model
</label>
<select class="form-control m-input" id="model" name="model">
<option value=""></option>
{% for model in models %}
<option value="{{ model.getID() }}"{{ obj.getModel() and obj.getModel().getID() ? ' selected' }}>{{ model.getName() }}</option>
{% endfor %}
</select>
<div class="form-control-feedback hide" data-field="model"></div>
</div>
<div class="col-lg-4">
<label data-field="size">
Size
</label>
<select class="form-control m-input" id="size" name="size">
<option value=""></option>
{% for size in sizes %}
<option value="{{ size.getID() }}"{{ obj.getSize() and obj.getSize().getID() ? ' selected' }}>{{ size.getName() }}</option>
{% endfor %}
</select>
<div class="form-control-feedback hide" data-field="size"></div>
</div>
</div>
</div>
<div class="m-form__seperator m-form__seperator--dashed"></div>
<div class="m-form__section">
<div class="m-form__heading">
<h3 class="m-form__heading-title">
Warranty
</h3>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<label data-field="warr_private">
Personal
</label>
<input type="number" name="warr_private" class="form-control m-input" value="{{ obj.getWarrantyPrivate() }}">
<div class="form-control-feedback hide" data-field="warr_private"></div>
<span class="m-form__help">In months</span>
</div>
<div class="col-lg-4">
<label data-field="warr_commercial">
Commercial
</label>
<input type="number" name="warr_commercial" class="form-control m-input" value="{{ obj.getWarrantyCommercial() }}">
<div class="form-control-feedback hide" data-field="warr_commercial"></div>
<span class="m-form__help">In months</span>
</div>
</div>
</div>
<div class="m-form__section">
<div class="m-form__heading">
<h3 class="m-form__heading-title">
Specifications
</h3>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<label data-field="length">
Length
</label>
<input type="number" name="length" class="form-control m-input" value="{{ obj.getLength() }}">
<div class="form-control-feedback hide" data-field="length"></div>
<span class="m-form__help">In millimeters (mm)</span>
</div>
<div class="col-lg-4">
<label data-field="width">
Width
</label>
<input type="number" name="width" class="form-control m-input" value="{{ obj.getWidth() }}">
<div class="form-control-feedback hide" data-field="width"></div>
<span class="m-form__help">In millimeters (mm)</span>
</div>
<div class="col-lg-4">
<label data-field="height">
Height
</label>
<input type="number" name="height" class="form-control m-input" value="{{ obj.getHeight() }}">
<div class="form-control-feedback hide" data-field="height"></div>
<span class="m-form__help">In millimeters (mm)</span>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<label data-field="total_height">
Total Height
</label>
<input type="number" name="total_height" class="form-control m-input" value="{{ obj.getTotalHeight() }}">
<div class="form-control-feedback hide" data-field="total_height"></div>
<span class="m-form__help">In millimeters (mm)</span>
</div>
<div class="col-lg-4">
<label data-field="res_capacity">
Reserve Capacity
</label>
<input type="number" name="res_capacity" class="form-control m-input" value="{{ obj.getReserveCapacity() }}">
<div class="form-control-feedback hide" data-field="res_capacity"></div>
<span class="m-form__help">In minutes</span>
</div>
</div>
</div>
<div class="m-form__section m-form__section--first">
<div class="m-form__heading">
<h3 class="m-form__heading-title">
Product Details
</h3>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<label data-field="prod_code">
Product Code
</label>
<input type="text" name="prod_code" class="form-control m-input" value="{{ obj.getProductCode() }}">
<div class="form-control-feedback hide" data-field="prod_code"></div>
</div>
<div class="tab-pane" id="vehicle-compatibility" role="tabpanel">
<div class="form-group m-form__group row form-group-inner">
<div class="col-lg-12">
<div id="data-vehicles"></div>
</div>
<div class="col-lg-4">
<label data-field="sell_price">
Selling Price
</label>
<input type="text" name="sell_price" class="form-control m-input" value="{{ obj.getSellingPrice() }}">
<div class="form-control-feedback hide" data-field="sell_price"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<label data-field="manufacturer">
Manufacturer
</label>
<select class="form-control m-input" id="manufacturer" name="manufacturer">
<option value=""></option>
{% for manufacturer in bmfgs %}
<option value="{{ manufacturer.getID() }}"{{ obj.getManufacturer() and manufacturer.getID() == obj.getManufacturer().getID() ? ' selected' }}>{{ manufacturer.getName() }}</option>
{% endfor %}
</select>
<div class="form-control-feedback hide" data-field="manufacturer"></div>
</div>
<div class="form-group m-form__group row form-group-inner">
<label class="col-lg-1 col-form-label" data-field="vehicle_list">
Add Vehicle:
</label>
<div class="col-lg-3">
<select name="vmfg_list" class="form-control m-input" id="vmfg">
<option value="">Select a manufacturer</option>
{% for manufacturer in vmfgs %}
<option value="{{ manufacturer.getID() }}">{{ manufacturer.getName() }}</option>
{% endfor %}
</select>
</div>
<div class="col-lg-3">
<select name="vehicle_list" class="form-control m-input" id="vehicle" disabled>
<option value="">Select a manufacturer first</option>
</select>
</div>
<div class="col-lg-3">
<button type="button" class="btn btn-primary" id="btn-add-vehicle" disabled>Add to List</button>
</div>
<div class="col-lg-4">
<label data-field="model">
Model
</label>
<select class="form-control m-input" id="model" name="model">
<option value=""></option>
{% for model in models %}
<option value="{{ model.getID() }}"{{ obj.getModel() and obj.getModel().getID() ? ' selected' }}>{{ model.getName() }}</option>
{% endfor %}
</select>
<div class="form-control-feedback hide" data-field="model"></div>
</div>
<div class="col-lg-4">
<label data-field="size">
Size
</label>
<select class="form-control m-input" id="size" name="size">
<option value=""></option>
{% for size in sizes %}
<option value="{{ size.getID() }}"{{ obj.getSize() and obj.getSize().getID() ? ' selected' }}>{{ size.getName() }}</option>
{% endfor %}
</select>
<div class="form-control-feedback hide" data-field="size"></div>
</div>
</div>
</div>
<div class="m-form__seperator m-form__seperator--dashed"></div>
<div class="m-form__section">
<div class="m-form__heading">
<h3 class="m-form__heading-title">
Warranty
</h3>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<label data-field="warr_private">
Personal
</label>
<input type="number" name="warr_private" class="form-control m-input" value="{{ obj.getWarrantyPrivate() }}">
<div class="form-control-feedback hide" data-field="warr_private"></div>
<span class="m-form__help">In months</span>
</div>
<div class="col-lg-4">
<label data-field="warr_commercial">
Commercial
</label>
<input type="number" name="warr_commercial" class="form-control m-input" value="{{ obj.getWarrantyCommercial() }}">
<div class="form-control-feedback hide" data-field="warr_commercial"></div>
<span class="m-form__help">In months</span>
</div>
</div>
</div>
<div class="m-form__seperator m-form__seperator--dashed"></div>
<div class="m-form__section">
<div class="m-form__heading">
<h3 class="m-form__heading-title">
Specifications
</h3>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<label data-field="length">
Length
</label>
<input type="number" name="length" class="form-control m-input" value="{{ obj.getLength() }}">
<div class="form-control-feedback hide" data-field="length"></div>
<span class="m-form__help">In millimeters (mm)</span>
</div>
<div class="col-lg-4">
<label data-field="width">
Width
</label>
<input type="number" name="width" class="form-control m-input" value="{{ obj.getWidth() }}">
<div class="form-control-feedback hide" data-field="width"></div>
<span class="m-form__help">In millimeters (mm)</span>
</div>
<div class="col-lg-4">
<label data-field="height">
Height
</label>
<input type="number" name="height" class="form-control m-input" value="{{ obj.getHeight() }}">
<div class="form-control-feedback hide" data-field="height"></div>
<span class="m-form__help">In millimeters (mm)</span>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<label data-field="total_height">
Total Height
</label>
<input type="number" name="total_height" class="form-control m-input" value="{{ obj.getTotalHeight() }}">
<div class="form-control-feedback hide" data-field="total_height"></div>
<span class="m-form__help">In millimeters (mm)</span>
</div>
<div class="col-lg-4">
<label data-field="res_capacity">
Reserve Capacity
</label>
<input type="number" name="res_capacity" class="form-control m-input" value="{{ obj.getReserveCapacity() }}">
<div class="form-control-feedback hide" data-field="res_capacity"></div>
<span class="m-form__help">In minutes</span>
</div>
</div>
</div>
<div class="m-form__seperator m-form__seperator--dashed"></div>
<div class="m-form__section m-form__section--last">
<div class="m-form__heading">
<h3 class="m-form__heading-title">
Vehicle Compatibility
</h3>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-12">
<div id="data-vehicles"></div>
</div>
</div>
<div class="form-group m-form__group row">
<label class="col-lg-1 col-form-label" data-field="vehicle_list">
Add Vehicle:
</label>
<div class="col-lg-3">
<select name="vmfg_list" class="form-control m-input" id="vmfg">
<option value="">Select a manufacturer</option>
{% for manufacturer in vmfgs %}
<option value="{{ manufacturer.getID() }}">{{ manufacturer.getName() }}</option>
{% endfor %}
</select>
</div>
<div class="col-lg-3">
<select name="vehicle_list" class="form-control m-input" id="vehicle" disabled>
<option value="">Select a manufacturer first</option>
</select>
</div>
<div class="col-lg-3">
<button type="button" class="btn btn-primary" id="btn-add-vehicle" disabled>Add to List</button>
</div>
</div>
</div>
@ -264,38 +259,40 @@
}
});
}).fail(function(response) {
var errors = response.responseJSON.errors;
var firstfield = false;
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// 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 + "']");
// 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');
// 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);
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// 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);
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -171,12 +171,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -139,18 +139,18 @@
<div class="m_datatable" id="data-tickets"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-12">
<a href="{{ url('ticket_create', {'customer_id': obj.getID}) }}" class="btn btn-primary">Create Ticket</a>
</div>
</div>
</div>
{% endif %}
</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-6 text-left">
{% if mode == 'update' %}
<a href="{{ url('ticket_create', {'customer_id': obj.getID}) }}" class="btn btn-info"><i class="fa fa-ticket fa-fw"></i>Create Ticket</a>
{% endif %}
</div>
<div class="col-lg-6">
<div class="col-lg-12">
<button type="submit" class="btn btn-success">Submit</button>
<a href="{{ url('customer_list') }}" class="btn btn-secondary">Cancel</a>
</div>
@ -369,99 +369,101 @@
}
});
}).fail(function(response) {
var json = response.responseJSON;
var errors = json.errors;
var nerrors = json.nerrors;
var verrors = json.verrors;
var firstfield = false;
if (response.status == 422) {
var json = response.responseJSON;
var errors = json.errors;
var nerrors = json.nerrors;
var verrors = json.verrors;
var firstfield = false;
// remove all error classes first
removeErrors();
// remove all error classes first
removeErrors();
// display errors contextually
$.each(errors, function(field, msg) {
var formfield = $("[data-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;
}
// add error class to this tab
var tabId = $(formfield).closest('.tab-pane').prop('id');
$("#customer-tabs").find("a[href='#" + tabId + "']").addClass('has-danger');
});
// loop through mobile number errors
$.each(nerrors, function(rowindex, errorlist) {
var row = $("#data-mobile-numbers table").find("[name='index'][value='" + rowindex + "']").closest('tr');
$.each(errorlist, function(field, msg) {
var msgbox = row.find(".form-control-feedback[data-field='" + field + "']");
var col = msgbox.closest('span');
// display errors contextually
$.each(errors, function(field, msg) {
var formfield = $("[data-name='" + field + "']");
var label = $("label[data-field='" + field + "']");
var msgbox = $(".form-control-feedback[data-field='" + field + "']");
// add error classes to bad fields
col.addClass('has-danger');
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 = col.get(0);
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
// add error class to this tab
var tabId = $(col).closest('.tab-pane').prop('id');
var tabId = $(formfield).closest('.tab-pane').prop('id');
$("#customer-tabs").find("a[href='#" + tabId + "']").addClass('has-danger');
});
});
// loop through vehicle errors
$.each(verrors, function(rowindex, errorlist) {
var row = $("#data-vehicles table").find("[name='index'][value='" + rowindex + "']").closest('tr');
// loop through mobile number errors
$.each(nerrors, function(rowindex, errorlist) {
var row = $("#data-mobile-numbers table").find("[name='index'][value='" + rowindex + "']").closest('tr');
$.each(errorlist, function(field, msg) {
var msgbox = row.find(".form-control-feedback[data-field='" + field + "']");
var col = msgbox.closest('span');
$.each(errorlist, function(field, msg) {
var msgbox = row.find(".form-control-feedback[data-field='" + field + "']");
var col = msgbox.closest('span');
// add error classes to bad fields
col.addClass('has-danger');
msgbox.html(msg).addClass('has-danger').removeClass('hide');
// add error classes to bad fields
col.addClass('has-danger');
msgbox.html(msg).addClass('has-danger').removeClass('hide');
// check if this field comes first in DOM
var domfield = col.get(0);
// check if this field comes first in DOM
var domfield = col.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
// add error class to this tab
var tabId = $(col).closest('.tab-pane').prop('id');
$("#customer-tabs").find("a[href='#" + tabId + "']").addClass('has-danger');
// add error class to this tab
var tabId = $(col).closest('.tab-pane').prop('id');
$("#customer-tabs").find("a[href='#" + tabId + "']").addClass('has-danger');
});
});
});
// focus on tab containing first field
var firstTabId = $(firstfield).closest('.tab-pane').prop('id');
$("#customer-tabs").find("a[href='#" + firstTabId + "']").tab('show');
// loop through vehicle errors
$.each(verrors, function(rowindex, errorlist) {
var row = $("#data-vehicles table").find("[name='index'][value='" + rowindex + "']").closest('tr');
// focus on first bad field
firstfield.focus();
$.each(errorlist, function(field, msg) {
var msgbox = row.find(".form-control-feedback[data-field='" + field + "']");
var col = msgbox.closest('span');
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
// add error classes to bad fields
col.addClass('has-danger');
msgbox.html(msg).addClass('has-danger').removeClass('hide');
// check if this field comes first in DOM
var domfield = col.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
// add error class to this tab
var tabId = $(col).closest('.tab-pane').prop('id');
$("#customer-tabs").find("a[href='#" + tabId + "']").addClass('has-danger');
});
});
// focus on tab containing first field
var firstTabId = $(firstfield).closest('.tab-pane').prop('id');
$("#customer-tabs").find("a[href='#" + firstTabId + "']").tab('show');
// 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);
}
});
});

View file

@ -192,12 +192,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -269,38 +269,40 @@ $(function() {
}
});
}).fail(function(response) {
var errors = response.responseJSON.errors;
var firstfield = false;
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// 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 + "']");
// 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');
// 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);
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// 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);
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -154,12 +154,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -698,38 +698,40 @@ $(function() {
}
});
}).fail(function(response) {
var errors = response.responseJSON.errors;
var firstfield = false;
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// remove all error classes first
removeErrors();
// display errors contextually
$.each(errors, function(field, msg) {
var formfield = $("[name='" + field + "'], [data-name='" + field + "']");
var label = $("label[data-field='" + field + "']");
var msgbox = $(".form-control-feedback[data-field='" + field + "']");
// display errors contextually
$.each(errors, function(field, msg) {
var formfield = $("[name='" + field + "'], [data-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');
// 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);
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// 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);
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -248,38 +248,40 @@ $(function() {
}
});
}).fail(function(response) {
var errors = response.responseJSON.errors;
var firstfield = false;
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// 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 + "']");
// 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');
// 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);
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// 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);
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -158,12 +158,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -114,38 +114,40 @@ $(function() {
}
});
}).fail(function(response) {
var errors = response.responseJSON.errors;
var firstfield = false;
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// 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 + "']");
// 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');
// 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);
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// 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);
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -146,12 +146,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -169,38 +169,40 @@
}
});
}).fail(function(response) {
var errors = response.responseJSON.errors;
var firstfield = false;
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// 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 + "']");
// 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');
// 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);
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// 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);
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -161,12 +161,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -116,38 +116,40 @@
}
});
}).fail(function(response) {
var errors = response.responseJSON.errors;
var firstfield = false;
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// 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 + "']");
// 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');
// 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);
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// 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);
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -133,12 +133,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -102,7 +102,7 @@
<div class="row">
<div class="col-lg-12">
<button type="submit" class="btn btn-success">Submit</button>
<a href="{{ url('ticket_list') }}" class="btn btn-secondary">Cancel</a>
<a href="{{ redirect_url }}" class="btn btn-secondary">Cancel</a>
</div>
</div>
</div>
@ -138,38 +138,40 @@
}
});
}).fail(function(response) {
var errors = response.responseJSON.errors;
var firstfield = false;
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// 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 + "']");
// 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');
// 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);
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// 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);
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -163,12 +163,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -184,38 +184,40 @@
}
});
}).fail(function(response) {
var errors = response.responseJSON.errors;
var firstfield = false;
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// 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 + "']");
// 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');
// 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);
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// 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);
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -165,12 +165,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -86,38 +86,40 @@
}
});
}).fail(function(response) {
var errors = response.responseJSON.errors;
var firstfield = false;
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// 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 + "']");
// 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');
// 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);
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// 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);
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -137,12 +137,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -122,38 +122,40 @@
}
});
}).fail(function(response) {
var errors = response.responseJSON.errors;
var firstfield = false;
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// 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 + "']");
// 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');
// 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);
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// 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);
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -145,12 +145,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});