2016-03-25 01:18:05 -07:00
|
|
|
@extends('layouts/default')
|
|
|
|
|
|
|
|
{{-- Page title --}}
|
|
|
|
@section('title')
|
|
|
|
{{ trans('admin/custom_fields/general.custom_fields') }}
|
|
|
|
@parent
|
|
|
|
@stop
|
|
|
|
|
2016-07-28 08:10:15 -07:00
|
|
|
@section('header_right')
|
2016-12-27 12:03:47 -08:00
|
|
|
<a href="{{ route('fields.index') }}" class="btn btn-primary pull-right">
|
2016-07-28 08:10:15 -07:00
|
|
|
{{ trans('general.back') }}</a>
|
|
|
|
@stop
|
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
@section('content')
|
2016-12-27 12:03:47 -08:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
|
|
|
<div class="box box-default">
|
|
|
|
<div class="box-header with-border">
|
2020-03-31 23:36:56 -07:00
|
|
|
<h2 class="box-title">{{ $custom_fieldset->name }} {{ trans('admin/custom_fields/general.fieldset') }}</h2>
|
2016-12-27 12:03:47 -08:00
|
|
|
<div class="box-tools pull-right">
|
|
|
|
</div>
|
|
|
|
</div><!-- /.box-header -->
|
|
|
|
<div class="box-body">
|
|
|
|
<table
|
2017-01-18 04:58:56 -08:00
|
|
|
name="fieldsets" id="sort" class="table table-responsive todo-list">
|
2016-12-27 12:03:47 -08:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2018-07-12 18:28:20 -07:00
|
|
|
{{-- Hide the sorting handle if we can't update the fieldset --}}
|
|
|
|
@can('update', $custom_fieldset)
|
2021-11-02 03:27:53 -07:00
|
|
|
<th class="col-md-1"><span class="sr-only">{{ trans('admin/custom_fields/general.reorder') }}</span></th>
|
2018-07-12 18:28:20 -07:00
|
|
|
@endcan
|
2016-12-27 12:03:47 -08:00
|
|
|
<th class="col-md-1">{{ trans('admin/custom_fields/general.order') }}</th>
|
|
|
|
<th class="col-md-3">{{ trans('admin/custom_fields/general.field_name') }}</th>
|
|
|
|
<th class="col-md-2">{{ trans('admin/custom_fields/general.field_format') }}</th>
|
|
|
|
<th class="col-md-2">{{ trans('admin/custom_fields/general.field_element') }}</th>
|
|
|
|
<th class="col-md-1">{{ trans('admin/custom_fields/general.encrypted') }}</th>
|
|
|
|
<th class="col-md-1">{{ trans('admin/custom_fields/general.required') }}</th>
|
2021-11-02 03:27:53 -07:00
|
|
|
<th class="col-md-1"><span class="sr-only">{{ trans('button.remove') }}</span></th>
|
2016-12-27 12:03:47 -08:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
@foreach($custom_fieldset->fields as $field)
|
2018-07-12 18:28:20 -07:00
|
|
|
<tr class="{{ Auth::user()->can('update', $custom_fieldset)?'cansort':'' }}" data-index="{{ $field->pivot->custom_field_id }}" id="item_{{ $field->pivot->custom_field_id }}">
|
|
|
|
{{-- Hide the sorting handle if we can't update the fieldset --}}
|
|
|
|
@can('update', $custom_fieldset)
|
2016-12-27 12:03:47 -08:00
|
|
|
<td>
|
|
|
|
<!-- drag handle -->
|
|
|
|
<span class="handle">
|
2021-09-26 01:11:08 -07:00
|
|
|
<i class="fas fa-ellipsis-v"></i>
|
|
|
|
<i class="fas fa-ellipsis-v"></i>
|
2016-12-27 12:03:47 -08:00
|
|
|
</span>
|
|
|
|
</td>
|
2018-07-12 18:28:20 -07:00
|
|
|
@endcan
|
2016-12-27 12:03:47 -08:00
|
|
|
<td class="index">{{$field->pivot->order}}</td>
|
|
|
|
<td>{{$field->name}}</td>
|
|
|
|
<td>{{$field->format}}</td>
|
|
|
|
<td>{{$field->element}}</td>
|
|
|
|
<td>{{ $field->field_encrypted=='1' ? trans('general.yes') : trans('general.no') }}</td>
|
2020-04-24 00:47:19 -07:00
|
|
|
<td>
|
2021-11-16 10:34:20 -08:00
|
|
|
|
2020-04-24 00:47:19 -07:00
|
|
|
@if ($field->pivot->required)
|
2021-11-05 10:53:48 -07:00
|
|
|
<form method="post" action="{{ route('fields.optional', [$custom_fieldset->id, $field->id]) }}">
|
|
|
|
@csrf
|
|
|
|
<button type="submit" class="btn btn-link"><i class="fa fa-check text-success" aria-hidden="true"></i></button>
|
|
|
|
</form>
|
|
|
|
|
2020-04-24 00:47:19 -07:00
|
|
|
@else
|
2021-11-05 10:53:48 -07:00
|
|
|
|
|
|
|
<form method="post" action="{{ route('fields.required', [$custom_fieldset->id, $field->id]) }}">
|
|
|
|
@csrf
|
|
|
|
<button type="submit" class="btn btn-link"><i class="fa fa-times text-danger" aria-hidden="true"></i></button>
|
|
|
|
</form>
|
2020-04-24 00:47:19 -07:00
|
|
|
@endif
|
2021-11-16 10:34:20 -08:00
|
|
|
|
2020-04-24 00:47:19 -07:00
|
|
|
</td>
|
2016-12-27 12:03:47 -08:00
|
|
|
<td>
|
2018-07-12 18:28:20 -07:00
|
|
|
@can('update', $custom_fieldset)
|
2021-11-16 10:34:20 -08:00
|
|
|
<form method="post" action="{{ route('fields.disassociate', [$field, $custom_fieldset->id]) }}">
|
|
|
|
@csrf
|
2021-11-19 03:12:11 -08:00
|
|
|
<button type="submit" class="btn btn-sm btn-danger">{{ trans('button.remove') }}</button>
|
|
|
|
</form>
|
|
|
|
@endcan
|
2016-12-27 12:03:47 -08:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
@endforeach
|
|
|
|
</tbody>
|
2020-04-01 01:26:44 -07:00
|
|
|
@can('update', $custom_fieldset)
|
2016-12-27 12:03:47 -08:00
|
|
|
<tfoot>
|
|
|
|
<tr>
|
2020-04-01 01:26:44 -07:00
|
|
|
<td colspan="8">
|
2016-12-27 12:03:47 -08:00
|
|
|
{{ Form::open(['route' =>
|
|
|
|
["fieldsets.associate",$custom_fieldset->id],
|
|
|
|
'class'=>'form-horizontal',
|
|
|
|
'id' => 'ordering']) }}
|
2020-04-01 01:26:44 -07:00
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group col-md-4">
|
|
|
|
<label for="field_id" class="sr-only">
|
2021-11-02 03:27:53 -07:00
|
|
|
{{ trans('admin/custom-field/general.add_field_to_fieldset')}}
|
2020-04-01 01:26:44 -07:00
|
|
|
</label>
|
|
|
|
{{ Form::select("field_id",$custom_fields_list,"",['aria-label'=>'field_id', 'class'=>'select2']) }}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group col-md-2" style="vertical-align: middle;">
|
|
|
|
|
|
|
|
<label for="required">
|
2020-04-21 03:58:31 -07:00
|
|
|
{{ Form::checkbox('required', 'on', old('required'), array('class' => 'minimal', 'aria-label'=>'required')) }}
|
2020-04-01 01:26:44 -07:00
|
|
|
{{ trans('admin/custom_fields/general.required') }}
|
|
|
|
</label>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-md-2">
|
|
|
|
|
|
|
|
{{ Form::text('order', $maxid, array('class' => 'form-control col-sm-1 col-md-1', 'style'=> 'width: 80px; padding-;right: 10px;', 'aria-label'=>'order', 'maxlength'=>'3', 'size'=>'3')) }}
|
2021-11-02 03:27:53 -07:00
|
|
|
<label for="order">{{ trans('admin/custom_fields/general.order') }}</label>
|
2020-04-01 01:26:44 -07:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group col-md-3">
|
|
|
|
<button type="submit" class="btn btn-primary"> {{ trans('general.save') }}</button>
|
|
|
|
</div>
|
2016-12-27 12:03:47 -08:00
|
|
|
{{ Form::close() }}
|
2020-04-01 01:26:44 -07:00
|
|
|
|
2016-12-27 12:03:47 -08:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tfoot>
|
2020-04-01 01:26:44 -07:00
|
|
|
@endcan
|
2016-12-27 12:03:47 -08:00
|
|
|
</table>
|
|
|
|
</div> <!-- /.box-body-->
|
|
|
|
</div> <!-- /.box.box-default-->
|
|
|
|
</div> <!-- /.col-md-12-->
|
|
|
|
</div> <!--/.row-->
|
2016-03-25 01:18:05 -07:00
|
|
|
|
2016-12-27 12:03:47 -08:00
|
|
|
@stop
|
2016-03-25 01:18:05 -07:00
|
|
|
|
2020-11-12 23:38:12 -08:00
|
|
|
@push('js')
|
2018-07-12 18:28:20 -07:00
|
|
|
@can('update', $custom_fieldset)
|
|
|
|
|
2017-09-28 19:45:15 -07:00
|
|
|
<script nonce="{{ csrf_token() }}">
|
2016-03-25 01:18:05 -07:00
|
|
|
var fixHelperModified = function(e, tr) {
|
|
|
|
var $originals = tr.children();
|
|
|
|
var $helper = tr.clone();
|
|
|
|
$helper.children().each(function(index) {
|
|
|
|
$(this).width($originals.eq(index).width())
|
|
|
|
});
|
|
|
|
return $helper;
|
|
|
|
},
|
|
|
|
updateIndex = function(e, ui) {
|
|
|
|
$('td.index', ui.item.parent()).each(function (i) {
|
|
|
|
$(this).html(i + 1);
|
2016-04-19 07:19:12 -07:00
|
|
|
$.ajax({
|
2016-05-14 14:06:59 -07:00
|
|
|
method: "POST",
|
|
|
|
url: "{{ route('api.customfields.order', $custom_fieldset->id) }}",
|
2017-01-18 04:58:56 -08:00
|
|
|
headers: {
|
|
|
|
"X-Requested-With": 'XMLHttpRequest',
|
|
|
|
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')
|
|
|
|
},
|
2016-05-14 14:06:59 -07:00
|
|
|
data: $("#sort tbody").sortable('serialize', {
|
|
|
|
}),
|
2016-04-19 07:19:12 -07:00
|
|
|
|
2016-05-14 14:06:59 -07:00
|
|
|
success: function(data) {
|
|
|
|
//console.log('ajax fired');
|
|
|
|
// do some stuff here
|
|
|
|
|
2016-05-14 15:06:27 -07:00
|
|
|
|
2016-05-14 14:06:59 -07:00
|
|
|
}
|
2016-04-19 07:19:12 -07:00
|
|
|
});
|
2016-03-25 01:18:05 -07:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-11-12 23:38:12 -08:00
|
|
|
// this uses the jquery UI sortable method, NOT the query-dragtable library
|
2016-03-25 01:18:05 -07:00
|
|
|
$("#sort tbody").sortable({
|
|
|
|
helper: fixHelperModified,
|
|
|
|
stop: updateIndex
|
|
|
|
}).disableSelection();
|
|
|
|
</script>
|
2018-07-12 18:28:20 -07:00
|
|
|
@endcan
|
2020-11-12 23:38:12 -08:00
|
|
|
@endpush
|