snipe-it/resources/views/custom_fields/fields/edit.blade.php

196 lines
8.4 KiB
PHP
Raw Normal View History

@php
use App\Models\CustomField;
@endphp
2016-03-25 01:18:05 -07:00
@extends('layouts/default')
2016-03-25 01:18:05 -07:00
{{-- Page title --}}
@section('title')
{{ trans('admin/custom_fields/general.custom_fields') }}
2016-03-25 01:18:05 -07:00
@parent
@stop
@section('content')
@section('header_right')
<a href="{{ route('fields.index') }}" class="btn btn-primary pull-right">
2016-03-25 01:18:05 -07:00
{{ trans('general.back') }}</a>
@stop
{{-- Page content --}}
@section('content')
<div class="row">
<div class="col-md-9">
<!-- Horizontal Form -->
@if ($field->id)
{{ Form::open(['route' => ['fields.update', $field->id], 'class'=>'form-horizontal']) }}
{{ method_field('PUT') }}
@else
{{ Form::open(['route' => 'fields.store', 'class'=>'form-horizontal']) }}
@endif
2016-03-25 01:18:05 -07:00
<div class="box box-default">
<div class="box-body">
<!-- Name -->
<div class="form-group {{ $errors->has('name') ? ' has-error' : '' }}">
<label for="name" class="col-md-4 control-label">
{{ trans('admin/custom_fields/general.field_name') }}
</label>
<div class="col-md-6 required">
2020-04-21 03:58:31 -07:00
{{ Form::text('name', old('name', $field->name), array('class' => 'form-control', 'aria-label'=>'name')) }}
2020-04-01 03:21:15 -07:00
{!! $errors->first('name', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
2016-03-25 01:18:05 -07:00
</div>
<!-- Element Type -->
2016-03-25 01:18:05 -07:00
<div class="form-group {{ $errors->has('element') ? ' has-error' : '' }}">
<label for="element" class="col-md-4 control-label">
{{ trans('admin/custom_fields/general.field_element') }}
</label>
<div class="col-md-6 required">
2016-03-25 01:18:05 -07:00
2020-04-21 03:58:31 -07:00
{!! Form::customfield_elements('element', old('element', $field->element), 'field_element select2 form-control') !!}
2020-04-01 03:21:15 -07:00
{!! $errors->first('element', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
2016-03-25 01:18:05 -07:00
</div>
2016-03-25 01:18:05 -07:00
</div>
<!-- Element values -->
<div class="form-group {{ $errors->has('element') ? ' has-error' : '' }}" id="field_values_text" style="display:none;">
<label for="field_values" class="col-md-4 control-label">
{{ trans('admin/custom_fields/general.field_values') }}
</label>
<div class="col-md-6 required">
2020-04-21 03:58:31 -07:00
{!! Form::textarea('field_values', old('name', $field->field_values), ['style' => 'width: 100%', 'rows' => 4, 'class' => 'form-control', 'aria-label'=>'field_values']) !!}
2020-04-01 03:21:15 -07:00
{!! $errors->first('field_values', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
<p class="help-block">{{ trans('admin/custom_fields/general.field_values_help') }}</p>
</div>
</div>
2016-03-25 01:18:05 -07:00
<!-- Format -->
<div class="form-group {{ $errors->has('format') ? ' has-error' : '' }}">
<label for="format" class="col-md-4 control-label">
{{ trans('admin/custom_fields/general.field_format') }}
</label>
<div class="col-md-6 required">
2020-04-01 01:26:44 -07:00
{{ Form::select("format",\App\Helpers\Helper::predefined_formats(), $field->format, array('class'=>'format select2 form-control', 'aria-label'=>'format')) }}
2020-04-01 03:21:15 -07:00
{!! $errors->first('format', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
2016-03-25 01:18:05 -07:00
</div>
<!-- Custom Format -->
2016-08-23 18:52:54 -07:00
<div class="form-group {{ $errors->has('custom_format') ? ' has-error' : '' }}" id="custom_regex" style="display:none;">
<label for="custom_format" class="col-md-4 control-label">
{{ trans('admin/custom_fields/general.field_custom_format') }}
</label>
<div class="col-md-6 required">
2020-04-21 03:58:31 -07:00
{{ Form::text('custom_format', old('custom_format', (($field->format!='') && (stripos($field->format,'regex')===0)) ? $field->format : ''), array('class' => 'form-control', 'id' => 'custom_format','aria-label'=>'custom_format', 'placeholder'=>'regex:/^[0-9]{15}$/')) }}
<p class="help-block">{!! trans('admin/custom_fields/general.field_custom_format_help') !!}</p>
2020-04-01 03:21:15 -07:00
{!! $errors->first('custom_format', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
2016-03-25 01:18:05 -07:00
</div>
<!-- Help Text -->
<div class="form-group {{ $errors->has('help_text') ? ' has-error' : '' }}">
<label for="help_text" class="col-md-4 control-label">
Help Text
</label>
<div class="col-md-6">
2020-04-21 03:58:31 -07:00
{{ Form::text('help_text', old('help_text', $field->help_text), array('class' => 'form-control', 'aria-label'=>'help_text')) }}
<p class="help-block">This is optional text that will appear below the form elements while editing an asset to provide context on the field.</p>
2020-04-01 03:21:15 -07:00
{!! $errors->first('help_text', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>
<!-- Show in Email -->
<div class="form-group {{ $errors->has('show_in_email') ? ' has-error' : '' }}" id="show_in_email">
<div class="col-md-8 col-md-offset-4">
<label for="show_in_email">
2020-04-21 03:58:31 -07:00
<input type="checkbox" name="show_in_email" aria-label="show_in_email" value="1" class="minimal"{{ (old('show_in_email') || $field->show_in_email) ? ' checked="checked"' : '' }}>
{{ trans('admin/custom_fields/general.show_in_email') }}
</label>
</div>
</div>
@if (!$field->id)
<!-- Encrypted -->
<div class="form-group {{ $errors->has('encrypted') ? ' has-error' : '' }}">
<div class="col-md-8 col-md-offset-4">
<label for="field_encrypted">
<input type="checkbox" value="1" name="field_encrypted" id="field_encrypted" class="minimal"{{ (Request::old('field_encrypted') || $field->field_encrypted) ? ' checked="checked"' : '' }}>
{{ trans('admin/custom_fields/general.encrypt_field') }}
</label>
</div>
<div class="col-md-6 col-md-offset-4" id="encrypt_warning" style="display:none;">
Notification improvements (#5254) * Added “show fields in email” to custom fields * Added “show images in email” to settings * Added nicer HTML emails * Break notifications out into their own, instead of trying to mash them all together * Remove old notification for accessory checkout * Janky fix for #5076 - “The asset you have attempted to accept was not checked out to you” * Add method for image url for accessories * Added accessory checkout email blade * Make accessory email notification on checkout screen consistent with assets * Added native consumables notifications * Fixes for asset notification * Updated notification blades with correct-er fields * Updated notifications * License checkin notification - does not work yet Need to figure out whether the license seat is assigned to a person or an asset before we can pass the target * Added alternate “cc” email for admins * Only try to trigger notifications if the target is a user * Fix tests * Fixed consumable URL * Removed unused notification * Pass target type in params * Show slack status * Pass additional parameters There is a logic bug in this :( Will send to slack twice, since the admin CC and the user are both using the same notification. Fuckity fuck fuck fuck. * Pass a variable to the notification to supress the duplicate slack message * Slack is broken :( Trying to fix Will try a git bisect * Put preview back into checkout * Pulled old archaic mail * Removed debugging * Fixed wrong email title * Fixed slack endpoint not firing * Poobot, we hardly knew ye. * Removed old, manual mail from API * Typo :-/ * Code cleanup * Use defined formatted date in JSON * Use static properties for checkin/checkout notifiers for cleaner code * Removed debugging * Use date formatter * Fixed target_type * Fixed language in consumable email
2018-03-25 13:46:57 -07:00
<div class="callout callout-danger">
2020-04-01 01:26:44 -07:00
<p><i class="fa fa-warning" aria-hidden="true"></i> {{ trans('admin/custom_fields/general.encrypt_field_help') }}</p>
</div>
</div>
</div>
@endif
</div> <!-- /.box-body-->
<div class="box-footer text-right">
2020-04-01 01:26:44 -07:00
<button type="submit" class="btn btn-primary"> {{ trans('general.save') }}</button>
</div>
</div> <!--.box.box-default-->
{{ Form::close() }}
</div> <!--/.col-md-9-->
<div class="col-md-3">
2020-04-01 01:26:44 -07:00
<h2>About Custom Fields</h2>
<p>Custom fields allow you to add arbitrary attributes to assets.</p>
2016-03-25 01:18:05 -07:00
</div>
2016-03-25 01:18:05 -07:00
</div>
@stop
2016-03-25 01:18:05 -07:00
2016-08-23 18:52:54 -07:00
@section('moar_scripts')
2017-09-28 19:45:15 -07:00
<script nonce="{{ csrf_token() }}">
$(document).ready(function(){
// Only display the custom format field if it's a custom format validation type
$(".format").change(function(){
$(this).find("option:selected").each(function(){
2018-06-21 09:35:04 -07:00
if ($('.format').prop("selectedIndex") == 1) {
$("#custom_regex").show();
} else{
$("#custom_regex").hide();
}
2016-08-23 18:52:54 -07:00
});
}).change();
// Only display the field element if the type is not text
$(".field_element").change(function(){
$(this).find("option:selected").each(function(){
2018-06-21 09:35:04 -07:00
if (($(this).attr("value")!="text") && ($(this).attr("value")!="textarea")){
$("#field_values_text").show();
} else{
$("#field_values_text").hide();
}
});
}).change();
});
// Checkbox handling
$('#field_encrypted').on('ifChecked', function(event){
$("#encrypt_warning").show();
Notification improvements (#5254) * Added “show fields in email” to custom fields * Added “show images in email” to settings * Added nicer HTML emails * Break notifications out into their own, instead of trying to mash them all together * Remove old notification for accessory checkout * Janky fix for #5076 - “The asset you have attempted to accept was not checked out to you” * Add method for image url for accessories * Added accessory checkout email blade * Make accessory email notification on checkout screen consistent with assets * Added native consumables notifications * Fixes for asset notification * Updated notification blades with correct-er fields * Updated notifications * License checkin notification - does not work yet Need to figure out whether the license seat is assigned to a person or an asset before we can pass the target * Added alternate “cc” email for admins * Only try to trigger notifications if the target is a user * Fix tests * Fixed consumable URL * Removed unused notification * Pass target type in params * Show slack status * Pass additional parameters There is a logic bug in this :( Will send to slack twice, since the admin CC and the user are both using the same notification. Fuckity fuck fuck fuck. * Pass a variable to the notification to supress the duplicate slack message * Slack is broken :( Trying to fix Will try a git bisect * Put preview back into checkout * Pulled old archaic mail * Removed debugging * Fixed wrong email title * Fixed slack endpoint not firing * Poobot, we hardly knew ye. * Removed old, manual mail from API * Typo :-/ * Code cleanup * Use defined formatted date in JSON * Use static properties for checkin/checkout notifiers for cleaner code * Removed debugging * Use date formatter * Fixed target_type * Fixed language in consumable email
2018-03-25 13:46:57 -07:00
$("#show_in_email").hide();
});
2016-08-23 18:52:54 -07:00
$('#field_encrypted').on('ifUnchecked', function(event){
$("#encrypt_warning").hide();
Notification improvements (#5254) * Added “show fields in email” to custom fields * Added “show images in email” to settings * Added nicer HTML emails * Break notifications out into their own, instead of trying to mash them all together * Remove old notification for accessory checkout * Janky fix for #5076 - “The asset you have attempted to accept was not checked out to you” * Add method for image url for accessories * Added accessory checkout email blade * Make accessory email notification on checkout screen consistent with assets * Added native consumables notifications * Fixes for asset notification * Updated notification blades with correct-er fields * Updated notifications * License checkin notification - does not work yet Need to figure out whether the license seat is assigned to a person or an asset before we can pass the target * Added alternate “cc” email for admins * Only try to trigger notifications if the target is a user * Fix tests * Fixed consumable URL * Removed unused notification * Pass target type in params * Show slack status * Pass additional parameters There is a logic bug in this :( Will send to slack twice, since the admin CC and the user are both using the same notification. Fuckity fuck fuck fuck. * Pass a variable to the notification to supress the duplicate slack message * Slack is broken :( Trying to fix Will try a git bisect * Put preview back into checkout * Pulled old archaic mail * Removed debugging * Fixed wrong email title * Fixed slack endpoint not firing * Poobot, we hardly knew ye. * Removed old, manual mail from API * Typo :-/ * Code cleanup * Use defined formatted date in JSON * Use static properties for checkin/checkout notifiers for cleaner code * Removed debugging * Use date formatter * Fixed target_type * Fixed language in consumable email
2018-03-25 13:46:57 -07:00
$("#show_in_email").show();
});
2016-08-23 18:52:54 -07:00
</script>
2016-03-25 01:18:05 -07:00
@stop