Skip to content

Commit

Permalink
add list for all forms links connected to an ext
Browse files Browse the repository at this point in the history
  • Loading branch information
atmonshi committed Feb 10, 2024
1 parent d2a09b8 commit afd0bcf
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"pest_2.33.4","defects":{"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_Form_List":8,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_Collection_List":8,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_Category_List":8},"times":{"P\\Tests\\ArchTest::__pest_evaluable_it_will_not_use_debugging_functions":0.185,"P\\Tests\\FormsTest::__pest_evaluable_it_can_list_Form":0.008,"P\\Tests\\FormsTest::__pest_evaluable_it_can_render_Form_List":0.049,"P\\Tests\\FormsTest::__pest_evaluable_it_can_not_edit":0.034,"P\\Tests\\FormsTest::__pest_evaluable_it_can_render_create_form_page":0.081,"P\\Tests\\FormsTest::__pest_evaluable_it_can_create":0.008,"P\\Tests\\FormsTest::__pest_evaluable_it_see_form_when_not_require_login":0.01,"P\\Tests\\FormsTest::__pest_evaluable_it_see_form_when_not_require_login_for_guest":0.01,"P\\Tests\\FormsTest::__pest_evaluable_it_see_form_require_login_for_guest_user":0.011,"P\\Tests\\FormsTest::__pest_evaluable_it_can_retrieve_data":0.057,"P\\Tests\\FormsTest::__pest_evaluable_it_can_render_list_Forms":0.009,"P\\Tests\\FormsTest::__pest_evaluable_it_the_form_can_be_rendered":0.009,"P\\Tests\\FormsTest::__pest_evaluable_it_can_render_show_Form":0.015,"P\\Tests\\FormsTest::__pest_evaluable_it_see_form_require_login_for_logged_in_user":0.01,"P\\Tests\\FormsTest::__pest_evaluable_it_can_save":1.204,"P\\Tests\\FormsTest::__pest_evaluable_it_see_form_date_is_valid":0.012,"P\\Tests\\FormsTest::__pest_evaluable_it_see_ended_form_date":0.01,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_Form_List":0.058,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_Category_List":0.052,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_Collection_List":0.037,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_test":0.006,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_collection_list":0.03,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_form_list":0.083,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_category_list":0.078}}
{"version":"pest_2.33.4","defects":{"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_Form_List":8,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_Collection_List":8,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_Category_List":8},"times":{"P\\Tests\\ArchTest::__pest_evaluable_it_will_not_use_debugging_functions":0.2,"P\\Tests\\FormsTest::__pest_evaluable_it_can_list_Form":0.008,"P\\Tests\\FormsTest::__pest_evaluable_it_can_render_Form_List":0.047,"P\\Tests\\FormsTest::__pest_evaluable_it_can_not_edit":0.042,"P\\Tests\\FormsTest::__pest_evaluable_it_can_render_create_form_page":0.09,"P\\Tests\\FormsTest::__pest_evaluable_it_can_create":0.009,"P\\Tests\\FormsTest::__pest_evaluable_it_see_form_when_not_require_login":0.009,"P\\Tests\\FormsTest::__pest_evaluable_it_see_form_when_not_require_login_for_guest":0.011,"P\\Tests\\FormsTest::__pest_evaluable_it_see_form_require_login_for_guest_user":0.012,"P\\Tests\\FormsTest::__pest_evaluable_it_can_retrieve_data":0.095,"P\\Tests\\FormsTest::__pest_evaluable_it_can_render_list_Forms":0.013,"P\\Tests\\FormsTest::__pest_evaluable_it_the_form_can_be_rendered":0.032,"P\\Tests\\FormsTest::__pest_evaluable_it_can_render_show_Form":0.013,"P\\Tests\\FormsTest::__pest_evaluable_it_see_form_require_login_for_logged_in_user":0.01,"P\\Tests\\FormsTest::__pest_evaluable_it_can_save":1.19,"P\\Tests\\FormsTest::__pest_evaluable_it_see_form_date_is_valid":0.015,"P\\Tests\\FormsTest::__pest_evaluable_it_see_ended_form_date":0.01,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_Form_List":0.058,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_Category_List":0.052,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_Collection_List":0.037,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_test":0.01,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_collection_list":0.034,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_form_list":0.052,"P\\Tests\\ResourcesTest::__pest_evaluable_it_can_render_category_list":0.256}}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"guava/filament-icon-picker": "^2.0",
"lara-zeus/accordion": "^1.0",
"lara-zeus/core": "^3.1",
"lara-zeus/list-group": "^1.0",
"ryangjchandler/blade-tabler-icons": "^2.2"
},
"require-dev": {
Expand Down
156 changes: 122 additions & 34 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion resources/lang/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,6 @@
"Design": "التصميم",
"View Form": "عرض",
"Thanks": "شكرا لك",
"New Submission in": "لديك سجل جديد في النموذج"
"New Submission in": "لديك سجل جديد في النموذج",
"Form Links": "روابط النموذج"
}
3 changes: 2 additions & 1 deletion resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,6 @@
"Design": "Design",
"View Form": "View Form",
"Thanks": "Thanks",
"New Submission in": "New Submission in"
"New Submission in": "New Submission in",
"Form Links": "Form Links"
}
18 changes: 5 additions & 13 deletions src/Filament/Resources/FormResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use LaraZeus\Bolt\Filament\Actions\ReplicateFormAction;
use LaraZeus\Bolt\Filament\Resources\FormResource\Pages;
use LaraZeus\Bolt\Models\Form as ZeusForm;
use LaraZeus\ListGroup\Infolists\ListEntry;

class FormResource extends BoltResource
{
Expand Down Expand Up @@ -88,20 +89,11 @@ public static function infolist(Infolist $infolist): Infolist
TextEntry::make('name')
->label(__('name')),

/*SimpleListEntry::make('links')
->inline(true)
->openUrlInNewTab()
->listStyle('inline')
->badge('-')
->badgeColor('gray')
->emptyStateHeading('item not available')
->emptyStateIcon('heroicon-o-exclamation-triangle')
->itemUrl(fn ($record) => $record['url'])
->itemLabel(fn ($record) => $record['label'])
->getStateUsing(fn (ZeusForm $record) => $record->getUrl())
ListEntry::make('items')
->visible(fn (ZeusForm $record) => $record->extensions !== null)
->itemIcon('heroicon-o-arrow-top-right-on-square')
->label(__('Form Links')),*/
->heading(__('Form Links'))
->list()
->state(fn ($record) => $record->slug_url),

TextEntry::make('slug')
->label(__('slug'))
Expand Down
11 changes: 11 additions & 0 deletions src/Models/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class Form extends Model

protected $guarded = [];

protected $appends = [
'slug_url',
];

protected $casts = [
'start_date' => 'datetime',
'end_date' => 'datetime',
Expand Down Expand Up @@ -172,6 +176,13 @@ public function onePerUser(): bool
&& $this->responses()->where('user_id', auth()->user()->id)->exists();
}

protected function slugUrl(): Attribute
{
return Attribute::make(
get: fn () => $this->getUrl(),
);
}

public function getUrl(): string | array
{
if ($this->extensions === null) {
Expand Down

0 comments on commit afd0bcf

Please sign in to comment.