add todos and improve db schema

This commit is contained in:
Dennis Eichhorn 2020-01-01 21:05:12 +01:00
parent 1b70ddce75
commit 401ca50d2c
3 changed files with 55 additions and 150 deletions

View File

@ -340,43 +340,6 @@
}
}
},
"country": {
"name": "country",
"fields": {
"country_id": {
"name": "country_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"country_name": {
"name": "country_name",
"type": "VARCHAR(100)",
"null": false
},
"country_native": {
"name": "country_native",
"type": "VARCHAR(100)",
"null": false
},
"country_code2": {
"name": "country_code2",
"type": "VARCHAR(2)",
"null": false
},
"country_code3": {
"name": "country_code3",
"type": "VARCHAR(3)",
"null": false
},
"country_codenum": {
"name": "country_codenum",
"type": "INT(11)",
"null": false
}
}
},
"account": {
"name": "account",
"fields": {
@ -568,36 +531,6 @@
}
}
},
"account_settings": {
"name": "account_settings",
"fields": {
"account_settings_id": {
"name": "account_settings_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"account_settings_name": {
"name": "account_settings_name",
"type": "VARCHAR(30)",
"null": false,
"unique": true
},
"account_settings_content": {
"name": "account_settings_content",
"type": "VARCHAR(250)",
"null": false
},
"account_settings_account": {
"name": "account_settings_account",
"type": "INT",
"null": false,
"foreignTable": "account",
"foreignKey": "account_id"
}
}
},
"settings": {
"name": "settings",
"fields": {
@ -635,6 +568,14 @@
"null": true,
"foreignTable": "group",
"foreignKey": "group_id"
},
"settings_account": {
"name": "settings_account",
"type": "INT",
"default": null,
"null": true,
"foreignTable": "account",
"foreignKey": "account_id"
}
}
}

View File

