Skip to content

Commit 8f39603

Browse files
committed
Improved determination of attribute object being dirty, improved detection of blank input and processing
1 parent bcea6de commit 8f39603

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

app/Classes/LDAP/Attribute.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,9 @@ public function hints(): array
253253
*/
254254
public function isDirty(): bool
255255
{
256-
return (($a=$this->values_old->dot())->keys()->count() !== ($b=$this->values->dot())->keys()->count())
257-
|| ($a->values()->count() !== $b->values()->count())
258-
|| ($a->keys()->diff($b->keys())->count() !== 0)
259-
|| ($a->values()->diff($b->values())->count() !== 0);
256+
return (($a=$this->values_old->dot()->filter())->keys()->count() !== ($b=$this->values->dot()->filter())->keys()->count())
257+
|| ($a->count() !== $b->count())
258+
|| ($a->diff($b)->count() !== 0);
260259
}
261260

262261
/**

app/Http/Controllers/HomeController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ public function entry_update(EntryRequest $request): \Illuminate\Http\RedirectRe
349349

350350
return Redirect::to('/')
351351
->withInput()
352-
->with('updated',collect($dirty)->map(fn($key,$item)=>$o->getObject($item)));
352+
->with('updated',collect($dirty)->map(fn($item,$key)=>$o->getObject(collect(explode(';',$key))->first())));
353353
}
354354

355355
/**
@@ -376,7 +376,7 @@ public function frame(Request $request,?Collection $old=NULL): \Illuminate\View\
376376
// If we are rendering a DN, rebuild our object
377377
$o = config('server')->fetch($key['dn']);
378378

379-
foreach (collect(old())->except(['key','step','_token','userpassword_hash']) as $attr => $value)
379+
foreach (collect(old())->except(['key','dn','step','_token','userpassword_hash']) as $attr => $value)
380380
$o->{$attr} = $value;
381381

382382
return match ($key['cmd']) {

resources/views/components/updated.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<p>{{ __('Entry updated') }}</p>
66
<ul style="list-style-type: square;">
77
@foreach (session()->pull('updated') as $key => $o)
8-
<li><abbr title="{{ $o->description }}">{{ $o->name }}</abbr>: {{ $o->values->map(fn($item,$key)=>$o->render_item_new($key))->join(',') }}</li>
8+
<li><abbr title="{{ $o->description }}">{{ $o->name }}</abbr>: {{ $o->values->dot()->filter()->join(',') }}</li>
99
@endforeach
1010
</ul>
1111
</div>

resources/views/update.blade.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@
5050
{{ $dotkey }}
5151
</th>
5252

53-
<td>{{ (($r=$oo->render_item_old($dotkey)) !== NULL) ? $r : '['.strtoupper(__('New Value')).']' }}</td>
54-
<td>{{ (($r=$oo->render_item_new($dotkey)) !== NULL) ? $r : '['.strtoupper(__('Deleted')).']' }}<input type="hidden" name="{{ $key }}[{{ collect(explode('.',$dotkey))->first() }}][]" value="{{ Arr::get($oo,$dotkey) }}"></td>
53+
@if((! Arr::get($oo->values_old->dot(),$dotkey)) && (! Arr::get($oo->values->dot(),$dotkey)))
54+
<td colspan="2" class="text-center">@lang('Ignoring blank value')</td>
55+
@else
56+
<td>{{ (($r=$oo->render_item_old($dotkey)) !== NULL) ? $r : '['.strtoupper(__('New Value')).']' }}</td>
57+
<td>{{ (($r=$oo->render_item_new($dotkey)) !== NULL) ? $r : '['.strtoupper(__('Deleted')).']' }}<input type="hidden" name="{{ $key }}[{{ collect(explode('.',$dotkey))->first() }}][]" value="{{ Arr::get($oo,$dotkey) }}"></td>
58+
@endif
5559
@endforeach
5660
</tr>
5761
@endforeach

0 commit comments

Comments
 (0)