Skip to content

Commit 5f146ce

Browse files
committed
Fixed drag & drop on boards
1 parent d7dc59d commit 5f146ce

File tree

10 files changed

+85370
-36
lines changed

10 files changed

+85370
-36
lines changed

database/migrations/add_pipeline_order_to_laravel_crm_tables.php.stub

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,25 @@ return new class extends Migration
1313
*/
1414
public function up()
1515
{
16-
Schema::table(config('laravel-crm.db_table_prefix').'quote_products', function (Blueprint $table) {
16+
Schema::table(config('laravel-crm.db_table_prefix').'leads', function (Blueprint $table) {
1717
$table->integer('pipeline_stage_order')->nullable()->after('pipeline_stage_id');
1818
});
19-
20-
Schema::table(config('laravel-crm.db_table_prefix').'order_products', function (Blueprint $table) {
19+
Schema::table(config('laravel-crm.db_table_prefix').'deals', function (Blueprint $table) {
2120
$table->integer('pipeline_stage_order')->nullable()->after('pipeline_stage_id');
2221
});
23-
24-
Schema::table(config('laravel-crm.db_table_prefix').'invoice_lines', function (Blueprint $table) {
22+
Schema::table(config('laravel-crm.db_table_prefix').'quotes', function (Blueprint $table) {
2523
$table->integer('pipeline_stage_order')->nullable()->after('pipeline_stage_id');
2624
});
27-
28-
Schema::table(config('laravel-crm.db_table_prefix').'delivery_products', function (Blueprint $table) {
25+
Schema::table(config('laravel-crm.db_table_prefix').'orders', function (Blueprint $table) {
2926
$table->integer('pipeline_stage_order')->nullable()->after('pipeline_stage_id');
3027
});
31-
32-
Schema::table(config('laravel-crm.db_table_prefix').'purchase_order_lines', function (Blueprint $table) {
28+
Schema::table(config('laravel-crm.db_table_prefix').'invoices', function (Blueprint $table) {
29+
$table->integer('pipeline_stage_order')->nullable()->after('pipeline_stage_id');
30+
});
31+
Schema::table(config('laravel-crm.db_table_prefix').'deliveries', function (Blueprint $table) {
32+
$table->integer('pipeline_stage_order')->nullable()->after('pipeline_stage_id');
33+
});
34+
Schema::table(config('laravel-crm.db_table_prefix').'purchase_orders', function (Blueprint $table) {
3335
$table->integer('pipeline_stage_order')->nullable()->after('pipeline_stage_id');
3436
});
3537
}
@@ -41,23 +43,25 @@ return new class extends Migration
4143
*/
4244
public function down()
4345
{
44-
Schema::table(config('laravel-crm.db_table_prefix').'quote_products', function (Blueprint $table) {
46+
Schema::table(config('laravel-crm.db_table_prefix').'leads', function (Blueprint $table) {
4547
$table->dropColumn('pipeline_stage_order');
4648
});
47-
48-
Schema::table(config('laravel-crm.db_table_prefix').'order_products', function (Blueprint $table) {
49+
Schema::table(config('laravel-crm.db_table_prefix').'deals', function (Blueprint $table) {
4950
$table->dropColumn('pipeline_stage_order');
5051
});
51-
52-
Schema::table(config('laravel-crm.db_table_prefix').'invoice_lines', function (Blueprint $table) {
53-
$table->dropColumn('pipeline_stage_order');;
52+
Schema::table(config('laravel-crm.db_table_prefix').'quotes', function (Blueprint $table) {
53+
$table->dropColumn('pipeline_stage_order');
5454
});
55-
56-
Schema::table(config('laravel-crm.db_table_prefix').'delivery_products', function (Blueprint $table) {
55+
Schema::table(config('laravel-crm.db_table_prefix').'orders', function (Blueprint $table) {
5756
$table->dropColumn('pipeline_stage_order');
5857
});
59-
60-
Schema::table(config('laravel-crm.db_table_prefix').'purchase_order_lines', function (Blueprint $table) {
58+
Schema::table(config('laravel-crm.db_table_prefix').'invoices', function (Blueprint $table) {
59+
$table->dropColumn('pipeline_stage_order');
60+
});
61+
Schema::table(config('laravel-crm.db_table_prefix').'deliveries', function (Blueprint $table) {
62+
$table->dropColumn('pipeline_stage_order');
63+
});
64+
Schema::table(config('laravel-crm.db_table_prefix').'purchase_orders', function (Blueprint $table) {
6165
$table->dropColumn('pipeline_stage_order');
6266
});
6367
}

resources/assets/css/app.css

Lines changed: 10071 additions & 8 deletions
Large diffs are not rendered by default.

resources/assets/css/document.css

Lines changed: 9266 additions & 1 deletion
Large diffs are not rendered by default.

resources/assets/js/app.js

Lines changed: 65983 additions & 2 deletions
Large diffs are not rendered by default.

resources/sass/app.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
// Trix
2929
@import "~trix/dist/trix.css";
3030

31-
// Custom
31+
// Custom
3232
@import "custom";
3333

3434
// Portal

resources/views/layouts/app.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
1919

2020
<!-- Styles -->
21-
<link href="{{ asset('vendor/laravel-crm/css/app.css') }}?v=9096565677680" rel="stylesheet">
21+
<link href="{{ asset('vendor/laravel-crm/css/app.css') }}?v=5468797097856746" rel="stylesheet">
2222

2323
@livewireStyles
2424

@@ -82,7 +82,7 @@
8282
</div>
8383
</footer>
8484
</div>
85-
<script src="{{ asset('vendor/laravel-crm/js/app.js') }}?v=53156542375858"></script>
85+
<script src="{{ asset('vendor/laravel-crm/js/app.js') }}?v=5468797097856746"></script>
8686
<script src="{{ asset('vendor/laravel-crm/libs/bootstrap-multiselect/bootstrap-multiselect.min.js') }}"></script>
8787
<script src="https://cdn.jsdelivr.net/npm/bs-custom-file-input/dist/bs-custom-file-input.min.js"></script>
8888
@livewireScripts

resources/views/livewire/kanban-board/board.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div>
22
<div class="container-fluid mt-3">
3-
<div class="row flex-row flex-sm-nowrap py-3">
3+
<div wire:ignore class="row flex-row flex-sm-nowrap py-3">
44
@foreach($stages as $stage)
55
@include('laravel-crm::livewire.kanban-board.stage', [
66
'stage' => $stage

src/Http/Controllers/LeadController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ public function board(Request $request)
428428
Lead::resetSearchValue($request);
429429
$params = Lead::filters($request);
430430

431-
$leads = Lead::filter($params)->whereNull('converted_at')->latest()->get();
431+
$leads = Lead::filter($params)->whereNull('converted_at')->orderBy('pipeline_stage_order')->oldest()->get();
432432

433433
return view('laravel-crm::leads.board', [
434434
'leads' => $leads,

src/Http/Livewire/LiveDealBoard.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,32 @@ public function stages(): Collection
2323
}
2424
}
2525

26+
public function onStageSorted($orderedIds)
27+
{
28+
foreach ($orderedIds as $orderNumber => $dealId) {
29+
Deal::find($dealId)->update([
30+
'pipeline_stage_order' => $orderNumber + 1,
31+
]);
32+
}
33+
}
34+
2635
public function onStageChanged($recordId, $stageId, $fromOrderedIds, $toOrderedIds)
2736
{
2837
Deal::find($recordId)->update([
2938
'pipeline_stage_id' => $stageId
3039
]);
40+
41+
foreach ($fromOrderedIds as $orderNumber => $dealId) {
42+
Deal::find($dealId)->update([
43+
'pipeline_stage_order' => $orderNumber + 1,
44+
]);
45+
}
46+
47+
foreach ($toOrderedIds as $orderNumber => $dealId) {
48+
Deal::find($dealId)->update([
49+
'pipeline_stage_order' => $orderNumber + 1,
50+
]);
51+
}
3152
}
3253

3354
public function records(): Collection

src/Http/Livewire/LiveLeadBoard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function onStageSorted($orderedIds)
3535
public function onStageChanged($recordId, $stageId, $fromOrderedIds, $toOrderedIds)
3636
{
3737
Lead::find($recordId)->update([
38-
'pipeline_stage_id' => $stageId
38+
'pipeline_stage_id' => $stageId,
3939
]);
4040

4141
foreach ($fromOrderedIds as $orderNumber => $leadId) {

0 commit comments

Comments
 (0)