Skip to content

Commit a7be4e0

Browse files
committed
Fix rendering new attributes, so that they dont render as dynamic. Fix adding new objectClasses to entries, need langtag to render the component
1 parent 2abc321 commit a7be4e0

File tree

6 files changed

+14
-9
lines changed

6 files changed

+14
-9
lines changed

app/Classes/LDAP/Attribute/ObjectClass.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Support\Collection;
77

88
use App\Classes\LDAP\Attribute;
9+
use App\Ldap\Entry;
910

1011
/**
1112
* Represents an ObjectClass Attribute
@@ -74,6 +75,7 @@ public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
7475
return view('components.attribute.objectclass')
7576
->with('o',$this)
7677
->with('edit',$edit)
78+
->with('langtag',Entry::TAG_NOTAG)
7779
->with('old',$old)
7880
->with('new',$new);
7981
}

app/Http/Controllers/APIController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ public function schema_view(Request $request)
9797
/**
9898
* Return the required and additional attributes for an object class
9999
*
100-
* @param Request $request
101100
* @param string $objectclass
102101
* @return array
103102
*/

app/Http/Controllers/HomeController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ public function entry_attr_add(Request $request,string $id): \Illuminate\View\Vi
9393

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

app/View/Components/Attribute.php

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

33
namespace App\View\Components;
44

5+
use Closure;
6+
use Illuminate\Contracts\View\View;
57
use Illuminate\View\Component;
68

79
use App\Classes\LDAP\Attribute as LDAPAttribute;
@@ -32,13 +34,13 @@ public function __construct(?LDAPAttribute $o,bool $edit=FALSE,bool $old=FALSE,b
3234
/**
3335
* Get the view / contents that represent the component.
3436
*
35-
* @return \Illuminate\Contracts\View\View|\Closure|string
37+
* @return View|string
3638
*/
37-
public function render()
39+
public function render(): View|string
3840
{
3941
return $this->o
4042
? $this->o
41-
->render($this->edit,$this->old,$this->new)
43+
->render(edit: $this->edit,old: $this->old,new: $this->new)
4244
: $this->na;
4345
}
4446
}

app/View/Components/AttributeType.php

Lines changed: 1 addition & 2 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

@@ -30,7 +29,7 @@ public function __construct(LDAPAttribute $o,bool $new=FALSE,bool $edit=FALSE,st
3029
/**
3130
* Get the view / contents that represent the component.
3231
*/
33-
public function render(): View|Closure|string
32+
public function render(): View
3433
{
3534
return view('components.attribute-type')
3635
->with('o',$this->o)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ function process_oc() {
4646
if (added_oc.indexOf(item) !== -1)
4747
return;
4848
49+
// Add our new OC to the list of OCs
50+
oc.push(item);
51+
4952
// Add attribute to the page
5053
$.ajax({
5154
method: 'POST',
@@ -146,7 +149,7 @@ function process_oc() {
146149
if (x.length) {
147150
x.remove();
148151
149-
// Add this to the must attrs list, because its been rendered
152+
// Add this to the must attrs list, because its been rendered
150153
} else {
151154
attrs.push(mayitem);
152155
}

0 commit comments

Comments
 (0)