#62 - wip
This commit is contained in:
parent
3a1b9862c1
commit
5d64ad9d2a
@ -24,8 +24,8 @@ use PhpOffice\PhpSpreadsheet\Style\Border;
|
|||||||
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
||||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
use Toby\Domain\Enums\VacationRequestState;
|
|
||||||
use Toby\Domain\Enums\VacationType;
|
use Toby\Domain\Enums\VacationType;
|
||||||
|
use Toby\Domain\States\VacationRequest\Approved;
|
||||||
use Toby\Eloquent\Models\Holiday;
|
use Toby\Eloquent\Models\Holiday;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\Vacation;
|
use Toby\Eloquent\Models\Vacation;
|
||||||
@ -189,7 +189,7 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With
|
|||||||
return $user->vacations()
|
return $user->vacations()
|
||||||
->with("vacationRequest")
|
->with("vacationRequest")
|
||||||
->whereBetween("date", [$period->start, $period->end])
|
->whereBetween("date", [$period->start, $period->end])
|
||||||
->whereRelation("vacationRequest", "state", VacationRequestState::Approved->value)
|
->whereRelation("vacationRequest", "state", Approved::$name)
|
||||||
->get()
|
->get()
|
||||||
->groupBy(
|
->groupBy(
|
||||||
[
|
[
|
||||||
|
@ -48,7 +48,7 @@ class VacationRequestStatesRetriever
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function filterByStatus(string $filter): array
|
public static function filterByStatusGroup(string $filter): array
|
||||||
{
|
{
|
||||||
return match ($filter) {
|
return match ($filter) {
|
||||||
"pending" => self::pendingStates(),
|
"pending" => self::pendingStates(),
|
||||||
|
@ -40,7 +40,7 @@ class VacationRequestController extends Controller
|
|||||||
->with("vacations")
|
->with("vacations")
|
||||||
->where("year_period_id", $yearPeriodRetriever->selected()->id)
|
->where("year_period_id", $yearPeriodRetriever->selected()->id)
|
||||||
->latest()
|
->latest()
|
||||||
->states(VacationRequestStatesRetriever::filterByStatus($status))
|
->states(VacationRequestStatesRetriever::filterByStatusGroup($status))
|
||||||
->paginate();
|
->paginate();
|
||||||
|
|
||||||
return inertia("VacationRequest/Index", [
|
return inertia("VacationRequest/Index", [
|
||||||
@ -53,7 +53,7 @@ class VacationRequestController extends Controller
|
|||||||
|
|
||||||
public function indexForApprovers(
|
public function indexForApprovers(
|
||||||
Request $request,
|
Request $request,
|
||||||
YearPeriodRetriever $yearPeriodRetriever
|
YearPeriodRetriever $yearPeriodRetriever,
|
||||||
): RedirectResponse|Response {
|
): RedirectResponse|Response {
|
||||||
if ($request->user()->cannot("listAll", VacationRequest::class)) {
|
if ($request->user()->cannot("listAll", VacationRequest::class)) {
|
||||||
return redirect()->route("vacation.requests.index");
|
return redirect()->route("vacation.requests.index");
|
||||||
@ -67,7 +67,7 @@ class VacationRequestController extends Controller
|
|||||||
->with(["user", "vacations"])
|
->with(["user", "vacations"])
|
||||||
->where("year_period_id", $yearPeriod->id)
|
->where("year_period_id", $yearPeriod->id)
|
||||||
->when($user !== null, fn(Builder $query) => $query->where("user_id", $user))
|
->when($user !== null, fn(Builder $query) => $query->where("user_id", $user))
|
||||||
->when($status !== null, fn (Builder $query) => $query->states(VacationRequestStatesRetriever::filterByStatus($status)))
|
->when($status !== null, fn(Builder $query) => $query->states([$status]))
|
||||||
->latest()
|
->latest()
|
||||||
->paginate();
|
->paginate();
|
||||||
|
|
||||||
|
@ -9,14 +9,16 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \
|
|||||||
&& docker-php-ext-enable xdebug \
|
&& docker-php-ext-enable xdebug \
|
||||||
;fi
|
;fi
|
||||||
|
|
||||||
RUN pecl install redis \
|
RUN apk add --no-cache pcre-dev $PHPIZE_DEPS \
|
||||||
&& apk --no-cache add \
|
|
||||||
postgresql-dev \
|
postgresql-dev \
|
||||||
zip \
|
zip \
|
||||||
libzip-dev \
|
libzip-dev \
|
||||||
|
libpng-dev \
|
||||||
|
&& pecl install redis \
|
||||||
&& docker-php-ext-install \
|
&& docker-php-ext-install \
|
||||||
pdo_pgsql \
|
pdo_pgsql \
|
||||||
zip \
|
zip \
|
||||||
|
gd \
|
||||||
&& docker-php-ext-configure \
|
&& docker-php-ext-configure \
|
||||||
zip \
|
zip \
|
||||||
&& docker-php-ext-enable \
|
&& docker-php-ext-enable \
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="overflow-x-auto xl:overflow-x-visible overflow-y-auto xl:overflow-y-visible">
|
<div class="overflow-x-auto xl:overflow-x-visible overflow-y-auto xl:overflow-y-visible">
|
||||||
<div class="border-t border-gray-200">
|
<div class="border-t border-gray-200">
|
||||||
<div class="px-4 grid grid-cols-2 lg:grid-cols-4 gap-4">
|
<div class="px-4 grid grid-cols-2 gap-4">
|
||||||
<div class="max-w-md">
|
<div>
|
||||||
<Listbox
|
<Listbox
|
||||||
v-model="form.user"
|
v-model="form.user"
|
||||||
as="div"
|
as="div"
|
||||||
@ -59,7 +59,7 @@
|
|||||||
class="absolute z-10 mt-1 w-full max-w-lg bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm"
|
class="absolute z-10 mt-1 w-full max-w-lg bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm"
|
||||||
>
|
>
|
||||||
<ListboxOption
|
<ListboxOption
|
||||||
v-slot="{ active, selected }"
|
v-slot="{ active }"
|
||||||
as="template"
|
as="template"
|
||||||
:value="null"
|
:value="null"
|
||||||
>
|
>
|
||||||
@ -71,7 +71,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="selected"
|
v-if="form.user === null"
|
||||||
:class="[active ? 'text-white' : 'text-blumilk-600', 'absolute inset-y-0 right-0 flex items-center pr-4']"
|
:class="[active ? 'text-white' : 'text-blumilk-600', 'absolute inset-y-0 right-0 flex items-center pr-4']"
|
||||||
>
|
>
|
||||||
<CheckIcon class="h-5 w-5" />
|
<CheckIcon class="h-5 w-5" />
|
||||||
@ -81,7 +81,7 @@
|
|||||||
<ListboxOption
|
<ListboxOption
|
||||||
v-for="user in users.data"
|
v-for="user in users.data"
|
||||||
:key="user.id"
|
:key="user.id"
|
||||||
v-slot="{ active, selected }"
|
v-slot="{ active }"
|
||||||
as="template"
|
as="template"
|
||||||
:value="user"
|
:value="user"
|
||||||
>
|
>
|
||||||
@ -91,16 +91,14 @@
|
|||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<img
|
<img
|
||||||
:src="user.avatar"
|
:src="user.avatar"
|
||||||
alt=""
|
|
||||||
class="flex-shrink-0 h-6 w-6 rounded-full"
|
class="flex-shrink-0 h-6 w-6 rounded-full"
|
||||||
>
|
>
|
||||||
<span :class="[selected ? 'font-semibold' : 'font-normal', 'ml-3 block truncate']">
|
<span :class="[form.user?.id === user.id ? 'font-semibold' : 'font-normal', 'ml-3 block truncate']">
|
||||||
{{ user.name }}
|
{{ user.name }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="selected"
|
v-if="form.user?.id === user.id"
|
||||||
:class="[active ? 'text-white' : 'text-blumilk-600', 'absolute inset-y-0 right-0 flex items-center pr-4']"
|
:class="[active ? 'text-white' : 'text-blumilk-600', 'absolute inset-y-0 right-0 flex items-center pr-4']"
|
||||||
>
|
>
|
||||||
<CheckIcon class="h-5 w-5" />
|
<CheckIcon class="h-5 w-5" />
|
||||||
@ -112,7 +110,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</Listbox>
|
</Listbox>
|
||||||
</div>
|
</div>
|
||||||
<div class="max-w-md">
|
<div>
|
||||||
<Listbox
|
<Listbox
|
||||||
v-model="form.status"
|
v-model="form.status"
|
||||||
as="div"
|
as="div"
|
||||||
@ -132,7 +130,7 @@
|
|||||||
v-else
|
v-else
|
||||||
class="flex items-center"
|
class="flex items-center"
|
||||||
>
|
>
|
||||||
<Status :status="form.status" />
|
{{ form.status.text }}
|
||||||
</span>
|
</span>
|
||||||
<span class="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none">
|
<span class="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none">
|
||||||
<SelectorIcon class="h-5 w-5 text-gray-400" />
|
<SelectorIcon class="h-5 w-5 text-gray-400" />
|
||||||
@ -148,7 +146,7 @@
|
|||||||
class="absolute z-10 mt-1 w-full max-w-lg bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm"
|
class="absolute z-10 mt-1 w-full max-w-lg bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm"
|
||||||
>
|
>
|
||||||
<ListboxOption
|
<ListboxOption
|
||||||
v-slot="{ active, selected }"
|
v-slot="{ active }"
|
||||||
as="template"
|
as="template"
|
||||||
:value="null"
|
:value="null"
|
||||||
>
|
>
|
||||||
@ -156,11 +154,11 @@
|
|||||||
:class="[active ? 'text-white bg-blumilk-600' : 'text-gray-900', 'cursor-default select-none relative py-2 pl-3 pr-9']"
|
:class="[active ? 'text-white bg-blumilk-600' : 'text-gray-900', 'cursor-default select-none relative py-2 pl-3 pr-9']"
|
||||||
>
|
>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
Wszyscy pracownicy
|
Wszystkie statusy
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="selected"
|
v-if="form.status === null"
|
||||||
:class="[active ? 'text-white' : 'text-blumilk-600', 'absolute inset-y-0 right-0 flex items-center pr-4']"
|
:class="[active ? 'text-white' : 'text-blumilk-600', 'absolute inset-y-0 right-0 flex items-center pr-4']"
|
||||||
>
|
>
|
||||||
<CheckIcon class="h-5 w-5" />
|
<CheckIcon class="h-5 w-5" />
|
||||||
@ -168,28 +166,19 @@
|
|||||||
</li>
|
</li>
|
||||||
</ListboxOption>
|
</ListboxOption>
|
||||||
<ListboxOption
|
<ListboxOption
|
||||||
v-for="user in users.data"
|
v-for="status in statuses"
|
||||||
:key="user.id"
|
:key="status.value"
|
||||||
v-slot="{ active, selected }"
|
v-slot="{ active }"
|
||||||
as="template"
|
as="template"
|
||||||
:value="user"
|
:value="status"
|
||||||
>
|
>
|
||||||
<li
|
<li
|
||||||
:class="[active ? 'text-white bg-blumilk-600' : 'text-gray-900', 'cursor-default select-none relative py-2 pl-3 pr-9']"
|
:class="[active ? 'text-white bg-blumilk-600' : 'text-gray-900', 'cursor-default select-none relative py-2 pl-3 pr-9']"
|
||||||
>
|
>
|
||||||
<div class="flex items-center">
|
{{ status.text }}
|
||||||
<img
|
|
||||||
:src="user.avatar"
|
|
||||||
alt=""
|
|
||||||
class="flex-shrink-0 h-6 w-6 rounded-full"
|
|
||||||
>
|
|
||||||
<span :class="[selected ? 'font-semibold' : 'font-normal', 'ml-3 block truncate']">
|
|
||||||
{{ user.name }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="selected"
|
v-if="form.status?.value === status.value"
|
||||||
:class="[active ? 'text-white' : 'text-blumilk-600', 'absolute inset-y-0 right-0 flex items-center pr-4']"
|
:class="[active ? 'text-white' : 'text-blumilk-600', 'absolute inset-y-0 right-0 flex items-center pr-4']"
|
||||||
>
|
>
|
||||||
<CheckIcon class="h-5 w-5" />
|
<CheckIcon class="h-5 w-5" />
|
||||||
@ -387,6 +376,7 @@ import {watch, reactive} from 'vue'
|
|||||||
import {debounce} from 'lodash'
|
import {debounce} from 'lodash'
|
||||||
import {Inertia} from '@inertiajs/inertia'
|
import {Inertia} from '@inertiajs/inertia'
|
||||||
import {Listbox, ListboxButton, ListboxLabel, ListboxOption, ListboxOptions} from '@headlessui/vue'
|
import {Listbox, ListboxButton, ListboxLabel, ListboxOption, ListboxOptions} from '@headlessui/vue'
|
||||||
|
import {useStatusInfo} from '@/Composables/statusInfo'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'VacationRequestIndex',
|
name: 'VacationRequestIndex',
|
||||||
@ -425,21 +415,23 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
|
const {getStatues, findStatus} = useStatusInfo()
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
user: props.users.data.find(user => user.id === props.filters.user) ?? null,
|
user: props.users.data.find(user => user.id === props.filters.user) ?? null,
|
||||||
status: props.filters.status,
|
status: findStatus(props.filters.status) ?? null,
|
||||||
})
|
})
|
||||||
|
|
||||||
const statuses = useStatusInfo()
|
const statuses = getStatues()
|
||||||
|
|
||||||
watch(form, debounce(() => {
|
watch(form, debounce(() => {
|
||||||
Inertia.get('/vacation-requests', {user: form.user?.id, status: form.status}, {
|
Inertia.get('/vacation-requests', {user: form.user?.id, status: form.status?.value}, {
|
||||||
preserveState: true,
|
preserveState: true,
|
||||||
replace: true,
|
replace: true,
|
||||||
})
|
})
|
||||||
}, 300))
|
}, 300))
|
||||||
|
|
||||||
return {form}
|
return {form, statuses}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -48,7 +48,9 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const statusInfo = computed(() => useStatusInfo(props.activity.state))
|
const { findStatus } = useStatusInfo()
|
||||||
|
|
||||||
|
const statusInfo = computed(() => findStatus(props.activity.state))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
statusInfo,
|
statusInfo,
|
||||||
|
@ -25,7 +25,9 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const statusInfo = computed(() => useStatusInfo(props.status))
|
const { findStatus } = useStatusInfo()
|
||||||
|
|
||||||
|
const statusInfo = computed(() => findStatus(props.status))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
statusInfo,
|
statusInfo,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user