File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
resources/views/components Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ {{-- components.editable
2+
3+ Render an editable input field
4+
5+ --}}
6+
7+ <div
8+ x-data =" {
9+ field: '{{ $field } } ',
10+ id: {{ $model -> id } } ,
11+ value: {{ json_encode ($model -> $field ) } } ,
12+ original: {{ json_encode ($model -> $field ) } } ,
13+ editing: false
14+ }"
15+ @click .away =" editing = false; value = original;"
16+ >
17+ <input
18+ x-cloak
19+ x-ref =" input"
20+ x-show =" editing"
21+ x-model =" value"
22+ @keydown .enter ="
23+ $wire.update({
24+ id: id,
25+ value: value,
26+ field: field
27+ }); editing = false;"
28+ @keydown .escape =" editing = false; value = original;"
29+ class =" bg-green-100 text-black-700 border border-green-200 rounded py-2 px-4 leading-tight outline-none w-full"
30+ >
31+ <div
32+ x-show =" !editing"
33+ @click =" editing = true; $nextTick(() => {$refs.input.focus();$refs.input.setSelectionRange(-1, -1);});"
34+ x-html =" value"
35+ class =' transition-all duration-300 ease-in-out inline-block cursor-pointer border-b-2 border-dotted border-gray-400 hover:bg-gray-100 p-1' >
36+ {!! $model -> $field ! !}
37+ </div >
38+
39+ </div >
Original file line number Diff line number Diff line change 66
77class UI
88{
9+ public function editable ($ model , $ field )
10+ {
11+ return view ('laravel-views::components.editable ' , [
12+ 'model ' => $ model ,
13+ 'field ' => $ field
14+ ])->render ();
15+ }
16+
917 public function badge ($ title , $ type = 'default ' )
1018 {
1119 return $ this ->component ('laravel-views::components.badge ' , [
You can’t perform that action at this time.
0 commit comments