This commit is contained in:
Adrian Hopek 2022-02-22 10:42:20 +01:00
parent 6b4b583632
commit 0cc495acab
8 changed files with 18 additions and 18 deletions

View File

@ -20,7 +20,7 @@ class HandleCreatedVacationRequest
{
$vacationRequest = $event->vacationRequest;
if ($vacationRequest->shouldSkipFlow()) {
if ($vacationRequest->hasFlowSkipped()) {
$this->stateManager->approve($vacationRequest);
return;

View File

@ -19,9 +19,9 @@ class SendCreatedVacationRequestNotification
$vacationRequest = $event->vacationRequest;
if ($vacationRequest->creator->is($vacationRequest->user)) {
$event->vacationRequest->user->notify(new VacationRequestCreatedNotification($event->vacationRequest));
$vacationRequest->user->notify(new VacationRequestCreatedNotification($vacationRequest));
} else {
$event->vacationRequest->user->notify(new VacationRequestCreatedOnEmployeeBehalf($event->vacationRequest));
$vacationRequest->user->notify(new VacationRequestCreatedOnEmployeeBehalf($vacationRequest));
}
}
}

View File

@ -22,7 +22,7 @@ use Toby\Domain\Enums\VacationType;
* @property Carbon $from
* @property Carbon $to
* @property string $comment
* @property boolean $skip_flow
* @property bool $flow_skipped
* @property User $user
* @property User $creator
* @property YearPeriod $yearPeriod
@ -76,9 +76,9 @@ class VacationRequest extends Model
$this->save();
}
public function shouldSkipFlow(): bool
public function hasFlowSkipped(): bool
{
return $this->skip_flow;
return $this->flow_skipped;
}
public function scopeStates(Builder $query, array $states): Builder

View File

@ -20,7 +20,7 @@ class VacationRequestRequest extends FormRequest
"type" => ["required", new Enum(VacationType::class)],
"from" => ["required", "date_format:Y-m-d", new YearPeriodExists()],
"to" => ["required", "date_format:Y-m-d", new YearPeriodExists()],
"skipFlow" => ["nullable", "boolean"],
"flowSkipped" => ["nullable", "boolean"],
"comment" => ["nullable"],
];
}
@ -36,7 +36,7 @@ class VacationRequestRequest extends FormRequest
"to" => $this->get("to"),
"year_period_id" => YearPeriod::findByYear(Carbon::create($from)->year)->id,
"comment" => $this->get("comment"),
"skip_flow" => $this->boolean("skipFlow"),
"flow_skipped" => $this->boolean("flowSkipped"),
];
}
}

View File

@ -24,9 +24,9 @@ class VacationRequestFactory extends Factory
return [
"user_id" => User::factory(),
"creator_id" => fn(array $attributes) => $attributes["user_id"],
"creator_id" => fn(array $attributes): int => $attributes["user_id"],
"year_period_id" => YearPeriod::factory(),
"name" => fn(array $attributes) => $this->generateName($attributes),
"name" => fn(array $attributes): string => $this->generateName($attributes),
"type" => $this->faker->randomElement(VacationType::cases()),
"state" => $this->faker->randomElement(VacationRequestState::cases()),
"from" => $from,

View File

@ -22,7 +22,7 @@ return new class() extends Migration {
$table->date("from");
$table->date("to");
$table->text("comment")->nullable();
$table->boolean("skip_flow")->default(false);
$table->boolean("flow_skipped")->default(false);
$table->timestamps();
});
}

View File

@ -233,19 +233,19 @@
</div>
<div class="sm:grid sm:grid-cols-3 py-4 items-center">
<label
for="skipFlow"
for="flowSkipped"
class="block text-sm font-medium text-gray-700"
>
Natychmiastowo zatwierdź wniosek
</label>
<div class="mt-1 sm:mt-0 sm:col-span-2">
<Switch
id="skipFlow"
v-model="form.skipFlow"
:class="[form.skipFlow ? 'bg-blumilk-500' : 'bg-gray-200', 'relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500']"
id="flowSkipped"
v-model="form.flowSkipped"
:class="[form.flowSkipped ? 'bg-blumilk-500' : 'bg-gray-200', 'relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500']"
>
<span
:class="[form.skipFlow ? 'translate-x-5' : 'translate-x-0', 'pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200']"
:class="[form.flowSkipped ? 'translate-x-5' : 'translate-x-0', 'pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200']"
/>
</Switch>
</div>
@ -319,7 +319,7 @@ export default {
to: null,
type: props.vacationTypes[0],
comment: null,
skipFlow: false,
flowSkipped: false,
})
const estimatedDays = ref([])

View File

@ -150,7 +150,7 @@ class VacationRequestTest extends FeatureTestCase
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
"comment" => "Comment for the vacation request.",
"skipFlow" => 1,
"flowSkipped" => true,
])
->assertSessionHasNoErrors();