Compare commits

..

2 Commits

Author SHA1 Message Date
bb9374ec01 When removing added objectClasses, blank out any attributes added by those objectClasses
All checks were successful
Create Docker Image / Test Application (x86_64) (push) Successful in 34s
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 1m23s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 3m30s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2025-02-06 23:10:47 +11:00
c0e6b62ee5 Fix rendering Add Objectclasses, remove existing OCs from the list and dont rebuild the select list after the first invocation 2025-02-04 20:54:55 +11:00
5 changed files with 73 additions and 30 deletions

View File

@ -116,8 +116,9 @@ class HomeController extends Controller
{
$dn = Crypt::decryptString($id);
$o = config('server')->fetch($dn);
$oc = $o->getObject('objectclass');
$ocs = $o->getObject('objectclass')
$ocs = $oc
->structural
->map(fn($item)=>$item->getParents())
->flatten()
@ -125,6 +126,8 @@ class HomeController extends Controller
config('server')->schema('objectclasses')
->filter(fn($item)=>$item->isAuxiliary())
)
// Remove the original objectlcasses
->filter(fn($item)=>(! $oc->values->contains($item)))
->sortBy(fn($item)=>$item->name);
return $ocs->groupBy(fn($item)=>$item->isStructural())

View File

@ -297,7 +297,7 @@ select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__
font-weight: 800;
}
div#objectclass .input-group-delete {
div#objectClass .input-group-delete {
position: relative;
float: inline-end;
bottom: 30px;

View File

@ -10,7 +10,7 @@
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name') }} - @yield('htmlheader_title','🥇 The BEST ldap admin tool!')</title>
<title>{{ config('app.name') }} - @yield('htmlheader_title','🥇 An LDAP Administration Tool')</title>
<link rel="shortcut icon" href="/{{ config('app.favicon','favicon.ico') }}" />
<!-- App CSS -->

View File

@ -1,7 +1,7 @@
<div class="row pt-2">
<div @class(['col-1','d-none'=>(! $edit)])></div>
<div class="col-10 p-2">
<div id="{{ $o->name_lc }}">
<div id="{{ $o->name }}">
{{ $slot }}
</div>

View File

@ -39,27 +39,32 @@
<script type="text/javascript">
$(document).ready(function() {
var added_oc = []; // Object classes being added to this entry
var rendered = false;
// Show our ObjectClass modal so that we can add more objectclasses
$('#new_objectclass-modal').on('shown.bs.modal',function() {
$.ajax({
type: 'POST',
success: function(data) {
$('select#newoc').select2({
dropdownParent: $('#new_objectclass-modal'),
theme: 'bootstrap-5',
allowClear: true,
multiple: true,
data: data,
});
},
error: function(e) {
if (e.status != 412)
alert('That didnt work? Please try again....');
},
url: '{{ url('entry/objectclass/add') }}/'+dn,
cache: false
});
if (! rendered)
$.ajax({
type: 'POST',
// @todo When this is opened a second time, the data is appended.
success: function(data) {
$('select#newoc').select2({
dropdownParent: $('#new_objectclass-modal'),
theme: 'bootstrap-5',
allowClear: true,
multiple: true,
data: data,
});
},
error: function(e) {
if (e.status != 412)
alert('That didnt work? Please try again....');
},
url: '{{ url('entry/objectclass/add') }}/'+dn,
cache: false
});
rendered = true;
})
// When the ObjectClass modal is closed, process what was selected
@ -85,7 +90,7 @@
type: 'POST',
beforeSend: function() {},
success: function(data) {
$('#{{ $o->name_lc }}').append(data);
$('#{{ $o->name }}').append(data);
},
error: function(e) {
if (e.status != 412)
@ -134,7 +139,7 @@
if (data.may.length) {
var newattr = $('select#newattr');
// @todo It might be nice to resort this options
// @todo It might be nice to re-sort these options
data.may.forEach(function(item) {
newattr.append(new Option(item,item,false,false));
});
@ -155,10 +160,45 @@
if (newadded.indexOf(item) === -1) {
$('span#objectclass_'+item).empty();
// @todo remove any required attributes that are no longer defined as a result of removing this OC
console.log('Remove required attributes of:'+item);
// @todo Remove attributes from "Add new Attribute" that are no longer available
console.log('Remove additional attributes of:'+item);
$.ajax({
type: 'POST',
beforeSend: function() {},
success: function(data) {
var attrs = [];
// Remove attributes from "Add new Attribute" that are no longer available
if (data.may.length) {
data.may.forEach(function(mayitem) {
var x = $("select#newattr option[value='"+mayitem+"']");
if (x.length) {
x.remove();
// Add this to the must attrs list, because its been rendered
} else {
attrs.push(mayitem);
}
});
}
data.must.concat(attrs).forEach(function(attr) {
var x = $('#'+attr).find('input');
x.css('background-color','#f0c0c0').attr('readonly',true).attr('placeholder',x.val()).val('');
});
// remove the Add Values box
// Remove any keyed in values
// @todo remove any required attributes that are no longer defined as a result of removing this OC
},
error: function(e) {
if (e.status != 412)
alert('That didnt work? Please try again....');
},
url: '{{ url('api/schema/objectclass/attrs') }}/'+item,
cache: false
});
}
});
@ -172,17 +212,17 @@
@case('App\Classes\LDAP\Attribute')
@default
@php($clone=TRUE)
<span @class(['btn','btn-sm','btn-outline-primary','mt-3','addable','d-none'=>(! $new)]) id="{{ $o->name_lc }}"><i class="fas fa-fw fa-plus"></i> @lang('Add Value')</span>
<span @class(['btn','btn-sm','btn-outline-primary','mt-3','addable','d-none'=>(! $new)]) id="{{ $o->name }}-addnew"><i class="fas fa-fw fa-plus"></i> @lang('Add Value')</span>
@section('page-scripts')
@if($clone && $edit && $o->can_addvalues)
<script type="text/javascript">
$(document).ready(function() {
// Create a new entry when Add Value clicked
$('#{{ $o->name_lc }}.addable').click(function (item) {
$('#{{ $o->name }}-addnew.addable').click(function (item) {
var cln = $(this).parent().parent().find('input:last').parent().clone();
cln.find('input:last').attr('value','').attr('placeholder', '[@lang('NEW')]');
cln.appendTo('#' + item.currentTarget.id)
cln.appendTo('#'+item.currentTarget.id.replace('-addnew',''));
});
});
</script>