Skip to content

Commit

Permalink
feat(search): add search ML by elements on elements page
Browse files Browse the repository at this point in the history
  • Loading branch information
ScuffedNewt committed Sep 16, 2024
1 parent 8798a09 commit 120766c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
9 changes: 9 additions & 0 deletions app/Models/Element/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ public function getIdUrlAttribute() {
return url('world/elements/'.$this->id);
}

/**
* Search the masterlist for this element.
*
* @return string
*/
public function getSearchUrlAttribute() {
return url('masterlist?element_ids[]='.$this->id);
}

/**
* Gets the admin edit URL.
*
Expand Down
8 changes: 7 additions & 1 deletion resources/views/admin/elements/create_edit_element.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,13 @@
<h3>Preview</h3>
<div class="card mb-3">
<div class="card-body">
@include('world._element_entry', ['imageUrl' => $element->imageUrl, 'name' => $element->displayName, 'description' => $element->parsed_description, 'searchUrl' => $element->searchUrl])
@include('world._element_entry', [
'imageUrl' => $element->imageUrl,
'name' => $element->displayName,
'description' => $element->parsed_description,
'idUrl' => $element->idUrl,
'searchUrl' => $element->searchUrl,
])
</div>
</div>
@endif
Expand Down
5 changes: 5 additions & 0 deletions resources/views/world/_element_entry.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
<i class="fas fa-search"></i>
</a>
@endif
@if (isset($searchUrl) && $searchUrl)
<a href="{{ $searchUrl }}" class="world-entry-search text-muted">
<i class="fas fa-list"></i>
</a>
@endif
</h3>
<div class="world-entry-text">
{!! $description !!}
Expand Down
8 changes: 7 additions & 1 deletion resources/views/world/elements.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@
@foreach ($elements as $element)
<div class="card mb-3">
<div class="card-body">
@include('world._element_entry', ['imageUrl' => $element->imageUrl, 'name' => $element->displayName, 'description' => $element->parsed_description, 'idUrl' => $element->idUrl])
@include('world._element_entry', [
'imageUrl' => $element->imageUrl,
'name' => $element->displayName,
'description' => $element->parsed_description,
'idUrl' => $element->idUrl,
'searchUrl' => $element->searchUrl,
])
</div>
</div>
@endforeach
Expand Down

0 comments on commit 120766c

Please sign in to comment.