From: Hamatoma Date: Sat, 23 Oct 2021 08:33:05 +0000 (+0200) Subject: Refactoring, new module starters X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=e4e8aede49a61ed8477fa0178666ceb06867d745;p=exhibition.git Refactoring, new module starters * Refactoring: ** UserMeta renamed to UsersMeta (filename-classname convention) ** Fields renamed: changed -> changedAt, created -> createdAt ** ListMetaPage: new: toolTipAddButton --- diff --git a/lib/meta/benchmarks_meta.dart b/lib/meta/benchmarks_meta.dart index 39a21e2..b2d2ee7 100644 --- a/lib/meta/benchmarks_meta.dart +++ b/lib/meta/benchmarks_meta.dart @@ -5,12 +5,12 @@ import 'module_meta_data.dart'; final i18n = I18N(); final M = i18n.module("Benchmarks"); -class BenchmarkMeta extends ModuleMetaData { - static BenchmarkMeta instance = BenchmarkMeta.internal(); - factory BenchmarkMeta() { +class BenchmarksMeta extends ModuleMetaData { + static BenchmarksMeta instance = BenchmarksMeta.internal(); + factory BenchmarksMeta() { return instance; } - BenchmarkMeta.internal() + BenchmarksMeta.internal() : super('Benchmarks', [ PropertyMetaData('id', i18n.tr('Id'), DataType.reference, ':primary:', displayType: DisplayType.combobox), @@ -30,13 +30,13 @@ class BenchmarkMeta extends ModuleMetaData { displayType: DisplayType.switchWidget), PropertyMetaData('weight', i18n.tr('Weight'), DataType.float, ''), PropertyMetaData('income', i18n.tr('Income'), DataType.currency, ''), - PropertyMetaData( - 'created', i18n.tr('Created'), DataType.datetime, ':hidden:'), + PropertyMetaData('createdAt', i18n.tr('Created at'), + DataType.datetime, ':hidden:'), PropertyMetaData( 'createdBy', i18n.tr('Created by'), DataType.string, ':hidden:', size: 32), - PropertyMetaData( - 'changed', i18n.tr('Changed'), DataType.datetime, ':hidden:'), + PropertyMetaData('changedAt', i18n.tr('Changed at'), + DataType.datetime, ':hidden:'), PropertyMetaData( 'changedBy', i18n.tr('Changed by'), DataType.string, ':hidden:', size: 32), @@ -44,17 +44,17 @@ class BenchmarkMeta extends ModuleMetaData { PageMetaData( 'New Benchmark', PageType.create, - fields: [CopyDbFields('filters')], + fields: [CopyDbFields('fields')], ), PageMetaData( 'Change Benchmark', PageType.edit, - fields: [CopyDbFields('filters')], + fields: [CopyDbFields('fields')], ), PageMetaData( 'Delete Benchmark', PageType.delete, - fields: [CopyDbFields('filters')], + fields: [CopyDbFields('fields')], ), ListPageMetaData( 'Benchmarks Overview', @@ -63,6 +63,7 @@ class BenchmarkMeta extends ModuleMetaData { 'text', i18n.tr('Text'), DataType.string, ':pattern:', size: 64), ], + toolTipAddButton: i18n.tr('Add a benchmark item'), tableColumns: 'benchmark_id;benchmark_lastname;benchmark_firstname;benchmark_birthday;benchmark_active;benchmark_income', tableHeaders: diff --git a/lib/meta/module_meta_data.dart b/lib/meta/module_meta_data.dart index 1a65781..659d488 100644 --- a/lib/meta/module_meta_data.dart +++ b/lib/meta/module_meta_data.dart @@ -56,6 +56,7 @@ class ListPageMetaData extends PageMetaData { final String selectItems; final String joinItems; final String widgetsBelowFilter; + final String toolTipAddButton; /// Constructor. /// @@ -98,7 +99,8 @@ class ListPageMetaData extends PageMetaData { this.orderBy = '', this.selectItems = '', this.joinItems = '', - this.widgetsBelowFilter = ''}) + this.widgetsBelowFilter = '', + this.toolTipAddButton = ''}) : super(label, PageType.list, name: name, fields: fields, globalComboBoxes: globalComboBoxes); } @@ -108,11 +110,11 @@ class MetaException extends FormatException {} /// Stores the meta data of a module. class ModuleMetaData { static final metaColumns = [ - 'created', + 'createdAt', 'createdBy', - 'changed', + 'changedAt', 'changedBy', - 'deleted', + 'deletedAt', 'deletedBy' ]; diff --git a/lib/meta/modules.dart b/lib/meta/modules.dart index 10f555e..13cd8da 100644 --- a/lib/meta/modules.dart +++ b/lib/meta/modules.dart @@ -2,6 +2,7 @@ import 'module_meta_data.dart'; import 'benchmarks_meta.dart'; import 'roles_meta.dart'; +import 'starters_meta.dart'; import 'structures_meta.dart'; import 'users_meta.dart'; @@ -11,16 +12,19 @@ ModuleMetaData? moduleByName(String name) { ModuleMetaData? rc; switch (name) { case 'Benchmarks': - rc = BenchmarkMeta(); + rc = BenchmarksMeta(); break; case 'Roles': - rc = RoleMeta(); + rc = RolesMeta(); + break; + case 'Starters': + rc = StartersMeta(); break; case 'Structures': - rc = StructureMeta(); + rc = StructuresMeta(); break; case 'Users': - rc = UserMeta(); + rc = UsersMeta(); break; default: break; @@ -33,6 +37,7 @@ List moduleNames() { return [ 'Benchmarks', 'Roles', + 'Starters', 'Structures', 'Users', ]; diff --git a/lib/meta/roles_meta.dart b/lib/meta/roles_meta.dart index e91e3fc..ed49469 100644 --- a/lib/meta/roles_meta.dart +++ b/lib/meta/roles_meta.dart @@ -5,33 +5,33 @@ import 'module_meta_data.dart'; final i18n = I18N(); final M = i18n.module("Roles"); -class RoleMeta extends ModuleMetaData { - static RoleMeta instance = RoleMeta.internal(); - factory RoleMeta() { +class RolesMeta extends ModuleMetaData { + static RolesMeta instance = RolesMeta.internal(); + factory RolesMeta() { return instance; } - RoleMeta.internal() + RolesMeta.internal() : super('Roles', [ PropertyMetaData('id', i18n.tr('Id'), DataType.reference, ':primary:', displayType: DisplayType.combobox), PropertyMetaData( 'name', i18n.tr('Name'), DataType.string, ':notnull:', size: 64), - PropertyMetaData( - 'created', i18n.tr('Created'), DataType.datetime, ':hidden:'), + PropertyMetaData('createdAt', i18n.tr('Created at'), + DataType.datetime, ':hidden:'), PropertyMetaData( 'createdBy', i18n.tr('Created by'), DataType.string, ':hidden:', size: 32), PropertyMetaData( - 'changed', i18n.tr('Changed'), DataType.datetime, ':hidden:'), + 'changedAt', i18n.tr('ChangedAt'), DataType.datetime, ':hidden:'), PropertyMetaData( 'changedBy', i18n.tr('Changed by'), DataType.string, ':hidden:', size: 32), ], [ PageMetaData('New Role', PageType.create, - fields: [CopyDbFields('filters')]), + fields: [CopyDbFields('fields')]), PageMetaData('Change Role', PageType.edit, - fields: [CopyDbFields('filters')]), + fields: [CopyDbFields('fields')]), ListPageMetaData( 'Roles Overview', fields: [ @@ -39,8 +39,9 @@ class RoleMeta extends ModuleMetaData { ':where=!text IS NONE OR (role_name like !text):', size: 64), ], + toolTipAddButton: i18n.tr('Add a new role'), tableColumns: 'role_id;role_name', - tableHeaders: i18n.tr('Id;Name'), + tableHeaders: i18n.tr(';Id;Name'), ), ]); @override diff --git a/lib/meta/starters_meta.dart b/lib/meta/starters_meta.dart new file mode 100644 index 0000000..150ab1f --- /dev/null +++ b/lib/meta/starters_meta.dart @@ -0,0 +1,59 @@ +import '../base/defines.dart'; +import '../base/i18n.dart'; +import 'module_meta_data.dart'; + +final i18n = I18N(); +final M = i18n.module("Starters"); + +class StartersMeta extends ModuleMetaData { + static StartersMeta instance = StartersMeta.internal(); + factory StartersMeta() { + return instance; + } + StartersMeta.internal() + : super('Starters', [ + PropertyMetaData('id', i18n.tr('Id'), DataType.reference, ':primary:', + displayType: DisplayType.combobox), + PropertyMetaData( + 'name', i18n.tr('Name'), DataType.string, ':notnull:', + size: 64), + PropertyMetaData( + 'link', i18n.tr('Link'), DataType.string, ':notnull:', + size: 64), + PropertyMetaData( + 'icon', i18n.tr('Icon'), DataType.string, ':notnull:', + size: 64), + PropertyMetaData('createdAt', i18n.tr('Created at'), + DataType.datetime, ':hidden:'), + PropertyMetaData( + 'createdBy', i18n.tr('Created by'), DataType.string, ':hidden:', + size: 32), + PropertyMetaData('changedAt', i18n.tr('Changed at'), + DataType.datetime, ':hidden:'), + PropertyMetaData( + 'changedBy', i18n.tr('Changed by'), DataType.string, ':hidden:', + size: 32), + ], [ + PageMetaData('New Starter', PageType.create, + fields: [CopyDbFields('fields')]), + PageMetaData('Change Starter', PageType.edit, + fields: [CopyDbFields('fields')]), + PageMetaData('Delete Starter', PageType.delete, + fields: [CopyDbFields('fields')]), + ListPageMetaData( + 'Starters Overview', + fields: [ + PropertyMetaData('text', i18n.tr('Text'), DataType.string, + ':where=!text IS NONE OR starter_name like !text OR starter_link like !text:', + size: 64), + ], + toolTipAddButton: i18n.tr('Add a new starter'), + tableColumns: 'starter_id;starter_name;starter_link;starter_icon', + tableHeaders: i18n.tr(';Id;Name;Link;Icon'), + ), + ]); + @override + void onInitialized() { + super.onInitialized(); + } +} diff --git a/lib/meta/structures_meta.dart b/lib/meta/structures_meta.dart index 7bfccdc..2f58149 100644 --- a/lib/meta/structures_meta.dart +++ b/lib/meta/structures_meta.dart @@ -5,12 +5,12 @@ import 'module_meta_data.dart'; final i18n = I18N(); final M = i18n.module("Structures"); -class StructureMeta extends ModuleMetaData { - static StructureMeta instance = StructureMeta.internal(); - factory StructureMeta() { +class StructuresMeta extends ModuleMetaData { + static StructuresMeta instance = StructuresMeta.internal(); + factory StructuresMeta() { return instance; } - StructureMeta.internal() + StructuresMeta.internal() : super('Structures', [ PropertyMetaData('id', i18n.tr('Id'), DataType.reference, ':primary:', displayType: DisplayType.combobox), @@ -25,23 +25,23 @@ class StructureMeta extends ModuleMetaData { size: 32), PropertyMetaData( 'position', i18n.tr('Position', M), DataType.int, ''), - PropertyMetaData( - 'created', i18n.tr('Created'), DataType.datetime, ':hidden:'), + PropertyMetaData('createdAt', i18n.tr('Created at'), + DataType.datetime, ':hidden:'), PropertyMetaData( 'createdBy', i18n.tr('Created by'), DataType.string, ':hidden:', size: 32), - PropertyMetaData( - 'changed', i18n.tr('Changed'), DataType.datetime, ':hidden:'), + PropertyMetaData('changedAt', i18n.tr('Changed at'), + DataType.datetime, ':hidden:'), PropertyMetaData( 'changedBy', i18n.tr('Changed by'), DataType.string, ':hidden:', size: 32), ], [ PageMetaData('New Structure', PageType.create, - fields: [CopyDbFields('filters')]), + fields: [CopyDbFields('fields')]), PageMetaData('Change Structure', PageType.edit, - fields: [CopyDbFields('filters')]), + fields: [CopyDbFields('fields')]), PageMetaData('Delete Structure', PageType.delete, - fields: [CopyDbFields('filters')]), + fields: [CopyDbFields('fields')]), ListPageMetaData( 'Structures Overview', fields: [ @@ -49,9 +49,10 @@ class StructureMeta extends ModuleMetaData { ':where=!text IS NONE OR structure_name like !text OR structure_value like !text:', size: 64), ], + toolTipAddButton: i18n.tr('Add a structure item'), tableColumns: 'structure_id;structure_scope;structure_name;structure_value;structure_position', - tableHeaders: i18n.tr('Id;Scope;Name;Value;Position'), + tableHeaders: i18n.tr(';Id;Scope;Name;Value;Position'), ), ]); @override diff --git a/lib/meta/users_meta.dart b/lib/meta/users_meta.dart index d6807b5..40c017d 100644 --- a/lib/meta/users_meta.dart +++ b/lib/meta/users_meta.dart @@ -5,12 +5,12 @@ import 'module_meta_data.dart'; final i18n = I18N(); final M = i18n.module("Users"); -class UserMeta extends ModuleMetaData { - static UserMeta instance = UserMeta.internal(); - factory UserMeta() { +class UsersMeta extends ModuleMetaData { + static UsersMeta instance = UsersMeta.internal(); + factory UsersMeta() { return instance; } - UserMeta.internal() + UsersMeta.internal() : super('Users', [ PropertyMetaData('id', i18n.tr('Id'), DataType.reference, ':primary:', displayType: DisplayType.combobox), @@ -27,13 +27,13 @@ class UserMeta extends ModuleMetaData { 'role', i18n.tr('Role'), DataType.reference, ':notnull:', displayType: DisplayType.combobox, foreignKey: 'roles.role_id;role_name;role'), - PropertyMetaData( - 'created', i18n.tr('Created'), DataType.datetime, ':hidden:'), + PropertyMetaData('createdAt', i18n.tr('Created at'), + DataType.datetime, ':hidden:'), PropertyMetaData( 'createdBy', i18n.tr('Created by'), DataType.string, ':hidden:', size: 32), - PropertyMetaData( - 'changed', i18n.tr('Changed'), DataType.datetime, ':hidden:'), + PropertyMetaData('changedAt', i18n.tr('Changed at'), + DataType.datetime, ':hidden:'), PropertyMetaData( 'changedBy', i18n.tr('Changed by'), DataType.string, ':hidden:', size: 32), @@ -66,6 +66,7 @@ class UserMeta extends ModuleMetaData { displayType: DisplayType.combobox, foreignKey: 'roles.role_id;role_name;role'), ], + toolTipAddButton: i18n.tr('Add a new user'), tableColumns: 'user_id;user_name;user_displayname;user_email;role', tableHeaders: i18n.tr(';Id;Name;Display Name;Email;Role'), globalComboBoxes: 'comboRoles', diff --git a/lib/page/benchmarks/benchmark_data.dart b/lib/page/benchmarks/benchmark_data.dart index aacaf19..c693772 100644 --- a/lib/page/benchmarks/benchmark_data.dart +++ b/lib/page/benchmarks/benchmark_data.dart @@ -12,9 +12,9 @@ class BenchmarkData extends DataRecord { bool? active; double? weight; int? income; - DateTime? created; + DateTime? createdAt; String? createdBy; - DateTime? changed; + DateTime? changedAt; String? changedBy; BenchmarkData( {this.id, @@ -25,9 +25,9 @@ class BenchmarkData extends DataRecord { this.active, this.weight, this.income, - this.created, + this.createdAt, this.createdBy, - this.changed, + this.changedAt, this.changedBy}); BenchmarkData.createFromMap(DataMap map) { fromMap(map); @@ -58,14 +58,14 @@ class BenchmarkData extends DataRecord { income = map.containsKey('benchmark_income') ? fromString(map['benchmark_income'], dataType: DataType.currency) : null; - created = map.containsKey('benchmark_created') - ? fromString(map['benchmark_created'], dataType: DataType.datetime) + createdAt = map.containsKey('benchmark_createdat') + ? fromString(map['benchmark_createdat'], dataType: DataType.datetime) : null; createdBy = map.containsKey('benchmark_createdby') ? fromString(map['benchmark_createdby'], dataType: DataType.string) : null; - changed = map.containsKey('benchmark_changed') - ? fromString(map['benchmark_changed'], dataType: DataType.datetime) + changedAt = map.containsKey('benchmark_changedat') + ? fromString(map['benchmark_changedat'], dataType: DataType.datetime) : null; changedBy = map.containsKey('benchmark_changedby') ? fromString(map['benchmark_changedby'], dataType: DataType.string) @@ -109,13 +109,13 @@ class BenchmarkData extends DataRecord { case 'income': rc = DataType.currency; break; - case 'created': + case 'createdAt': rc = DataType.datetime; break; case 'createdBy': rc = DataType.string; break; - case 'changed': + case 'changedAt': rc = DataType.datetime; break; case 'changedBy': @@ -141,9 +141,9 @@ class BenchmarkData extends DataRecord { map['benchmark_active'] = active; map['benchmark_weight'] = weight; map['benchmark_income'] = income; - map['benchmark_created'] = created; + map['benchmark_createdat'] = createdAt; map['benchmark_createdby'] = createdBy; - map['benchmark_changed'] = changed; + map['benchmark_changedat'] = changedAt; map['benchmark_changedby'] = changedBy; return map; } diff --git a/lib/page/benchmarks/create_benchmark_page.dart b/lib/page/benchmarks/create_benchmark_page.dart index 2dc8272..bac42c0 100644 --- a/lib/page/benchmarks/create_benchmark_page.dart +++ b/lib/page/benchmarks/create_benchmark_page.dart @@ -16,8 +16,8 @@ class CreateBenchmarkPage extends StatefulWidget { this, rc, GlobalData(), - BenchmarkMeta.instance.pageByName('create')!, - BenchmarkMeta.instance, + BenchmarksMeta.instance.pageByName('create')!, + BenchmarksMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/benchmarks/delete_benchmark_page.dart b/lib/page/benchmarks/delete_benchmark_page.dart index 9891dd6..d521ed4 100644 --- a/lib/page/benchmarks/delete_benchmark_page.dart +++ b/lib/page/benchmarks/delete_benchmark_page.dart @@ -17,8 +17,8 @@ class DeleteBenchmarkPage extends StatefulWidget { this, rc, GlobalData(), - BenchmarkMeta.instance.pageByName('delete')!, - BenchmarkMeta.instance, + BenchmarksMeta.instance.pageByName('delete')!, + BenchmarksMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/benchmarks/edit_benchmark_page.dart b/lib/page/benchmarks/edit_benchmark_page.dart index 32c9316..43e540f 100644 --- a/lib/page/benchmarks/edit_benchmark_page.dart +++ b/lib/page/benchmarks/edit_benchmark_page.dart @@ -17,8 +17,8 @@ class EditBenchmarkPage extends StatefulWidget { this, rc, GlobalData(), - BenchmarkMeta.instance.pageByName('edit')!, - BenchmarkMeta.instance, + BenchmarksMeta.instance.pageByName('edit')!, + BenchmarksMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/benchmarks/list_benchmark_custom.dart b/lib/page/benchmarks/list_benchmark_custom.dart index 2907e7e..b20bc85 100644 --- a/lib/page/benchmarks/list_benchmark_custom.dart +++ b/lib/page/benchmarks/list_benchmark_custom.dart @@ -29,11 +29,11 @@ class ListBenchmarkCustom extends State { appBar: globalData.appBarBuilder(i18n.tr('Overview benchmarks')), drawer: globalData.drawerBuilder(context), floatingActionButton: FloatingActionButton( - onPressed: () { - globalData.navigate(context, '/Benchmarks/create'); - }, - child: const Icon(Icons.add), - ), + onPressed: () { + globalData.navigate(context, '/Benchmarks/create'); + }, + child: const Icon(Icons.add), + tooltip: 'Add a benchmark item'), body: SafeArea( child: FutureBuilder( future: _futureDbData, diff --git a/lib/page/benchmarks/list_benchmark_page.dart b/lib/page/benchmarks/list_benchmark_page.dart index 1f6410f..6e1c6af 100644 --- a/lib/page/benchmarks/list_benchmark_page.dart +++ b/lib/page/benchmarks/list_benchmark_page.dart @@ -16,8 +16,8 @@ class ListBenchmarkPage extends StatefulWidget { this, rc, GlobalData(), - BenchmarkMeta.instance.pageByName('list')!, - BenchmarkMeta.instance, + BenchmarksMeta.instance.pageByName('list')!, + BenchmarksMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/page_manager.dart b/lib/page/page_manager.dart index cea3c73..7eb7266 100644 --- a/lib/page/page_manager.dart +++ b/lib/page/page_manager.dart @@ -9,6 +9,10 @@ import 'benchmarks/list_benchmark_page.dart'; import 'roles/create_role_page.dart'; import 'roles/edit_role_page.dart'; import 'roles/list_role_page.dart'; +import 'starters/create_starter_page.dart'; +import 'starters/edit_starter_page.dart'; +import 'starters/delete_starter_page.dart'; +import 'starters/list_starter_page.dart'; import 'structures/create_structure_page.dart'; import 'structures/edit_structure_page.dart'; import 'structures/delete_structure_page.dart'; @@ -55,6 +59,18 @@ class PageManager { case '/Roles/list': rc = ListRolePage(); break; + case '/Starters/create': + rc = CreateStarterPage(); + break; + case '/Starters/edit': + rc = EditStarterPage(arg1); + break; + case '/Starters/delete': + rc = DeleteStarterPage(arg1); + break; + case '/Starters/list': + rc = ListStarterPage(); + break; case '/Structures/create': rc = CreateStructurePage(); break; diff --git a/lib/page/roles/create_role_page.dart b/lib/page/roles/create_role_page.dart index d6cf4ee..2601a43 100644 --- a/lib/page/roles/create_role_page.dart +++ b/lib/page/roles/create_role_page.dart @@ -16,8 +16,8 @@ class CreateRolePage extends StatefulWidget { this, rc, GlobalData(), - RoleMeta.instance.pageByName('create')!, - RoleMeta.instance, + RolesMeta.instance.pageByName('create')!, + RolesMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/roles/edit_role_page.dart b/lib/page/roles/edit_role_page.dart index 8ce66cb..9a7a3d3 100644 --- a/lib/page/roles/edit_role_page.dart +++ b/lib/page/roles/edit_role_page.dart @@ -17,8 +17,8 @@ class EditRolePage extends StatefulWidget { this, rc, GlobalData(), - RoleMeta.instance.pageByName('edit')!, - RoleMeta.instance, + RolesMeta.instance.pageByName('edit')!, + RolesMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/roles/list_role_custom.dart b/lib/page/roles/list_role_custom.dart index d2c3c8d..9f190cd 100644 --- a/lib/page/roles/list_role_custom.dart +++ b/lib/page/roles/list_role_custom.dart @@ -29,11 +29,11 @@ class ListRoleCustom extends State { appBar: globalData.appBarBuilder(i18n.tr('Overview roles')), drawer: globalData.drawerBuilder(context), floatingActionButton: FloatingActionButton( - onPressed: () { - globalData.navigate(context, '/Roles/create'); - }, - child: const Icon(Icons.add), - ), + onPressed: () { + globalData.navigate(context, '/Roles/create'); + }, + child: const Icon(Icons.add), + tooltip: 'Add a new role'), body: SafeArea( child: FutureBuilder( future: _futureDbData, @@ -95,7 +95,10 @@ class ListRoleCustom extends State { final table = DataTable( columns: [ DataColumn( - label: Text(i18n.tr('d;Name')), + label: Text(i18n.tr('Id')), + ), + DataColumn( + label: Text(i18n.tr('Name')), ), ], rows: rows as List, @@ -107,6 +110,7 @@ class ListRoleCustom extends State { onTap: (offset) { _fieldData.theOffset = offset; requestRecords(); + setState(() => 1); }); final frameWidget = ListView(children: [ form, diff --git a/lib/page/roles/list_role_page.dart b/lib/page/roles/list_role_page.dart index 91335a8..41a4331 100644 --- a/lib/page/roles/list_role_page.dart +++ b/lib/page/roles/list_role_page.dart @@ -16,8 +16,8 @@ class ListRolePage extends StatefulWidget { this, rc, GlobalData(), - RoleMeta.instance.pageByName('list')!, - RoleMeta.instance, + RolesMeta.instance.pageByName('list')!, + RolesMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/roles/role_data.dart b/lib/page/roles/role_data.dart index 7b019ac..317e9db 100644 --- a/lib/page/roles/role_data.dart +++ b/lib/page/roles/role_data.dart @@ -6,16 +6,16 @@ import '../../persistence/data_record.dart'; class RoleData extends DataRecord { int? id; String? name; - DateTime? created; + DateTime? createdAt; String? createdBy; - DateTime? changed; + DateTime? changedAt; String? changedBy; RoleData( {this.id, this.name, - this.created, + this.createdAt, this.createdBy, - this.changed, + this.changedAt, this.changedBy}); RoleData.createFromMap(DataMap map) { fromMap(map); @@ -28,14 +28,14 @@ class RoleData extends DataRecord { name = map.containsKey('role_name') ? fromString(map['role_name'], dataType: DataType.string) : null; - created = map.containsKey('role_created') - ? fromString(map['role_created'], dataType: DataType.datetime) + createdAt = map.containsKey('role_createdat') + ? fromString(map['role_createdat'], dataType: DataType.datetime) : null; createdBy = map.containsKey('role_createdby') ? fromString(map['role_createdby'], dataType: DataType.string) : null; - changed = map.containsKey('role_changed') - ? fromString(map['role_changed'], dataType: DataType.datetime) + changedAt = map.containsKey('role_changedat') + ? fromString(map['role_changedat'], dataType: DataType.datetime) : null; changedBy = map.containsKey('role_changedby') ? fromString(map['role_changedby'], dataType: DataType.string) @@ -61,13 +61,13 @@ class RoleData extends DataRecord { case 'name': rc = DataType.string; break; - case 'created': + case 'createdAt': rc = DataType.datetime; break; case 'createdBy': rc = DataType.string; break; - case 'changed': + case 'changedAt': rc = DataType.datetime; break; case 'changedBy': @@ -87,9 +87,9 @@ class RoleData extends DataRecord { } map['role_id'] = id; map['role_name'] = name; - map['role_created'] = created; + map['role_createdat'] = createdAt; map['role_createdby'] = createdBy; - map['role_changed'] = changed; + map['role_changedat'] = changedAt; map['role_changedby'] = changedBy; return map; } diff --git a/lib/page/start_page.dart b/lib/page/start_page.dart index 8c79d6f..ab5b3b0 100644 --- a/lib/page/start_page.dart +++ b/lib/page/start_page.dart @@ -96,7 +96,7 @@ class StartPageState extends State { RestPersistence.fromConfig(configuration, logger), logger); globalData.initializeAsync().then((value) { - globalData.navigate(context, '/Users/list'); + globalData.navigate(context, '/Starters/list'); }); } }); diff --git a/lib/page/starters/create_starter_custom.dart b/lib/page/starters/create_starter_custom.dart new file mode 100644 index 0000000..fffaf2f --- /dev/null +++ b/lib/page/starters/create_starter_custom.dart @@ -0,0 +1,152 @@ +// This file is created by the meta_tool. But it can be customized. +// It will never overridden by the meta_tool. +import 'package:flutter/material.dart'; + +import '../../base/defines.dart'; +import '../../base/helper.dart'; +import '../../base/i18n.dart'; +import '../../base/validators.dart'; +import '../../services/global_widget.dart'; +import '../../setting/global_data.dart'; +import '../../widget/attended_page.dart'; +import '../../widget/message_line.dart'; +import '../../widget/widget_form.dart'; +import 'create_starter_page.dart'; + +final i18n = I18N(); + +class CreateStarterCustom extends State with MessageLine { + final globalData = GlobalData(); + AttendedPage? attendedPage; + final _fieldData = _FieldData(); + final GlobalKey _formKey = + GlobalKey(debugLabel: 'CreateStarter'); + final nameController = TextEditingController(); + final linkController = TextEditingController(); + final iconController = TextEditingController(); + CreateStarterCustom(); + @override + Widget build(BuildContext context) { + final rc = Scaffold( + appBar: globalData.appBarBuilder(i18n.tr('New Starter')), + drawer: globalData.drawerBuilder(context), + body: SafeArea(child: buildFrame())); + return rc; + } + + Widget buildFrame() { + final padding = GlobalThemeData.padding; + nameController.text = _fieldData.name; + linkController.text = _fieldData.link; + iconController.text = _fieldData.icon; + final formItems = [ + FormItem( + TextFormField( + controller: nameController, + decoration: InputDecoration(labelText: i18n.tr('Name')), + validator: (input) => notEmpty(input), + onSaved: (value) => _fieldData.name = value ?? ''), + weight: 6), + FormItem( + TextFormField( + controller: linkController, + decoration: InputDecoration(labelText: i18n.tr('Link')), + validator: (input) => notEmpty(input), + onSaved: (value) => _fieldData.link = value ?? ''), + weight: 6), + FormItem( + TextFormField( + controller: iconController, + decoration: InputDecoration(labelText: i18n.tr('Icon')), + validator: (input) => notEmpty(input), + onSaved: (value) => _fieldData.icon = value ?? ''), + weight: 6), + FormItem( + ElevatedButton( + onPressed: () => onVerifyAndStore(), + child: Text(i18n.tr('Save'))), + weight: 8, + gapAbove: 2 * padding), + FormItem( + ElevatedButton( + onPressed: () { + attendedPage!.pageStates.dbDataState.clear(); + globalData.navigate(context, '/Starters/list'); + }, + child: Text(i18n.tr('Cancel')), + ), + weight: 4) + ]; + final rc = Form( + key: _formKey, + child: Card( + margin: + EdgeInsets.symmetric(vertical: padding, horizontal: padding), + child: Padding( + padding: EdgeInsets.symmetric( + vertical: padding, horizontal: padding), + child: WidgetForm.flexibleGrid( + formItems, + screenWidth: attendedPage!.pageStates.screenWidth, + padding: padding, + )))); + return rc; + } + + @override + void dispose() { + helperDummyUsage(DataType.int); + globalWidgetDummyUsage(); + nameController.dispose(); + linkController.dispose(); + iconController.dispose(); + super.dispose(); + } + + @override + void initState() { + super.initState(); + } + + void onStore() { + final parameters = { + 'module': 'Starters', + 'sql': 'insert', + }; + _fieldData.toMap(parameters); + globalData.restPersistence! + .store(what: 'store', map: parameters) + .then((answer) { + if (answer.startsWith('id:')) { + final id = int.tryParse(answer.substring(3)); + if (id == null || id == 0) { + setError(i18n.tr('Saving data failed: $answer')); + setState(() => 1); + } else { + attendedPage!.pageStates.dbDataState.clear(); + globalData.navigate(context, '/Starters/edit;$id'); + } + } + }); + } + + void onVerifyAndStore() { + if (_formKey.currentState!.validate()) { + _formKey.currentState!.save(); + onStore(); + } + } +} + +class _FieldData { + String name = ''; + String link = ''; + String icon = ''; + + void toMap(Map map) { + map[':name'] = name; + map[':link'] = link; + map[':icon'] = icon; + map[':createdBy'] = GlobalData.loginUserName; + } +} diff --git a/lib/page/starters/create_starter_page.dart b/lib/page/starters/create_starter_page.dart new file mode 100644 index 0000000..29fc58b --- /dev/null +++ b/lib/page/starters/create_starter_page.dart @@ -0,0 +1,61 @@ +// DO NOT CHANGE. This file is created by the meta_tool! +import 'package:flutter/material.dart'; + +import '../../meta/starters_meta.dart'; +import '../../setting/global_data.dart'; +import '../../widget/attended_page.dart'; +import 'create_starter_custom.dart'; + +class CreateStarterPage extends StatefulWidget { + final PageStates pageStates = PageStates(); + CreateStarterPage() : super(); + @override + _CreateStarterPageState createState() { + final rc = _CreateStarterPageState(); + rc.attendedPage = AttendedPage( + this, + rc, + GlobalData(), + StartersMeta.instance.pageByName('create')!, + StartersMeta.instance, + pageStates, + (afterReload, rebuild) => + rc.reload(afterReload: afterReload, rebuild: rebuild)); + pageStates.attendedPage = rc.attendedPage; + return rc; + } +} + +class _CreateStarterPageState extends CreateStarterCustom { + _CreateStarterPageState() : super(); + @override + void didChangeDependencies() { + final size = MediaQuery.of(context).size; + attendedPage!.pageStates.screenWidth = size.width; + attendedPage!.pageStates.screenHeight = size.height; + super.didChangeDependencies(); + } + + /// Renders the widget tree again. + /// + /// [afterReload] is a function used as parameter of setState(). + /// + /// If [rebuild] is true the state has been changed and didChangeDependencies() + /// will be called. + void reload({Function? afterReload, bool rebuild = false}) { + if (afterReload == null) { + if (rebuild) { + setState(() => didChangeDependencies()); + } else { + setState(() => 1); + } + } else { + setState(() { + afterReload(); + if (rebuild) { + didChangeDependencies(); + } + }); + } + } +} diff --git a/lib/page/starters/delete_starter_custom.dart b/lib/page/starters/delete_starter_custom.dart new file mode 100644 index 0000000..c99708d --- /dev/null +++ b/lib/page/starters/delete_starter_custom.dart @@ -0,0 +1,164 @@ +// This file is created by the meta_tool. But it can be customized. +// It will never overridden by the meta_tool. +import 'package:flutter/material.dart'; + +import '../../base/defines.dart'; +import '../../base/helper.dart'; +import '../../base/i18n.dart'; +import '../../base/validators.dart'; +import '../../persistence/persistence.dart'; +import '../../services/global_widget.dart'; +import '../../setting/global_data.dart'; +import '../../widget/attended_page.dart'; +import '../../widget/message_line.dart'; +import '../../widget/widget_form.dart'; +import 'delete_starter_page.dart'; + +final i18n = I18N(); + +class DeleteStarterCustom extends State with MessageLine { + final int primaryKey; + final globalData = GlobalData(); + late Future _futureDbData; + AttendedPage? attendedPage; + final _fieldData = _FieldData(); + final GlobalKey _formKey = + GlobalKey(debugLabel: 'DeleteStarter'); + final nameController = TextEditingController(); + final linkController = TextEditingController(); + final iconController = TextEditingController(); + DeleteStarterCustom(this.primaryKey); + @override + Widget build(BuildContext context) { + final rc = Scaffold( + appBar: globalData.appBarBuilder(i18n.tr('Delete Starter')), + drawer: globalData.drawerBuilder(context), + body: SafeArea( + child: FutureBuilder( + future: _futureDbData, + builder: (context, snapshot) { + final rc = attendedPage!.loadRecord(snapshot, (record) { + _fieldData.fromMap(record); + return buildFrame(); + }); + return rc; + }))); + return rc; + } + + Widget buildFrame() { + final padding = GlobalThemeData.padding; + nameController.text = _fieldData.name; + linkController.text = _fieldData.link; + iconController.text = _fieldData.icon; + final formItems = [ + FormItem( + TextFormField( + controller: nameController, + decoration: InputDecoration(labelText: i18n.tr('Name')), + validator: (input) => notEmpty(input), + onSaved: (value) => _fieldData.name = value ?? ''), + weight: 6), + FormItem( + TextFormField( + controller: linkController, + decoration: InputDecoration(labelText: i18n.tr('Link')), + validator: (input) => notEmpty(input), + onSaved: (value) => _fieldData.link = value ?? ''), + weight: 6), + FormItem( + TextFormField( + controller: iconController, + decoration: InputDecoration(labelText: i18n.tr('Icon')), + validator: (input) => notEmpty(input), + onSaved: (value) => _fieldData.icon = value ?? ''), + weight: 6), + FormItem( + ElevatedButton( + onPressed: () => onVerifyAndDelete(), + child: Text(i18n.tr('Delete'))), + weight: 8, + gapAbove: 2 * padding), + FormItem( + ElevatedButton( + onPressed: () { + attendedPage!.pageStates.dbDataState.clear(); + globalData.navigate(context, '/Starters/list'); + }, + child: Text(i18n.tr('Cancel')), + ), + weight: 4) + ]; + final rc = Form( + key: _formKey, + child: Card( + margin: + EdgeInsets.symmetric(vertical: padding, horizontal: padding), + child: Padding( + padding: EdgeInsets.symmetric( + vertical: padding, horizontal: padding), + child: WidgetForm.flexibleGrid( + formItems, + screenWidth: attendedPage!.pageStates.screenWidth, + padding: padding, + )))); + return rc; + } + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + requestRecord(); + } + + @override + void dispose() { + helperDummyUsage(DataType.int); + globalWidgetDummyUsage(); + nameController.dispose(); + linkController.dispose(); + iconController.dispose(); + super.dispose(); + } + + @override + void initState() { + super.initState(); + } + + void requestRecord() => _futureDbData = globalData.restPersistence!.query( + what: 'query', + data: {'module': 'Users', 'sql': 'byId', ':id': primaryKey}); + + void onDelete() { + final parameters = { + 'module': 'Starters', + 'sql': 'delete', + ':id': primaryKey + }; + globalData.restPersistence! + .store(what: 'store', map: parameters) + .then((answer) { + globalData.navigate(context, '/Starters/list'); + }); + } + + void onVerifyAndDelete() { + if (_formKey.currentState!.validate()) { + _formKey.currentState!.save(); + onDelete(); + } + } +} + +class _FieldData { + String name = ''; + String link = ''; + String icon = ''; + + void fromMap(Map map) { + name = map['starter_name']; + link = map['starter_link']; + icon = map['starter_icon']; + } +} diff --git a/lib/page/starters/delete_starter_page.dart b/lib/page/starters/delete_starter_page.dart new file mode 100644 index 0000000..9d872e6 --- /dev/null +++ b/lib/page/starters/delete_starter_page.dart @@ -0,0 +1,62 @@ +// DO NOT CHANGE. This file is created by the meta_tool! +import 'package:flutter/material.dart'; + +import '../../meta/starters_meta.dart'; +import '../../setting/global_data.dart'; +import '../../widget/attended_page.dart'; +import 'delete_starter_custom.dart'; + +class DeleteStarterPage extends StatefulWidget { + final int primaryKey; + final PageStates pageStates = PageStates(); + DeleteStarterPage(this.primaryKey) : super(); + @override + _DeleteStarterPageState createState() { + final rc = _DeleteStarterPageState(this.primaryKey); + rc.attendedPage = AttendedPage( + this, + rc, + GlobalData(), + StartersMeta.instance.pageByName('delete')!, + StartersMeta.instance, + pageStates, + (afterReload, rebuild) => + rc.reload(afterReload: afterReload, rebuild: rebuild)); + pageStates.attendedPage = rc.attendedPage; + return rc; + } +} + +class _DeleteStarterPageState extends DeleteStarterCustom { + _DeleteStarterPageState(int primaryKey) : super(primaryKey); + @override + void didChangeDependencies() { + final size = MediaQuery.of(context).size; + attendedPage!.pageStates.screenWidth = size.width; + attendedPage!.pageStates.screenHeight = size.height; + super.didChangeDependencies(); + } + + /// Renders the widget tree again. + /// + /// [afterReload] is a function used as parameter of setState(). + /// + /// If [rebuild] is true the state has been changed and didChangeDependencies() + /// will be called. + void reload({Function? afterReload, bool rebuild = false}) { + if (afterReload == null) { + if (rebuild) { + setState(() => didChangeDependencies()); + } else { + setState(() => 1); + } + } else { + setState(() { + afterReload(); + if (rebuild) { + didChangeDependencies(); + } + }); + } + } +} diff --git a/lib/page/starters/edit_starter_custom.dart b/lib/page/starters/edit_starter_custom.dart new file mode 100644 index 0000000..60c5384 --- /dev/null +++ b/lib/page/starters/edit_starter_custom.dart @@ -0,0 +1,175 @@ +// This file is created by the meta_tool. But it can be customized. +// It will never overridden by the meta_tool. +import 'package:flutter/material.dart'; + +import '../../base/defines.dart'; +import '../../base/helper.dart'; +import '../../base/i18n.dart'; +import '../../base/validators.dart'; +import '../../persistence/persistence.dart'; +import '../../services/global_widget.dart'; +import '../../setting/global_data.dart'; +import '../../widget/attended_page.dart'; +import '../../widget/message_line.dart'; +import '../../widget/widget_form.dart'; +import 'edit_starter_page.dart'; + +final i18n = I18N(); + +class EditStarterCustom extends State with MessageLine { + final int primaryKey; + final globalData = GlobalData(); + late Future _futureDbData; + AttendedPage? attendedPage; + final _fieldData = _FieldData(); + final GlobalKey _formKey = + GlobalKey(debugLabel: 'EditStarter'); + final nameController = TextEditingController(); + final linkController = TextEditingController(); + final iconController = TextEditingController(); + EditStarterCustom(this.primaryKey); + @override + Widget build(BuildContext context) { + final rc = Scaffold( + appBar: globalData.appBarBuilder(i18n.tr('Change Starter')), + drawer: globalData.drawerBuilder(context), + body: SafeArea( + child: FutureBuilder( + future: _futureDbData, + builder: (context, snapshot) { + final rc = attendedPage!.loadRecord(snapshot, (record) { + _fieldData.fromMap(record); + return buildFrame(); + }); + return rc; + }))); + return rc; + } + + Widget buildFrame() { + final padding = GlobalThemeData.padding; + nameController.text = _fieldData.name; + linkController.text = _fieldData.link; + iconController.text = _fieldData.icon; + final formItems = [ + FormItem( + TextFormField( + controller: nameController, + decoration: InputDecoration(labelText: i18n.tr('Name')), + validator: (input) => notEmpty(input), + onSaved: (value) => _fieldData.name = value ?? ''), + weight: 6), + FormItem( + TextFormField( + controller: linkController, + decoration: InputDecoration(labelText: i18n.tr('Link')), + validator: (input) => notEmpty(input), + onSaved: (value) => _fieldData.link = value ?? ''), + weight: 6), + FormItem( + TextFormField( + controller: iconController, + decoration: InputDecoration(labelText: i18n.tr('Icon')), + validator: (input) => notEmpty(input), + onSaved: (value) => _fieldData.icon = value ?? ''), + weight: 6), + FormItem( + ElevatedButton( + onPressed: () => onVerifyAndStore(), + child: Text(i18n.tr('Save'))), + weight: 8, + gapAbove: 2 * padding), + FormItem( + ElevatedButton( + onPressed: () { + attendedPage!.pageStates.dbDataState.clear(); + globalData.navigate(context, '/Starters/list'); + }, + child: Text(i18n.tr('Cancel')), + ), + weight: 4) + ]; + final rc = Form( + key: _formKey, + child: Card( + margin: + EdgeInsets.symmetric(vertical: padding, horizontal: padding), + child: Padding( + padding: EdgeInsets.symmetric( + vertical: padding, horizontal: padding), + child: WidgetForm.flexibleGrid( + formItems, + screenWidth: attendedPage!.pageStates.screenWidth, + padding: padding, + )))); + return rc; + } + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + requestRecord(); + } + + @override + void dispose() { + helperDummyUsage(DataType.int); + globalWidgetDummyUsage(); + nameController.dispose(); + linkController.dispose(); + iconController.dispose(); + super.dispose(); + } + + @override + void initState() { + super.initState(); + } + + void requestRecord() => _futureDbData = globalData.restPersistence!.query( + what: 'query', + data: {'module': 'Users', 'sql': 'byId', ':id': primaryKey}); + + void onStore() { + final parameters = { + 'module': 'Starters', + 'sql': 'update', + ':id': primaryKey + }; + _fieldData.toMap(parameters); + globalData.restPersistence! + .store(what: 'store', map: parameters) + .then((answer) { + requestRecord(); + attendedPage!.pageStates.dbDataState.clear(); + setState(() => 1); + }); + } + + void onVerifyAndStore() { + if (_formKey.currentState!.validate()) { + _formKey.currentState!.save(); + onStore(); + } + } +} + +class _FieldData { + String name = ''; + String link = ''; + String icon = ''; + + void fromMap(Map map) { + name = map['starter_name']; + link = map['starter_link']; + icon = map['starter_icon']; + } + + void toMap(Map map) { + // please set outside: map[':id'] = primaryKey; + map[':name'] = name; + map[':link'] = link; + map[':icon'] = icon; + map[':changedBy'] = GlobalData.loginUserName; + } +} diff --git a/lib/page/starters/edit_starter_page.dart b/lib/page/starters/edit_starter_page.dart new file mode 100644 index 0000000..a1022ae --- /dev/null +++ b/lib/page/starters/edit_starter_page.dart @@ -0,0 +1,62 @@ +// DO NOT CHANGE. This file is created by the meta_tool! +import 'package:flutter/material.dart'; + +import '../../meta/starters_meta.dart'; +import '../../setting/global_data.dart'; +import '../../widget/attended_page.dart'; +import 'edit_starter_custom.dart'; + +class EditStarterPage extends StatefulWidget { + final int primaryKey; + final PageStates pageStates = PageStates(); + EditStarterPage(this.primaryKey) : super(); + @override + _EditStarterPageState createState() { + final rc = _EditStarterPageState(this.primaryKey); + rc.attendedPage = AttendedPage( + this, + rc, + GlobalData(), + StartersMeta.instance.pageByName('edit')!, + StartersMeta.instance, + pageStates, + (afterReload, rebuild) => + rc.reload(afterReload: afterReload, rebuild: rebuild)); + pageStates.attendedPage = rc.attendedPage; + return rc; + } +} + +class _EditStarterPageState extends EditStarterCustom { + _EditStarterPageState(int primaryKey) : super(primaryKey); + @override + void didChangeDependencies() { + final size = MediaQuery.of(context).size; + attendedPage!.pageStates.screenWidth = size.width; + attendedPage!.pageStates.screenHeight = size.height; + super.didChangeDependencies(); + } + + /// Renders the widget tree again. + /// + /// [afterReload] is a function used as parameter of setState(). + /// + /// If [rebuild] is true the state has been changed and didChangeDependencies() + /// will be called. + void reload({Function? afterReload, bool rebuild = false}) { + if (afterReload == null) { + if (rebuild) { + setState(() => didChangeDependencies()); + } else { + setState(() => 1); + } + } else { + setState(() { + afterReload(); + if (rebuild) { + didChangeDependencies(); + } + }); + } + } +} diff --git a/lib/page/starters/list_starter_custom.dart b/lib/page/starters/list_starter_custom.dart new file mode 100644 index 0000000..e2cce7e --- /dev/null +++ b/lib/page/starters/list_starter_custom.dart @@ -0,0 +1,173 @@ +// This file is created by the meta_tool. But it can be customized. +// It will never overridden by the meta_tool. +import 'package:flutter/material.dart'; + +import '../../base/defines.dart'; +import '../../base/helper.dart'; +import '../../base/i18n.dart'; +import '../../services/global_widget.dart'; +import '../../setting/global_data.dart'; +import '../../widget/attended_page.dart'; +import '../../widget/widget_form.dart'; +import '../../persistence/persistence.dart'; +import 'list_starter_page.dart'; + +final i18n = I18N(); + +class ListStarterCustom extends State { + final globalData = GlobalData(); + late Future _futureDbData; + AttendedPage? attendedPage; + final _fieldData = _FieldData(); + final GlobalKey _formKey = + GlobalKey(debugLabel: 'CreateStarter'); + final textController = TextEditingController(); + ListStarterCustom(); + @override + Widget build(BuildContext context) { + final rc = Scaffold( + appBar: globalData.appBarBuilder(i18n.tr('Overview starters')), + drawer: globalData.drawerBuilder(context), + floatingActionButton: FloatingActionButton( + onPressed: () { + globalData.navigate(context, '/Starters/create'); + }, + child: const Icon(Icons.add), + tooltip: 'Add a new starter'), + body: SafeArea( + child: FutureBuilder( + future: _futureDbData, + builder: (context, snapshot) { + Widget rc; + if (snapshot.connectionState != ConnectionState.done) { + rc = const CircularProgressIndicator(); + } else { + if (snapshot.hasData) { + final rows = attendedPage!.getRows( + dbData: snapshot.data!, + columnList: + 'starter_id;starter_name;starter_link;starter_icon', + onDone: () => setState(() => 1), + routeEdit: '/Starters/edit', + context: context); + rc = buildFrame( + totalCount: snapshot.data?.count ?? rows.length, rows: rows); + } else if (snapshot.hasError) { + rc = Text('Backend problem: ${snapshot.error}'); + } else { + rc = const CircularProgressIndicator(); + } + } + return rc; + }, + )), + ); + return rc; + } + + Widget buildFrame({required JsonList rows, required int totalCount}) { + final padding = GlobalThemeData.padding; + final formItems = [ + FormItem( + TextFormField( + controller: textController, + decoration: InputDecoration(labelText: i18n.tr('Text')), + onSaved: (value) => _fieldData.text = value ?? ''), + weight: 6), + FormItem( + ElevatedButton( + onPressed: () => search(), child: Text(i18n.tr('Search'))), + weight: 12, + gapAbove: padding), + ]; + final form = Form( + key: _formKey, + child: Card( + color: GlobalThemeData.formBackgroundColor, + elevation: GlobalThemeData.formElevation, + margin: + EdgeInsets.symmetric(vertical: padding, horizontal: padding), + child: Padding( + padding: EdgeInsets.symmetric( + vertical: padding, horizontal: padding), + child: WidgetForm.flexibleGrid(formItems, + screenWidth: attendedPage!.pageStates.screenWidth, + padding: padding)))); + final table = DataTable( + columns: [ + DataColumn( + label: Text(i18n.tr('Id')), + ), + DataColumn( + label: Text(i18n.tr('Name')), + ), + DataColumn( + label: Text(i18n.tr('Link')), + ), + DataColumn( + label: Text(i18n.tr('Icon')), + ), + ], + rows: rows as List, + ); + Widget? tabBar = attendedPage!.buildChipBar( + totalCount: totalCount, + offset: _fieldData.theOffset, + pageSize: _fieldData.thePageSize, + onTap: (offset) { + _fieldData.theOffset = offset; + requestRecords(); + setState(() => 1); + }); + final frameWidget = ListView(children: [ + form, + if (tabBar != null) tabBar, + SizedBox(height: padding), + SizedBox(width: double.infinity, child: table), + ]); + return frameWidget; + } + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + requestRecords(); + } + + @override + void dispose() { + helperDummyUsage(DataType.string); + globalWidgetDummyUsage(); + textController.dispose(); + super.dispose(); + } + + @override + void initState() { + super.initState(); + } + + void requestRecords() => + _futureDbData = globalData.restPersistence!.query(what: 'query', data: { + 'module': 'Starters', + 'sql': 'list', + 'offset': _fieldData.theOffset, + 'size': _fieldData.thePageSize, + ':text': _fieldData.text, + }); + + void search() { + attendedPage!.pageStates.dbDataState.clear(); + if (_formKey.currentState!.validate()) { + _formKey.currentState!.save(); + requestRecords(); + setState(() => 1); + } + } +} + +class _FieldData { + int thePageSize = 10; + int theOffset = 0; + String text = ''; +} diff --git a/lib/page/starters/list_starter_page.dart b/lib/page/starters/list_starter_page.dart new file mode 100644 index 0000000..a0849ef --- /dev/null +++ b/lib/page/starters/list_starter_page.dart @@ -0,0 +1,61 @@ +// DO NOT CHANGE. This file is created by the meta_tool! +import 'package:flutter/material.dart'; + +import '../../meta/starters_meta.dart'; +import '../../setting/global_data.dart'; +import '../../widget/attended_page.dart'; +import 'list_starter_custom.dart'; + +class ListStarterPage extends StatefulWidget { + final PageStates pageStates = PageStates(); + ListStarterPage() : super(); + @override + _ListStarterPageState createState() { + final rc = _ListStarterPageState(); + rc.attendedPage = AttendedPage( + this, + rc, + GlobalData(), + StartersMeta.instance.pageByName('list')!, + StartersMeta.instance, + pageStates, + (afterReload, rebuild) => + rc.reload(afterReload: afterReload, rebuild: rebuild)); + pageStates.attendedPage = rc.attendedPage; + return rc; + } +} + +class _ListStarterPageState extends ListStarterCustom { + _ListStarterPageState() : super(); + @override + void didChangeDependencies() { + final size = MediaQuery.of(context).size; + attendedPage!.pageStates.screenWidth = size.width; + attendedPage!.pageStates.screenHeight = size.height; + super.didChangeDependencies(); + } + + /// Renders the widget tree again. + /// + /// [afterReload] is a function used as parameter of setState(). + /// + /// If [rebuild] is true the state has been changed and didChangeDependencies() + /// will be called. + void reload({Function? afterReload, bool rebuild = false}) { + if (afterReload == null) { + if (rebuild) { + setState(() => didChangeDependencies()); + } else { + setState(() => 1); + } + } else { + setState(() { + afterReload(); + if (rebuild) { + didChangeDependencies(); + } + }); + } + } +} diff --git a/lib/page/starters/starter_data.dart b/lib/page/starters/starter_data.dart new file mode 100644 index 0000000..cf9a884 --- /dev/null +++ b/lib/page/starters/starter_data.dart @@ -0,0 +1,114 @@ +// DO NOT CHANGE. This file is created by the meta_tool +import '../../base/defines.dart'; +import '../../base/helper.dart'; +import '../../persistence/data_record.dart'; + +class StarterData extends DataRecord { + int? id; + String? name; + String? link; + String? icon; + DateTime? createdAt; + String? createdBy; + DateTime? changedAt; + String? changedBy; + StarterData( + {this.id, + this.name, + this.link, + this.icon, + this.createdAt, + this.createdBy, + this.changedAt, + this.changedBy}); + StarterData.createFromMap(DataMap map) { + fromMap(map); + } + @override + void fromMap(DataMap map) { + id = map.containsKey('starter_id') + ? fromString(map['starter_id'], dataType: DataType.reference) + : null; + name = map.containsKey('starter_name') + ? fromString(map['starter_name'], dataType: DataType.string) + : null; + link = map.containsKey('starter_link') + ? fromString(map['starter_link'], dataType: DataType.string) + : null; + icon = map.containsKey('starter_icon') + ? fromString(map['starter_icon'], dataType: DataType.string) + : null; + createdAt = map.containsKey('starter_createdat') + ? fromString(map['starter_createdat'], dataType: DataType.datetime) + : null; + createdBy = map.containsKey('starter_createdby') + ? fromString(map['starter_createdby'], dataType: DataType.string) + : null; + changedAt = map.containsKey('starter_changedat') + ? fromString(map['starter_changedat'], dataType: DataType.datetime) + : null; + changedBy = map.containsKey('starter_changedby') + ? fromString(map['starter_changedby'], dataType: DataType.string) + : null; + } + + @override + int keyOf() { + return id ?? 0; + } + + @override + String nameOfKey() { + return 'starter_id'; + } + + static DataType? dataTypeOf(String name) { + DataType? rc; + switch (name) { + case 'id': + rc = DataType.reference; + break; + case 'name': + rc = DataType.string; + break; + case 'link': + rc = DataType.string; + break; + case 'icon': + rc = DataType.string; + break; + case 'createdAt': + rc = DataType.datetime; + break; + case 'createdBy': + rc = DataType.string; + break; + case 'changedAt': + rc = DataType.datetime; + break; + case 'changedBy': + rc = DataType.string; + break; + default: + break; + } + return rc; + } + + @override + DataMap toMap({DataMap? map, bool clear = true}) { + map ??= DataMap(); + if (clear) { + map.clear(); + } + map['starter_id'] = id; + map['starter_name'] = name; + map['starter_link'] = link; + map['starter_icon'] = icon; + map['starter_createdat'] = createdAt; + map['starter_createdby'] = createdBy; + map['starter_changedat'] = changedAt; + map['starter_changedby'] = changedBy; + return map; + } +} diff --git a/lib/page/structures/create_structure_page.dart b/lib/page/structures/create_structure_page.dart index 3eec391..a46570b 100644 --- a/lib/page/structures/create_structure_page.dart +++ b/lib/page/structures/create_structure_page.dart @@ -16,8 +16,8 @@ class CreateStructurePage extends StatefulWidget { this, rc, GlobalData(), - StructureMeta.instance.pageByName('create')!, - StructureMeta.instance, + StructuresMeta.instance.pageByName('create')!, + StructuresMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/structures/delete_structure_page.dart b/lib/page/structures/delete_structure_page.dart index fc458a6..b974f29 100644 --- a/lib/page/structures/delete_structure_page.dart +++ b/lib/page/structures/delete_structure_page.dart @@ -17,8 +17,8 @@ class DeleteStructurePage extends StatefulWidget { this, rc, GlobalData(), - StructureMeta.instance.pageByName('delete')!, - StructureMeta.instance, + StructuresMeta.instance.pageByName('delete')!, + StructuresMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/structures/edit_structure_page.dart b/lib/page/structures/edit_structure_page.dart index 8baf89c..b8c92b9 100644 --- a/lib/page/structures/edit_structure_page.dart +++ b/lib/page/structures/edit_structure_page.dart @@ -17,8 +17,8 @@ class EditStructurePage extends StatefulWidget { this, rc, GlobalData(), - StructureMeta.instance.pageByName('edit')!, - StructureMeta.instance, + StructuresMeta.instance.pageByName('edit')!, + StructuresMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/structures/list_structure_custom.dart b/lib/page/structures/list_structure_custom.dart index 04f0d64..952c08c 100644 --- a/lib/page/structures/list_structure_custom.dart +++ b/lib/page/structures/list_structure_custom.dart @@ -29,11 +29,11 @@ class ListStructureCustom extends State { appBar: globalData.appBarBuilder(i18n.tr('Overview structures')), drawer: globalData.drawerBuilder(context), floatingActionButton: FloatingActionButton( - onPressed: () { - globalData.navigate(context, '/Structures/create'); - }, - child: const Icon(Icons.add), - ), + onPressed: () { + globalData.navigate(context, '/Structures/create'); + }, + child: const Icon(Icons.add), + tooltip: 'Add a structure item'), body: SafeArea( child: FutureBuilder( future: _futureDbData, @@ -96,7 +96,19 @@ class ListStructureCustom extends State { final table = DataTable( columns: [ DataColumn( - label: Text(i18n.tr('d;Scope;Name;Value;Position')), + label: Text(i18n.tr('Id')), + ), + DataColumn( + label: Text(i18n.tr('Scope')), + ), + DataColumn( + label: Text(i18n.tr('Name')), + ), + DataColumn( + label: Text(i18n.tr('Value')), + ), + DataColumn( + label: Text(i18n.tr('Position')), ), ], rows: rows as List, @@ -108,6 +120,7 @@ class ListStructureCustom extends State { onTap: (offset) { _fieldData.theOffset = offset; requestRecords(); + setState(() => 1); }); final frameWidget = ListView(children: [ form, diff --git a/lib/page/structures/list_structure_page.dart b/lib/page/structures/list_structure_page.dart index c60cda3..cc03dc1 100644 --- a/lib/page/structures/list_structure_page.dart +++ b/lib/page/structures/list_structure_page.dart @@ -16,8 +16,8 @@ class ListStructurePage extends StatefulWidget { this, rc, GlobalData(), - StructureMeta.instance.pageByName('list')!, - StructureMeta.instance, + StructuresMeta.instance.pageByName('list')!, + StructuresMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/structures/structure_data.dart b/lib/page/structures/structure_data.dart index b09010a..c5d8586 100644 --- a/lib/page/structures/structure_data.dart +++ b/lib/page/structures/structure_data.dart @@ -9,9 +9,9 @@ class StructureData extends DataRecord { String? name; String? value; int? position; - DateTime? created; + DateTime? createdAt; String? createdBy; - DateTime? changed; + DateTime? changedAt; String? changedBy; StructureData( {this.id, @@ -19,9 +19,9 @@ class StructureData extends DataRecord { this.name, this.value, this.position, - this.created, + this.createdAt, this.createdBy, - this.changed, + this.changedAt, this.changedBy}); StructureData.createFromMap(DataMap map) { fromMap(map); @@ -43,14 +43,14 @@ class StructureData extends DataRecord { position = map.containsKey('structure_position') ? fromString(map['structure_position'], dataType: DataType.int) : null; - created = map.containsKey('structure_created') - ? fromString(map['structure_created'], dataType: DataType.datetime) + createdAt = map.containsKey('structure_createdat') + ? fromString(map['structure_createdat'], dataType: DataType.datetime) : null; createdBy = map.containsKey('structure_createdby') ? fromString(map['structure_createdby'], dataType: DataType.string) : null; - changed = map.containsKey('structure_changed') - ? fromString(map['structure_changed'], dataType: DataType.datetime) + changedAt = map.containsKey('structure_changedat') + ? fromString(map['structure_changedat'], dataType: DataType.datetime) : null; changedBy = map.containsKey('structure_changedby') ? fromString(map['structure_changedby'], dataType: DataType.string) @@ -85,13 +85,13 @@ class StructureData extends DataRecord { case 'position': rc = DataType.int; break; - case 'created': + case 'createdAt': rc = DataType.datetime; break; case 'createdBy': rc = DataType.string; break; - case 'changed': + case 'changedAt': rc = DataType.datetime; break; case 'changedBy': @@ -114,9 +114,9 @@ class StructureData extends DataRecord { map['structure_name'] = name; map['structure_value'] = value; map['structure_position'] = position; - map['structure_created'] = created; + map['structure_createdat'] = createdAt; map['structure_createdby'] = createdBy; - map['structure_changed'] = changed; + map['structure_changedat'] = changedAt; map['structure_changedby'] = changedBy; return map; } diff --git a/lib/page/users/create_user_page.dart b/lib/page/users/create_user_page.dart index 8f11c94..a476371 100644 --- a/lib/page/users/create_user_page.dart +++ b/lib/page/users/create_user_page.dart @@ -16,8 +16,8 @@ class CreateUserPage extends StatefulWidget { this, rc, GlobalData(), - UserMeta.instance.pageByName('create')!, - UserMeta.instance, + UsersMeta.instance.pageByName('create')!, + UsersMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/users/delete_user_page.dart b/lib/page/users/delete_user_page.dart index 6b563ac..d87137a 100644 --- a/lib/page/users/delete_user_page.dart +++ b/lib/page/users/delete_user_page.dart @@ -17,8 +17,8 @@ class DeleteUserPage extends StatefulWidget { this, rc, GlobalData(), - UserMeta.instance.pageByName('delete')!, - UserMeta.instance, + UsersMeta.instance.pageByName('delete')!, + UsersMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/users/edit_user_page.dart b/lib/page/users/edit_user_page.dart index b1ca38c..9b0c24f 100644 --- a/lib/page/users/edit_user_page.dart +++ b/lib/page/users/edit_user_page.dart @@ -17,8 +17,8 @@ class EditUserPage extends StatefulWidget { this, rc, GlobalData(), - UserMeta.instance.pageByName('edit')!, - UserMeta.instance, + UsersMeta.instance.pageByName('edit')!, + UsersMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/users/list_user_custom.dart b/lib/page/users/list_user_custom.dart index 330f896..4d5be2f 100644 --- a/lib/page/users/list_user_custom.dart +++ b/lib/page/users/list_user_custom.dart @@ -29,11 +29,11 @@ class ListUserCustom extends State { appBar: globalData.appBarBuilder(i18n.tr('Overview users')), drawer: globalData.drawerBuilder(context), floatingActionButton: FloatingActionButton( - onPressed: () { - globalData.navigate(context, '/Users/create'); - }, - child: const Icon(Icons.add), - ), + onPressed: () { + globalData.navigate(context, '/Users/create'); + }, + child: const Icon(Icons.add), + tooltip: 'Add a new user'), body: SafeArea( child: FutureBuilder( future: _futureDbData, @@ -135,6 +135,7 @@ class ListUserCustom extends State { onTap: (offset) { _fieldData.theOffset = offset; requestRecords(); + setState(() => 1); }); final frameWidget = ListView(children: [ form, diff --git a/lib/page/users/list_user_page.dart b/lib/page/users/list_user_page.dart index 186994f..41a1c6c 100644 --- a/lib/page/users/list_user_page.dart +++ b/lib/page/users/list_user_page.dart @@ -16,8 +16,8 @@ class ListUserPage extends StatefulWidget { this, rc, GlobalData(), - UserMeta.instance.pageByName('list')!, - UserMeta.instance, + UsersMeta.instance.pageByName('list')!, + UsersMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); diff --git a/lib/page/users/user_data.dart b/lib/page/users/user_data.dart index 427c74d..61a9eea 100644 --- a/lib/page/users/user_data.dart +++ b/lib/page/users/user_data.dart @@ -9,9 +9,9 @@ class UserData extends DataRecord { String? displayName; String? email; int? role; - DateTime? created; + DateTime? createdAt; String? createdBy; - DateTime? changed; + DateTime? changedAt; String? changedBy; UserData( {this.id, @@ -19,9 +19,9 @@ class UserData extends DataRecord { this.displayName, this.email, this.role, - this.created, + this.createdAt, this.createdBy, - this.changed, + this.changedAt, this.changedBy}); UserData.createFromMap(DataMap map) { fromMap(map); @@ -43,14 +43,14 @@ class UserData extends DataRecord { role = map.containsKey('user_role') ? fromString(map['user_role'], dataType: DataType.reference) : null; - created = map.containsKey('user_created') - ? fromString(map['user_created'], dataType: DataType.datetime) + createdAt = map.containsKey('user_createdat') + ? fromString(map['user_createdat'], dataType: DataType.datetime) : null; createdBy = map.containsKey('user_createdby') ? fromString(map['user_createdby'], dataType: DataType.string) : null; - changed = map.containsKey('user_changed') - ? fromString(map['user_changed'], dataType: DataType.datetime) + changedAt = map.containsKey('user_changedat') + ? fromString(map['user_changedat'], dataType: DataType.datetime) : null; changedBy = map.containsKey('user_changedby') ? fromString(map['user_changedby'], dataType: DataType.string) @@ -85,13 +85,13 @@ class UserData extends DataRecord { case 'role': rc = DataType.reference; break; - case 'created': + case 'createdAt': rc = DataType.datetime; break; case 'createdBy': rc = DataType.string; break; - case 'changed': + case 'changedAt': rc = DataType.datetime; break; case 'changedBy': @@ -114,9 +114,9 @@ class UserData extends DataRecord { map['user_displayname'] = displayName; map['user_email'] = email; map['user_role'] = role; - map['user_created'] = created; + map['user_createdat'] = createdAt; map['user_createdby'] = createdBy; - map['user_changed'] = changed; + map['user_changedat'] = changedAt; map['user_changedby'] = changedBy; return map; } diff --git a/lib/setting/drawer_exhibition.dart b/lib/setting/drawer_exhibition.dart index da7b246..d7160d7 100644 --- a/lib/setting/drawer_exhibition.dart +++ b/lib/setting/drawer_exhibition.dart @@ -1,4 +1,5 @@ import 'package:dart_bones/dart_bones.dart'; +import 'package:exhibition/base/helper.dart'; import 'package:exhibition/page/page_manager.dart'; import 'package:flutter/material.dart'; @@ -73,6 +74,9 @@ class MenuConverter { IconData iconByName(String name, BaseLogger logger) { IconData? rc; switch (name) { + case 'widgets_outlined': + rc = Icons.widgets_outlined; + break; case 'people_outlined': rc = Icons.people_outline; break; @@ -118,17 +122,21 @@ class MenuItem { final collection = PageManager(); return [ MenuItem( - 'Benchmarks', + i18n.tr('Benchmarks'), () => collection.newPageByRoute('/Benchmarks/list'), converter.iconByName('analytics_outlined', logger)), - MenuItem('Users', () => collection.newPageByRoute('/Users/list'), + MenuItem( + i18n.tr('Starters'), + () => collection.newPageByRoute('/Starters/list'), + converter.iconByName('widgets_outlined', logger)), + MenuItem(i18n.tr('Users'), () => collection.newPageByRoute('/Users/list'), converter.iconByName('people_outlined', logger)), - MenuItem('Protokoll', () => collection.newPageByRoute('/log'), + MenuItem(i18n.tr('Protocol'), () => collection.newPageByRoute('/log'), converter.iconByName('line_weight_outlined', logger)), - MenuItem('Information', () => collection.newPageByRoute('/info'), + MenuItem(i18n.tr('Information'), () => collection.newPageByRoute('/info'), converter.iconByName('info_outline', logger)), MenuItem( - 'Konfiguration', + i18n.tr('Configuration'), () => collection.newPageByRoute('/configuration'), converter.iconByName('settings_applications_outlined', logger)), ]; diff --git a/metatool/bin/page_generator.dart b/metatool/bin/page_generator.dart index 9252dad..80e4a37 100644 --- a/metatool/bin/page_generator.dart +++ b/metatool/bin/page_generator.dart @@ -50,8 +50,8 @@ DEF_PRIMARY final PageStates pageStates = PageStates(); this, rc, GlobalData(), - UserMeta.instance.pageByName('edit')!, - UserMeta.instance, + UsersMeta.instance.pageByName('edit')!, + UsersMeta.instance, pageStates, (afterReload, rebuild) => rc.reload(afterReload: afterReload, rebuild: rebuild)); @@ -134,6 +134,7 @@ class ListUserCustom extends State { globalData.navigate(context, '/Users/create'); }, child: const Icon(Icons.add), + tooltip: #TIP_ADD ), body: SafeArea( child: FutureBuilder( @@ -470,8 +471,9 @@ StatefulWidget? customPageByRoute(String route) { (field as PropertyMetaData).displayType == DisplayType.text) { var value = '_fieldData.${field.name}'; if (field.dataType != DataType.string) { - value = field.dataType == DataType.date ? 'asString($value, dateOnly: true)' - : 'asString($value)'; + value = field.dataType == DataType.date + ? 'asString($value, dateOnly: true)' + : 'asString($value)'; } buffer.writeln(' ${field.name}Controller.text = $value;'); } @@ -807,6 +809,8 @@ StatefulWidget? customPageByRoute(String route) { /// Returns a Dart class definition of the [page] that should not be modified. String createListPage(ListPageMetaData page) { + final toolTip = + page.toolTipAddButton.isEmpty ? 'null' : "'${page.toolTipAddButton}'"; var rc = replaceVariables(templateListCustom, page) .replaceFirst('#DEF_CONTROLLERS', buildDefinitionControllers(page)) .replaceFirst('#INIT_COMBOS', buildInitializeComboBoxes(page)) @@ -817,7 +821,8 @@ StatefulWidget? customPageByRoute(String route) { .replaceFirst('#DISPOSE_CONTROLLER', buildDisposeControllers(page)) .replaceFirst('#DEF_FIELDS', buildDefinitionFields(page)) .replaceFirst('#EDIT1', 'Edit') - .replaceFirst('#EDIT2', 'edit'); + .replaceFirst('#EDIT2', 'edit') + .replaceFirst('#TIP_ADD', toolTip); return rc; } @@ -872,8 +877,8 @@ StatefulWidget? customPageByRoute(String route) { storageDone = templateStorageDoneCreate.replaceFirst( '#MODULE', page.module.moduleName); body = templateBodySimple; - didChangeDependencies = definitionFuture = importPersistence - = informAboutChanges = setPrimary = requestRecord = ''; + didChangeDependencies = definitionFuture = importPersistence = + informAboutChanges = setPrimary = requestRecord = ''; break; case PageType.edit: callToMap = ' _fieldData.toMap(parameters);\n'; diff --git a/metatool/bin/sql_generator.dart b/metatool/bin/sql_generator.dart index 1eb0926..106d2eb 100644 --- a/metatool/bin/sql_generator.dart +++ b/metatool/bin/sql_generator.dart @@ -135,14 +135,17 @@ update: } } parameters.write(']'); - var item = module.properties['changed']!; + if (! module.properties.containsKey('changedAt')){ + logger.error('Module $moduleName misses changedAt'); + } + var item = module.properties['changedAt']!; assignments.write(' ${item.columnName}=NOW()'); // parameters: [":id", ":name", ":displayname", ":email", ":changedby"] buffer.writeln(parameters); buffer.write(' sql: |\n'); buffer.write(' UPDATE $tableName SET\n'); buffer.writeln(assignments); - //user_name=:name, user_displayname=:displayname, user_email=:email, user_changed=NOW(), user_changedby=:changedby + //user_name=:name, user_displayname=:displayname, user_email=:email, user_changedAt=NOW(), user_changedby=:changedby buffer.write(' WHERE ${list[0].columnName}=:${list[0].name};\n'); items = module.standardColumns('createdBy'); @@ -176,12 +179,12 @@ update: } } parameters.write(']'); - item = module.properties['created']!; + item = module.properties['createdAt']!; addToBuffer('${item.columnName})', maxLength: 80, separator: ',', indent: 4, buffer: sql1); addToBuffer('NOW());', maxLength: 80, separator: ',', indent: 4, buffer: sql2); - // parameters: [":name", ":displayname", ":email", ":changedby"] + // parameters: [":name", ":displayname", ":email", ":createdAt"] buffer.write('''insert: type: insert '''); diff --git a/rest_server/data/sql/benchmarks.sql.yaml b/rest_server/data/sql/benchmarks.sql.yaml index 1214dba..67a1e38 100644 --- a/rest_server/data/sql/benchmarks.sql.yaml +++ b/rest_server/data/sql/benchmarks.sql.yaml @@ -34,7 +34,7 @@ update: benchmark_active=:active, benchmark_weight=:weight, benchmark_income=:income, - benchmark_changed=NOW() + benchmark_changedat=NOW() WHERE benchmark_id=:id; insert: type: insert @@ -43,6 +43,6 @@ insert: sql: | INSERT INTO benchmarks(benchmark_lastname,benchmark_firstname, benchmark_email,benchmark_birthday,benchmark_active,benchmark_weight, - benchmark_income,benchmark_createdby,benchmark_created) + benchmark_income,benchmark_createdby,benchmark_createdat) VALUES(:lastName,:firstName,:email,:birthday,:active,:weight,:income, :createdBy,NOW()); diff --git a/rest_server/data/sql/roles.sql.yaml b/rest_server/data/sql/roles.sql.yaml index 901ab64..34251b2 100644 --- a/rest_server/data/sql/roles.sql.yaml +++ b/rest_server/data/sql/roles.sql.yaml @@ -24,11 +24,11 @@ update: sql: | UPDATE roles SET role_name=:name, - role_changed=NOW() + role_changedat=NOW() WHERE role_id=:id; insert: type: insert parameters: [":name",":createdBy"] sql: | - INSERT INTO roles(role_name,role_createdby,role_created) + INSERT INTO roles(role_name,role_createdby,role_createdat) VALUES(:name,:createdBy,NOW()); diff --git a/rest_server/data/sql/starter.sql.yaml b/rest_server/data/sql/starter.sql.yaml new file mode 100644 index 0000000..56262e3 --- /dev/null +++ b/rest_server/data/sql/starter.sql.yaml @@ -0,0 +1,37 @@ +--- +# DO NOT CHANGE. This file is created by the meta_tool +# SQL statements of the module "Starters": + +module: Starters +list: + type: list + parameters: [] + order: "starter_id" + sql: | + SELECT + t0.* FROM starters t0 +byId: + type: record + parameters: [ ":id" ] + sql: "SELECT * FROM starters WHERE starter_id=:id;" +delete: + type: delete + parameters: [ ":id" ] + sql: "DELETE * FROM starters WHERE starter_id=:id;" +update: + type: update + parameters: [":id",":name",":link",":icon"] + sql: | + UPDATE starters SET + starter_name=:name, + starter_link=:link, + starter_icon=:icon, + starter_changedat=NOW() + WHERE starter_id=:id; +insert: + type: insert + parameters: [":name",":link",":icon",":createdBy"] + sql: | + INSERT INTO starters(starter_name,starter_link,starter_icon, + starter_createdby,starter_createdat) + VALUES(:name,:link,:icon,:createdBy,NOW()); diff --git a/rest_server/data/sql/starters.sql.yaml b/rest_server/data/sql/starters.sql.yaml new file mode 100644 index 0000000..56262e3 --- /dev/null +++ b/rest_server/data/sql/starters.sql.yaml @@ -0,0 +1,37 @@ +--- +# DO NOT CHANGE. This file is created by the meta_tool +# SQL statements of the module "Starters": + +module: Starters +list: + type: list + parameters: [] + order: "starter_id" + sql: | + SELECT + t0.* FROM starters t0 +byId: + type: record + parameters: [ ":id" ] + sql: "SELECT * FROM starters WHERE starter_id=:id;" +delete: + type: delete + parameters: [ ":id" ] + sql: "DELETE * FROM starters WHERE starter_id=:id;" +update: + type: update + parameters: [":id",":name",":link",":icon"] + sql: | + UPDATE starters SET + starter_name=:name, + starter_link=:link, + starter_icon=:icon, + starter_changedat=NOW() + WHERE starter_id=:id; +insert: + type: insert + parameters: [":name",":link",":icon",":createdBy"] + sql: | + INSERT INTO starters(starter_name,starter_link,starter_icon, + starter_createdby,starter_createdat) + VALUES(:name,:link,:icon,:createdBy,NOW()); diff --git a/rest_server/data/sql/structures.sql.yaml b/rest_server/data/sql/structures.sql.yaml index eb68f17..957a3cb 100644 --- a/rest_server/data/sql/structures.sql.yaml +++ b/rest_server/data/sql/structures.sql.yaml @@ -27,12 +27,12 @@ update: structure_name=:name, structure_value=:value, structure_position=:position, - structure_changed=NOW() + structure_changedat=NOW() WHERE structure_id=:id; insert: type: insert parameters: [":scope",":name",":value",":position",":createdBy"] sql: | INSERT INTO structures(structure_scope,structure_name,structure_value, - structure_position,structure_createdby,structure_created) + structure_position,structure_createdby,structure_createdat) VALUES(:scope,:name,:value,:position,:createdBy,NOW()); diff --git a/rest_server/data/sql/users.sql.yaml b/rest_server/data/sql/users.sql.yaml index 00a4637..18133b3 100644 --- a/rest_server/data/sql/users.sql.yaml +++ b/rest_server/data/sql/users.sql.yaml @@ -32,12 +32,12 @@ update: user_displayname=:displayName, user_email=:email, user_role=:role, - user_changed=NOW() + user_changedat=NOW() WHERE user_id=:id; insert: type: insert parameters: [":name",":displayName",":email",":role",":createdBy"] sql: | INSERT INTO users(user_name,user_displayname,user_email,user_role, - user_createdby,user_created) + user_createdby,user_createdat) VALUES(:name,:displayName,:email,:role,:createdBy,NOW());