Merge pull request #1011 from mj-isip23/BUG_NEW_TAX_MODAL
fix add tax modal
This commit is contained in:
commit
f08b574f1f
@ -98,7 +98,8 @@
|
||||
'data-item' => 'tax_id',
|
||||
'v-model' => 'row.tax_id',
|
||||
'change' => 'onCalculateTotal',
|
||||
'class' => 'form-control'
|
||||
'class' => 'form-control',
|
||||
'path' => route('modals.taxes.create')
|
||||
], 'mb-0 select-tax') }}
|
||||
@stack('tax_id_input_end')
|
||||
</td>
|
||||
|
@ -1,93 +1,15 @@
|
||||
<div class="modal fade create-tax-{{ $rand }} d-none" id="modal-create-tax">
|
||||
<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.taxes', 1)]) }}</h4>
|
||||
</div>
|
||||
{!! Form::open([
|
||||
'id' => 'form-create-tax',
|
||||
'role' => 'form',
|
||||
'class' => 'form-loading-button'
|
||||
]) !!}
|
||||
<div class="row">
|
||||
{{ Form::textGroup('name', trans('general.name'), 'id-card-o') }}
|
||||
|
||||
<div class="modal-body">
|
||||
{!! Form::open(['id' => 'form-create-tax', 'role' => 'form', 'class' => 'form-loading-button']) !!}
|
||||
<div class="row">
|
||||
{{ Form::textGroup('name', trans('general.name'), 'id-card-o') }}
|
||||
{{ Form::textGroup('rate', trans('taxes.rate'), 'percent') }}
|
||||
|
||||
{{ Form::textGroup('rate', trans('taxes.rate'), 'percent') }}
|
||||
{{ Form::selectGroup('type', trans_choice('general.types', 1), 'bars', $types, 'normal') }}
|
||||
|
||||
{{ Form::selectGroup('type', trans_choice('general.types', 1), 'bars', $types, 'normal') }}
|
||||
|
||||
{!! 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-tax', '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>
|
||||
</div>
|
||||
{!! Form::hidden('enabled', '1', []) !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('.create-tax-{{ $rand }}#modal-create-tax').modal('show');
|
||||
|
||||
$('.create-tax-{{ $rand }} #rate').focus();
|
||||
|
||||
$(".create-tax-{{ $rand }} #type").select2({
|
||||
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.types', 1)]) }}"
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.create-tax-{{ $rand }} #button-create-tax', function (e) {
|
||||
$('.create-tax-{{ $rand }}#modal-create-tax .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: 16em !important;margin-left: 35%;margin-top: 8%;"></i></span>');
|
||||
|
||||
$.ajax({
|
||||
url: '{{ url("modals/taxes") }}',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
data: $(".create-tax-{{ $rand }} #form-create-tax").serialize(),
|
||||
beforeSend: function () {
|
||||
$('.create-tax-{{ $rand }} #button-create-tax').button('loading');
|
||||
|
||||
$(".create-tax-{{ $rand }} .form-group").removeClass("has-error");
|
||||
$(".create-tax-{{ $rand }} .help-block").remove();
|
||||
},
|
||||
complete: function() {
|
||||
$('.create-tax-{{ $rand }} #button-create-tax').button('reset');
|
||||
},
|
||||
success: function(json) {
|
||||
var data = json['data'];
|
||||
|
||||
$('.create-tax-{{ $rand }} #span-loading').remove();
|
||||
|
||||
$('.create-tax-{{ $rand }}#modal-create-tax').modal('hide');
|
||||
|
||||
$('#tax_id').append('<option value="' + data.id + '" selected="selected">' + data.name + '</option>');
|
||||
$('#tax_id').trigger('change');
|
||||
$('#tax_id').select2('refresh');
|
||||
|
||||
@if ($tax_selector)
|
||||
$('{{ $tax_selector }}').append('<option value="' + data.id + '" selected="selected">' + data.name + '</option>');
|
||||
$('{{ $tax_selector }}').trigger('change');
|
||||
$('{{ $tax_selector }}').select2('refresh');
|
||||
@endif
|
||||
},
|
||||
error: function(error, textStatus, errorThrown) {
|
||||
$('.create-tax-{{ $rand }} #span-loading').remove();
|
||||
|
||||
if (error.responseJSON.name) {
|
||||
$(".create-tax-{{ $rand }}#modal-create-tax input[name='name']").parent().parent().addClass('has-error');
|
||||
$(".create-tax-{{ $rand }}#modal-create-tax input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>');
|
||||
}
|
||||
|
||||
if (error.responseJSON.rate) {
|
||||
$(".create-tax-{{ $rand }}#modal-create-tax input[name='rate']").parent().parent().addClass('has-error');
|
||||
$(".create-tax-{{ $rand }}#modal-create-tax input[name='rate']").parent().after('<p class="help-block">' + error.responseJSON.rate + '</p>');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{!! Form::close() !!}
|
||||
|
@ -15,6 +15,7 @@
|
||||
@if (!empty($attributes['path']))
|
||||
:add-new-path="'{{ $attributes['path'] }}'"
|
||||
@endif
|
||||
@new_item="onNewItem($event)"
|
||||
@interface="{{ !empty($attributes['v-model']) ? $attributes['v-model'] . ' = $event' : 'form.' . $name . ' = $event' }}"
|
||||
@if (!empty($attributes['change']))
|
||||
@change="{{ $attributes['change'] }}($event)"
|
||||
|
Loading…
x
Reference in New Issue
Block a user