Skip to content

Commit

Permalink
Update stability of some things,
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkregel committed Feb 23, 2024
1 parent 40d8a09 commit d2e2b73
Show file tree
Hide file tree
Showing 27 changed files with 602 additions and 179 deletions.
16 changes: 16 additions & 0 deletions app/Http/Controllers/Api/Projects/CreateTaskController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Http\Controllers\Api\Projects;

use App\Http\Controllers\Controller;
use App\Http\Requests\UpdateProjectRequest;
use App\Models\Project;
use Illuminate\Http\Request;

class CreateTaskController extends Controller
{
public function __invoke(UpdateProjectRequest $request, Project $project)
{
return $project->tasks()->create($request->validated());
}
}
1 change: 1 addition & 0 deletions app/Http/Controllers/Spork/LocalAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class LocalAdminController extends Controller
'scripts' => App\Models\Spork\Script::class,
'servers' => App\Models\Server::class,
'tags' => App\Models\Tag::class,
'tasks' => App\Models\Task::class,
'threads' => App\Models\Thread::class,
'transactions' => App\Models\Finance\Transaction::class,
'users' => App\Models\User::class,
Expand Down
46 changes: 43 additions & 3 deletions app/Http/Controllers/Spork/ProjectsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use App\Http\Controllers\Controller;
use App\Models\Project;
use App\Models\Research;
use App\Models\Task;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Inertia\Inertia;
Expand All @@ -14,7 +16,21 @@ class ProjectsController extends Controller
{
public function index()
{
return Inertia::render('Projects/Projects', []);
$model = \App\Models\Project::class;
/** @var \Illuminate\Pagination\LengthAwarePaginator $paginator */
$paginator = $model::query()
->where('team_id', auth()->user()->current_team_id)
->paginate(request('limit', 15), ['*'], 'page', request('page', 1));

$data = $paginator->items();
$paginator = $paginator->toArray();

unset($paginator['data']);

return Inertia::render('Projects/Index', [
'data' => $data,
'paginator' => $paginator,
]);
}

public function show(Project $project)
Expand Down Expand Up @@ -81,8 +97,28 @@ public function show(Project $project)

],
],
'tasks' => $project->tasks()
->where('type', 'task')
'daily_tasks' => $project->tasks()
->where('status', '!=', 'done')
->whereIn('project_id', auth()->user()->projects()->pluck('project_id'))
->where('type', 'daily')
->get(),
'today_tasks' => $project->tasks()
->where('status', '!=', 'done')

->whereIn('project_id', auth()->user()->projects()->pluck('project_id'))
->where(function ($query) {
$query->where('start_date', '<=', now())
->orWhere('end_date', '>=', now())
->orWhereNull('end_date');
})
->get(),
'future_tasks' => $project->tasks()
->where('status', '!=', 'done')
->whereIn('project_id', auth()->user()->projects()->pluck('project_id'))
->where(function ($query) {
$query->where('start_date', '>=', now())
->orWhere('end_date', '>=', now());
})
->get(),
]);
}
Expand Down Expand Up @@ -141,6 +177,8 @@ public function attach(Project $project)
\App\Models\Domain::class,
\App\Models\Credential::class,
\App\Models\Page::class,
Research::class,
Task::class,
]),
]);

Expand Down Expand Up @@ -171,6 +209,8 @@ public function detach(Project $project)
\App\Models\Domain::class,
\App\Models\Credential::class,
\App\Models\Page::class,
Research::class,
Task::class,
]),
]);

Expand Down
11 changes: 9 additions & 2 deletions app/Http/Requests/UpdateProjectRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UpdateProjectRequest extends FormRequest
*/
public function authorize(): bool
{
return false;
return $this->route('project')->team_id === $this->user()->current_team_id;
}

