From 74bb0034403eee0f8e5f4caa158183d199449e8f Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 27 Apr 2025 22:08:38 +1000 Subject: [PATCH] Remove Components/AttributeType::class it wasnt providing any functionality --- app/Http/Controllers/HomeController.php | 13 +++--- app/View/Components/Attribute.php | 7 +--- app/View/Components/AttributeType.php | 40 ------------------- .../views/components/attribute-type.blade.php | 3 +- .../views/components/attribute.blade.php | 6 ++- .../components/attribute/layout.blade.php | 2 +- resources/views/fragment/dn/header.blade.php | 6 +-- 7 files changed, 19 insertions(+), 58 deletions(-) delete mode 100644 app/View/Components/AttributeType.php diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 681642a2..f4daf786 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -22,7 +22,6 @@ use App\Exceptions\Import\{GeneralException,VersionException}; use App\Exceptions\InvalidUsage; use App\Http\Requests\{EntryRequest,EntryAddRequest,ImportRequest}; use App\Ldap\Entry; -use App\View\Components\AttributeType; class HomeController extends Controller { @@ -90,15 +89,18 @@ class HomeController extends Controller $xx->index = 0; $dn = $request->dn ? Crypt::decrypt($request->dn) : ''; + $o = Factory::create(dn: $dn,attribute: $id,values: [],oc: $request->objectclasses); return $request->noheader ? view(sprintf('components.attribute.widget.%s',$id)) - ->with('o',Factory::create(dn: $dn,attribute: $id,values: [],oc: $request->objectclasses)) + ->with('o',$o) ->with('value',$request->value) ->with('langtag',Entry::TAG_NOTAG) ->with('loop',$xx) - : new AttributeType(Factory::create($dn,$id,[],$request->objectclasses),new: TRUE,edit: TRUE) - ->render(); + : view('components.attribute-type') + ->with('o',$o) + ->with('new',TRUE) + ->with('edit',TRUE); } public function entry_create(EntryAddRequest $request): \Illuminate\Http\RedirectResponse @@ -350,7 +352,8 @@ class HomeController extends Controller return Redirect::to('/') ->withInput() - ->with('updated',collect($dirty)->map(fn($item,$key)=>$o->getObject(collect(explode(';',$key))->first()))); + ->with('updated',collect($dirty) + ->map(fn($item,$key)=>$o->getObject(collect(explode(';',$key))->first()))); } /** diff --git a/app/View/Components/Attribute.php b/app/View/Components/Attribute.php index b94b6568..84dab452 100644 --- a/app/View/Components/Attribute.php +++ b/app/View/Components/Attribute.php @@ -2,7 +2,6 @@ namespace App\View\Components; -use Closure; use Illuminate\Contracts\View\View; use Illuminate\View\Component; @@ -16,19 +15,17 @@ class Attribute extends Component public bool $new; public bool $old; public string $langtag; - public ?string $na; // Text to render if the LDAPAttribute is null /** * Create a new component instance. */ - public function __construct(?LDAPAttribute $o,bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,string $langtag=Entry::TAG_NOTAG,?string $na=NULL) + public function __construct(?LDAPAttribute $o,bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,string $langtag=Entry::TAG_NOTAG) { $this->o = $o; $this->edit = $edit; $this->old = $old; $this->new = $new; $this->langtag = $langtag; - $this->na = $na; } /** @@ -41,6 +38,6 @@ class Attribute extends Component return $this->o ? $this->o ->render(edit: $this->edit,old: $this->old,new: $this->new) - : $this->na; + : __('Unknown'); } } \ No newline at end of file diff --git a/app/View/Components/AttributeType.php b/app/View/Components/AttributeType.php deleted file mode 100644 index 69bdfda4..00000000 --- a/app/View/Components/AttributeType.php +++ /dev/null @@ -1,40 +0,0 @@ -o = $o; - $this->new = $new; - $this->edit = $edit; - $this->langtag = $langtag; - } - - /** - * Get the view / contents that represent the component. - */ - public function render(): View - { - return view('components.attribute-type') - ->with('o',$this->o) - ->with('new',$this->new) - ->with('edit',$this->edit) - ->with('langtag',$this->langtag); - } -} \ 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 4a5c6f3c..75ad6b69 100644 --- a/resources/views/components/attribute-type.blade.php +++ b/resources/views/components/attribute-type.blade.php @@ -1,4 +1,3 @@ -
@@ -15,7 +14,7 @@
- + diff --git a/resources/views/components/attribute.blade.php b/resources/views/components/attribute.blade.php index 19a16d65..a18bec51 100644 --- a/resources/views/components/attribute.blade.php +++ b/resources/views/components/attribute.blade.php @@ -1,7 +1,9 @@ +@use(App\Ldap\Entry) + - +
- @foreach(Arr::get(old($o->name_lc,[$langtag=>$new ? [NULL] : $o->tagValues($langtag)]),$langtag,[]) as $key => $value) + @foreach(Arr::get(old($o->name_lc,[($langtag=($langtag ?? Entry::TAG_NOTAG))=>$new ? [NULL] : $o->tagValues($langtag)]),$langtag,[]) as $key => $value) @if($edit && (! $o->is_rdn))
($e=$errors->get($o->name_lc.'.'.$langtag.'.'.$loop->index)),'mb-1','border-focus'=>! ($tv=$o->tagValuesOld($langtag))->contains($value)]) name="{{ $o->name_lc }}[{{ $langtag }}][]" value="{{ $value }}" placeholder="{{ ! is_null($x=$tv->get($loop->index)) ? $x : '['.__('NEW').']' }}" @readonly(! $new) @disabled($o->isDynamic())> diff --git a/resources/views/components/attribute/layout.blade.php b/resources/views/components/attribute/layout.blade.php index be081785..99d5b436 100644 --- a/resources/views/components/attribute/layout.blade.php +++ b/resources/views/components/attribute/layout.blade.php @@ -1,5 +1,5 @@
-
(! $edit) && (! ($detail ?? false))])>
+
(! $edit) && (! ($detail ?? FALSE))])>
{{ $slot }} diff --git a/resources/views/fragment/dn/header.blade.php b/resources/views/fragment/dn/header.blade.php index 571c427f..39752a41 100644 --- a/resources/views/fragment/dn/header.blade.php +++ b/resources/views/fragment/dn/header.blade.php @@ -11,19 +11,19 @@ Created - [] + [] Modified - [] + [] UUID - + @if($langtags->count())