Skip to content

Commit bab5a26

Browse files
committed
Remove Components/AttributeType::class it wasnt providing any functionality
1 parent 6954b09 commit bab5a26

File tree

7 files changed

+19
-58
lines changed

7 files changed

+19
-58
lines changed

app/Http/Controllers/HomeController.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use App\Exceptions\InvalidUsage;
2323
use App\Http\Requests\{EntryRequest,EntryAddRequest,ImportRequest};
2424
use App\Ldap\Entry;
25-
use App\View\Components\AttributeType;
2625

2726
class HomeController extends Controller
2827
{
@@ -90,15 +89,18 @@ public function entry_attr_add(Request $request,string $id): \Illuminate\View\Vi
9089
$xx->index = 0;
9190

9291
$dn = $request->dn ? Crypt::decrypt($request->dn) : '';
92+
$o = Factory::create(dn: $dn,attribute: $id,values: [],oc: $request->objectclasses);
9393

9494
return $request->noheader
9595
? view(sprintf('components.attribute.widget.%s',$id))
96-
->with('o',Factory::create(dn: $dn,attribute: $id,values: [],oc: $request->objectclasses))
96+
->with('o',$o)
9797
->with('value',$request->value)
9898
->with('langtag',Entry::TAG_NOTAG)
9999
->with('loop',$xx)
100-
: new AttributeType(Factory::create($dn,$id,[],$request->objectclasses),new: TRUE,edit: TRUE)
101-
->render();
100+
: view('components.attribute-type')
101+
->with('o',$o)
102+
->with('new',TRUE)
103+
->with('edit',TRUE);
102104
}
103105

104106
public function entry_create(EntryAddRequest $request): \Illuminate\Http\RedirectResponse
@@ -350,7 +352,8 @@ public function entry_update(EntryRequest $request): \Illuminate\Http\RedirectRe
350352

351353
return Redirect::to('/')
352354
->withInput()
353-
->with('updated',collect($dirty)->map(fn($item,$key)=>$o->getObject(collect(explode(';',$key))->first())));
355+
->with('updated',collect($dirty)
356+
->map(fn($item,$key)=>$o->getObject(collect(explode(';',$key))->first())));
354357
}
355358

356359
/**

app/View/Components/Attribute.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace App\View\Components;
44

5-
use Closure;
65
use Illuminate\Contracts\View\View;
76
use Illuminate\View\Component;
87

@@ -16,19 +15,17 @@ class Attribute extends Component
1615
public bool $new;
1716
public bool $old;
1817
public string $langtag;
19-
public ?string $na; // Text to render if the LDAPAttribute is null
2018

2119
/**
2220
* Create a new component instance.
2321
*/
24-
public function __construct(?LDAPAttribute $o,bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,string $langtag=Entry::TAG_NOTAG,?string $na=NULL)
22+
public function __construct(?LDAPAttribute $o,bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE,string $langtag=Entry::TAG_NOTAG)
2523
{
2624
$this->o = $o;
2725
$this->edit = $edit;
2826
$this->old = $old;
2927
$this->new = $new;
3028
$this->langtag = $langtag;
31-
$this->na = $na;
3229
}
3330

3431
/**
@@ -41,6 +38,6 @@ public function render(): View|string
4138
return $this->o
4239
? $this->o
4340
->render(edit: $this->edit,old: $this->old,new: $this->new)
44-
: $this->na;
41+
: __('Unknown');
4542
}
4643
}

app/View/Components/AttributeType.php

Lines changed: 0 additions & 40 deletions
This file was deleted.

resources/views/components/attribute-type.blade.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<!-- $o=AttributeType::class -->
21
<div class="row pb-3">
32
<div class="col-12 col-sm-1 col-md-2"></div>
43
<div class="col-12 col-sm-10 col-md-8">
@@ -15,7 +14,7 @@
1514
</div>
1615
</div>
1716

18-
<x-attribute :o="$o" :edit="$edit" :new="$new" :langtag="$langtag"/>
17+
<x-attribute :o="$o" :edit="$edit ?? FALSE" :new="$new ?? FALSE" :langtag="$langtag ?? \App\Ldap\Entry::TAG_NOTAG"/>
1918
</div>
2019
</div>
2120

resources/views/components/attribute.blade.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
@use(App\Ldap\Entry)
2+
13
<!-- $o=Attribute::class -->
2-
<x-attribute.layout :edit="$edit" :new="$new" :o="$o">
4+
<x-attribute.layout :edit="$edit=($edit ?? FALSE)" :new="$new=($new ?? FALSE)" :o="$o">
35
<div class="col-12">
4-
@foreach(Arr::get(old($o->name_lc,[$langtag=>$new ? [NULL] : $o->tagValues($langtag)]),$langtag,[]) as $key => $value)
6+
@foreach(Arr::get(old($o->name_lc,[($langtag=($langtag ?? Entry::TAG_NOTAG))=>$new ? [NULL] : $o->tagValues($langtag)]),$langtag,[]) as $key => $value)
57
@if($edit && (! $o->is_rdn))
68
<div class="input-group has-validation">
79
<input type="text" @class(['form-control','is-invalid'=>($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())>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="row pt-2">
2-
<div @class(['col-1','d-none'=>(! $edit) && (! ($detail ?? false))])></div>
2+
<div @class(['col-1','d-none'=>(! $edit) && (! ($detail ?? FALSE))])></div>
33
<div class="col-10">
44
<attribute id="{{ $o->name }}">
55
{{ $slot }}

resources/views/fragment/dn/header.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
<tr class="mt-1">
1212
<td class="p-0 pe-2">Created</td>
1313
<th class="p-0">
14-
<x-attribute :o="$o->getObject('createtimestamp')" :na="__('Unknown')"/> [<x-attribute :o="$o->getObject('creatorsname')" :na="__('Unknown')"/>]
14+
<x-attribute :o="$o->getObject('createtimestamp')"/> [<x-attribute :o="$o->getObject('creatorsname')"/>]
1515
</th>
1616
</tr>
1717
<tr class="mt-1">
1818
<td class="p-0 pe-2">Modified</td>
1919
<th class="p-0">
20-
<x-attribute :o="$o->getObject('modifytimestamp')" :na="__('Unknown')"/> [<x-attribute :o="$o->getObject('modifiersname')" :na="__('Unknown')"/>]
20+
<x-attribute :o="$o->getObject('modifytimestamp')"/> [<x-attribute :o="$o->getObject('modifiersname')"/>]
2121
</th>
2222
</tr>
2323
<tr class="mt-1">
2424
<td class="p-0 pe-2">UUID</td>
2525
<th class="p-0">
26-
<x-attribute :o="$o->getObject('entryuuid')" :na="__('Unknown')"/>
26+
<x-attribute :o="$o->getObject('entryuuid')""/>
2727
</th>
2828
</tr>
2929
@if($langtags->count())

0 commit comments

Comments
 (0)