Working JS Template Engine with basic functionality
This commit is contained in:
@@ -17,4 +17,9 @@
|
||||
@if(file_exists('js/custom.js'))
|
||||
<!-- Any Custom JS -->
|
||||
<script src="{{ asset('js/custom.js') }}"></script>
|
||||
@endif
|
||||
|
||||
@if(file_exists('js/template.js'))
|
||||
<!-- Template Engine JS -->
|
||||
<script src="{{ asset('js/template.js') }}"></script>
|
||||
@endif
|
@@ -6,7 +6,19 @@
|
||||
<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
|
||||
@if ($template?->onChangeTarget($o->name_lc))
|
||||
<sup data-bs-toggle="tooltip" title="@lang('Value calculated by template')"><i class="fas fa-wand-magic-sparkles"></i></sup>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
@if($o->hints->count())
|
||||
<sup>
|
||||
[
|
||||
@@ -47,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>
|
||||
|
||||
|
@@ -33,4 +33,16 @@
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</x-attribute.layout>
|
||||
</x-attribute.layout>
|
||||
|
||||
@if($new && ($x=$template?->onChange($o->name))?->count())
|
||||
@section('page-scripts')
|
||||
<!-- START: ONCHANGE PROCESSING {{ $o->name }} -->
|
||||
<script type="text/javascript">
|
||||
$('#{{ $o->name_lc }}').on('change',function() {
|
||||
{!! $x->join('') !!}
|
||||
});
|
||||
</script>
|
||||
<!-- END: ONCHANGE PROCESSING {{ $o->name }} -->
|
||||
@append
|
||||
@endif
|
@@ -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>
|
||||
|
@@ -63,10 +63,11 @@
|
||||
@break
|
||||
|
||||
@case(2)
|
||||
<x-attribute-type :o="$o->getObject('rdn')" :edit="TRUE" :new="FALSE" :updated="FALSE"/>
|
||||
<input type="hidden" name="_template" value="{{ $template?->file }}">
|
||||
<x-attribute-type :o="$o->getObject('rdn')" :edit="TRUE" :new="TRUE" :template="$template" :updated="FALSE"/>
|
||||
|
||||
@foreach($o->getVisibleAttributes() as $ao)
|
||||
<x-attribute-type :o="$ao" :edit="TRUE" :new="FALSE" :template="$template" :updated="FALSE"/>
|
||||
<x-attribute-type :o="$ao" :edit="TRUE" :new="TRUE" :template="$template" :updated="FALSE"/>
|
||||
@endforeach
|
||||
|
||||
@if(! $template)
|
||||
|
@@ -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" :updated="$up->contains($ao->name_lc)"/>
|
||||
<x-attribute-type :o="$ao" :edit="TRUE" :new="FALSE" :template="NULL" :updated="$up->contains($ao->name)"/>
|
||||
@endforeach
|
||||
|
||||
@include('fragment.dn.add_attr')
|
||||
@@ -124,7 +124,7 @@
|
||||
<!-- Internal Attributes -->
|
||||
<div class="tab-pane mt-3" id="internal" role="tabpanel">
|
||||
@foreach($o->getInternalAttributes() as $ao)
|
||||
<x-attribute-type :o="$ao" :edit="FALSE" :new="FALSE" :updated="FALSE"/>
|
||||
<x-attribute-type :o="$ao" :edit="FALSE" :new="FALSE" :template="$template ?? NULL" :updated="FALSE"/>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user