From 75dbb37d8b49e1062b616637381198b823dc122d Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 3 May 2025 23:15:29 +1000 Subject: [PATCH] $langtag doesnt need to be passed to x-attribute.layout. Fix adding new userpassword. Only show Add Value when the Attribute has atleast 1 old value --- app/Classes/LDAP/Attribute/Password.php | 1 + resources/views/components/attribute.blade.php | 2 +- .../views/components/attribute/binary/jpegphoto.blade.php | 2 +- .../views/components/attribute/krbprincipalkey.blade.php | 4 ++-- .../views/components/attribute/objectclass.blade.php | 2 +- resources/views/components/attribute/password.blade.php | 8 ++++---- .../views/components/attribute/widget/options.blade.php | 4 +++- resources/views/components/syntax/certificate.blade.php | 2 +- .../views/components/syntax/certificatelist.blade.php | 2 +- 9 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/Classes/LDAP/Attribute/Password.php b/app/Classes/LDAP/Attribute/Password.php index e84e47c8..964a5e8b 100644 --- a/app/Classes/LDAP/Attribute/Password.php +++ b/app/Classes/LDAP/Attribute/Password.php @@ -18,6 +18,7 @@ final class Password extends Attribute use MD5Updates; protected(set) bool $no_attr_tags = TRUE; + protected(set) int $max_values_count = 1; private const password_helpers = 'Classes/LDAP/Attribute/Password'; public const commands = 'App\\Classes\\LDAP\\Attribute\\Password\\'; diff --git a/resources/views/components/attribute.blade.php b/resources/views/components/attribute.blade.php index 2bfa9b9f..7f069fa1 100644 --- a/resources/views/components/attribute.blade.php +++ b/resources/views/components/attribute.blade.php @@ -3,7 +3,7 @@
- @foreach(Arr::get(old($o->name_lc,[($langtag=($langtag ?? Entry::TAG_NOTAG))=>$new ? [NULL] : $o->tagValues($langtag)]),$langtag,[]) as $key => $value) + @foreach(Arr::get(old($o->name_lc,[$langtag=>$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),'bg-success-subtle'=>$updated]) 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/binary/jpegphoto.blade.php b/resources/views/components/attribute/binary/jpegphoto.blade.php index 33c129af..1f73b222 100644 --- a/resources/views/components/attribute/binary/jpegphoto.blade.php +++ b/resources/views/components/attribute/binary/jpegphoto.blade.php @@ -1,6 +1,6 @@ - + @foreach($o->tagValuesOld() as $key => $value) diff --git a/resources/views/components/attribute/krbprincipalkey.blade.php b/resources/views/components/attribute/krbprincipalkey.blade.php index 5e67eae9..0e7a72f6 100644 --- a/resources/views/components/attribute/krbprincipalkey.blade.php +++ b/resources/views/components/attribute/krbprincipalkey.blade.php @@ -1,10 +1,10 @@ - + @foreach($o->tagValuesOld($langtag) as $key => $value) @if($edit)
- ($e=$errors->get($o->name_lc.'.'.$langtag.'.'.$loop->index)),'mb-1','border-focus'=>! $o->tagValuesOld($langtag)->contains($value),'bg-success-subtle'=>$updated]) name="{{ $o->name_lc }}[{{ $langtag }}][]" value="{{ md5($value) }}" @readonly(true)> + ($e=$errors->get($o->name_lc.'.'.$langtag.'.'.$loop->index)),'mb-1','border-focus'=>! $o->tagValuesOld($langtag)->contains($value),'bg-success-subtle'=>$updated]) name="{{ $o->name_lc }}[{{ $langtag }}][]" value="{{ md5($value) }}" @readonly(! $new)>
@if($e) diff --git a/resources/views/components/attribute/objectclass.blade.php b/resources/views/components/attribute/objectclass.blade.php index f40b88e5..c9a9b133 100644 --- a/resources/views/components/attribute/objectclass.blade.php +++ b/resources/views/components/attribute/objectclass.blade.php @@ -1,5 +1,5 @@ - + @foreach(Arr::get(old($o->name_lc,[$langtag=>$new ? [NULL] : $o->tagValues($langtag)]),$langtag,[]) as $key => $value) @if($edit) diff --git a/resources/views/components/attribute/password.blade.php b/resources/views/components/attribute/password.blade.php index 900b3527..113d8e9d 100644 --- a/resources/views/components/attribute/password.blade.php +++ b/resources/views/components/attribute/password.blade.php @@ -1,11 +1,11 @@ - - @foreach($o->tagValuesOld($langtag) as $key => $value) + + @foreach(Arr::get(old($o->name_lc,[$langtag=>$new ? [NULL] : $o->tagValues($langtag)]),$langtag,[]) as $key => $value) @if($edit)
- - ($e=$errors->get($o->name_lc.'.'.$langtag.'.'.$loop->index)),'mb-1','border-focus'=>! $o->tagValuesOld($langtag)->contains($value),'bg-success-subtle'=>$updated]) name="{{ $o->name_lc }}[{{ $langtag }}][]" value="{{ md5($value) }}" @readonly(true)> + + ($e=$errors->get($o->name_lc.'.'.$langtag.'.'.$loop->index)),'mb-1','border-focus'=>! $o->tagValuesOld($langtag)->contains($value),'bg-success-subtle'=>$updated]) name="{{ $o->name_lc }}[{{ $langtag }}][]" value="{{ md5($value) }}" @readonly(! $new)>
@if($e) diff --git a/resources/views/components/attribute/widget/options.blade.php b/resources/views/components/attribute/widget/options.blade.php index 62ec946e..345e4587 100644 --- a/resources/views/components/attribute/widget/options.blade.php +++ b/resources/views/components/attribute/widget/options.blade.php @@ -255,7 +255,9 @@ @default @if($o->isDynamic()) @break @endif @php($clone=TRUE) - (! $new)]) id="{{ $o->name }}-addnew"> @lang('Add Value') + @if($o->values_old->count()) + (! $new)]) id="{{ $o->name }}-addnew"> @lang('Add Value') + @endif @section('page-scripts') @if($clone && $edit && $o->can_addvalues) diff --git a/resources/views/components/syntax/certificate.blade.php b/resources/views/components/syntax/certificate.blade.php index a8ec4155..ae9257de 100644 --- a/resources/views/components/syntax/certificate.blade.php +++ b/resources/views/components/syntax/certificate.blade.php @@ -1,7 +1,7 @@ @use(App\Classes\LDAP\Attribute\Certificate) - + @foreach($o->tagValuesOld('binary') as $key => $value) @if(($o instanceof Certificate) && $edit) diff --git a/resources/views/components/syntax/certificatelist.blade.php b/resources/views/components/syntax/certificatelist.blade.php index 11686ca9..994d944f 100644 --- a/resources/views/components/syntax/certificatelist.blade.php +++ b/resources/views/components/syntax/certificatelist.blade.php @@ -1,5 +1,5 @@ - + @foreach($o->tagValuesOld('binary') as $key => $value)
{{ $o->render_item_old('binary.'.$key) }}