Skip to content

Commit

Permalink
fix #147, fix #148, fix #150, fix #151, fix #154, (#170)
Browse files Browse the repository at this point in the history
fix #159
  • Loading branch information
FlorinZarafu authored Jul 27, 2023
1 parent 5d916e6 commit cead31e
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 38 deletions.
26 changes: 20 additions & 6 deletions app/Http/Controllers/Ngo/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Notification;
use Inertia\Inertia;
use App\Models\ActivityDomain;

class ProjectController extends Controller
{
Expand All @@ -32,21 +33,34 @@ public function index(Request $request)

public function create()
{
$countries = County::get(['name', 'id']);
$counties = cache()->remember('counties', 60 * 60 * 24, function () {
return \App\Models\County::get(['name', 'id']);
});

$projectCategories = cache()->remember('activityDomains', 60 * 60 * 24, function () {
return ActivityDomain::get(['name', 'id']);
});

return Inertia::render('AdminOng/Projects/AddProject', [
'countries' => $countries,
'projectCategories' => ProjectCategory::values(),
'counties' => $counties,
'projectCategories' => $projectCategories,
]);
}

public function createRegional()
{
$countries = County::get(['name', 'id']);
$counties = cache()->remember('counties', 60 * 60 * 24, function () {
return \App\Models\County::get(['name', 'id']);
});

$projectCategories = cache()->remember('activityDomains', 60 * 60 * 24, function () {
return ActivityDomain::get(['name', 'id']);
});


return Inertia::render('AdminOng/Projects/AddRegionalProject', [
'countries' => $countries,
'projectCategories' => ProjectCategory::values(),
'counties' => $counties,
'projectCategories' => $projectCategories,
]);
}

Expand Down
8 changes: 4 additions & 4 deletions public/images/svg/grid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions resources/js/Components/form/DatePeriod.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,19 @@
/** Selected Range */
const selectedDateRange = ref({
start: new Date(),
end: new Date(),
start: null,
end: null,
});
/** Format date range. */
const formattedDateRange = computed(() => {
const startDate = selectedDateRange.value.start ? formatDate(selectedDateRange.value.start) : '';
const endDate = selectedDateRange.value.end ? formatDate(selectedDateRange.value.end) : '';
return `${startDate} - ${endDate}`;
if (selectedDateRange.value.start && selectedDateRange.value.end) {
const startDate = selectedDateRange.value.start ? formatDate(selectedDateRange.value.start) : '';
const endDate = selectedDateRange.value.end ? formatDate(selectedDateRange.value.end) : '';
return `${startDate} - ${endDate}`;
}
return null
});
const open = ref(false);
Expand All @@ -112,7 +116,6 @@
const selectedYear = ref(new Date().getFullYear());
const calendar = computed(() => {
if (selectedDateRange.value.start && selectedDateRange.value.end) {
const year = selectedYear.value;
const month = selectedMonth.value;
Expand Down Expand Up @@ -140,9 +143,6 @@
}
return calendar;
} else {
return [];
}
});
function formatDate(date) {
Expand Down
10 changes: 7 additions & 3 deletions resources/js/Components/form/Radio.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<label class="text-sm font-semibold text-gray-700">{{ label }}</label>
<label v-if="label" class="text-sm font-semibold text-gray-700">{{ label }}</label>
<fieldset class="mt-4">
<div class="space-y-4">
<div
Expand All @@ -10,9 +10,10 @@
>
<input
:id="option.value"
name="test"
:name="name"
type="radio"
:value="option.value"
@input="$emit('update:modelValue', option.value)"
class="w-4 h-4 border-gray-300 text-primary-500 focus:ring-primary-500"
/>
<label :for="option.value" class="block ml-3 text-sm font-medium leading-6 text-gray-900">{{ option.label }}</label>
Expand All @@ -28,6 +29,9 @@
<script setup>
const props = defineProps({
options: Array,
error: String
error: String,
name: String,
modelValue: String,
label:String
});
</script>
14 changes: 8 additions & 6 deletions resources/js/Pages/AdminOng/Projects/AddProject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
:options="projectCategories"
v-model="form.category"
type="singleValue"
v-if="!form.is_national"
:error="form.errors.category"
/>

Expand Down Expand Up @@ -92,7 +91,7 @@
<SelectMultiple
class="w-full xl:w-1/2"
:label="$t('counties_label')"
:options="countries"
:options="counties"
type="object"
v-model="selectedCounties"
v-if="!form.is_national"
Expand Down Expand Up @@ -311,7 +310,7 @@ const form = useForm({
project_articles: [{url:''}]
});
let selectedCounties = [];
const props = defineProps(['projectCategories', 'countries']);
const props = defineProps(['projectCategories', 'counties']);
let projectLinks = ref(form.project_links);
let projectArticles = ref(form.project_articles);
Expand All @@ -326,13 +325,16 @@ function prepareExternalLinks() {
/** Create project. */
const createProject = () => {
form.counties = selectedCounties.map(item => item.id);
if(0 < form.category.length) {
form.category = form.category.map(item => item.id);
}
prepareProjectLinks();
prepareExternalLinks();
console.log(form);
form.post(route('admin.ong.project.store'), {
preserveScroll: true,
onError: () => {
},
onError: () => {},
});
};
</script>
20 changes: 14 additions & 6 deletions resources/js/Pages/AdminOng/Projects/AddRegionalProject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<SelectMultiple
class="w-full xl:w-1/2"
:label="$t('counties_label')"
:options="countries"
:options="counties"
v-model="selectedCounties"
:error="form.errors.counties"
/>
Expand All @@ -70,11 +70,12 @@
/>

<!-- Project category -->
<Select
<SelectMultiple
class="w-full xl:w-1/2"
:label="$t('project_category_label')"
:options="projectCategories"
v-model="form.category"
type="singleValue"
:error="form.errors.category"
/>

Expand Down Expand Up @@ -160,6 +161,7 @@
<Radio
:label="$t('regional_parteners_label')"
:options="[{'label': 'Da', 'value': 'yes'}, {'label': 'Nu', 'value': 'no'}]"
name="parteners"
v-model="form.parteners"
:error="form.errors.parteners"
/>
Expand Down Expand Up @@ -192,6 +194,7 @@
<Radio
:label="$t('regional_arie_label')"
:options="arias"
name="locations"
v-model="form.aria"
:error="form.errors.aria"
/>
Expand Down Expand Up @@ -372,7 +375,7 @@ import Radio from '@/Components/form/Radio.vue';
const form = useForm({
name: '',
description: '',
category: '',
category: [],
start: '',
end: '',
counties: [],
Expand All @@ -399,8 +402,9 @@ const form = useForm({
email: ''
}
});
let selectedCounties = [];
const props = defineProps(['projectCategories', 'countries']);
const props = defineProps(['projectCategories', 'counties']);
let projectLinks = ref(form.project_links);
const arias = [
Expand All @@ -425,11 +429,15 @@ function prepareProjectLinks() {
/** Create project. */
const createProject = () => {
form.counties = selectedCounties.map(item => item.id);
if(0 < form.category.length) {
form.category = form.category.map(item => item.id);
}
prepareProjectLinks();
form.post(route('admin.ong.project.storeRegional'), {
preserveScroll: true,
onError: () => {
},
onError: () => {},
});
};
</script>
6 changes: 3 additions & 3 deletions resources/js/Pages/Public/Projects/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

<div class="flex gap-6 pt-4 mr-6 bg-white">
<div class="flex items-center gap-2">
<div :class="['w-8 h-8 rounded-lg flex items-center justify-center', project.active ? 'bg-red-500' : 'bg-cyan-900']">
<SvgLoader :class="['shrink-0 stroke-white', project.active ? 'fill-red-500' : 'fill-cyan-900']" name="thunder" />
<div :class="['w-8 h-8 rounded-lg flex items-center justify-center', project.is_period_active ? 'bg-red-500' : 'bg-cyan-900']">
<SvgLoader :class="['shrink-0 stroke-white', project.is_period_active ? 'fill-red-500' : 'fill-cyan-900']" name="thunder" />
</div>
<p class="text-base font-semibold leading-6 text-gray-900">{{ project.active ? $t('active') : $t('inactive') }}</p>
<p class="text-base font-semibold leading-6 text-gray-900">{{ project.is_period_active ? $t('active') : $t('inactive') }}</p>
</div>

<div v-if="project.category" class="flex items-center gap-2">
Expand Down
2 changes: 1 addition & 1 deletion resources/js/locales/ro.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default {
"project_beneficiary_extra": "Descrie beneficiarii proiectului/comunitatea căreia i se adresează, incluzând timpul și numărul acestora. Nu depăși 500 caractere",
"why_to_donate": "De ce să donez?",
"why_to_donate_extra": "Precizează nevoile sesizate în rândul beneficiarilor/comunității în care va fi implementat proiectul.",
"has_comments_label": "Proiectul acceptă comentari?",
"has_comments_label": "Proiectul acceptă comentarii?",
"has_volunteers_label": "Proiectul acceptă voluntari?",
"photo_gallery": "Galerie foto",
"load_image": "Încarcă o imagine",
Expand Down

0 comments on commit cead31e

Please sign in to comment.