Skip to content

Commit

Permalink
auto fixes + some impl.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Eichhorn committed Jan 26, 2024
1 parent 1952b38 commit aa76b13
Show file tree
Hide file tree
Showing 51 changed files with 1,230 additions and 2,037 deletions.
2 changes: 1 addition & 1 deletion Admin/Install/Navigation.install.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"type": 0,
"subtype": 1,
"name": "Tasks",
"uri": "{/base}/task/single?{?}",
"uri": "{/base}/task/view?{?}",
"target": "self",
"icon": null,
"order": 1,
Expand Down
2 changes: 1 addition & 1 deletion Admin/Install/SearchCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use phpOMS\Router\RouteVerb;

return [
'^:tag .*$' => [
'^:tag (\?.*$|$)' => [
[
'dest' => '\Modules\Tasks\Controller\SearchController:searchTag',
'verb' => RouteVerb::ANY,
Expand Down
2 changes: 1 addition & 1 deletion Admin/Install/attributes.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
{
{
"name": "category",
"l11n": {
"en": "Category",
Expand Down
39 changes: 39 additions & 0 deletions Admin/Install/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@
"foreignTable": "account",
"foreignKey": "account_id"
},
"task_for": {
"name": "task_for",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "account",
"foreignKey": "account_id"
},
"task_created_at": {
"name": "task_created_at",
"type": "DATETIME",
Expand All @@ -119,6 +127,11 @@
"type": "VARCHAR(255)",
"null": false
},
"task_attr_type_datatype": {
"name": "task_attr_type_datatype",
"type": "INT(11)",
"null": false
},
"task_attr_type_fields": {
"name": "task_attr_type_fields",
"type": "INT(11)",
Expand All @@ -134,6 +147,11 @@
"type": "TINYINT(1)",
"null": false
},
"task_attr_type_internal": {
"name": "task_attr_type_internal",
"type": "TINYINT(1)",
"null": false
},
"task_attr_type_required": {
"description": "Every task must have this attribute type if set to true.",
"name": "task_attr_type_required",
Expand Down Expand Up @@ -222,6 +240,22 @@
"name": "task_attr_value_unit",
"type": "VARCHAR(255)",
"null": false
},
"task_attr_value_deptype": {
"name": "task_attr_value_deptype",
"type": "INT(11)",
"null": true,
"default": null,
"foreignTable": "task_attr_type",
"foreignKey": "task_attr_type_id"
},
"task_attr_value_depvalue": {
"name": "task_attr_value_depvalue",
"type": "INT(11)",
"null": true,
"default": null,
"foreignTable": "task_attr_value",
"foreignKey": "task_attr_value_id"
}
}
},
Expand Down Expand Up @@ -386,6 +420,11 @@
"type": "TINYINT",
"null": false
},
"task_element_duration": {
"name": "task_element_duration",
"type": "INT",
"null": false
},
"task_element_due": {
"name": "task_element_due",
"type": "DATETIME",
Expand Down
25 changes: 13 additions & 12 deletions Admin/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Module\InstallerAbstract;
use phpOMS\Module\ModuleInfo;
use phpOMS\Uri\HttpUri;

/**
* Installer class.
Expand Down Expand Up @@ -74,21 +73,24 @@ private static function createTaskAttributeTypes(ApplicationAbstract $app, array
/** @var array<string, array> $taskAttrType */
$taskAttrType = [];

/** @var \Modules\Tasks\Controller\ApiController $module */
$module = $app->moduleManager->getModuleInstance('Tasks');
/** @var \Modules\Tasks\Controller\ApiAttributeController $module */
$module = $app->moduleManager->getModuleInstance('Tasks', 'ApiAttribute');

/** @var array $attribute */
foreach ($attributes as $attribute) {
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();

$request->header->account = 1;
$request->setData('name', $attribute['name'] ?? '');
$request->setData('title', \reset($attribute['l11n']));
$request->setData('language', \array_keys($attribute['l11n'])[0] ?? 'en');
$request->setData('repeatable', $attribute['repeatable'] ?? false);
$request->setData('internal', $attribute['internal'] ?? false);
$request->setData('is_required', $attribute['is_required'] ?? false);
$request->setData('custom', $attribute['is_custom_allowed'] ?? false);
$request->setData('validation_pattern', $attribute['validation_pattern'] ?? '');
$request->setData('datatype', (int) $attribute['value_type']);

$module->apiTaskAttributeTypeCreate($request, $response);

Expand All @@ -109,7 +111,7 @@ private static function createTaskAttributeTypes(ApplicationAbstract $app, array
}

$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();

$request->header->account = 1;
$request->setData('title', $l11n);
Expand Down Expand Up @@ -139,23 +141,22 @@ private static function createTaskAttributeValues(ApplicationAbstract $app, arra
/** @var array<string, array> $taskAttrValue */
$taskAttrValue = [];

/** @var \Modules\Tasks\Controller\ApiController $module */
$module = $app->moduleManager->getModuleInstance('Tasks');
/** @var \Modules\Tasks\Controller\ApiAttributeController $module */
$module = $app->moduleManager->getModuleInstance('Tasks', 'ApiAttribute');

foreach ($attributes as $attribute) {
$taskAttrValue[$attribute['name']] = [];

/** @var array $value */
foreach ($attribute['values'] as $value) {
$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();

$request->header->account = 1;
$request->setData('value', $value['value'] ?? '');
$request->setData('value_type', $attribute['value_type'] ?? 0);
$request->setData('unit', $value['unit'] ?? '');
$request->setData('default', isset($attribute['values']) && !empty($attribute['values']));
$request->setData('attributetype', $taskAttrType[$attribute['name']]['id']);
$request->setData('default',true);
$request->setData('type', $taskAttrType[$attribute['name']]['id']);

if (isset($value['l11n']) && !empty($value['l11n'])) {
$request->setData('title', \reset($value['l11n']));
Expand Down Expand Up @@ -183,7 +184,7 @@ private static function createTaskAttributeValues(ApplicationAbstract $app, arra
}

$response = new HttpResponse();
$request = new HttpRequest(new HttpUri(''));
$request = new HttpRequest();

$request->header->account = 1;
$request->setData('title', $l11n);
Expand Down
2 changes: 1 addition & 1 deletion Admin/Routes/Web/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
],
],
],
'^.*/task/element.*$' => [
'^.*/task/element(\?.*$|$)' => [
[
'dest' => '\Modules\Tasks\Controller\ApiController:apiTaskElementCreate',
'verb' => RouteVerb::PUT,
Expand Down
8 changes: 4 additions & 4 deletions Admin/Routes/Web/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use phpOMS\Router\RouteVerb;

return [
'^.*/task/dashboard.*$' => [
'^.*/task/dashboard(\?.*$|$)' => [
[
'dest' => '\Modules\Tasks\Controller\BackendController:viewTaskDashboard',
'verb' => RouteVerb::GET,
Expand All @@ -29,7 +29,7 @@
],
],
],
'^.*/task/single.*$' => [
'^.*/task/view(\?.*$|$)' => [
[
'dest' => '\Modules\Tasks\Controller\BackendController:viewTaskView',
'verb' => RouteVerb::GET,
Expand All @@ -40,7 +40,7 @@
],
],
],
'^.*/task/create.*$' => [
'^.*/task/create(\?.*$|$)' => [
[
'dest' => '\Modules\Tasks\Controller\BackendController:viewTaskCreate',
'verb' => RouteVerb::GET,
Expand All @@ -51,7 +51,7 @@
],
],
],
'^.*/task/analysis.*$' => [
'^.*/task/analysis(\?.*$|$)' => [
[
'dest' => '\Modules\Tasks\Controller\BackendController:viewTaskAnalysis',
'verb' => RouteVerb::GET,
Expand Down
Loading

0 comments on commit aa76b13

Please sign in to comment.