Add preview pane

This commit is contained in:
Cram42 2022-11-02 19:31:34 +08:00
parent 36210f1c6a
commit f5fac50e91

View file

@ -20,8 +20,21 @@
}
</style>
<script>
function refreshPreview() {
var settingsOverride = {
'settings': Object.assign({}, ...$('#settingsForm')
.serializeArray()
.filter((value, index, all) => value.name.includes('label2_'))
.map((value, index, all) => ({[value.name]: value.value})))
};
var params = $.param(settingsOverride);
var url = "{{ route('labels.show', ['labelName' => ':label']) }}".replace(':label', settingsOverride.settings.label2_template) + "?" + params;
$('iframe#framePreview').attr('src', url);
}
</script>
{{ Form::open(['method' => 'POST', 'files' => false, 'autocomplete' => 'off', 'class' => 'form-horizontal', 'role' => 'form' ]) }}
{{ Form::open(['id' => 'settingsForm', 'method' => 'POST', 'files' => false, 'autocomplete' => 'off', 'class' => 'form-horizontal', 'role' => 'form' ]) }}
<!-- CSRF Token -->
{{csrf_field()}}
@ -60,6 +73,8 @@
<div class="form-group {{ $errors->has('label2_template') ? 'error' : '' }}">
<div class="col-md-3">
{{ Form::label('label2_template', trans('admin/settings/general.label2_template')) }}
<div>{{ Form::button('Refresh Preview', ['class'=>'btn btn-default btn-sm', 'style'=>'width:100%', 'onClick'=>'refreshPreview()']) }}</div>
<div><iframe id="framePreview" style="width:100%; height:400px;">Preview Here</iframe></div>
</div>
<div class="col-md-9">
<table