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 */
|
/** 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;
|
font-size: inherit;
|
||||||
width: 9em;
|
width: 9em;
|
||||||
border: #444054 1px solid;
|
border: #444054 1px solid;
|
||||||
@ -11,7 +11,7 @@ div#userPassword .select2-container--bootstrap-5 .select2-selection {
|
|||||||
border-top-right-radius: unset;
|
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;
|
position: absolute;
|
||||||
right: 1em;
|
right: 1em;
|
||||||
top: 0.5em;
|
top: 0.5em;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<div class="row pt-2">
|
<div class="row pt-2">
|
||||||
<div @class(['col-1','d-none'=>(! $edit)])></div>
|
<div @class(['col-1','d-none'=>(! $edit)])></div>
|
||||||
<div class="col-10 p-2">
|
<div class="col-10 p-2">
|
||||||
<div id="{{ $o->name }}">
|
<attribute id="{{ $o->name }}">
|
||||||
{{ $slot }}
|
{{ $slot }}
|
||||||
</div>
|
</attribute>
|
||||||
|
|
||||||
<x-attribute.widget.options :o="$o" :edit="$edit" :new="$new"/>
|
<x-attribute.widget.options :o="$o" :edit="$edit" :new="$new"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
|
@use(App\Classes\LDAP\Attribute\Binary\JpegPhoto)
|
||||||
|
@use(App\Classes\LDAP\Attribute\ObjectClass)
|
||||||
@php($clone=FALSE)
|
@php($clone=FALSE)
|
||||||
@if($o->is_rdn)
|
<span class="p-0 m-0">
|
||||||
<button class="btn btn-sm btn-outline-focus mt-3" disabled><i class="fas fa-fw fa-exchange"></i> @lang('Rename')</button>
|
@if($o->is_rdn)
|
||||||
@elseif($edit && $o->can_addvalues)
|
<br/>
|
||||||
<span class="p-0 m-0">
|
<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))
|
@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>
|
<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
|
@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>
|
<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 -->
|
<!-- NEW OBJECT CLASS -->
|
||||||
@ -37,42 +40,12 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var added_oc = []; // Object classes being added to this entry
|
var added_oc = []; // Object classes being added to this entry
|
||||||
var rendered = false;
|
var rendered = false;
|
||||||
|
var newadded = [];
|
||||||
|
|
||||||
// Show our ObjectClass modal so that we can add more objectclasses
|
if (newadded.length)
|
||||||
$('#new_objectclass-modal').on('shown.bs.modal',function() {
|
process_oc();
|
||||||
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;
|
|
||||||
|
|
||||||
|
function process_oc() {
|
||||||
// Find out what was selected, and add them
|
// Find out what was selected, and add them
|
||||||
newadded.forEach(function (item) {
|
newadded.forEach(function (item) {
|
||||||
if (added_oc.indexOf(item) !== -1)
|
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({
|
$.ajax({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '{{ url('api/schema/objectclass/attrs') }}/'+item,
|
url: '{{ url('api/schema/objectclass/attrs') }}/'+item,
|
||||||
@ -105,6 +79,9 @@
|
|||||||
// Render any must attributes
|
// Render any must attributes
|
||||||
if (data.must.length) {
|
if (data.must.length) {
|
||||||
data.must.forEach(function(item) {
|
data.must.forEach(function(item) {
|
||||||
|
if ($('attribute#'+item).length)
|
||||||
|
return;
|
||||||
|
|
||||||
// Add attribute to the page
|
// Add attribute to the page
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -174,7 +151,7 @@
|
|||||||
if (x.length) {
|
if (x.length) {
|
||||||
x.remove();
|
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 {
|
} else {
|
||||||
attrs.push(mayitem);
|
attrs.push(mayitem);
|
||||||
}
|
}
|
||||||
@ -196,13 +173,51 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
added_oc = newadded;
|
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>
|
</script>
|
||||||
@append
|
@append
|
||||||
@break
|
@break
|
||||||
|
|
||||||
@case('App\Classes\LDAP\Attribute')
|
<!-- All other attributes -->
|
||||||
@default
|
@default
|
||||||
@php($clone=TRUE)
|
@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>
|
<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
|
@endif
|
||||||
@append
|
@append
|
||||||
@endswitch
|
@endswitch
|
||||||
</span>
|
@endif
|
||||||
@endif
|
</span>
|
Loading…
x
Reference in New Issue
Block a user