Persist service variables

This commit is contained in:
Matthew Penner 2020-04-11 14:46:30 -06:00
parent dec6868a55
commit a7dab69711
2 changed files with 41 additions and 14 deletions

View file

@ -309,11 +309,31 @@
@section('footer-scripts')
@parent
{!! Theme::js('vendor/lodash/lodash.js') !!}
<script type="application/javascript">
// Persist 'Service Variables'
function serviceVariablesUpdated(eggId, ids) {
@if (old('egg_id'))
// Check if the egg id matches.
if (eggId != '{{ old('egg_id') }}') {
return;
}
@if (old('environment'))
@foreach (old('environment') as $key => $value)
$('#' + ids['{{ $key }}']).val('{{ $value }}');
@endforeach
@endif
@endif
}
// END Persist 'Service Variables'
</script>
{!! Theme::js('js/admin/new-server.js') !!}
<script type="application/javascript">
$(document).ready(function() {
<!-- Persist 'Server Owner' select2 -->
// Persist 'Server Owner' select2
@if (old('owner_id'))
$.ajax({
url: '/admin/users/accounts.json?user_id={{ old('owner_id') }}',
@ -324,19 +344,19 @@
@else
initUserIdSelect();
@endif
<!-- END Persist 'Server Owner' select2 -->
// END Persist 'Server Owner' select2
<!-- Persist 'Node' select2 -->
// Persist 'Node' select2
@if (old('node_id'))
$('#pNodeId').val('{{ old('node_id') }}').change();
<!-- Persist 'Default Allocation' select2 -->
// Persist 'Default Allocation' select2
@if (old('allocation_id'))
$('#pAllocation').val('{{ old('allocation_id') }}').change();
@endif
<!-- END Persist 'Default Allocation' select2 -->
// END Persist 'Default Allocation' select2
<!-- Persist 'Additional Allocations' select2 -->
// Persist 'Additional Allocations' select2
@if (old('allocation_additional'))
const additional_allocations = [];
@ -346,27 +366,27 @@
$('#pAllocationAdditional').val(additional_allocations).change();
@endif
<!-- END Persist 'Additional Allocations' select2 -->
// END Persist 'Additional Allocations' select2
@endif
<!-- END Persist 'Node' select2 -->
// END Persist 'Node' select2
<!-- Persist 'Nest' select2 -->
// Persist 'Nest' select2
@if (old('nest_id'))
$('#pNestId').val('{{ old('nest_id') }}').change();
<!-- Persist 'Egg' select2 -->
// Persist 'Egg' select2
@if (old('egg_id'))
$('#pEggId').val('{{ old('egg_id') }}').change();
@endif
<!-- END Persist 'Egg' select2 -->
// END Persist 'Egg' select2
<!-- Persist 'Data Pack' select2 -->
// Persist 'Data Pack' select2
@if (old('pack_id'))
$('#pPackId').val('{{ old('pack_id') }}').change();
@endif
<!-- END Persist 'Data Pack' select2 -->
// END Persist 'Data Pack' select2
@endif
<!-- END Persist 'Nest' select2 -->
// END Persist 'Nest' select2
});
</script>
@endsection