Skip to content

Commit

Permalink
Wizard currency and tax edit issue solved.
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Nov 7, 2018
1 parent 2d05fb8 commit c51edbc
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
9 changes: 8 additions & 1 deletion app/Http/Controllers/Wizard/Taxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ public function edit(Tax $tax)

$item = $tax;

return view('wizard.taxes.edit', compact('item'));
$html = view('wizard.TAXES.edit', compact('item'))->render();

return response()->json([
'success' => true,
'error' => false,
'message' => 'null',
'html' => $html,
]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion resources/views/wizard/currencies/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{ Form::radioGroup('enabled', trans('general.enabled'), trans('general.yes'), trans('general.no'), [], 'col-md-12') }}
</td>
<td class="text-center">
{!! Form::button('<span class="fa fa-save"></span>', ['type' => 'button', 'class' => 'btn btn-success currency-updated', 'data-loading-text' => trans('general.loading'), 'data-href' => url('wizard/currencies/' . $item->id), 'style' => 'padding: 9px 14px; margin-top: 10px;']) !!}
{!! Form::button('<span class="fa fa-save"></span>', ['type' => 'button', 'class' => 'btn btn-success currency-updated', 'data-loading-text' => trans('general.loading'), 'data-href' => url('wizard/currencies/' . $item->id), 'data-id' => $item->id, 'style' => 'padding: 9px 14px; margin-top: 10px;']) !!}
</td>
<td class="hidden">
{{ Form::numberGroup('precision', trans('currencies.precision'), 'bullseye', [], $item->precision) }}
Expand Down
16 changes: 15 additions & 1 deletion resources/views/wizard/currencies/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@
success: function(json) {
if (json['success']) {
$('#currency-' + data_id).after(json['html']);
$('#enabled_1').trigger('click');
$('#name').focus();
$("#code").select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans('currencies.code')]) }}"
Expand All @@ -239,18 +241,30 @@
$(this).html('<span class="fa fa-spinner fa-pulse"></span>');
$('.help-block').remove();
data = $('#tbl-currencies input[type=\'number\'], #tbl-currencies input[type=\'text\'], #tbl-currencies input[type=\'radio\'], #tbl-currencies input[type=\'hidden\'], #tbl-currencies textarea, #tbl-currencies select').serialize();
data_href = $(this).data('href');
data_id = $(this).data('id');
$.ajax({
url: data_href,
type: 'PATCH',
dataType: 'JSON',
data: $('#tbl-currencies input[type=\'number\'], #tbl-currencies input[type=\'text\'], #tbl-currencies input[type=\'radio\'], #tbl-currencies input[type=\'hidden\'], #tbl-currencies textarea, #tbl-currencies select').serialize(),
data: data,
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
success: function(json) {
$('.currency-updated').html('<span class="fa fa-save"></span>');
if (json['success']) {
$('#currency-' + data_id + ' .currency-name a').text($('#currency-edit #name').val());
$('#currency-' + data_id + ' .currency-code').text($('#currency-edit #code').val());
$('#currency-' + data_id + ' .currency-rate').text($('#currency-edit #rate').val());
if ($('#currency-edit #enabled').val()) {
$('#currency-' + data_id + ' .currency-status').html('<span class="label label-success">{{ trans('general.enabled') }}</span>');
} else {
$('#currency-' + data_id + ' .currency-status').html('<span class="label label-danger">{{ trans('general.disabled') }}</span>');
}
$('#currency-create').remove();
$('#currency-edit').remove();
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/wizard/taxes/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
{{ Form::radioGroup('enabled', trans('general.enabled'), trans('general.yes'), trans('general.no'), [], 'col-md-12') }}
</td>
<td class="text-center">
{!! Form::button('<span class="fa fa-save"></span>', ['type' => 'button', 'class' => 'btn btn-success tax-updated', 'data-loading-text' => trans('general.loading'), 'data-href' => url('wizard/taxes/' . $item->id), 'style' => 'padding: 9px 14px; margin-top: 10px;']) !!}
{!! Form::button('<span class="fa fa-save"></span>', ['type' => 'button', 'class' => 'btn btn-success tax-updated', 'data-loading-text' => trans('general.loading'), 'data-href' => url('wizard/taxes/' . $item->id), 'data-id' => $item->id, 'style' => 'padding: 9px 14px; margin-top: 10px;']) !!}
</td>
</tr>
11 changes: 11 additions & 0 deletions resources/views/wizard/taxes/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@
success: function(json) {
if (json['success']) {
$('#tax-' + data_id).after(json['html']);
$('#enabled_1').trigger('click');
$('#name').focus();
$("#code").select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans('taxes.code')]) }}"
Expand Down Expand Up @@ -249,6 +251,15 @@
$('.tax-updated').html('<span class="fa fa-save"></span>');
if (json['success']) {
$('#tax-' + data_id + ' .tax-name a').text($('#tax-edit #name').val());
$('#tax-' + data_id + ' .tax-rate').text($('#tax-edit #rate').val());
if ($('#tax-edit #enabled').val()) {
$('#tax-' + data_id + ' .tax-status').html('<span class="label label-success">{{ trans('general.enabled') }}</span>');
} else {
$('#tax-' + data_id + ' .tax-status').html('<span class="label label-danger">{{ trans('general.disabled') }}</span>');
}
$('#tax-create').remove();
$('#tax-edit').remove();
}
Expand Down

0 comments on commit c51edbc

Please sign in to comment.