close #767 Fixed: Modals dublicate action issue (Customer, Vendor, Tax, Payment etc)
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
<div class="modal fade" id="modal-create-category" style="display: none;">
|
||||
<div class="modal fade create-category-{{ $rand }}" id="modal-create-category" style="display: none;">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">{{ trans('general.title.new', ['type' => trans_choice('general.categories', 1)]) }}</h4>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
{!! Form::open(['id' => 'form-create-category', 'role' => 'form', 'class' => 'form-loading-button']) !!}
|
||||
|
||||
<div class="row">
|
||||
{{ Form::textGroup('name', trans('general.name'), 'id-card-o') }}
|
||||
|
||||
@ -23,11 +25,14 @@
|
||||
{!! Form::hidden('type', $type, []) !!}
|
||||
{!! Form::hidden('enabled', '1', []) !!}
|
||||
</div>
|
||||
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<div class="pull-left">
|
||||
{!! Form::button('<span class="fa fa-save"></span> ' . trans('general.save'), ['type' => 'button', 'id' =>'button-create-category', 'class' => 'btn btn-success button-submit', 'data-loading-text' => trans('general.loading')]) !!}
|
||||
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-times-circle"></span> {{ trans('general.cancel') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -37,34 +42,34 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#modal-create-category').modal('show');
|
||||
$('.create-category-{{ $rand }}#modal-create-category').modal('show');
|
||||
|
||||
$('#category-color-picker').colorpicker();
|
||||
$('.create-category-{{ $rand }} #category-color-picker').colorpicker();
|
||||
});
|
||||
|
||||
$(document).on('click', '#button-create-category', function (e) {
|
||||
$('#modal-create-category .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 10em !important;margin-left: 35%;margin-top: 8%;"></i></span>');
|
||||
$(document).on('click', '.create-category-{{ $rand }} #button-create-category', function (e) {
|
||||
$('.create-category-{{ $rand }}#modal-create-category .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 10em !important;margin-left: 35%;margin-top: 8%;"></i></span>');
|
||||
|
||||
$.ajax({
|
||||
url: '{{ url("modals/categories") }}',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
data: $("#form-create-category").serialize(),
|
||||
data: $(".create-category-{{ $rand }} #form-create-category").serialize(),
|
||||
beforeSend: function () {
|
||||
$('#button-create-category').button('loading');
|
||||
$('.create-category-{{ $rand }} #button-create-category').button('loading');
|
||||
|
||||
$(".form-group").removeClass("has-error");
|
||||
$(".help-block").remove();
|
||||
$(".create-category-{{ $rand }} .form-group").removeClass("has-error");
|
||||
$(".create-category-{{ $rand }} .help-block").remove();
|
||||
},
|
||||
complete: function() {
|
||||
$('#button-create-category').button('reset');
|
||||
$('.create-category-{{ $rand }} #button-create-category').button('reset');
|
||||
},
|
||||
success: function(json) {
|
||||
var data = json['data'];
|
||||
|
||||
$('#span-loading').remove();
|
||||
$('.create-category-{{ $rand }} #span-loading').remove();
|
||||
|
||||
$('#modal-create-category').modal('hide');
|
||||
$('.create-category-{{ $rand }}#modal-create-category').modal('hide');
|
||||
|
||||
$('#category_id').append('<option value="' + data.id + '" selected="selected">' + data.name + '</option>');
|
||||
$('#category_id').trigger('change');
|
||||
@ -77,18 +82,18 @@
|
||||
@endif
|
||||
},
|
||||
error: function(error, textStatus, errorThrown) {
|
||||
$('#span-loading').remove();
|
||||
$('.create-category-{{ $rand }} #span-loading').remove();
|
||||
|
||||
if (error.responseJSON.name) {
|
||||
$("#modal-create-category input[name='name']").parent().parent().addClass('has-error');
|
||||
$("#modal-create-category input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>');
|
||||
$(".create-category-{{ $rand }}#modal-create-category input[name='name']").parent().parent().addClass('has-error');
|
||||
$(".create-category-{{ $rand }}#modal-create-category input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>');
|
||||
}
|
||||
|
||||
if (error.responseJSON.color) {
|
||||
$("#modal-create-category input[name='color']").parent().parent().addClass('has-error');
|
||||
$("#modal-create-category input[name='color']").parent().after('<p class="help-block">' + error.responseJSON.color + '</p>');
|
||||
$(".create-category-{{ $rand }}#modal-create-category input[name='color']").parent().parent().addClass('has-error');
|
||||
$(".create-category-{{ $rand }}#modal-create-category input[name='color']").parent().after('<p class="help-block">' + error.responseJSON.color + '</p>');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user