Compare commits
8 Commits
735b1c542f
...
d3c7bfcf79
Author | SHA1 | Date | |
---|---|---|---|
d3c7bfcf79 | |||
43c92e542c | |||
7352293880 | |||
bc4490a075 | |||
05b2651ef4 | |||
f6b7bff605 | |||
e8aaa17122 | |||
ee7762d69b |
@ -58,6 +58,34 @@ class Template
|
||||
return array_key_exists($key,$this->template);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the attribute has been marked as read-only
|
||||
*
|
||||
* @param string $attribute
|
||||
* @return bool
|
||||
*/
|
||||
public function attributeReadOnly(string $attribute): bool
|
||||
{
|
||||
return ($x=Arr::get($this->template,'attributes.'.$attribute.'.readonly')) && $x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the title we should use for an attribute
|
||||
*
|
||||
* @param string $attribute
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function attributeTitle(string $attribute): string|NULL
|
||||
{
|
||||
return Arr::get($this->template,'attributes.'.$attribute.'.display');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the onChange JavaScript for an attribute
|
||||
*
|
||||
* @param string $attribute
|
||||
* @return Collection|NULL
|
||||
*/
|
||||
public function onChange(string $attribute): Collection|NULL
|
||||
{
|
||||
if (! $this->on_change_processed)
|
||||
@ -82,6 +110,9 @@ class Template
|
||||
->has(strtolower($attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the attributes for onChange JavaScript
|
||||
*/
|
||||
/**
|
||||
* Return the onchange JavaScript for attribute
|
||||
*
|
||||
|
@ -6,8 +6,11 @@
|
||||
<div class="col-12 bg-light text-dark p-2 rounded-2">
|
||||
<span class="d-flex justify-content-between">
|
||||
<span style="width: 20em;">
|
||||
<strong class="align-middle"><abbr title="{{ $o->description }}">{{ $o->name }}</abbr></strong>
|
||||
<strong class="align-middle"><abbr title="{{ (($x=$template?->attributeTitle($o->name)) ? $o->name.': ' : '').$o->description }}">{{ $x ?: $o->name }}</abbr></strong>
|
||||
@if($new)
|
||||
@if($template?->attributeReadOnly($o->name_lc))
|
||||
<sup data-bs-toggle="tooltip" title="@lang('Input disabled by template')"><i class="fas fa-ban"></i></sup>
|
||||
@endif
|
||||
@if($template?->onChangeAttribute($o->name_lc))
|
||||
<sup data-bs-toggle="tooltip" title="@lang('Value triggers an update to another attribute by template')"><i class="fas fa-keyboard"></i></sup>
|
||||
@endif
|
||||
@ -56,7 +59,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<x-attribute :o="$o" :edit="$edit" :new="$new" :updated="$updated"/>
|
||||
<x-attribute :o="$o" :edit="(! $template?->attributeReadOnly($o->name)) && $edit" :new="$new" :updated="$updated"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -5,20 +5,19 @@
|
||||
@foreach($o->langtags as $langtag)
|
||||
<span @class(['tab-pane','active'=>$loop->index === 0]) id="langtag-{{ $o->name_lc }}-{{ $langtag }}" role="tabpanel">
|
||||
@foreach(Arr::get(old($o->name_lc,[$langtag=>$new ? [NULL] : $o->tagValues($langtag)]),$langtag,[]) as $key => $value)
|
||||
@if($edit && (! $o->is_rdn))
|
||||
<div class="input-group has-validation">
|
||||
<div class="input-group has-validation">
|
||||
@if($edit && (! $o->is_rdn))
|
||||
<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),'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())>
|
||||
@else
|
||||
<input type="text" @class(['form-control','noedit','is-invalid'=>($e=$errors->get($o->name_lc.'.'.$langtag.'.'.$loop->index)),'mb-1','bg-success-subtle'=>$updated]) name="{{ $o->name_lc }}[{{ $langtag }}][]" value="{{ $value }}" readonly>
|
||||
@endif
|
||||
|
||||
<div class="invalid-feedback pb-2">
|
||||
@if($e)
|
||||
{{ join('|',$e) }}
|
||||
@endif
|
||||
</div>
|
||||
<div class="invalid-feedback pb-2">
|
||||
@if($e)
|
||||
{{ join('|',$e) }}
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@else
|
||||
<input type="text" @class(['form-control','mb-1','bg-success-subtle'=>$updated]) value="{{ $value }}" disabled>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
</span>
|
||||
@endforeach
|
||||
|
@ -1,6 +1,5 @@
|
||||
<div class="row pt-2">
|
||||
<div @class(['col-1','d-none'=>(! $edit) && (! ($detail ?? FALSE))])></div>
|
||||
<div class="col-10">
|
||||
<div class="col-10 offset-1">
|
||||
<attribute id="{{ $o->name_lc }}">
|
||||
{{ $slot }}
|
||||
</attribute>
|
||||
|
@ -38,7 +38,7 @@
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<x-form.select id="newoc" name="newoc" :label="__('Select from').'...'"/>
|
||||
<x-form.select id="newoc" :label="__('Select from').'...'"/>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
|
@ -106,6 +106,10 @@
|
||||
if (rdn_attr && ($(this)[0].name === rdn_attr+'[]'))
|
||||
return;
|
||||
|
||||
// Exclude attributes marked as noedit
|
||||
if ($(this).hasClass('noedit'))
|
||||
return;
|
||||
|
||||
$(this).attr('readonly',false);
|
||||
});
|
||||
|
||||
|
@ -101,7 +101,7 @@
|
||||
<div class="tab-content">
|
||||
@php($up=(session()->pull('updated') ?: collect()))
|
||||
@foreach($o->getVisibleAttributes() as $ao)
|
||||
<x-attribute-type :o="$ao" :edit="TRUE" :new="FALSE" :template="$template ?? NULL" :updated="$up->contains($ao->name)"/>
|
||||
<x-attribute-type :o="$ao" :edit="TRUE" :new="FALSE" :template="NULL" :updated="$up->contains($ao->name)"/>
|
||||
@endforeach
|
||||
|
||||
@include('fragment.dn.add_attr')
|
||||
|
@ -51,8 +51,7 @@
|
||||
"order": 6
|
||||
},
|
||||
"gidNumber": {
|
||||
"display": "UID Number",
|
||||
"readonly": true,
|
||||
"display": "GID Number",
|
||||
"onchange": [
|
||||
"=autoFill(homeDirectory;/home/users/%gidNumber|0-0/T%/%uid|3-%)"
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user