Skip to content

Commit

Permalink
Users can now Tag Tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
spitfire305 committed Sep 5, 2024
1 parent 40cc39e commit 34e9c3d
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/Datagrids/Bulks/TagBulk.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class TagBulk extends Bulk
'private_choice',
'auto_applied_choice',
'hide_choice',
'tags',
'entity_image',
'entity_header',
];
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Search/LiveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ public function tagChildren(Request $request, Campaign $campaign)
$term = trim($request->get('q', ''));

$exclude = [];
if ($request->has('exclude')) {
if ($request->has('exclude-entity')) {
/** @var Tag $tag */
$tag = Tag::findOrFail($request->get('exclude'));
$tag = Tag::findOrFail($request->get('exclude-entity'));
$exclude = $tag->entities->pluck('id')->toArray();
$exclude[] = $tag->entity->id;
}

return response()->json(
$this->search
->term($term)
->campaign($campaign)
->exclude([config('entities.ids.tag')])
->excludeIds($exclude)
->find()
);
Expand Down
1 change: 1 addition & 0 deletions resources/api-docs/1.0/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ To create a tag, use the following endpoint.
| `type` | `string` | The tag's type |
| `colour` | `string` | The tag's colour |
| `tag_id` | `integer` | The parent tag |
| `tags` | `array` | Array of tag ids |
| `entity_image_uuid` | `string` | Gallery image UUID for the entity image |
| `entity_header_uuid` | `string` | Gallery image UUID for the entity header (limited to premium campaigns) |
| `is_private` | `boolean` | If the tag is only visible to `admin` members of the campaign |
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/forms/tags.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<select multiple="multiple" name="tags[]" id="{{ $id }}"
class="form-tags"
style="width: 100%"
data-url="{{ route('tags.find', $campaign) }}"
data-url="{{ $model instanceof App\Models\Tag ? route('tags.find', [$campaign, 'exclude' => $model->id] ) : route('tags.find', $campaign) }}"
data-allow-new="{{ $allowNew ? 'true' : 'false' }}"
data-placeholder="{{ __('crud.placeholders.multiple') }}"
@if ($allowClear) data-allow-clear="true" @endif
Expand Down
2 changes: 0 additions & 2 deletions resources/views/entities/components/header.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,11 @@
</a>
@endforeach
@endif
@if(!($model instanceof \App\Models\Tag))
@can('update', $model)
<span role="button" tabindex="0" class="entity-tag-icon text-xl" data-toggle="dialog" data-url="{{ $addTagsUrl }}" data-target="primary-dialog" aria-haspopup="dialog">
<x-icon class="fa-solid fa-tag" tooltip="1" :title="__('Add or remove tags')" />
</span>
@endcan
@endif
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion resources/views/entities/creator/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class="w-full"
@php $allowNew = false; $dropdownParent = '#primary-dialog';@endphp
@include('entities.creator.forms.' . $singularType)

@if (!in_array($type, ['tags', 'posts', 'attribute_templates']))
@if (!in_array($type, ['posts', 'attribute_templates']))
<div id="quick-creator-tags-field">
@include('cruds.fields.tags', ['dropdownParent' => '#quick-creator-tags-field'])
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/tags/entities/_form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
name="entities[]"
id="entities[]"
:campaign="$campaign"
:route="route('search.tag-children', [$campaign, 'exclude-entity' => true])"
:route="route('search.tag-children', [$campaign, 'exclude-entity' => $model->id])"
>
</x-forms.foreign>
</x-grid>
Expand Down
2 changes: 2 additions & 0 deletions resources/views/tags/form/_entry.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<input type="checkbox" name="is_hidden" value="1" @if (old('is_hidden', $model->is_hidden ?? false)) checked="checked" @endif />
</x-checkbox>
</x-forms.field>

@include('cruds.fields.tags')
@include('cruds.fields.image')

</x-grid>

0 comments on commit 34e9c3d

Please sign in to comment.