Skip to content

Commit

Permalink
Fixed compatibility with Tabs component
Browse files Browse the repository at this point in the history
  • Loading branch information
kongulov committed Sep 17, 2021
1 parent 91a0ec1 commit c3bb557
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/NovaTabTranslatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class NovaTabTranslatable extends Field
public $component = 'nova-tab-translatable';

public $name = 'Tab translatable';
private $data = [];
public $data = [];
private $locales = [];
private $requiredLocales = [];
private $translatedFieldsByLocale = [];
Expand Down
14 changes: 11 additions & 3 deletions src/TranslatableTabToRowTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Kongulov\NovaTabTranslatable;

use Eminiarts\Tabs\Tabs;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
use Illuminate\Support\Collection;
Expand All @@ -25,15 +26,14 @@ public function availableFields(NovaRequest $request)
$availableFields = [];

foreach ($fields as $key => $field) {
$availableFields[] = $this->filterFieldForRequest($field, $request);

if ($field instanceof NovaTabTranslatable) {
$availableFields[] = $this->filterFieldForRequest($field, $request);
if($this->extractableRequest($request, $this->model())) {
if ($this->doesRouteRequireChildFields()) {
$this->extractChildFields($field, $key);
}
}
} else {
$availableFields[] = $this->filterFieldForRequest($field, $request);
}
}

Expand Down Expand Up @@ -125,6 +125,14 @@ protected function extractChildFields($field, $key)
if (array_search($childField->attribute, array_column($this->childFieldsArr, 'attribute')) === false) {
// @todo: we should not randomly apply rules to child-fields.
$childField = $this->applyRulesForChildFields($childField);
if (isset($field->meta['tabInfo'])){
$childField->withMeta([
'tab' => $field->meta['tab'] ?? '',
'tabSlug' => $field->meta['tabSlug'] ?? '',
'tabInfo' => $field->meta['tabInfo'] ?? [],
]);
}

if (isset($field->panel)) $childField->panel = $field->panel;
$this->childFieldsArr[$key][] = $childField;
}
Expand Down

0 comments on commit c3bb557

Please sign in to comment.