Skip to content

Commit

Permalink
Merge pull request #1426 from bakaphp/feat-task-list
Browse files Browse the repository at this point in the history
feat: task list
  • Loading branch information
kaioken authored Jun 8, 2024
2 parents 6a44c7b + ef588ca commit 1e04439
Show file tree
Hide file tree
Showing 15 changed files with 214 additions and 26 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"Kanvas\\Souk\\": "src/Domains/Souk",
"Kanvas\\Workflow\\": "src/Domains/Workflow",
"Kanvas\\Connectors\\": "src/Domains/Connectors",
"Kanvas\\ActionEngine\\": "src/Domains/ActionEngine",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
Expand Down
36 changes: 18 additions & 18 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('company_task_list', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->index();
$table->bigInteger('apps_id')->index();
$table->bigInteger('companies_id')->index();
$table->bigInteger('users_id')->index();
$table->string('name');
$table->json('config')->nullable();
$table->timestamps();
$table->tinyInteger('is_deleted')->default(0)->index();
});

Schema::create('company_task_list_items', function (Blueprint $table) {
$table->id();
$table->foreignId('task_list_id')->constrained('company_task_list')->onDelete('cascade');
$table->string('name');
$table->bigInteger('companies_action_id')->index();
$table->enum('status', ['pending', 'in_progress', 'completed'])->default('pending')->comment('pending, in_progress, completed')->index();
$table->json('config')->nullable();
$table->decimal('weight', 8, 2)->default(0)->index();
$table->timestamps();
$table->tinyInteger('is_deleted')->default(0)->index();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('company_task_list');
Schema::dropIfExists('company_task_list_items');
}
};
1 change: 1 addition & 0 deletions graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ scalar Null @scalar(class: "MLL\\GraphQLScalars\\NullScalar")
#import schemas/Social/*.graphql
#import schemas/ContentEngine/*.graphql
#import schemas/Souk/*.graphql
#import schemas/ActionEngine/*.graphql
#import schemas/Ecosystem/Admin/*.graphql
30 changes: 30 additions & 0 deletions graphql/schemas/ActionEngine/action.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
type Action {
id: ID!
name: String!
slug: String!
description: String
icon: String
form_fields: Mixed
form_config: Mixed
is_active: Boolean!
is_published: Boolean!
collects_info: Boolean!
config: Mixed
parent: Action
children: [Action!]
}

type CompanyAction {
id: ID!
action: Action!
company: Company!
name: String!
description: String
form_config: Mixed
status: String!
is_active: Boolean!
is_published: Boolean!
weight: Float!
parent: CompanyAction
children: [CompanyAction!]
}
27 changes: 27 additions & 0 deletions graphql/schemas/ActionEngine/task.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
type TaskList {
id: ID!
name: String!
company: Company!
config: Mixed
tasks: [TaskListItem!] @hasMany
}

type TaskListItem {
id: ID!
name: String!
status: String!
due_date: Date
completed_date: Date
config: Mixed
action: CompanyAction!
weight: Float!
}

extend type Query @guard {
leadTaskList (lead_id: ID!): [TaskList!]!
@paginate(
model: "Kanvas\\ActionEngine\\Tasks\\Models\\TaskList"
scopes: ["fromApp", "fromCompany"]
defaultCount: 25
)
}
2 changes: 1 addition & 1 deletion src/Domains/ActionEngine/Actions/Models/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Domains\ActionEngine\Actions\Models;
namespace Kanvas\ActionEngine\Actions\Models;

use Baka\Traits\UuidTrait;
use Kanvas\ActionEngine\Models\BaseModel;
Expand Down
2 changes: 1 addition & 1 deletion src/Domains/ActionEngine/Actions/Models/CompanyAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Domains\ActionEngine\Actions\Models;
namespace Kanvas\ActionEngine\Actions\Models;

use Baka\Traits\UuidTrait;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down
4 changes: 2 additions & 2 deletions src/Domains/ActionEngine/Engagegments/Models/Engagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace Domains\ActionEngine\Engagements\Models;
namespace Kanvas\ActionEngine\Engagements\Models;

use Baka\Traits\UuidTrait;
use Domains\ActionEngine\Actions\Models\CompanyAction;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Kanvas\ActionEngine\Actions\Models\CompanyAction;
use Kanvas\ActionEngine\Models\BaseModel;
use Kanvas\Guild\Customers\Models\People;
use Kanvas\Guild\Leads\Models\Lead;
Expand Down
2 changes: 1 addition & 1 deletion src/Domains/ActionEngine/Pipelines/Models/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Domains\ActionEngine\Pipelines\Models;
namespace Kanvas\ActionEngine\Pipelines\Models;

use Baka\Traits\UuidTrait;
use Illuminate\Database\Eloquent\Relations\HasMany;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Domains\ActionEngine\Pipelines\Models;
namespace Kanvas\ActionEngine\Pipelines\Models;

use Baka\Traits\UuidTrait;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Domains\ActionEngine\Pipelines\Models;
namespace Kanvas\ActionEngine\Pipelines\Models;

use Baka\Traits\UuidTrait;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down
38 changes: 38 additions & 0 deletions src/Domains/ActionEngine/Tasks/Models/TaskList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace Kanvas\ActionEngine\Tasks\Models;

use Baka\Casts\Json;
use Baka\Traits\UuidTrait;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Kanvas\ActionEngine\Models\BaseModel;

/**
* Class Tasks.
*
* @property int $id
* @property string $uuid
* @property int $apps_id
* @property int $companies_id
* @property int $users_id
* @property string $name
* @property string $config
*/
class TaskList extends BaseModel
{
use UuidTrait;

protected $table = 'company_task_list';
protected $guarded = [];

protected $casts = [
'config' => Json::class,
];

public function tasks(): HasMany
{
return $this->hasMany(TaskListItem::class, 'task_list_id')->orderBy('weight');
}
}
44 changes: 44 additions & 0 deletions src/Domains/ActionEngine/Tasks/Models/TaskListItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

namespace Kanvas\ActionEngine\Tasks\Models;

use Baka\Casts\Json;
use Baka\Traits\UuidTrait;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Kanvas\ActionEngine\Actions\Models\CompanyAction;
use Kanvas\ActionEngine\Models\BaseModel;

/**
* Class Tasks.
*
* @property int $id
* @property int $task_list_id
* @property int $companies_action_id
* @property string $name
* @property string $config
* @property string $status
* @property float $weight
*/
class TaskListItem extends BaseModel
{
use UuidTrait;

protected $table = 'company_task_list_items';
protected $guarded = [];

protected $casts = [
'config' => Json::class,
];

public function task(): BelongsTo
{
return $this->belongsTo(TaskList::class, 'task_list_id');
}

public function action(): BelongsTo
{
return $this->belongsTo(CompanyAction::class, 'companies_action_id');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public function execute(Users $user, Apps $app, array $params): array
];

$customer = $client->Customer->post($customer);
$shopifyUserKey = CustomFieldEnum::USER_SHOPIFY_ID->value . '-' . $app->getId();
//$shopifyUserKey = CustomFieldEnum::USER_SHOPIFY_ID->value . '-' . $app->getId();
$shopifyUserKey = CustomFieldEnum::USER_SHOPIFY_ID->value;
$user->set($shopifyUserKey, $customer['id']);

return [
Expand Down

0 comments on commit 1e04439

Please sign in to comment.