/**
Expand All @@ -24,7 +24,14 @@ public function authorize(): bool
public function rules(): array
{
return [
//
'name' => 'string',
'type' => 'string',
'status' => 'string',
'notes' => 'string',
'start_date' => 'date',
'checklist' => 'array',
'checklist.*.name' => 'string',
'checklist.*.checked' => 'boolean',
];
}
}
2 changes: 1 addition & 1 deletion app/Models/ShortCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ShortCode extends Model
class ShortCode extends Model implements Crud
{
use HasFactory;

Expand Down
7 changes: 6 additions & 1 deletion app/Models/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

namespace App\Models;

use App\Contracts\ModelQuery;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Task extends Model
class Task extends Model implements ModelQuery, Crud
{
use HasFactory;

Expand All @@ -22,6 +23,10 @@ class Task extends Model
'service_identifier',
];

protected $casts = [
'checklist' => 'json',
];

public function project()
{
return $this->belongsTo(Project::class);
Expand Down
4 changes: 4 additions & 0 deletions app/Services/Development/DescribeTableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public function describe(Model $model): array
// dd(array_map(fn ($q) => new $q, $actions));

return [
'name' => $model->getTable(),
'model' => get_class($model),
'pretty_name' => class_basename(get_class($model)),
'actions' => array_map(fn ($class) => (array) (new $class), $model->actions ?? []),
'query_actions' => ActionFilter::WHITELISTED_ACTIONS,
'fillable' => $fillable,
Expand Down Expand Up @@ -193,6 +196,7 @@ public function describeTable(string $table): array
});

return [
'name' => $table,
'actions' => ActionFilter::WHITELISTED_ACTIONS,
'fillable' => ['name'],
'fields' => $fields,
Expand Down
11 changes: 2 additions & 9 deletions resources/js/Components/AuthenticationCardLogo.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
<script setup>
import { Link } from '@inertiajs/vue3';
import {CpuChipIcon} from "@heroicons/vue/24/outline";
</script>

<template>
<Link :href="'/'">
<svg
class="w-16 h-16"
viewBox="0 0 48 48"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M11.395 44.428C4.557 40.198 0 32.632 0 24 0 10.745 10.745 0 24 0a23.891 23.891 0 0113.997 4.502c-.2 17.907-11.097 33.245-26.602 39.926z" fill="#6875F5" />
<path d="M14.134 45.885A23.914 23.914 0 0024 48c13.255 0 24-10.745 24-24 0-3.516-.756-6.856-2.115-9.866-4.659 15.143-16.608 27.092-31.75 31.751z" fill="#6875F5" />
</svg>
<CpuChipIcon class="h-16 w-16 text-slate-500" />
</Link>
</template>
37 changes: 37 additions & 0 deletions resources/js/Components/Spork/SmallTaskList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<template>
<div>
<div class="mx-4">{{ name }}</div>
<div v-if="tasks.length > 0" class="py-2 mx-2 flex-col gap-4">
<Task v-for="task in tasks" :task="task"></Task>
</div>
<div v-else>
<div class="text-center italic py-4 ">No tasks</div>
</div>

<div class="mx-4">
<SporkButton xsmall secondary @click="() => $emit('open')">Add Task</SporkButton>
</div>
</div>
</template>

<script setup>
import SporkChecklist from "@/Components/Spork/SporkChecklist.vue";
import SporkButton from "@/Components/Spork/SporkButton.vue";
import { watch } from 'vue';
import Task from "@/Components/Task.vue";
const { tasks, name } = defineProps({
name: {
type: String,
default: null
},
tasks: {
type: Array,
default: () => []
}
})
watch(tasks, (newVal, oldValue) => {
})
</script>
9 changes: 8 additions & 1 deletion resources/js/Components/Spork/SporkButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export default {
icon: {
default: undefined
},
xsmall: {
type: Boolean,
default: false
},
small: {
type: Boolean,
default: false
Expand Down Expand Up @@ -64,9 +68,12 @@ export default {
return 'border-transparent bg-red-100 hover:bg-red-200 focus:ring-red-500 dark:bg-red-500'
}

return 'border-stone-300 text-stone-700 dark:border-stone-600 dark:text-stone-200 focus:ring-stone-500'
return 'border-stone-300 text-stone-700 dark:border-stone-500 dark:text-stone-300 focus:ring-stone-500'
},
size() {
if (this.xsmall) {
return 'px-2 py-1 text-xs leading-4'
}
if (this.small) {
return 'px-3 py-2 text-sm leading-4'
}
Expand Down
63 changes: 63 additions & 0 deletions resources/js/Components/Spork/SporkChecklist.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<script setup>
import SporkLabel from "@/Components/Spork/SporkLabel.vue";
import SporkInput from "@/Components/Spork/SporkInput.vue";
import SporkButton from "@/Components/Spork/SporkButton.vue";
import DynamicIcon from "@/Components/DynamicIcon.vue";
defineProps({
label: {
type: String,
default: null
},
required: {
type: Boolean,
default: false
},
modelValue: {
type: Array,
default: () => []
},
type: {
type: String,
default: "text"
},
placeholder: {
type: String,
default: ""
},
canAddMore: {
type: Boolean,
default: true
}
});
defineEmits(["update:modelValue"]);
</script>

<template>
<div class="flex gap-2 flex-col">
<div v-if="label" class="block uppercase tracking-wide text-xs font-semibold dark:text-stone-300" >
{{ label }}
</div>
<label v-for="(item, index) in modelValue" class="flex items-center gap-2">
<input
type="checkbox"
:checked="modelValue[index].checked"
@change="(event) => { modelValue[index].checked = event.target.checked; $emit('update:modelValue', modelValue)}"
@click="(event) => { modelValue[index].checked = event.target.checked; $emit('update:modelValue', modelValue)}"
class="bg-stone-300 dark:bg-stone-700 rounded outline-none focus:outline-none"
/>
<SporkInput
:model-value="modelValue[index].name"
@change="(event) => { modelValue[index].name = event.target.value; $emit('update:modelValue', modelValue)}"
:type="type"
:placeholder="placeholder"
/>
<button @click="() => $emit('update:modelValue', modelValue.filter((item, i) => index !== i))">
<DynamicIcon icon-name="TrashIcon" class="w-5 h-5 text-red-500" />
</button>
</label>
<div v-if="canAddMore">
<SporkButton xsmall plain @click="() => $emit('update:modelValue', Array.isArray(modelValue) ? [...modelValue, { name: '', checked: false }] : [{ name: '', checked: false }])">Add</SporkButton>
</div>
</div>
</template>
10 changes: 8 additions & 2 deletions resources/js/Components/Spork/SporkDynamicInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
/>

</label>

<div v-if="errors" class="flex flex-col">
<div v-for="error in errors" :key="error" class="text-red-500 dark:text-red-400 px-4 text-xs py-1"> {{ error }}</div>
</div>
</div>
</template>

Expand All @@ -39,7 +43,8 @@ const {
type,
autofocus,
disabledInput,
editableLabel
editableLabel,
error
} = defineProps({
modelValue: Object,
type: String,
Expand All @@ -51,7 +56,8 @@ const {
editableLabel: {
type: Boolean,
default: () => false,
}
},
errors: Array | null
})
// emits: ['update:modelValue'],
Expand Down
Loading

0 comments on commit d2e2b73

Please sign in to comment.