Merge pull request #1870 from pavel-mironchik/delete-modal

Show a correct text in a delete modal for modules
This commit is contained in:
Cüneyt Şentürk 2021-02-17 11:20:08 +03:00 committed by GitHub
commit ddc08ddcb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 4 deletions

View File

@ -11,7 +11,7 @@ abstract class Document extends Component
{
$translation = '';
// if set config trasnlation config_key
// if set config translation config_key
if ($translation = config('type.' . $type . '.translation.' . $config_key)) {
return $translation;
}

View File

@ -155,6 +155,12 @@ abstract class DocumentIndex extends Base
/** @var string */
public $routeButtonDelete;
/** @var string */
public $textModalDelete;
/** @var string */
public $valueModalDelete;
/** @var bool */
public $hideButtonShow;
@ -204,6 +210,7 @@ abstract class DocumentIndex extends Base
string $textDocumentNumber = '', string $textContactName = '', string $classAmount = '', string $textIssuedAt = '', string $textDueAt = '', string $textDocumentStatus = '',
bool $checkButtonReconciled = true, bool $checkButtonCancelled = true,
string $routeButtonShow = '', string $routeButtonEdit = '', string $routeButtonDuplicate = '', string $routeButtonCancelled = '', string $routeButtonDelete = '',
string $textModalDelete = '', string $valueModalDelete = 'document_number',
bool $hideDocumentNumber = false, bool $hideContactName = false, bool $hideAmount = false, bool $hideIssuedAt = false, bool $hideDueAt = false, bool $hideStatus = false, bool $hideActions = false,
bool $hideButtonShow = false, bool $hideButtonEdit = false, bool $hideButtonDuplicate = false, bool $hideButtonCancel = false, bool $hideButtonDelete = false,
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = ''
@ -260,6 +267,9 @@ abstract class DocumentIndex extends Base
$this->routeButtonCancelled = $this->getRouteButtonCancelled($type, $routeButtonCancelled);
$this->routeButtonDelete = $this->getRouteButtonDelete($type, $routeButtonDelete);
$this->textModalDelete = $this->getTextModalDelete($type, $textModalDelete);
$this->valueModalDelete = $valueModalDelete;
$this->hideBulkAction = $hideBulkAction;
$this->hideDocumentNumber = $hideDocumentNumber;
$this->hideContactName = $hideContactName;
@ -915,6 +925,19 @@ abstract class DocumentIndex extends Base
return 'invoices.destroy';
}
protected function getTextModalDelete($type, $textModalDelete)
{
if (!empty($textModalDelete)) {
return $textModalDelete;
}
if ($alias = config('type.' . $type . '.alias')) {
return $alias . '::general.' . Str::plural(str_replace('-', '_', $type));
}
return '';
}
protected function getPermissionCreate($type, $permissionCreate)
{
if (!empty($permissionCreate)) {

View File

@ -242,10 +242,10 @@
@can($permissionDelete)
@if ($checkButtonReconciled)
@if (!$item->reconciled)
{!! Form::deleteLink($item, $routeButtonDelete) !!}
{!! Form::deleteLink($item, $routeButtonDelete, $textModalDelete, $valueModalDelete) !!}
@endif
@else
{!! Form::deleteLink($item, $routeButtonDelete) !!}
{!! Form::deleteLink($item, $routeButtonDelete, $textModalDelete, $valueModalDelete) !!}
@endif
@endcan
@endif

View File

@ -51,6 +51,8 @@
hide-button-delete="{{ $hideButtonDelete }}"
permission-delete="{{ $permissionDelete }}"
route-button-delete="{{ $routeButtonDelete }}"
text-modal-delete="{{ $textModalDelete }}"
value-modal-delete="{{ $valueModalDelete }}"
/>
<x-documents.index.card-footer