This commit is mainly as a result of creating DN entries and improves some backend functions:

* Enable creation of new entries,
* Change all our ajax frames to go through /frames URI instead of /dn,
* Add our frame command to the encrypted DN,
* Automatically redirect to root URL when selecting a tree item and currently in another path (as a result of a prior POST activity),
* Some validation improvements DNExists/HasStructuralObjectClass
This commit is contained in:
2025-02-23 18:14:41 +11:00
parent f08fdb1bcd
commit 996d7bb1dc
27 changed files with 687 additions and 147 deletions

View File

@@ -0,0 +1,64 @@
<!-- $o=RDN::class -->
<x-attribute.layout :edit="$edit ?? FALSE" :new="$new ?? FALSE" :o="$o">
@foreach($o->values as $value)
@if($edit)
<div class="input-group has-validation mb-3">
<select class="form-select @error('rdn')is-invalid @enderror" id="rdn" name="rdn">
<option value=""></option>
@foreach($o->attrs->map(fn($item)=>['id'=>$item,'value'=>$item]) as $option)
@continue(! Arr::get($option,'value'))
<option value="{{ Arr::get($option,'id') }}" @selected(Arr::get($option,'id') == old('rdn',$value ?? ''))>{{ Arr::get($option,'value') }}</option>
@endforeach
</select>
<span class="input-group-text">=</span>
<input type="text" @class(['form-control','is-invalid'=>$errors->get('rdn_value')]) id="rdn_value" name="rdn_value" value="{{ old('rdn_value') }}" placeholder="rdn">
<label class="input-group-text" for="inputGroupSelect02">,{{ $o->base }}</label>
<div class="invalid-feedback pb-2">
@error('rdn')
{{ $message }}
@enderror
@error('rdn_value')
{{ $message }}
@enderror
</div>
</div>
@else
{{ $value }}
@endif
@endforeach
</x-attribute.layout>
@section('page-scripts')
<script type="text/javascript">
$(document).ready(function() {
var rdn_value_set = null;
var rdn_attr = null;
function set_rdn_value() {
if (rdn_attr && rdn_value_set)
$('#'+rdn_attr).find('input').val($('input#rdn_value').val());
}
$('select#rdn').on('change',function() {
// if rdn_attr is already set (and its now different), remove read only and clear value
if (rdn_attr)
$('#'+rdn_attr).find('input').attr('readonly',false).val('');
// set RDN attribute read-only
if (rdn_attr = $(this).val())
$('#'+rdn_attr).find('input').attr('readonly',true).val('');
set_rdn_value();
})
$('input#rdn_value').on('change',function() {
rdn_value_set = $(this).val();
set_rdn_value();
})
});
</script>
@endsection

View File

@@ -46,12 +46,15 @@
if (! rendered)
$.ajax({
type: 'POST',
// @todo When this is opened a second time, the data is appended.
cache: false,
url: '{{ url('entry/objectclass/add') }}',
data: {
oc: oc,
},
success: function(data) {
$('select#newoc').select2({
dropdownParent: $('#new_objectclass-modal'),
theme: 'bootstrap-5',
allowClear: true,
multiple: true,
data: data,
});
@@ -60,8 +63,6 @@
if (e.status != 412)
alert('That didnt work? Please try again....');
},
url: '{{ url('entry/objectclass/add') }}/'+dn,
cache: false
});
rendered = true;

View File

@@ -15,7 +15,7 @@
{{ $slot }}
@isset($name)
<span class="invalid-feedback">
@error((! empty($old)) ? $old : $name)
@error((! empty($old)) ? $old : ($id ?? $name))
{{ $message }}
@elseif(isset($feedback))
{{ $feedback }}

View File

@@ -2,7 +2,7 @@
@isset($name)
<input type="hidden" id="{{ $id ?? $name }}_disabled" name="{{ $name }}" value="" disabled>
@endisset
<select class="form-select @isset($name)@error((! empty($old)) ? $old : $name) is-invalid @enderror @endisset" id="{{ $id ?? $name }}" @isset($name)name="{{ $name }}"@endisset @required(isset($required) && $required) @disabled(isset($disabled) && $disabled)>
<select class="form-select @isset($name)@error((! empty($old)) ? $old : ($id ?? $name)) is-invalid @enderror @endisset" id="{{ $id ?? $name }}" @isset($name)name="{{ $name }}"@endisset @required(isset($required) && $required) @disabled(isset($disabled) && $disabled)>
@if((empty($value) && ! empty($options)) || isset($addnew) || isset($choose))
<option value=""></option>
@isset($addnew)
@@ -54,10 +54,24 @@
width: 'style',
allowClear: {{ $allowclear ?? 'false' }},
placeholder: '{{ $placeholder ?? '' }}',
multiple: {{ $multiple ?? 'false' }},
@isset($addvalues)
tags: true,
@endisset
});
@if(isset($multiple) && (! $multiple))
$('#{{ $id ?? $name }}').val(' ');
$('#{{ $id ?? $name }}').trigger('change');
@endif
@isset($options)
@if($options->count() === 1)
$('#{{ $id ?? $name }}')
.val('{{ $options->first()['id'] }}')
.trigger("change")
@endif
@endisset
});
</script>
@append