mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-04 08:54:33 +08:00
Started migrating tag manager JS to HTML-first component
This commit is contained in:
@ -66,6 +66,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include('components.tag-manager', ['entity' => \BookStack\Entities\Book::find(1), 'entityType' => 'book'])
|
||||
|
||||
|
||||
@stop
|
||||
|
25
resources/views/components/tag-manager-list.blade.php
Normal file
25
resources/views/components/tag-manager-list.blade.php
Normal 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
|
@ -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>
|
||||
|
Reference in New Issue
Block a user