Skip to content

Commit

Permalink
Story /issues/452
Browse files Browse the repository at this point in the history
  • Loading branch information
SMEWebify committed Jul 12, 2024
1 parent 8cc1ddc commit 4e07992
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 52 deletions.
26 changes: 19 additions & 7 deletions app/Http/Controllers/Planning/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use App\Models\Planning\SubAssembly;
use Illuminate\Support\Facades\Auth;
use App\Models\Planning\TaskResources;
use App\Models\Methods\MethodsServices;
use App\Models\Planning\TaskActivities;
use App\Models\Methods\MethodsStandardNomenclature;

Expand Down Expand Up @@ -76,14 +77,25 @@ public function manage($id_type, $id_page, $id_line)
/**
* @return \Illuminate\Contracts\View\View
*/
public function kanban()
public function kanban(Request $request)
{
$tasks = Status::where('title', '!=', 'Supplied')
->orderBy('order', 'ASC')
->with('tasks.OrderLines.order')
->with('tasks.service')
->get();
return view('workflow/kanban-index', compact('tasks'));
// Retrieve services
$services = MethodsServices::all();

// Initialize the task query
$tasksQuery = Status::where('title', '!=', 'Supplied')
->orderBy('order', 'ASC')
->with(['tasks' => function ($query) use ($request) {
// Filter tasks by methods_services_id if provided
if ($request->has('methods_services_id') && !empty($request->input('methods_services_id'))) {
$query->where('tasks.methods_services_id', $request->input('methods_services_id'));
}
}, 'tasks.OrderLines.order', 'tasks.service']);

// Retrieve filtered tasks
$tasks = $tasksQuery->get();

return view('workflow/kanban-index', compact('tasks', 'services'));
}

/**
Expand Down
72 changes: 28 additions & 44 deletions resources/js/components/KanbanBoard.vue
Original file line number Diff line number Diff line change
@@ -1,52 +1,40 @@
<template>
<div class="row">
<!-- Columns (Statuses) -->
<div v-for="status in statuses" :key="status.title" class="col-12 col-lg-6 col-xl-3" >
<div v-for="status in statuses" :key="status.title" class="col-12 col-lg-6 col-xl-3">
<div class="card">
<div class="card-header bg-blue">
<h5 >
{{ status.title }}
</h5>
<h5>{{ status.title }}</h5>
</div>
<div class="card-body p-3">
<!-- Tasks -->
<draggable class="flex-1 overflow-hidden" v-model="status.tasks" v-bind="taskDragOptions" @end="handleTaskMoved" >
<transition-group class="flex-1 flex flex-col h-full overflow-x-hidden overflow-y-auto rounded shadow-xs" tag="div" >
<div v-for="task in status.tasks" :key="task.id" class="card mb-5 bg-light" >
<div class="card-body p-3 ">
<a :href="'/production/Task/Statu/Id/' + task.id ">
#{{ task.id }}
</a>
-
<span class="font-weight-bold">
<a :href="'/orders/' + task.order_lines.orders_id">
{{ task.order_lines.order.code }}
</a>
</span> - {{ task.label }} - {{ task.order_lines.delivery_date }}<br/>
<span class="font-weight-bold">{{ task.order_lines.label }} || qty {{ task.order_lines.qty }}</span><br/>
<div class="float-right">
<div class="row">
<div class="col-4">
<img v-if="task.service.picture" :src="'/images/methods/'+task.service.picture" class="profile-user-img img-fluid img-circle" >
</div>
<div class="col-8">
<span class="font-weight-bold">Setting Time :</span> {{ task.seting_time }}<br/>
<span class="font-weight-bold">Unit Time :</span> {{ task.unit_time }}
</div>
<!-- <div class="col-4">
<span class="font-weight-bold">Advancement :</span> {{ task.progress }}
</div>-->
<draggable class="flex-1 overflow-hidden" v-model="status.tasks" v-bind="taskDragOptions" @end="handleTaskMoved">
<transition-group class="flex-1 flex flex-col h-full overflow-x-hidden overflow-y-auto rounded shadow-xs" tag="div">
<div v-for="task in status.tasks" :key="task.id" class="card mb-5 bg-light">
<div class="card-body p-3">
<a :href="'/production/Task/Statu/Id/' + task.id">#{{ task.id }}</a> -
<span class="font-weight-bold">
<a :href="'/orders/' + task.order_lines.orders_id">{{ task.order_lines.order.code }}</a>
</span> - {{ task.label }} - {{ task.order_lines.delivery_date }}<br/>
<span class="font-weight-bold">{{ task.order_lines.label }} || qty {{ task.order_lines.qty }}</span><br/>
<div class="float-right">
<div class="row">
<div class="col-4">
<img v-if="task.service.picture" :src="'/images/methods/'+task.service.picture" class="profile-user-img img-fluid img-circle">
</div>
<div class="col-8">
<span class="font-weight-bold">Setting Time :</span> {{ task.seting_time }}<br/>
<span class="font-weight-bold">Unit Time :</span> {{ task.unit_time }}
</div>
</div>
<!-- <a class="btn btn-outline-primary btn-sm" href="#">View</a>-->
</div>
</div>
</div>
<!-- ./Tasks -->
</transition-group>
</draggable>
<!-- No Tasks -->
<div v-show="!status.tasks.length && newTaskForStatus !== status.id" class="flex-1 p-4 flex flex-col items-center justify-center" >
<span class="text-gray-600">No tasks yet</span>
<div v-show="!status.tasks.length && newTaskForStatus !== status.id" class="flex-1 p-4 flex flex-col items-center justify-center">
<span class="text-gray-600">No tasks yet</span>
</div>
<!-- ./No Tasks -->
</div>
Expand All @@ -61,11 +49,14 @@ import draggable from "vuedraggable";
export default {
components: { draggable },
props: {
initialData: Array
initialData: {
type: Array,
required: true
}
},
data() {
return {
statuses: [],
statuses: this.initialData || [],
newTaskForStatus: 0
};
},
Expand All @@ -78,14 +69,7 @@ export default {
};
}
},
mounted() {
// 'clone' the statuses so we don't alter the prop when making changes
this.statuses = JSON.parse(JSON.stringify(this.initialData));
},
methods: {
closeAddTaskForm() {
this.newTaskForStatus = 0;
},
handleTaskMoved(evt) {
axios.put("/task/sync", { columns: this.statuses }).catch(err => {
console.log(err.response);
Expand All @@ -100,4 +84,4 @@ export default {
transition: transform 0.5s;
transition-property: all;
}
</style>
</style>
19 changes: 18 additions & 1 deletion resources/views/workflow/kanban-index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,24 @@

@section('content')
<x-InfocalloutComponent note="{{ __('general_content.workflow_info_1_trans_key') }}" />
<div id="card" >

<!-- Formulaire de sélection du service -->
<form method="GET" action="{{ route('production.kanban') }}" class="mb-4">
<div class="form-group">
<label for="methods_services_id">Select Service:</label>
<select name="methods_services_id" id="methods_services_id" class="form-control">
<option value="">All Services</option>
@foreach($services as $service)
<option value="{{ $service->id }}" {{ request()->input('methods_services_id') == $service->id ? 'selected' : '' }}>
{{ $service->label }}
</option>
@endforeach
</select>
</div>
<button type="submit" class="btn btn-primary">Filter</button>
</form>

<div id="card">
<kanban-board :initial-data="{{ $tasks }}"></kanban-board>
</div>
@stop
Expand Down

0 comments on commit 4e07992

Please sign in to comment.