Started migrating tag manager JS to HTML-first component

This commit is contained in:
Dan Brown
2020-06-28 23:15:05 +01:00
parent 10305a4446
commit 4e107b9160
8 changed files with 201 additions and 16 deletions

View File

@ -66,6 +66,7 @@
</div>
</div>
@include('components.tag-manager', ['entity' => \BookStack\Entities\Book::find(1), 'entityType' => 'book'])
@stop

View File

@ -0,0 +1,25 @@
@foreach(array_merge($tags, [new \BookStack\Actions\Tag]) as $index => $tag)
<div class="card drag-card">
<div class="handle">@icon('grip')</div>
@foreach(['name', 'value'] as $type)
<div component="auto-suggest"
option:auto-suggest:url="{{ url('/ajax/tags/suggest/' . $type . 's') }}"
option:auto-suggest:type="{{ $type }}"
class="outline">
<input value="{{ $tag->$type ?? '' }}"
placeholder="{{ trans('entities.tag_' . $type) }}"
aria-label="{{ trans('entities.tag_' . $type) }}"
name="tags[{{ $index }}][{{ $type }}]"
type="text"
refs="auto-suggest@input"
autocomplete="off"/>
<ul refs="auto-suggest@list" class="suggestion-box dropdown-menu"></ul>
</div>
@endforeach
<button refs="tag-manager@remove" type="button"
aria-label="{{ trans('entities.tags_remove') }}"
class="text-center drag-card-action text-neg {{ count($tags) > 0 ? '' : 'hidden' }}">
@icon('close')
</button>
</div>
@endforeach

View File

@ -1,7 +1,9 @@
<div id="tag-manager" entity-id="{{ isset($entity) ? $entity->id : 0 }}" entity-type="{{ $entity ? $entity->getType() : $entityType }}">
<div id="tag-manager" entity-id="{{ $entity->id ?? 0 }}" entity-type="{{ $entity ? $entity->getType() : $entityType }}">
<div class="tags">
<p class="text-muted small">{!! nl2br(e(trans('entities.tags_explain'))) !!}</p>
@include('components.tag-manager-list', ['tags' => $entity->tags->all() ?? []])
<draggable :options="{handle: '.handle'}" :list="tags" element="div">
<div v-for="(tag, i) in tags" :key="tag.key" class="card drag-card">
<div class="handle" >@icon('grip')</div>