Tax rates for all states
This commit is contained in:
parent
fafa0df14a
commit
fbfd710f1c
|
|
@ -45,7 +45,7 @@
|
|||
<span class="control-error" v-if="errors.has('identifier')">@{{ errors.first('identifier') }}</span>
|
||||
</div>
|
||||
|
||||
@include ('admin::customers.country-state', ['countryCode' => old('country'), 'stateCode' => old('state')])
|
||||
<country-state></country-state>
|
||||
|
||||
<div class="control-group">
|
||||
<span class="checkbox">
|
||||
|
|
@ -83,6 +83,50 @@
|
|||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/x-template" id="country-state-template">
|
||||
<div>
|
||||
<div class="control-group" :class="[errors.has('country') ? 'has-error' : '']">
|
||||
<label for="country" class="required">
|
||||
{{ __('admin::app.customers.customers.country') }}
|
||||
</label>
|
||||
|
||||
<select type="text" v-validate="'required'" class="control" id="country" name="country" v-model="country" data-vv-as=""{{ __('admin::app.customers.customers.country') }}"">
|
||||
<option value=""></option>
|
||||
|
||||
@foreach (core()->countries() as $country)
|
||||
|
||||
<option value="{{ $country->code }}">{{ $country->name }}</option>
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<span class="control-error" v-if="errors.has('country')">
|
||||
@{{ errors.first('country') }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('state') ? 'has-error' : '']">
|
||||
<label for="state">
|
||||
{{ __('admin::app.customers.customers.state') }}
|
||||
</label>
|
||||
|
||||
<select class="control" id="state" name="state" v-model="state">
|
||||
|
||||
<option value="" :selected="! haveStates()">*</option>
|
||||
|
||||
<option v-for='(state, index) in countryStates[country]' :value="state.code">
|
||||
@{{ state.default_name }}
|
||||
</option>
|
||||
|
||||
</select>
|
||||
|
||||
<span class="control-error" v-if="errors.has('state')">
|
||||
@{{ errors.first('state') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
Vue.component('tax-rate-form', {
|
||||
|
||||
|
|
@ -96,5 +140,31 @@
|
|||
}
|
||||
},
|
||||
});
|
||||
|
||||
Vue.component('country-state', {
|
||||
|
||||
template: '#country-state-template',
|
||||
|
||||
inject: ['$validator'],
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
country: "{{ old('country') }}",
|
||||
|
||||
state: "{{ old('state') }}",
|
||||
|
||||
countryStates: @json(core()->groupedStatesByCountries())
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
haveStates: function () {
|
||||
if (this.countryStates[this.country] && this.countryStates[this.country].length)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
},
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
<span class="control-error" v-if="errors.has('identifier')">@{{ errors.first('identifier') }}</span>
|
||||
</div>
|
||||
|
||||
@include ('admin::customers.country-state', ['countryCode' => old('country') ?? $taxRate->country, 'stateCode' => old('state') ?? $taxRate->state])
|
||||
<country-state></country-state>
|
||||
|
||||
@if ($taxRate->is_zip)
|
||||
<input type="hidden" id="is_zip" name="is_zip" value="{{ $taxRate->is_zip }}">
|
||||
|
|
@ -71,3 +71,78 @@
|
|||
</form>
|
||||
</div>
|
||||
@stop
|
||||
|
||||
@push('scripts')
|
||||
|
||||
<script type="text/x-template" id="country-state-template">
|
||||
<div>
|
||||
<div class="control-group" :class="[errors.has('country') ? 'has-error' : '']">
|
||||
<label for="country" class="required">
|
||||
{{ __('admin::app.customers.customers.country') }}
|
||||
</label>
|
||||
|
||||
<select type="text" v-validate="'required'" class="control" id="country" name="country" v-model="country" data-vv-as=""{{ __('admin::app.customers.customers.country') }}"">
|
||||
<option value=""></option>
|
||||
|
||||
@foreach (core()->countries() as $country)
|
||||
|
||||
<option value="{{ $country->code }}">{{ $country->name }}</option>
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<span class="control-error" v-if="errors.has('country')">
|
||||
@{{ errors.first('country') }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('state') ? 'has-error' : '']">
|
||||
<label for="state">
|
||||
{{ __('admin::app.customers.customers.state') }}
|
||||
</label>
|
||||
|
||||
<select class="control" id="state" name="state" v-model="state">
|
||||
|
||||
<option value="" :selected="! haveStates()">*</option>
|
||||
|
||||
<option v-for='(state, index) in countryStates[country]' :value="state.code">
|
||||
@{{ state.default_name }}
|
||||
</option>
|
||||
|
||||
</select>
|
||||
|
||||
<span class="control-error" v-if="errors.has('state')">
|
||||
@{{ errors.first('state') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
Vue.component('country-state', {
|
||||
|
||||
template: '#country-state-template',
|
||||
|
||||
inject: ['$validator'],
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
country: "{{ old('country') ?? $taxRate->country }}",
|
||||
|
||||
state: "{{ old('state') ?? $taxRate->state }}",
|
||||
|
||||
countryStates: @json(core()->groupedStatesByCountries())
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
haveStates: function () {
|
||||
if (this.countryStates[this.country] && this.countryStates[this.country].length)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
},
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
Loading…
Reference in New Issue