mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Merge pull request #15367 from snipe/fixes/15344_added_freeform_to_country_select2
Fixed #15344 - make select2 for countries freeform-ish
This commit is contained in:
commit
9608414eae
|
@ -561,5 +561,6 @@ return [
|
||||||
'remaining_var' => ':count Remaining',
|
'remaining_var' => ':count Remaining',
|
||||||
'label' => 'Label',
|
'label' => 'Label',
|
||||||
'import_asset_tag_exists' => 'An asset with the asset tag :asset_tag already exists and an update was not requested. No change was made.',
|
'import_asset_tag_exists' => 'An asset with the asset tag :asset_tag already exists and an update was not requested. No change was made.',
|
||||||
|
'countries_manually_entered_help' => 'Values with an asterisk (*) were manually entered and do not match existing ISO 3166 dropdown values',
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -135,6 +135,7 @@ return [
|
||||||
'EC'=>'Ecuador',
|
'EC'=>'Ecuador',
|
||||||
'EE'=>'Estonia',
|
'EE'=>'Estonia',
|
||||||
'EG'=>'Egypt',
|
'EG'=>'Egypt',
|
||||||
|
'GB-ENG'=>'England',
|
||||||
'ER'=>'Eritrea',
|
'ER'=>'Eritrea',
|
||||||
'ES'=>'Spain',
|
'ES'=>'Spain',
|
||||||
'ET'=>'Ethiopia',
|
'ET'=>'Ethiopia',
|
||||||
|
@ -233,6 +234,7 @@ return [
|
||||||
'NG'=>'Nigeria',
|
'NG'=>'Nigeria',
|
||||||
'NI'=>'Nicaragua',
|
'NI'=>'Nicaragua',
|
||||||
'NL'=>'Netherlands',
|
'NL'=>'Netherlands',
|
||||||
|
'GB-NIR' => 'Northern Ireland',
|
||||||
'NO'=>'Norway',
|
'NO'=>'Norway',
|
||||||
'NP'=>'Nepal',
|
'NP'=>'Nepal',
|
||||||
'NR'=>'Nauru',
|
'NR'=>'Nauru',
|
||||||
|
@ -260,7 +262,7 @@ return [
|
||||||
'RU'=>'Russian Federation',
|
'RU'=>'Russian Federation',
|
||||||
'RW'=>'Rwanda',
|
'RW'=>'Rwanda',
|
||||||
'SA'=>'Saudi Arabia',
|
'SA'=>'Saudi Arabia',
|
||||||
'UK'=>'Scotland',
|
'GB-SCT'=>'Scotland',
|
||||||
'SB'=>'Solomon Islands',
|
'SB'=>'Solomon Islands',
|
||||||
'SC'=>'Seychelles',
|
'SC'=>'Seychelles',
|
||||||
'SS'=>'South Sudan',
|
'SS'=>'South Sudan',
|
||||||
|
@ -312,6 +314,7 @@ return [
|
||||||
'VI'=>'Virgin Islands (U.S.)',
|
'VI'=>'Virgin Islands (U.S.)',
|
||||||
'VN'=>'Viet Nam',
|
'VN'=>'Viet Nam',
|
||||||
'VU'=>'Vanuatu',
|
'VU'=>'Vanuatu',
|
||||||
|
'GB-WLS' =>'Wales',
|
||||||
'WF'=>'Wallis And Futuna Islands',
|
'WF'=>'Wallis And Futuna Islands',
|
||||||
'WS'=>'Samoa',
|
'WS'=>'Samoa',
|
||||||
'YE'=>'Yemen',
|
'YE'=>'Yemen',
|
||||||
|
|
|
@ -32,18 +32,27 @@ Form::macro('countries', function ($name = 'country', $selected = null, $class =
|
||||||
|
|
||||||
$idclause = (!is_null($id)) ? $id : '';
|
$idclause = (!is_null($id)) ? $id : '';
|
||||||
|
|
||||||
$select = '<select name="'.$name.'" class="'.$class.'" style="width:100%" '.$idclause.' aria-label="'.$name.'" data-placeholder="'.trans('localizations.select_country').'">';
|
// Pull the autoglossonym array from the localizations translation file
|
||||||
|
$countries_array = trans('localizations.countries');
|
||||||
|
|
||||||
|
$select = '<select name="'.$name.'" class="'.$class.'" style="width:100%" '.$idclause.' aria-label="'.$name.'" data-placeholder="'.trans('localizations.select_country').'" data-allow-clear="true" data-tags="true">';
|
||||||
$select .= '<option value="" role="option">'.trans('localizations.select_country').'</option>';
|
$select .= '<option value="" role="option">'.trans('localizations.select_country').'</option>';
|
||||||
|
|
||||||
// Pull the autoglossonym array from the localizations translation file
|
foreach ($countries_array as $abbr => $country) {
|
||||||
foreach (trans('localizations.countries') as $abbr => $country) {
|
|
||||||
|
|
||||||
// We have to handle it this way to handle deprecication warnings since you can't strtoupper on null
|
// We have to handle it this way to handle deprecication warnings since you can't strtoupper on null
|
||||||
if ($abbr!='') {
|
if ($abbr!='') {
|
||||||
$abbr = strtoupper($abbr);
|
$abbr = strtoupper($abbr);
|
||||||
}
|
}
|
||||||
|
|
||||||
$select .= '<option value="'.$abbr.'"'.(($selected == $abbr) ? ' selected="selected" role="option" aria-selected="true"' : ' aria-selected="false"').'>'.$country.'</option> ';
|
// Loop through the countries configured in the localization file
|
||||||
|
$select .= '<option value="'.$abbr.'" selected="selected" role="option" '.(($selected == $abbr) ? ' selected="selected" role="option" aria-selected="true"' : ' aria-selected="false"').'>'.$country.'</option> ';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the country value doesn't exist in the array, add it as a new option and select it so we don't drop that data
|
||||||
|
if (!in_array($selected, $countries_array)) {
|
||||||
|
$select .= '<option value="' . $selected . '" selected="selected" role="option" aria-selected="true">' . $selected .' *</option> ';
|
||||||
}
|
}
|
||||||
|
|
||||||
$select .= '</select>';
|
$select .= '</select>';
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
{{ Form::label('country', trans('general.country'), array('class' => 'col-md-3 control-label')) }}
|
{{ Form::label('country', trans('general.country'), array('class' => 'col-md-3 control-label')) }}
|
||||||
<div class="col-md-7">
|
<div class="col-md-7">
|
||||||
{!! Form::countries('country', old('country', $item->country), 'select2') !!}
|
{!! Form::countries('country', old('country', $item->country), 'select2') !!}
|
||||||
|
<p class="help-block">{{ trans('general.countries_manually_entered_help') }}</p>
|
||||||
{!! $errors->first('country', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
{!! $errors->first('country', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -451,6 +451,8 @@
|
||||||
<label class="col-md-3 control-label" for="country">{{ trans('general.country') }}</label>
|
<label class="col-md-3 control-label" for="country">{{ trans('general.country') }}</label>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
{!! Form::countries('country', old('country', $user->country), 'col-md-12 select2') !!}
|
{!! Form::countries('country', old('country', $user->country), 'col-md-12 select2') !!}
|
||||||
|
|
||||||
|
<p class="help-block">{{ trans('general.countries_manually_entered_help') }}</p>
|
||||||
{!! $errors->first('country', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
{!! $errors->first('country', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -197,7 +197,9 @@
|
||||||
{{ trans('admin/users/general.print_assigned') }}
|
{{ trans('admin/users/general.print_assigned') }}
|
||||||
</a>
|
</a>
|
||||||
@else
|
@else
|
||||||
<button style="width: 100%;" class="btn btn-sm btn-primary hidden-print" rel="noopener" disabled title="{{ trans('admin/users/message.user_has_no_assets_assigned') }}">{{ trans('admin/users/general.print_assigned') }}</button>
|
<button style="width: 100%;" class="btn btn-sm btn-primary btn-social hidden-print" rel="noopener" disabled title="{{ trans('admin/users/message.user_has_no_assets_assigned') }}">
|
||||||
|
<x-icon type="print" />
|
||||||
|
{{ trans('admin/users/general.print_assigned') }}</button>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endcan
|
@endcan
|
||||||
|
|
Loading…
Reference in a new issue