diff --git a/app/Classes/LDAP/Attribute.php b/app/Classes/LDAP/Attribute.php index 4caaa18..272a13f 100644 --- a/app/Classes/LDAP/Attribute.php +++ b/app/Classes/LDAP/Attribute.php @@ -247,9 +247,9 @@ class Attribute implements \Countable, \ArrayAccess /** * Display the attribute value * - * @param bool $edit - * @param bool $old - * @param bool $new + * @param bool $edit Render an edit form + * @param bool $old Use old value + * @param bool $new Enable adding values * @return View */ public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View diff --git a/app/Ldap/Entry.php b/app/Ldap/Entry.php index edc1e18..f8a85b9 100644 --- a/app/Ldap/Entry.php +++ b/app/Ldap/Entry.php @@ -45,7 +45,9 @@ class Entry extends Model */ public function getAttributes(): array { - return $this->objects->map(function($item) { return $item->values->toArray(); })->toArray(); + return $this->objects + ->map(fn($item)=>$item->values->toArray()) + ->toArray(); } /** @@ -55,16 +57,14 @@ class Entry extends Model { $key = $this->normalizeAttributeKey($key); - if ((! array_key_exists($key, $this->original)) && (! $this->objects->has($key))) { + if ((! array_key_exists($key,$this->original)) && (! $this->objects->has($key))) return TRUE; - } $current = $this->attributes[$key]; $original = $this->objects->get($key)->values; - if ($current === $original) { - return true; - } + if ($current === $original) + return TRUE; return ! $this->getObject($key)->isDirty(); } @@ -134,8 +134,8 @@ class Entry extends Model /** * Return a key to use for sorting * - * @todo This should be the DN in reverse order * @return string + * @todo This should be the DN in reverse order */ public function getSortKeyAttribute(): string { @@ -148,7 +148,7 @@ class Entry extends Model { $key = $this->normalizeAttributeKey($key); - if (config('server')->schema('attributetypes')->has($key) === FALSE) + if (! config('server')->schema('attributetypes')->contains($key)) throw new AttributeException('Schema doesnt have attribute [%s]',$key); if ($x=$this->objects->get($key)) { @@ -199,10 +199,10 @@ class Entry extends Model } } - $sort = collect(config('ldap.attr_display_order',[]))->transform(function($item) { return strtolower($item); }); + $sort = collect(config('ldap.attr_display_order',[]))->map(fn($item)=>strtolower($item)); // Order the attributes - $result = $result->sortBy([function(Attribute $a,Attribute $b) use ($sort): int { + return $result->sortBy([function(Attribute $a,Attribute $b) use ($sort): int { if ($a === $b) return 0; @@ -225,9 +225,7 @@ class Entry extends Model // Case where at least one attribute or its friendly name is in $attrs_display_order // return -1 if $a before $b in $attrs_display_order return ($a_key < $b_key) ? -1 : 1; - } ]); - - return $result; + }]); } /** @@ -261,9 +259,8 @@ class Entry extends Model */ public function getInternalAttributes(): Collection { - return $this->objects->filter(function($item) { - return $item->is_internal; - }); + return $this->objects + ->filter(fn($item)=>$item->is_internal); } /** @@ -274,7 +271,8 @@ class Entry extends Model */ public function getObject(string $key): Attribute|null { - return $this->objects->get($this->normalizeAttributeKey($key)); + return $this->objects + ->get($this->normalizeAttributeKey($key)); } public function getObjects(): Collection @@ -293,7 +291,8 @@ class Entry extends Model */ public function getMissingAttributes(): Collection { - return $this->getAvailableAttributes()->diff($this->getVisibleAttributes()); + return $this->getAvailableAttributes() + ->diff($this->getVisibleAttributes()); } /** @@ -303,14 +302,14 @@ class Entry extends Model */ public function getVisibleAttributes(): Collection { - return $this->objects->filter(function($item) { - return ! $item->is_internal; - }); + return $this->objects + ->filter(fn($item)=>! $item->is_internal); } public function hasAttribute(int|string $key): bool { - return $this->objects->has($key); + return $this->objects + ->has($key); } /** diff --git a/app/View/Components/Attribute.php b/app/View/Components/Attribute.php index b5599fb..c88adca 100644 --- a/app/View/Components/Attribute.php +++ b/app/View/Components/Attribute.php @@ -8,22 +8,22 @@ use App\Classes\LDAP\Attribute as LDAPAttribute; class Attribute extends Component { - public LDAPAttribute $o; + public ?LDAPAttribute $o; public bool $edit; public bool $new; public bool $old; + public ?string $na; /** * Create a new component instance. - * - * @return void */ - public function __construct(LDAPAttribute $o,bool $edit,bool $old=FALSE,bool $new=FALSE) + public function __construct(?LDAPAttribute $o,bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,string $na=NULL) { $this->o = $o; $this->edit = $edit; $this->old = $old; $this->new = $new; + $this->na = $na; } /** @@ -33,6 +33,9 @@ class Attribute extends Component */ public function render() { - return $this->o->render($this->edit,$this->old,$this->new); + return $this->o + ? $this->o + ->render($this->edit,$this->old,$this->new) + : $this->na; } } \ No newline at end of file diff --git a/resources/views/components/attribute-type.blade.php b/resources/views/components/attribute-type.blade.php index f684b12..7484a44 100644 --- a/resources/views/components/attribute-type.blade.php +++ b/resources/views/components/attribute-type.blade.php @@ -15,6 +15,6 @@ - + \ No newline at end of file diff --git a/resources/views/components/attribute.blade.php b/resources/views/components/attribute.blade.php index 0aa3945..ff942c7 100644 --- a/resources/views/components/attribute.blade.php +++ b/resources/views/components/attribute.blade.php @@ -1,9 +1,9 @@ - - @foreach (old($o->name_lc,$new ? [NULL] : $o->values) as $value) - @if ($edit && ! $o->is_rdn) + + @foreach(old($o->name_lc,($new ?? FALSE) ? [NULL] : $o->values) as $value) + @if (($edit ?? FALSE) && ! $o->is_rdn)
- + ($e=$errors->get($o->name_lc.'.'.$loop->index)),'mb-1','border-focus'=>($o->values->contains($value))]) name="{{ $o->name_lc }}[]" value="{{ $value }}" placeholder="{{ ! is_null($x=Arr::get($o->values,$loop->index)) ? $x : '['.__('NEW').']' }}" @readonly(! ($new ?? FALSE))>
@if($e) diff --git a/resources/views/components/attribute/binary/jpegphoto.blade.php b/resources/views/components/attribute/binary/jpegphoto.blade.php index e8ab6e7..0d7414d 100644 --- a/resources/views/components/attribute/binary/jpegphoto.blade.php +++ b/resources/views/components/attribute/binary/jpegphoto.blade.php @@ -9,7 +9,7 @@ @default - + ($e=$errors->get($o->name_lc.'.'.$loop->index))]) src="data:{{ $x }};base64, {{ base64_encode($value) }}" /> @if ($edit)
diff --git a/resources/views/components/attribute/layout.blade.php b/resources/views/components/attribute/layout.blade.php index 42c8064..f139668 100644 --- a/resources/views/components/attribute/layout.blade.php +++ b/resources/views/components/attribute/layout.blade.php @@ -1,5 +1,5 @@
-
+
(! $edit)])>
{{ $slot }} diff --git a/resources/views/components/attribute/objectclass.blade.php b/resources/views/components/attribute/objectclass.blade.php index 38b2ef3..d759df4 100644 --- a/resources/views/components/attribute/objectclass.blade.php +++ b/resources/views/components/attribute/objectclass.blade.php @@ -3,7 +3,7 @@ @foreach (old($o->name_lc,$o->values) as $value) @if ($edit && ($value === NULL || (! $o->isStructural($value))))
- + ($e=$errors->get($o->name_lc.'.'.$loop->index)),'mb-1','border-focus'=>$o->values->contains($value)]) name="{{ $o->name_lc }}[]" value="{{ $value }}" placeholder="{{ ! is_null($x=Arr::get($o->values,$loop->index)) ? $x : '['.__('NEW').']' }}" @readonly(true)>
@if($e) {{ join('|',$e) }} diff --git a/resources/views/components/attribute/password.blade.php b/resources/views/components/attribute/password.blade.php index 7a75d5c..048738e 100644 --- a/resources/views/components/attribute/password.blade.php +++ b/resources/views/components/attribute/password.blade.php @@ -4,7 +4,7 @@ @foreach ($o->values as $value) @if ($edit)
- + ($e=$errors->get($o->name_lc.'.'.$loop->index)),'mb-1','border-focus'=>$o->values->contains($value)]) name="{{ $o->name_lc }}[]" value="{{ md5($value) }}" @readonly(true)>
@if($e) diff --git a/resources/views/components/attribute/widget/options.blade.php b/resources/views/components/attribute/widget/options.blade.php index 5739bda..17a1c08 100644 --- a/resources/views/components/attribute/widget/options.blade.php +++ b/resources/views/components/attribute/widget/options.blade.php @@ -2,7 +2,7 @@ @lang('Rename') @elseif($edit && $o->can_addvalues) - @lang('Add Value') + (! $new)]) id="{{ $o->name_lc }}"> @lang('Add Value') @if($new) +@append \ No newline at end of file diff --git a/resources/views/fragment/dn/header.blade.php b/resources/views/fragment/dn/header.blade.php new file mode 100644 index 0000000..020a3cc --- /dev/null +++ b/resources/views/fragment/dn/header.blade.php @@ -0,0 +1,32 @@ + + + + + + + + +
+ {!! $x ? $x->render(FALSE,TRUE) : sprintf('
',$o->icon() ?? "fas fa-info") !!} +
{{ $dn }}
+ + + + + + + + + + + + + +
Created + [] +
Modified + [] +
UUID + +
+
\ No newline at end of file diff --git a/resources/views/frames/dn.blade.php b/resources/views/frames/dn.blade.php index f2624c3..1e5c0db 100644 --- a/resources/views/frames/dn.blade.php +++ b/resources/views/frames/dn.blade.php @@ -1,30 +1,7 @@ @extends('layouts.dn') @section('page_title') - - - - - - - - -
{!! $x ? $x->render() : sprintf('
',$o->icon() ?? "fas fa-info") !!}
{{ $dn }}
- - - - - - - - - - - - - -
Created{{ ($x=$o->getObject('createtimestamp')) ? $x->render() : __('Unknown') }} [{{ ($x=$o->getObject('creatorsname')) ? $x->render() : __('Unknown') }}]
Modified{{ ($x=$o->getObject('modifytimestamp')) ? $x->render() : __('Unknown') }} [{{ ($x=$o->getObject('modifiersname')) ? $x->render() : __('Unknown') }}]
UUID{{ $o->entryuuid[0] ?? '' }}
-
+ @include('fragment.dn.header') @endsection @section('main-content') @@ -74,13 +51,7 @@
- - +
@endif diff --git a/resources/views/update.blade.php b/resources/views/update.blade.php index da62654..8da1ddc 100644 --- a/resources/views/update.blade.php +++ b/resources/views/update.blade.php @@ -1,36 +1,7 @@ @extends('home') @section('page_title') - - - - - - - - -
- {!! $x ? $x->render(FALSE,TRUE) : sprintf('
',$o->icon() ?? "fas fa-info") !!} -
{{ $dn }}
- - - - - - - - - - - - - -
Created - {{ ($x=$o->getObject('createtimestamp')) ? $x->render() : __('Unknown') }} [{{ ($x=$o->getObject('creatorsname')) ? $x->render() : __('Unknown') }}] -
Modified - {{ ($x=$o->getObject('modifytimestamp')) ? $x->render() : __('Unknown') }} [{{ ($x=$o->getObject('modifiersname')) ? $x->render() : __('Unknown') }}] -
UUID{{ $o->entryuuid[0] ?? '' }}
-
+ @include('fragment.dn.header') @endsection @section('main-content')