Skip to content

Commit c588e13

Browse files
committed
Clear some javascript @todos: fancytree options, optionclass processing
1 parent dc623b1 commit c588e13

File tree

6 files changed

+51
-61
lines changed

6 files changed

+51
-61
lines changed

app/Classes/LDAP/Attribute.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ public function hints(): array
241241
// @todo
242242

243243
// objectClasses requiring this attribute
244+
// @todo limit this to this DNs objectclasses
244245
// eg: $result->put('required','Required by objectClasses: a,b');
245246
if ($this->required_by->count())
246247
$result->put(__('required'),sprintf('%s: %s',__('Required Attribute by ObjectClass(es)'),$this->required_by->join(',')));

app/Http/Controllers/HomeController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function entry_add(EntryAddRequest $request)
9696
*/
9797
public function entry_attr_add(Request $request,string $id): string
9898
{
99-
$xx = new \stdClass();
99+
$xx = new \stdClass;
100100
$xx->index = 0;
101101

102102
$x = $request->noheader

public/css/fixes.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ table.dataTable thead .sorting {
6969
*/
7070

7171
/** Fancy Tree Fixes **/
72-
/*
73-
@todo The unopened lazy branches off the tree are off by 5px. see *-cdl. below
74-
@todo The last node is missing some dots, connecting to the previous node
75-
*/
7672
/* So our tree can be longer than the frame */
7773
.scrollbar-sidebar {
7874
overflow: auto;
@@ -117,7 +113,7 @@ ul.fancytree-container ul {
117113
}
118114
.fancytree-node.fancytree-exp-n span.fancytree-expander,
119115
.fancytree-node.fancytree-exp-n span.fancytree-expander:hover { /* node */
120-
margin-top: 4px;
116+
margin-top: 3px;
121117
background-position: 0 -63px;
122118
}
123119
.fancytree-node.fancytree-exp-nl span.fancytree-expander { /* node last */

public/js/custom.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,14 @@ $(document).ready(function() {
6464
// and pass the tree options as an argument to the fancytree() function:
6565
$('#tree').fancytree({
6666
clickFolderMode: 3,
67-
extensions: ['glyph','persist'],
67+
extensions: ['persist'],
6868
autoCollapse: true, // Automatically collapse all siblings, when a node is expanded.
6969
autoScroll: true, // Automatically scroll nodes into visible area.
7070
focusOnSelect: true, // Set focus when node is checked by a mouse click
71-
glyph: {
72-
preset: 'bootstrap3', // @todo look at changing this to awesome5
73-
map: {}
74-
},
7571
persist: {
7672
// Available options with their default:
7773
cookieDelimiter: '~', // character used to join key strings
78-
cookiePrefix: undefined, // 'fancytree-<treeId>-' by default
74+
cookiePrefix: 'pla-<treeId>-', // 'fancytree-<treeId>-' by default
7975
cookie: { // settings passed to jquery.cookie plugin
8076
raw: false,
8177
expires: '',
@@ -85,14 +81,14 @@ $(document).ready(function() {
8581
},
8682
expandLazy: true, // true: recursively expand and load lazy nodes
8783
expandOpts: undefined, // optional `opts` argument passed to setExpanded()
84+
fireActivate: false, //
8885
overrideSource: true, // true: cookie takes precedence over `source` data attributes.
8986
store: 'auto', // 'cookie': use cookie, 'local': use localStore, 'session': use sessionStore
9087
types: 'active expanded focus selected' // which status types to store
9188
},
9289
click: function(event,data) {
93-
if (data.targetType == 'title') {
90+
if (data.targetType === 'title')
9491
getNode(data.node.data.item);
95-
}
9692
},
9793
source: sources,
9894
lazyLoad: function(event,data) {

resources/views/components/attribute/objectclass.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- $o=Attribute::class -->
22
<x-attribute.layout :edit="$edit" :new="$new" :o="$o">
3-
@foreach (old($o->name_lc,$o->values) as $value)
3+
@foreach(old($o->name_lc,$o->values) as $value)
44
@if ($edit)
55
<x-attribute.widget.objectclass :o="$o" :edit="$edit" :new="$new" :loop="$loop" :value="$value"/>
66
@else

resources/views/components/attribute/widget/options.blade.php

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727

2828
<div class="modal-footer">
2929
<button type="button" class="btn btn-sm btn-primary" data-bs-dismiss="modal">Next</button>
30-
{{--
31-
<button type="button" class="btn btn-sm btn-primary" data-bs-dismiss="modal"><i class="fas fa-fw fa-spinner fa-spin d-none"></i> Next</button>
32-
--}}
3330
</div>
3431
</div>
3532
</div>
@@ -45,12 +42,12 @@
4542
$('#new_objectclass-modal').on('shown.bs.modal',function() {
4643
if (! rendered)
4744
$.ajax({
48-
type: 'POST',
49-
cache: false,
45+
method: 'POST',
5046
url: '{{ url('entry/objectclass/add') }}',
5147
data: {
5248
oc: oc,
5349
},
50+
cache: false,
5451
success: function(data) {
5552
$('select#newoc').select2({
5653
dropdownParent: $('#new_objectclass-modal'),
@@ -60,7 +57,7 @@
6057
});
6158
},
6259
error: function(e) {
63-
if (e.status != 412)
60+
if (e.status !== 412)
6461
alert('That didnt work? Please try again....');
6562
},
6663
});
@@ -70,11 +67,10 @@
7067
7168
// When the ObjectClass modal is closed, process what was selected
7269
$('#new_objectclass-modal').on('hide.bs.modal',function() {
73-
var c = {{ $o->values->count() }}; // @todo do we need this?
7470
var newadded = $('select#newoc').val();
7571
7672
// If nothing selected, we dont have anything to do
77-
if (added_oc.sort().join('|') == newadded.sort().join('|'))
73+
if (added_oc.sort().join('|') === newadded.sort().join('|'))
7874
return;
7975
8076
// Find out what was selected, and add them
@@ -84,70 +80,77 @@
8480
8581
// Add attribute to the page
8682
$.ajax({
87-
type: 'POST',
88-
beforeSend: function() {},
89-
success: function(data) {
90-
$('#{{ $o->name }}').append(data);
91-
},
92-
error: function(e) {
93-
if (e.status != 412)
94-
alert('That didnt work? Please try again....');
95-
},
83+
method: 'POST',
9684
url: '{{ url('entry/attr/add',[$o->name_lc]) }}',
9785
data: {
9886
noheader: true,
9987
value: item,
10088
objectclasses: oc,
101-
loop: c++, // @todo can we omit loop and c
10289
},
103-
cache: false
90+
cache: false,
91+
success: function(data) {
92+
$('#{{ $o->name }}').append(data);
93+
},
94+
error: function(e) {
95+
if (e.status !== 412)
96+
alert('That didnt work? Please try again....');
97+
},
10498
});
10599
106100
$.ajax({
107-
type: 'POST',
108-
beforeSend: function() {},
101+
method: 'POST',
102+
url: '{{ url('api/schema/objectclass/attrs') }}/'+item,
103+
cache: false,
109104
success: function(data) {
110105
// Render any must attributes
111106
if (data.must.length) {
112107
data.must.forEach(function(item) {
113108
// Add attribute to the page
114109
$.ajax({
115-
type: 'POST',
116-
beforeSend: function() {},
110+
method: 'POST',
111+
url: '{{ url('entry/attr/add') }}/'+item,
112+
data: {
113+
value: item,
114+
objectclasses: oc,
115+
},
116+
cache: false,
117117
success: function(data) {
118118
$('#newattrs').append(data);
119119
},
120120
error: function(e) {
121-
if (e.status != 412)
121+
if (e.status !== 412)
122122
alert('That didnt work? Please try again....');
123123
},
124-
url: '{{ url('entry/attr/add') }}/'+item,
125-
data: {
126-
value: item,
127-
objectclasses: oc,
128-
loop: c++, // @todo can we omit loop and c
129-
},
130-
cache: false
131124
});
132125
})
133126
}
134127
135128
// Add attributes to "Add new Attribute" that are now available
136129
if (data.may.length) {
137130
var newattr = $('select#newattr');
131+
var oldoptions = $('select#newattr option').map((i,o)=>o.value).get();
138132
139-
// @todo It might be nice to re-sort these options
140133
data.may.forEach(function(item) {
141-
newattr.append(new Option(item,item,false,false));
134+
if (! oldoptions.includes(item))
135+
newattr.append(new Option(item,item,false,false));
142136
});
137+
138+
// Sort the attributes
139+
newattr
140+
.append($('select#newattr option')
141+
.remove()
142+
.sort(function (a,b) {
143+
let at = $(a).text(),
144+
bt = $(b).text();
145+
return (at > bt) ? 1 : ((at < bt) ? -1 : 0);
146+
}))
147+
.val('');
143148
}
144149
},
145150
error: function(e) {
146-
if (e.status != 412)
151+
if (e.status !== 412)
147152
alert('That didnt work? Please try again....');
148153
},
149-
url: '{{ url('api/schema/objectclass/attrs') }}/'+item,
150-
cache: false
151154
});
152155
});
153156
@@ -156,10 +159,10 @@
156159
if (newadded.indexOf(item) === -1) {
157160
$('span#objectclass_'+item).empty();
158161
159-
// @todo Remove attributes from "Add new Attribute" that are no longer available
160162
$.ajax({
161-
type: 'POST',
162-
beforeSend: function() {},
163+
method: 'POST',
164+
url: '{{ url('api/schema/objectclass/attrs') }}/'+item,
165+
cache: false,
163166
success: function(data) {
164167
var attrs = [];
165168
@@ -183,17 +186,11 @@
183186
184187
x.css('background-color','#f0c0c0').attr('readonly',true).attr('placeholder',x.val()).val('');
185188
});
186-
187-
// remove the Add Values box
188-
// Remove any keyed in values
189-
// @todo remove any required attributes that are no longer defined as a result of removing this OC
190189
},
191190
error: function(e) {
192-
if (e.status != 412)
191+
if (e.status !== 412)
193192
alert('That didnt work? Please try again....');
194193
},
195-
url: '{{ url('api/schema/objectclass/attrs') }}/'+item,
196-
cache: false
197194
});
198195
}
199196
});

0 commit comments

Comments
 (0)