Skip to content

Commit

Permalink
Merge pull request #44 from art-institute-of-chicago/drift/directory-…
Browse files Browse the repository at this point in the history
…context

Include additional on/off view context on Directory
  • Loading branch information
nikhiltri authored May 21, 2024
2 parents 05b0a27 + 40cdb94 commit e92087d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
28 changes: 28 additions & 0 deletions app/Models/Artwork.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Libraries\Api\Builders\ApiQueryBuilder;
use Exception;
use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
Expand Down Expand Up @@ -164,6 +165,33 @@ public function scopeOffView(Builder $query): void
$query->where('is_on_view', false);
}

protected function onJourneyMaker(): Attribute
{
return Attribute::make(
get: fn () => $this->is_on_view
&& $this->gallery_id != 2147475902
&& $this->published
&& $this->translations->reject(fn ($translation) => $translation->active)->isEmpty()
&& $this->themePrompts->reject(fn ($prompt) => $prompt->on_journey_maker)->isEmpty(),
);
}

protected function offJourneyMakerReasons(): Attribute
{
return Attribute::make(
get: fn () => collect([
'Off View' => ! $this->is_on_view,
'Unpublished' => ! $this->published,
'Missing Translations' => $this->translations->reject(fn ($translation) => $translation->active)->isNotEmpty(),
'In Regenstein Hall' => $this->gallery_id == 2147475902,
'Not Included in Visible Prompt' => $this->themePrompts->reject(fn ($prompt) => $prompt->on_journey_maker)->isNotEmpty(),
])
->filter(fn ($reason) => $reason)
->keys()
->join(', '),
);
}

public function defaultCmsImage($params = [])
{
// If requesting a thumbnail, return the thumbnail image
Expand Down
11 changes: 11 additions & 0 deletions app/Models/ThemePrompt.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use A17\Twill\Models\Behaviors\Sortable;
use A17\Twill\Models\Model;
use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class ThemePrompt extends Model implements Sortable
Expand Down Expand Up @@ -50,4 +51,14 @@ public function scopeActive(Builder $query): void
->published()
->whereDoesntHave('translations', fn (Builder $query) => $query->where('active', false));
}

protected function onJourneyMaker(): Attribute
{
return Attribute::make(
get: fn () => $this->published
&& $this->translations->reject(fn ($translation) => $translation->active)->isEmpty()
&& $this->theme->published
&& $this->theme->translations->reject(fn ($translation) => $translation->active)->isEmpty(),
);
}
}
5 changes: 3 additions & 2 deletions resources/views/admin/directory.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
<br><small class="text-xs text-gray-400">{{ $artwork->artwork->artist }}</small>
</a>
</td>
<td class="px-3 py-4 text-sm" title="{{ $artwork->artwork->is_on_view? 'On View' : 'Off View' }}">
{{ $artwork->artwork->is_on_view? '' : '' }}
<td class="px-3 py-4 text-sm" title="{{ $artwork->artwork->on_journey_maker? 'On JourneyMaker' : 'Not On JourneyMaker' }}">
{{ $artwork->artwork->on_journey_maker? '' : '' }}
{{ $artwork->artwork->off_journey_maker_reasons }}
</td>
</tr>
@endforeach
Expand Down

0 comments on commit e92087d

Please sign in to comment.