diff --git a/app/Classes/LDAP/Attribute.php b/app/Classes/LDAP/Attribute.php index a60ce120..de256e24 100644 --- a/app/Classes/LDAP/Attribute.php +++ b/app/Classes/LDAP/Attribute.php @@ -241,6 +241,7 @@ class Attribute implements \Countable, \ArrayAccess, \Iterator // @todo // objectClasses requiring this attribute + // @todo limit this to this DNs objectclasses // eg: $result->put('required','Required by objectClasses: a,b'); if ($this->required_by->count()) $result->put(__('required'),sprintf('%s: %s',__('Required Attribute by ObjectClass(es)'),$this->required_by->join(','))); diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 7c1744f9..306d3fc8 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -96,7 +96,7 @@ class HomeController extends Controller */ public function entry_attr_add(Request $request,string $id): string { - $xx = new \stdClass(); + $xx = new \stdClass; $xx->index = 0; $x = $request->noheader diff --git a/public/css/fixes.css b/public/css/fixes.css index 3fc5e4a2..21480d9d 100644 --- a/public/css/fixes.css +++ b/public/css/fixes.css @@ -69,10 +69,6 @@ table.dataTable thead .sorting { */ /** Fancy Tree Fixes **/ -/* -@todo The unopened lazy branches off the tree are off by 5px. see *-cdl. below -@todo The last node is missing some dots, connecting to the previous node -*/ /* So our tree can be longer than the frame */ .scrollbar-sidebar { overflow: auto; @@ -117,7 +113,7 @@ ul.fancytree-container ul { } .fancytree-node.fancytree-exp-n span.fancytree-expander, .fancytree-node.fancytree-exp-n span.fancytree-expander:hover { /* node */ - margin-top: 4px; + margin-top: 3px; background-position: 0 -63px; } .fancytree-node.fancytree-exp-nl span.fancytree-expander { /* node last */ diff --git a/public/js/custom.js b/public/js/custom.js index 414e691d..0fa1e07f 100644 --- a/public/js/custom.js +++ b/public/js/custom.js @@ -64,18 +64,14 @@ $(document).ready(function() { // and pass the tree options as an argument to the fancytree() function: $('#tree').fancytree({ clickFolderMode: 3, - extensions: ['glyph','persist'], + extensions: ['persist'], autoCollapse: true, // Automatically collapse all siblings, when a node is expanded. autoScroll: true, // Automatically scroll nodes into visible area. focusOnSelect: true, // Set focus when node is checked by a mouse click - glyph: { - preset: 'bootstrap3', // @todo look at changing this to awesome5 - map: {} - }, persist: { // Available options with their default: cookieDelimiter: '~', // character used to join key strings - cookiePrefix: undefined, // 'fancytree--' by default + cookiePrefix: 'pla--', // 'fancytree--' by default cookie: { // settings passed to jquery.cookie plugin raw: false, expires: '', @@ -85,14 +81,14 @@ $(document).ready(function() { }, expandLazy: true, // true: recursively expand and load lazy nodes expandOpts: undefined, // optional `opts` argument passed to setExpanded() + fireActivate: false, // overrideSource: true, // true: cookie takes precedence over `source` data attributes. store: 'auto', // 'cookie': use cookie, 'local': use localStore, 'session': use sessionStore types: 'active expanded focus selected' // which status types to store }, click: function(event,data) { - if (data.targetType == 'title') { + if (data.targetType === 'title') getNode(data.node.data.item); - } }, source: sources, lazyLoad: function(event,data) { diff --git a/resources/views/components/attribute/objectclass.blade.php b/resources/views/components/attribute/objectclass.blade.php index 717ecd6c..d87c999e 100644 --- a/resources/views/components/attribute/objectclass.blade.php +++ b/resources/views/components/attribute/objectclass.blade.php @@ -1,6 +1,6 @@ - @foreach (old($o->name_lc,$o->values) as $value) + @foreach(old($o->name_lc,$o->values) as $value) @if ($edit) @else diff --git a/resources/views/components/attribute/widget/options.blade.php b/resources/views/components/attribute/widget/options.blade.php index 90eb545b..fbed2c60 100644 --- a/resources/views/components/attribute/widget/options.blade.php +++ b/resources/views/components/attribute/widget/options.blade.php @@ -27,9 +27,6 @@ @@ -45,12 +42,12 @@ $('#new_objectclass-modal').on('shown.bs.modal',function() { if (! rendered) $.ajax({ - type: 'POST', - cache: false, + method: 'POST', url: '{{ url('entry/objectclass/add') }}', data: { oc: oc, }, + cache: false, success: function(data) { $('select#newoc').select2({ dropdownParent: $('#new_objectclass-modal'), @@ -60,7 +57,7 @@ }); }, error: function(e) { - if (e.status != 412) + if (e.status !== 412) alert('That didnt work? Please try again....'); }, }); @@ -70,11 +67,10 @@ // When the ObjectClass modal is closed, process what was selected $('#new_objectclass-modal').on('hide.bs.modal',function() { - var c = {{ $o->values->count() }}; // @todo do we need this? var newadded = $('select#newoc').val(); // If nothing selected, we dont have anything to do - if (added_oc.sort().join('|') == newadded.sort().join('|')) + if (added_oc.sort().join('|') === newadded.sort().join('|')) return; // Find out what was selected, and add them @@ -84,50 +80,47 @@ // Add attribute to the page $.ajax({ - type: 'POST', - beforeSend: function() {}, - success: function(data) { - $('#{{ $o->name }}').append(data); - }, - error: function(e) { - if (e.status != 412) - alert('That didnt work? Please try again....'); - }, + method: 'POST', url: '{{ url('entry/attr/add',[$o->name_lc]) }}', data: { noheader: true, value: item, objectclasses: oc, - loop: c++, // @todo can we omit loop and c }, - cache: false + cache: false, + success: function(data) { + $('#{{ $o->name }}').append(data); + }, + error: function(e) { + if (e.status !== 412) + alert('That didnt work? Please try again....'); + }, }); $.ajax({ - type: 'POST', - beforeSend: function() {}, + method: 'POST', + url: '{{ url('api/schema/objectclass/attrs') }}/'+item, + cache: false, success: function(data) { // Render any must attributes if (data.must.length) { data.must.forEach(function(item) { // Add attribute to the page $.ajax({ - type: 'POST', - beforeSend: function() {}, - success: function(data) { - $('#newattrs').append(data); - }, - error: function(e) { - if (e.status != 412) - alert('That didnt work? Please try again....'); - }, + method: 'POST', url: '{{ url('entry/attr/add') }}/'+item, data: { value: item, objectclasses: oc, - loop: c++, // @todo can we omit loop and c }, - cache: false + cache: false, + success: function(data) { + $('#newattrs').append(data); + }, + error: function(e) { + if (e.status !== 412) + alert('That didnt work? Please try again....'); + }, }); }) } @@ -135,19 +128,29 @@ // Add attributes to "Add new Attribute" that are now available if (data.may.length) { var newattr = $('select#newattr'); + var oldoptions = $('select#newattr option').map((i,o)=>o.value).get(); - // @todo It might be nice to re-sort these options data.may.forEach(function(item) { - newattr.append(new Option(item,item,false,false)); + if (! oldoptions.includes(item)) + newattr.append(new Option(item,item,false,false)); }); + + // Sort the attributes + newattr + .append($('select#newattr option') + .remove() + .sort(function (a,b) { + let at = $(a).text(), + bt = $(b).text(); + return (at > bt) ? 1 : ((at < bt) ? -1 : 0); + })) + .val(''); } }, error: function(e) { - if (e.status != 412) + if (e.status !== 412) alert('That didnt work? Please try again....'); }, - url: '{{ url('api/schema/objectclass/attrs') }}/'+item, - cache: false }); }); @@ -156,10 +159,10 @@ if (newadded.indexOf(item) === -1) { $('span#objectclass_'+item).empty(); - // @todo Remove attributes from "Add new Attribute" that are no longer available $.ajax({ - type: 'POST', - beforeSend: function() {}, + method: 'POST', + url: '{{ url('api/schema/objectclass/attrs') }}/'+item, + cache: false, success: function(data) { var attrs = []; @@ -183,17 +186,11 @@ 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) + if (e.status !== 412) alert('That didnt work? Please try again....'); }, - url: '{{ url('api/schema/objectclass/attrs') }}/'+item, - cache: false }); } });