Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users can now Tag Tags. #964

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Console/Commands/Migrations/MigrateTutorials.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function handle()
$tutorial->code = mb_substr($key, 9);
$tutorial->save();
unset($settings[$key]);
} elseif(str_starts_with($key, 'releases_')) {
} elseif (str_starts_with($key, 'releases_')) {
$tutorial = new Tutorial();
$tutorial->user_id = $user->id;
$tutorial->code = $key . '_' . $setting;
Expand Down
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
2 changes: 0 additions & 2 deletions app/Http/Controllers/Entity/Attributes/LiveApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
use App\Http\Controllers\Controller;
use App\Http\Requests\StoreAttribute;
use App\Http\Requests\UpdateAttribute;
use App\Http\Requests\UpdateEntityAttribute;
use App\Http\Resources\Attributes\LiveAttributeResource;
use App\Models\Attribute;
use App\Models\Campaign;
use App\Models\Entity;
use App\Services\Attributes\ApiService;
use App\Traits\GuestAuthTrait;

class LiveApiController extends Controller
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: 0 additions & 1 deletion app/Http/Middleware/ApiLogMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Http\Middleware;

use App\Facades\ApiLog;

use Closure;

class ApiLogMiddleware
Expand Down
1 change: 0 additions & 1 deletion app/Http/Middleware/OTPMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Http\Middleware;

use App\Models\Google2FAAuthentication;

use Closure;
use App\Facades\Identity;

Expand Down
2 changes: 0 additions & 2 deletions app/Http/Resources/Attributes/LiveAttributeResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace App\Http\Resources\Attributes;

use App\Models\Attribute;
use App\Traits\CampaignAware;
use App\Traits\EntityAware;
use Illuminate\Http\Resources\Json\JsonResource;

class LiveAttributeResource extends JsonResource
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Resources/GalleryFileFull.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public function toArray(Request $request): array
$file = $this->resource;

$mentions = [];
foreach($file->inEntities() as $entity) {
foreach ($file->inEntities() as $entity) {
$mentions[] = [
'url' => $entity->url(),
'name' => $entity->name,
'type' => 'image',
];
}
foreach ($file->mentions as $mention) {
if($mention->isPost()) {
if ($mention->isPost()) {
$mentions[] = [
'url' => $mention->entity->url() . '?#post-' . $mention->post_id,
'name' => $mention->post->name,
Expand Down
2 changes: 1 addition & 1 deletion app/Renderers/DatagridRenderer2.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public function isHighlighted(mixed $row): bool
public function rowAttributes(mixed $row): string
{
$attributes = [];
foreach($row->rowAttributes() as $attr => $val) {
foreach ($row->rowAttributes() as $attr => $val) {
if ($val instanceof UnitEnum) {
// @phpstan-ignore-next-line
$val = $val->value;
Expand Down
2 changes: 1 addition & 1 deletion app/Services/BulkService.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public function editing(array $fields, Bulk $bulk): int
}
$entityFields = $filledFields;

if(isset($entityFields[$parent]) && intval($entityFields[$parent]) == $entity->id) {
if (isset($entityFields[$parent]) && intval($entityFields[$parent]) == $entity->id) {
unset($entityFields[$parent]);
}

Expand Down
1 change: 0 additions & 1 deletion app/Services/EntityMappingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use App\Models\Post;
use App\Models\QuestElement;
use App\Models\TimelineElement;

use App\Traits\MentionTrait;
use Exception;
use Illuminate\Database\Eloquent\Model;
Expand Down
8 changes: 4 additions & 4 deletions app/View/Components/Ad.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ protected function hasAd(): bool
return false;
}
// Parameter to force ads to be displayed
if (request()->has('_showads')) {
return true;
}
return (bool) (request()->has('_showads'))


// Temp workaround for venatus to fix their ads
return false;
;
if (isset($this->user)) {
// Subscribed users don't have ads
if ($this->user->isSubscriber()) {
Expand Down
2 changes: 1 addition & 1 deletion app/View/Components/Cta.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(
public bool $superboost = false,
public bool $premium = false,
public bool $minimal = false,
public bool $max = false,
public bool $max = false,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion app/View/Components/Dialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(
public array $form = [],
public bool $full = false,
public bool $loading = false,
public bool $dismissible = true,
public bool $dismissible = true,
) {
if (empty($this->id)) {
$this->id = uniqid();
Expand Down
1 change: 0 additions & 1 deletion database/factories/CharacterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Database\Factories;

//use Faker\Generator as Faker;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Factories\Factory;
use App\Models\Character;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CreateRealVisibilitiesTable extends Migration
*/
public function up()
{
if(Schema::hasTable('visibilities')) {
if (Schema::hasTable('visibilities')) {
return;
}
Schema::create('visibilities', function (Blueprint $table) {
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>