Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 16 additions & 0 deletions app/Models/Feature/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ public function parent()
return $this->belongsTo('App\Models\Feature\Feature', 'parent_id');
}

/**
* Get the parent of this feature, if present and visible.
*/
public function parentVisible()
{
return $this->belongsTo('App\Models\Feature\Feature', 'parent_id')->where('is_visible', 1);
Comment thread
SpeedyD marked this conversation as resolved.
Outdated
}

/**
* Get alternate types of this feature.
*/
Expand All @@ -112,6 +120,14 @@ public function altTypes()
return $this->hasMany('App\Models\Feature\Feature', 'parent_id');
}

/**
* Get alternate types of this feature, but only those visible.
*/
public function altTypesVisible()
{
return $this->hasMany('App\Models\Feature\Feature', 'parent_id')->where('is_visible', 1);
Comment thread
SpeedyD marked this conversation as resolved.
Outdated
}

/**********************************************************************************************

SCOPES
Expand Down
1 change: 1 addition & 0 deletions app/Services/FeatureService.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ public function updateFeature($feature, $data, $user, $parent = null)
'display_separate' => $alt ? (isset($data['alt']['display_separate'][$key]) ? 1 : 0) : 1,
'image' => isset($data['alt']['image'][$key]) ? $data['alt']['image'][$key] : null,
'remove_image' => $alt ? (isset($data['alt']['remove_image'][$key]) ? 1 : 0) : 0,
'is_visible' => $alt ? (isset($data['alt']['is_visible'][$key]) ? 1 : 0) : 0,
];

// If the ID is already set, modify the existing feature
Expand Down
4 changes: 4 additions & 0 deletions resources/views/admin/features/create_edit_feature.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@
{!! Form::checkbox('alt[display_separate]['.$altType->id.']', 1, $altType->display_separate, ['class' => 'form-check-input', 'data-toggle' => 'toggle']) !!}
{!! Form::label('alt[display_separate]', 'Display Separately', ['class' => 'form-check-label ml-3']) !!} {!! add_help('If enabled, this trait will be displayed separately from its parent in general trait listings, including species\' visual trait indexes if enabled.') !!}
</div>
<div class="form-group">
{!! Form::checkbox('alt[is_visible]['.$altType->id.']', 1, $altType->id ? $altType->is_visible : 1, ['class' => 'form-check-input', 'data-toggle' => 'toggle']) !!}
{!! Form::label('alt[is_visible]['.$altType->id.']', 'Is Visible', ['class' => 'form-check-label ml-3']) !!} {!! add_help('If turned off, the trait will not be visible in the trait list or available for selection in search and design updates. Permissioned staff will still be able to add them to characters, however.') !!}
</div>
@if(isset($altType->display_separate) && $altType->display_separate)
<h4>Preview</h4>
<hr/>
Expand Down
6 changes: 3 additions & 3 deletions resources/views/world/_feature_entry.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@if($feature->feature_category_id)
<div><strong>Category:</strong> {!! $feature->category->displayName !!}</div>
@endif
@if($feature->parent_id)
@if($feature->parent_id && $feature->parentVisible)
Comment thread
SpeedyD marked this conversation as resolved.
Outdated
<div><strong>Parent Trait:</strong> {!! $feature->parent->displayName !!}</div>
@endif
@if($feature->species_id)
Expand All @@ -16,14 +16,14 @@
<div class="world-entry-text parsed-text">
{!! $feature->parsed_description !!}
</div>
@if($feature->altTypes->count())
@if($feature->altTypesVisible->count())
Comment thread
SpeedyD marked this conversation as resolved.
Outdated
<h5 class="inventory-header">
Alternate Types
<a class="small collapse-toggle collapsed" href="#alt-{{ $feature->id }}" data-toggle="collapse">Show</a></h3>
</h5>
<div class="collapse show" id="alt-{{ $feature->id }}">
<ul>
@foreach($feature->altTypes as $altType)
@foreach($feature->altTypesVisible as $altType)
Comment thread
SpeedyD marked this conversation as resolved.
Outdated
<li>
{!! $altType->displayName !!} <a href="{{ $altType->searchUrl }}" class="world-entry-search text-muted"><i class="fas fa-search"></i></a>
@if(!$altType->display_separately)
Expand Down