Skip to content

Commit

Permalink
Allow modules to provide a custom title for the "advanced" section in…
Browse files Browse the repository at this point in the history
… a document.
  • Loading branch information
pavel-mironchik committed May 26, 2021
1 parent f0f4e99 commit c2d09a4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion app/Abstracts/View/Components/DocumentForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ abstract class DocumentForm extends Base
/** @var string */
public $categoryType;

/** @var string */
public $textAdvancedAccordion;

/** @var bool */
public $hideRecurring;

Expand Down Expand Up @@ -214,7 +217,7 @@ abstract class DocumentForm extends Base
public function __construct(
$type, $document = false, $currencies = false, $currency = false, $currency_code = false,
/** Advanced Component Start */
string $categoryType = '', bool $hideRecurring = false, bool $hideCategory = false, bool $hideAttachment = false,
string $categoryType = '', string $textAdvancedAccordion = '', bool $hideRecurring = false, bool $hideCategory = false, bool $hideAttachment = false,
/** Advanced Component End */
/** Company Component Start */
bool $hideLogo = false, bool $hideDocumentTitle = false, bool $hideDocumentSubheading = false, bool $hideCompanyEdit = false,
Expand Down Expand Up @@ -248,6 +251,7 @@ public function __construct(

/** Advanced Component Start */
$this->categoryType = $this->getCategoryType($type, $categoryType);
$this->textAdvancedAccordion = $this->getTextAdvancedAccordion($type, $textAdvancedAccordion);
$this->hideRecurring = $hideRecurring;
$this->hideCategory = $hideCategory;
$this->hideAttachment = $hideAttachment;
Expand Down Expand Up @@ -415,6 +419,21 @@ protected function getCategoryType($type, $categoryType)
return config('type.' . $type . '.category_type');
}

protected function getTextAdvancedAccordion($type, $textAdvancedAccordion)
{
if (!empty($textAdvancedAccordion)) {
return $textAdvancedAccordion;
}

$translation = $this->getTextFromConfig($type, 'advanced_accordion');

if (!empty($translation)) {
return $translation;
}

return 'general.recurring_and_more';
}

protected function getContacts($type, $contacts)
{
if (!empty($contacts)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="accordion">
<div class="card border-1 box-shadow-none">
<div class="card-header background-none collapsed" id="accordion-recurring-and-more-header" data-toggle="collapse" data-target="#accordion-recurring-and-more-body" aria-expanded="false" aria-controls="accordion-recurring-and-more-body">
<h4 class="mb-0">{{ trans('general.recurring_and_more') }}</h4>
<h4 class="mb-0">{{ trans($textAdvancedAccordion) }}</h4>
</div>

<div id="accordion-recurring-and-more-body" class="collapse hide" aria-labelledby="accordion-recurring-and-more-header">
Expand Down

0 comments on commit c2d09a4

Please sign in to comment.