@ -17,6 +17,7 @@ namespace Modules\Admin\Admin;
use phpOMS\DataStorage\Database\Connection\SQLiteConnection;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\DataStorage\Database\Query\Builder;
use phpOMS\Module\InfoManager;
use phpOMS\Module\InstallerAbstract;
@ -43,47 +44,11 @@ final class Installer extends InstallerAbstract
'database' => __DIR__ . '/../../../phpOMS/Localization/Defaults/localization.sqlite'
]);
self::installCountries($sqlite, $dbPool);
self::installLanguages($sqlite, $dbPool);
$sqlite->close();
}
/**
* Install countries
*
* @param SQLiteConnection $sqlite SQLLite database connection of the source data
* @param DatabasePool $dbPool Database pool to save data to
*
* @return void
*
* @since 1.0.0
*/
private static function installCountries(SQLiteConnection $sqlite, DatabasePool $dbPool) : void
{
$con = $dbPool->get();
$query = new Builder($con);
$query->prefix($con->getPrefix())
->insert('country_name', 'country_native', 'country_code2', 'country_code3', 'country_codenum')
->into('country');
$querySqlite = new Builder($sqlite);
$countries = $querySqlite->select('*')->from('country')->execute();
foreach ($countries as $country) {
$query->values(
$country['country_name'],
$country['country_name'],
$country['country_code2'],
$country['country_code3'],
$country['country_numeric']
);
}
$query->execute();
}
/**
* Install languages
*

View File

@ -1,48 +1,47 @@
<template id="group-selector-tpl">
<section id="group-selector" class="box w-50" style="z-index: 9; position: absolute; margin: 0 auto; left: 50%; top: 50%; transform: translate(-50%, -50%);">
<header><h1><?= $this->getHtml('Group', 'Admin') ?></h1></header>
<div class="inner">
<label for="iSearchGroup">Search</label>
<input type="text" id="iSearchGroup" name="receiver-search" data-action='[
{
"key": 1, "listener": "keyup", "action": [
{"key": 1, "type": "utils.timer", "id": "iSearchGroup", "delay": 500, "resets": true},
{"key": 2, "type": "dom.table.clear", "id": "acc-table"},
{"key": 3, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/group?search={#iSearchGroup}", "method": "GET", "request_type": "json"},
{"key": 4, "type": "dom.table.append", "id": "acc-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}
]
}
]' autocomplete="off">
<table id="acc-table" class="table">
<thead>
<tr>
<th data-name="id">ID
<th data-name="name">Name
<th data-name="address">Address
<th data-name="city">City
<th data-name="zip">Zip
<th data-name="country">Country
<!-- todo: get data from tr in action and pass it to next actions, or make new request based on table cell? -->
<tbody data-action='[
{
"key": 1, "listener": "click", "selector": "#acc-table tbody tr", "action": [
{"key": 1, "type": "dom.getvalue", "base": "self", "selector": ""},
{"key": 2, "type": "dom.setvalue", "overwrite": false, "selector": "#{$id}-idlist", "value": "{0/id}", "data": ""},
{"key": 3, "type": "dom.setvalue", "overwrite": false, "selector": "#{$id}-taglist", "value": "<span id=\"{$id}-taglist-{0/id}\" class=\"tag red\" data-id=\"{0/id}\"><i class=\"fa fa-times\"></i> {0/name/0}, {0/name/1}<span>", "data": ""},
{"key": 4, "type": "dom.setvalue", "overwrite": true, "selector": "#{$id}", "value": "", "data": ""}
]
}
]'>
<tfoot>
</table>
<button type="button" id="iSearchGroup-close" data-action='[
{
"key": 1, "listener": "click", "action": [
{"key": 1, "type": "dom.remove", "selector": "#group-selector", "aniOut": "fadeOut"}
]
}
]'><?= $this->getHtml('Close', 'Admin') ?></button>
</div>
</section>
<template id="group-selector-tpl">
<section id="group-selector" class="box w-50" style="z-index: 9; position: absolute; margin: 0 auto; left: 50%; top: 50%; transform: translate(-50%, -50%);">
<header><h1><?= $this->getHtml('Group', 'Admin') ?></h1></header>
<div class="inner">
<label for="iSearchGroup">Search</label>
<input type="text" id="iSearchGroup" name="receiver-search" data-action='[
{
"key": 1, "listener": "keyup", "action": [
{"key": 1, "type": "utils.timer", "id": "iSearchGroup", "delay": 500, "resets": true},
{"key": 2, "type": "dom.table.clear", "id": "acc-table"},
{"key": 3, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/group?search={#iSearchGroup}", "method": "GET", "request_type": "json"},
{"key": 4, "type": "dom.table.append", "id": "acc-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}
]
}
]' autocomplete="off">
<table id="acc-table" class="table">
<thead>
<tr>
<th data-name="id">ID
<th data-name="name">Name
<th data-name="address">Address
<th data-name="city">City
<th data-name="zip">Zip
<th data-name="country">Country
<tbody data-action='[
{
"key": 1, "listener": "click", "selector": "#acc-table tbody tr", "action": [
{"key": 1, "type": "dom.getvalue", "base": "self", "selector": ""},
{"key": 2, "type": "dom.setvalue", "overwrite": false, "selector": "#{$id}-idlist", "value": "{0/id}", "data": ""},
{"key": 3, "type": "dom.setvalue", "overwrite": false, "selector": "#{$id}-taglist", "value": "<span id=\"{$id}-taglist-{0/id}\" class=\"tag red\" data-id=\"{0/id}\"><i class=\"fa fa-times\"></i> {0/name/0}, {0/name/1}<span>", "data": ""},
{"key": 4, "type": "dom.setvalue", "overwrite": true, "selector": "#{$id}", "value": "", "data": ""}
]
}
]'>
<tfoot>
</table>
<button type="button" id="iSearchGroup-close" data-action='[
{
"key": 1, "listener": "click", "action": [
{"key": 1, "type": "dom.remove", "selector": "#group-selector", "aniOut": "fadeOut"}
]
}
]'><?= $this->getHtml('Close', 'Admin') ?></button>
</div>
</section>
</template>