When adding new attributes as a result of adding a new objectclass, dont duplicate existing attributes already present
This commit is contained in:
parent
e94a7d58e1
commit
d4c916923d
4
public/css/custom.css
vendored
4
public/css/custom.css
vendored
@ -1,5 +1,5 @@
|
||||
/** ensure our userpassword has select is next to the password input */
|
||||
div#userPassword .select2-container--bootstrap-5 .select2-selection {
|
||||
attribute#userPassword .select2-container--bootstrap-5 .select2-selection {
|
||||
font-size: inherit;
|
||||
width: 9em;
|
||||
border: #444054 1px solid;
|
||||
@ -11,7 +11,7 @@ div#userPassword .select2-container--bootstrap-5 .select2-selection {
|
||||
border-top-right-radius: unset;
|
||||
}
|
||||
|
||||
div#objectClass .input-group-end:not(input.form-control) {
|
||||
attribute#objectClass .input-group-end:not(input.form-control) {
|
||||
position: absolute;
|
||||
right: 1em;
|
||||
top: 0.5em;
|
||||
|
@ -1,10 +1,10 @@
|
||||
<div class="row pt-2">
|
||||
<div @class(['col-1','d-none'=>(! $edit)])></div>
|
||||
<div class="col-10 p-2">
|
||||
<div id="{{ $o->name }}">
|
||||
<attribute id="{{ $o->name }}">
|
||||
{{ $slot }}
|
||||
</div>
|
||||
</attribute>
|
||||
|
||||
<x-attribute.widget.options :o="$o" :edit="$edit" :new="$new"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,15 +1,18 @@
|
||||
@use(App\Classes\LDAP\Attribute\Binary\JpegPhoto)
|
||||
@use(App\Classes\LDAP\Attribute\ObjectClass)
|
||||
@php($clone=FALSE)
|
||||
@if($o->is_rdn)
|
||||
<button class="btn btn-sm btn-outline-focus mt-3" disabled><i class="fas fa-fw fa-exchange"></i> @lang('Rename')</button>
|
||||
@elseif($edit && $o->can_addvalues)
|
||||
<span class="p-0 m-0">
|
||||
<span class="p-0 m-0">
|
||||
@if($o->is_rdn)
|
||||
<br/>
|
||||
<button class="btn btn-sm btn-outline-focus mt-3" disabled><i class="fas fa-fw fa-exchange"></i> @lang('Rename')</button>
|
||||
@elseif($edit && $o->can_addvalues)
|
||||
@switch(get_class($o))
|
||||
@case('App\Classes\LDAP\Attribute\Binary\JpegPhoto')
|
||||
@case(JpegPhoto::class)
|
||||
<button @class(['btn','btn-sm','btn-outline-primary','mt-3','addable','d-none'=>(! $new)]) id="{{ $o->name_lc }}" disabled><i class="fas fa-fw fa-plus"></i> @lang('Upload JpegPhoto')</button>
|
||||
|
||||
@break
|
||||
|
||||
@case('App\Classes\LDAP\Attribute\ObjectClass')
|
||||
@case(ObjectClass::class)
|
||||
<button type="button" @class(['btn','btn-sm','btn-outline-primary','mt-3','addable','d-none'=>(! $new)]) data-bs-toggle="modal" data-bs-target="#new_objectclass-modal"><i class="fas fa-fw fa-plus"></i> @lang('Add Objectclass')</button>
|
||||
|
||||
<!-- NEW OBJECT CLASS -->
|
||||
@ -37,42 +40,12 @@
|
||||
$(document).ready(function() {
|
||||
var added_oc = []; // Object classes being added to this entry
|
||||
var rendered = false;
|
||||
var newadded = [];
|
||||
|
||||
// Show our ObjectClass modal so that we can add more objectclasses
|
||||
$('#new_objectclass-modal').on('shown.bs.modal',function() {
|
||||
if (! rendered)
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: '{{ url('entry/objectclass/add') }}',
|
||||
data: {
|
||||
oc: oc,
|
||||
},
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
$('select#newoc').select2({
|
||||
dropdownParent: $('#new_objectclass-modal'),
|
||||
theme: 'bootstrap-5',
|
||||
multiple: true,
|
||||
data: data,
|
||||
});
|
||||
},
|
||||
error: function(e) {
|
||||
if (e.status !== 412)
|
||||
alert('That didnt work? Please try again....');
|
||||
},
|
||||
});
|
||||
|
||||
rendered = true;
|
||||
})
|
||||
|
||||
// When the ObjectClass modal is closed, process what was selected
|
||||
$('#new_objectclass-modal').on('hide.bs.modal',function() {
|
||||
var newadded = $('select#newoc').val();
|
||||
|
||||
// If nothing selected, we dont have anything to do
|
||||
if (added_oc.sort().join('|') === newadded.sort().join('|'))
|
||||
return;
|
||||
if (newadded.length)
|
||||
process_oc();
|
||||
|
||||
function process_oc() {
|
||||
// Find out what was selected, and add them
|
||||
newadded.forEach(function (item) {
|
||||
if (added_oc.indexOf(item) !== -1)
|
||||
@ -97,6 +70,7 @@
|
||||
},
|
||||
});
|
||||
|
||||
// Get a list of attributes already on the page, so we dont double up
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: '{{ url('api/schema/objectclass/attrs') }}/'+item,
|
||||
@ -105,6 +79,9 @@
|
||||
// Render any must attributes
|
||||
if (data.must.length) {
|
||||
data.must.forEach(function(item) {
|
||||
if ($('attribute#'+item).length)
|
||||
return;
|
||||
|
||||
// Add attribute to the page
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
@ -174,7 +151,7 @@
|
||||
if (x.length) {
|
||||
x.remove();
|
||||
|
||||
// Add this to the must attrs list, because its been rendered
|
||||
// Add this to the must attrs list, because its been rendered
|
||||
} else {
|
||||
attrs.push(mayitem);
|
||||
}
|
||||
@ -196,13 +173,51 @@
|
||||
});
|
||||
|
||||
added_oc = newadded;
|
||||
}
|
||||
|
||||
// Show our ObjectClass modal so that we can add more objectclasses
|
||||
$('#new_objectclass-modal').on('shown.bs.modal',function() {
|
||||
if (! rendered)
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: '{{ url('entry/objectclass/add') }}',
|
||||
data: {
|
||||
oc: oc,
|
||||
},
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
$('select#newoc').select2({
|
||||
dropdownParent: $('#new_objectclass-modal'),
|
||||
theme: 'bootstrap-5',
|
||||
multiple: true,
|
||||
data: data,
|
||||
});
|
||||
},
|
||||
error: function(e) {
|
||||
if (e.status !== 412)
|
||||
alert('That didnt work? Please try again....');
|
||||
},
|
||||
});
|
||||
|
||||
rendered = true;
|
||||
})
|
||||
|
||||
// When the ObjectClass modal is closed, process what was selected
|
||||
$('#new_objectclass-modal').on('hide.bs.modal',function() {
|
||||
newadded = $('select#newoc').val();
|
||||
|
||||
// If nothing selected, we dont have anything to do
|
||||
if (added_oc.sort().join('|') === newadded.sort().join('|'))
|
||||
return;
|
||||
|
||||
process_oc();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@append
|
||||
@break
|
||||
|
||||
@case('App\Classes\LDAP\Attribute')
|
||||
<!-- All other attributes -->
|
||||
@default
|
||||
@php($clone=TRUE)
|
||||
<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>
|
||||
@ -222,5 +237,5 @@
|
||||
@endif
|
||||
@append
|
||||
@endswitch
|
||||
</span>
|
||||
@endif
|
||||
@endif
|
||||
</span>
|
Loading…
x
Reference in New Issue
Block a user