Skip to content

Commit

Permalink
fix projects edit is national fix show category page on articles
Browse files Browse the repository at this point in the history
  • Loading branch information
gheorghelupu17 committed Oct 24, 2023
1 parent e446dd9 commit 804e43b
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 4 deletions.
3 changes: 1 addition & 2 deletions app/Filament/Resources/Articles/ArticleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Filament\Resources\Table;
use Filament\Tables;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\Layout;
use Filament\Tables\Filters\SelectFilter;
use FilamentTiptapEditor\TiptapEditor;

Expand Down Expand Up @@ -50,6 +49,7 @@ public static function getPluralModelLabel(): string
{
return __('article.label.plural');
}

protected static function getNavigationBadge(): ?string
{
return (string) Article::count();
Expand Down Expand Up @@ -177,7 +177,6 @@ public static function table(Table $table): Table
]);
}


public static function getPages(): array
{
return [
Expand Down
6 changes: 6 additions & 0 deletions app/Http/Controllers/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public function category(ArticleCategory $category, Request $request): Response
->orderByDesc('id')
->paginate(5)
),
'topArticles' => ArticleCardResource::collection(
Article::query()
->wherePublished()
->inRandomOrder()
->limit(3)
->get())
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/Project/EditProjectResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function toArray(Request $request): array
'name' => $this->organization->name,
'id' => $this->organization->id,
],
'is_national' => \boolval($this->is_national),
'beneficiaries' => $this->beneficiaries ?? '',
'start' => $this->start?->format('Y-m-d'),
'end' => $this->end?->format('Y-m-d'),
Expand All @@ -40,6 +39,7 @@ public function toArray(Request $request): array
'reason_to_donate' => $this->reason_to_donate ?? '',
'accepting_volunteers' => $this->accepting_volunteers ? __('field.boolean.true') : __('field.boolean.false'),
'accepting_comments' => $this->accepting_comments ? __('field.boolean.true') : __('field.boolean.false'),
'is_national' => $this->is_national ? __('field.boolean.true') : __('field.boolean.false'),
'videos' => empty($this->videos) ? [] : $this->videos,
'external_links' => empty($this->external_links) ? [] : $this->external_links,
'counties' => $this->counties->pluck('id')->toArray(),
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Article extends Model implements HasMedia
'title',
'slug',
'content',
'is_active',
'is_published',
'article_category_id',
'author',
];
Expand Down
45 changes: 45 additions & 0 deletions resources/js/Pages/AdminOng/Projects/EditProject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,51 @@
</EditModal>
</template>
</Field>
<Field
:label="$t('is_national')"
:hasPendingChanges="changes.includes('is_national')"
:errors="formChangeStatus.errors.is_national"
alt
>
<template #value>
{{ originalProject.is_national }}
</template>

<template #action>
<EditModal
@action="editField('is_national')"
@cancel="resetField('is_national')"
class="flex justify-end col-span-1"
>
<fieldset>
<legend class="text-sm font-semibold leading-6 text-gray-900">
{{ $t('accepting_volunteers') }}
</legend>
<div class="mt-6 space-y-6">
<div class="relative flex gap-x-3">
<div class="flex items-center h-6">
<Checkbox
class="form-checkbox"
id="accepting_comments"
color="gray-700"
v-model="project.is_national"
:checked="project.is_national === 'Da'"
:error="errors.is_national"
/>
</div>
<div class="text-sm leading-6">
<label for="accepting_comments" class="font-medium text-gray-900">
{{ $t('is_national') }}
</label>

</div>
</div>
</div>
</fieldset>

</EditModal>
</template>
</Field>

<Field
:label="$t('project_description_label')"
Expand Down

0 comments on commit 804e43b

Please sign in to comment.