excluded = RegExp.escape(excluded).replaceAll(';', '|');
}
parser.regExpExcluded = RegExp('^($excluded)\$');
- logger.log('excluding: ' + parser.regExpExcluded!.pattern, LEVEL_FINE);
+ logger.log('excluding: ' + parser.regExpExcluded.pattern, LEVEL_FINE);
}
parser.scanDirectory(args[0], 0);
parser.writePot(args[1]);
List<String> lines = [];
int currentLineNo = 0;
int currentIxLines = 0;
- RegExp? regExpExcluded;
+ late RegExp regExpExcluded;
// ...........................1.............1.........2
final regExpModule =
RegExp(r'''(\w+) = (I18N\(\)|i18n)\.module\(["'](.*?)['"]\);''');
}
for (var node in subDirs) {
if (depth == 0 &&
- regExpExcluded != null &&
- regExpExcluded!.firstMatch(node) != null) {
+ regExpExcluded.firstMatch(node) != null) {
logger.log('ignoring $node');
} else {
scanDirectory(
rc = removeInvisibleTag(count == 1 ? keySingular : keyPlural);
} else {
if (map.containsKey(keySingular)) {
- final info = map[keySingular];
- if (info!.list != null && count < info.list!.length) {
+ final info = map[keySingular]!;
+ if (info.list != null && count < info.list!.length) {
rc = info.list![count];
} else {
rc = count == 1 ? info.singular : info.plural;
':active': 'T',
':createdBy': 'benchmark'
};
- final answer = await globalData.restPersistence!
+ final answer = await globalData.restPersistence
.store(what: 'store', map: parameters);
if (!answer.startsWith('id:')) {
rc = '+++ storage failed: $answer';
/// The related database table.
String tableName = '';
+ final needsSqlAll;
+
/// If true the fields create, createdBy ... have the same ("short") column name
/// instead of prefix and name.
bool shortModifiedLabel = false;
{String tableName = '',
String moduleNameSingular = '',
String columnPrefix = '',
- bool shortModifiedLabel = false}) {
+ bool shortModifiedLabel = false,
+ bool this.needsSqlAll = false}) {
this.tableName = tableName.isEmpty ? moduleName.toLowerCase() : tableName;
this.shortModifiedLabel = shortModifiedLabel;
if (moduleNameSingular.isEmpty) {
/// Returns the meta data of a page given by its [name] or null if missing.
PageMetaData? pageByName(String name) {
- final rc =
- pageList.firstWhere((element) => element.name == name, orElse: null);
+ PageMetaData? rc;
+ for (var item in pageList) {
+ if (item.name == name) {
+ rc = item;
+ break;
+ }
+ }
+ return rc;
+ }
+
+ /// Returns the list of pages with a given [pageType]. May be empty.
+ List<PageMetaData> pagesByType(PageType pageType) {
+ final rc = <PageMetaData>[];
+ for (var item in pageList) {
+ if (item.pageType == pageType) {
+ rc.add(item);
+ break;
+ }
+ }
return rc;
}
/// Returns the primary key of the relation.
PropertyMetaData? primaryOf() {
- final rc = propertyList.firstWhere(
- (element) => element.options.contains('primary'),
- orElse: null);
+ PropertyMetaData? rc;
+ for (var item in propertyList) {
+ if (item.options.contains('primary')) {
+ rc = item;
+ break;
+ }
+ }
return rc;
}
return instance;
}
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('createdAt', i18n.tr('Created at'),
- DataType.datetime, ':hidden:'),
- PropertyMetaData(
- 'createdBy', i18n.tr('Created by'), DataType.string, ':hidden:',
- size: 32),
- PropertyMetaData(
- '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('fields')]),
- PageMetaData('Change Role', PageType.edit,
- fields: [CopyDbFields('fields')]),
- ListPageMetaData(
- 'Roles Overview',
- fields: [
- PropertyMetaData('text', i18n.tr('Text'), DataType.string,
- ':where=!text IS NONE OR (role_name like !text):',
+ : super(
+ 'Roles',
+ [
+ PropertyMetaData(
+ 'id', i18n.tr('Id'), DataType.reference, ':primary:',
+ displayType: DisplayType.combobox),
+ PropertyMetaData(
+ 'name', i18n.tr('Name'), 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('ChangedAt'),
+ DataType.datetime, ':hidden:'),
+ PropertyMetaData('changedBy', i18n.tr('Changed by'),
+ DataType.string, ':hidden:',
+ size: 32),
],
- toolTipAddButton: i18n.tr('Add a new role'),
- tableColumns: 'role_id;role_name',
- tableHeaders: i18n.tr(';Id;Name'),
- ),
- ]);
+ [
+ PageMetaData('New Role', PageType.create,
+ fields: [CopyDbFields('fields')]),
+ PageMetaData('Change Role', PageType.edit,
+ fields: [CopyDbFields('fields')]),
+ ListPageMetaData(
+ 'Roles Overview',
+ fields: [
+ PropertyMetaData('text', i18n.tr('Text'), DataType.string,
+ ':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'),
+ ),
+ ],
+ needsSqlAll: true);
@override
void onInitialized() {
super.onInitialized();
return instance;
}
RoleStarterMeta.internal()
- : super('RoleStarter', [
- PropertyMetaData('id', i18n.tr('Id'), DataType.reference, ':primary:',
- displayType: DisplayType.combobox),
- PropertyMetaData(
- 'role', i18n.tr('Role'), DataType.reference, ':notnull:',
- displayType: DisplayType.combobox,
- foreignKey: 'roles.role_id;role_name;role'),
- PropertyMetaData(
- 'starter', i18n.tr('Starter'), DataType.reference, ':notnull:',
- displayType: DisplayType.combobox,
- foreignKey: 'starters.starter_id;starter_name;starter'),
- 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),
- ], [
- MappingPageMetaData(
- i18n.tr('Role-Starter Assignment'),
- ),
- ]);
+ : super(
+ 'RoleStarter',
+ [
+ PropertyMetaData(
+ 'id', i18n.tr('Id'), DataType.reference, ':primary:',
+ displayType: DisplayType.combobox),
+ PropertyMetaData(
+ 'role', i18n.tr('Role'), DataType.reference, ':notnull:',
+ displayType: DisplayType.combobox,
+ foreignKey: 'roles.role_id;role_name;role'),
+ PropertyMetaData('starter', i18n.tr('Starter'),
+ DataType.reference, ':notnull:',
+ displayType: DisplayType.combobox,
+ foreignKey: 'starters.starter_id;starter_name;starter'),
+ PropertyMetaData('order', i18n.tr('Order'), DataType.int, ''),
+ 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),
+ ],
+ [
+ MappingPageMetaData(
+ i18n.tr('Role-Starter Assignment'),
+ ),
+ ListPageMetaData(
+ 'Role/Starter Assignment Overview',
+ fields: [],
+ tableColumns:
+ 'rolestarter_id;rolestarter_position;role;starter',
+ tableHeaders: i18n.tr(';Id;Position;Role;Starter'),
+ ),
+ ],
+ needsSqlAll: true);
@override
void onInitialized() {
super.onInitialized();
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:',
+ : super(
+ 'Starters',
+ [
+ PropertyMetaData(
+ 'id', i18n.tr('Id'), DataType.reference, ':primary:',
+ displayType: DisplayType.combobox),
+ PropertyMetaData(
+ 'name', i18n.tr('Name'), DataType.string, ':notnull:',
size: 64),
+ PropertyMetaData(
+ 'route', i18n.tr('Route'), DataType.string, ':notnull:',
+ size: 128),
+ 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_route like !text:',
+ size: 64),
+ ],
+ toolTipAddButton: i18n.tr('Add a new starter'),
+ tableColumns:
+ 'starter_id;starter_name;starter_route;starter_icon',
+ tableHeaders: i18n.tr(';Id;Name;Route;Icon'),
+ ),
],
- toolTipAddButton: i18n.tr('Add a new starter'),
- tableColumns: 'starter_id;starter_name;starter_link;starter_icon',
- tableHeaders: i18n.tr(';Id;Name;Link;Icon'),
- ),
- ]);
+ needsSqlAll: true);
@override
void onInitialized() {
super.onInitialized();
class CreateBenchmarkCustom extends State<CreateBenchmarkPage>
with MessageLine {
final globalData = GlobalData();
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'CreateBenchmark');
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Benchmarks/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
'sql': 'insert',
};
_fieldData.toMap(parameters);
- globalData.restPersistence!
+ globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {
if (answer.startsWith('id:')) {
setError(i18n.tr('Saving data failed: $answer'));
setState(() => 1);
} else {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Benchmarks/edit;$id');
}
}
}
void onVerifyAndStore() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
onStore();
}
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
final int primaryKey;
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'DeleteBenchmark');
child: FutureBuilder<DbData>(
future: _futureDbData,
builder: (context, snapshot) {
- final rc = attendedPage!.loadRecord(snapshot, (record) {
+ final rc = attendedPage.loadRecord(snapshot, (record) {
_fieldData.fromMap(record);
return buildFrame();
});
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Benchmarks/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
super.initState();
}
- void requestRecord() => _futureDbData = globalData.restPersistence!.query(
+ void requestRecord() => _futureDbData = globalData.restPersistence.query(
what: 'query',
data: {'module': 'Users', 'sql': 'byId', ':id': primaryKey});
'sql': 'delete',
':id': primaryKey
};
- globalData.restPersistence!
+ globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {
globalData.navigate(context, '/Benchmarks/list');
}
void onVerifyAndDelete() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
onDelete();
}
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
final int primaryKey;
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'EditBenchmark');
child: FutureBuilder<DbData>(
future: _futureDbData,
builder: (context, snapshot) {
- final rc = attendedPage!.loadRecord(snapshot, (record) {
+ final rc = attendedPage.loadRecord(snapshot, (record) {
_fieldData.fromMap(record);
return buildFrame();
});
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Benchmarks/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
super.initState();
}
- void requestRecord() => _futureDbData = globalData.restPersistence!.query(
+ void requestRecord() => _futureDbData = globalData.restPersistence.query(
what: 'query',
data: {'module': 'Users', 'sql': 'byId', ':id': primaryKey});
':id': primaryKey
};
_fieldData.toMap(parameters);
- globalData.restPersistence!
+ globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {
requestRecord();
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
setState(() => 1);
});
}
void onVerifyAndStore() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
onStore();
}
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
class ListBenchmarkCustom extends State<ListBenchmarkPage> {
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'CreateBenchmark');
rc = const CircularProgressIndicator();
} else {
if (snapshot.hasData) {
- final rows = attendedPage!.getRows(
+ final rows = attendedPage.getRows(
dbData: snapshot.data!,
columnList:
'benchmark_id;benchmark_lastname;benchmark_firstname;benchmark_birthday;benchmark_active;benchmark_income',
padding: EdgeInsets.symmetric(
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding))));
final table = DataTable(
columns: <DataColumn>[
],
rows: rows as List<DataRow>,
);
- Widget? tabBar = attendedPage!.buildChipBar(
+ Widget? tabBar = attendedPage.buildChipBar(
totalCount: totalCount,
offset: _fieldData.theOffset,
pageSize: _fieldData.thePageSize,
}
void requestRecords() =>
- _futureDbData = globalData.restPersistence!.query(what: 'query', data: {
+ _futureDbData = globalData.restPersistence.query(what: 'query', data: {
'module': 'Benchmarks',
'sql': 'list',
'offset': _fieldData.theOffset,
});
void search() {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
requestRecords();
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
String? href,
String? title,
) async {
- if (href!.startsWith('file:')) {
- if (++clickCounter > 3) {
- // globalData.navigate(context, '/configurations/base');
+ if (href != null) {
+ if (href.startsWith('file:')) {
+ if (++clickCounter > 3) {
+ // globalData.navigate(context, '/configurations/base');
+ }
+ } else {
+ await canLaunch(href)
+ ? await launch(href)
+ : globalData.logger.error('Could not launch $href');
}
- } else {
- await canLaunch(href)
- ? await launch(href)
- : globalData.logger.error('Could not launch $href');
}
}
}
void store(context) async {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
}
}
import 'roles/edit_role_page.dart';
import 'roles/list_role_page.dart';
import 'rolestarter/mapping_rolestarter_page.dart';
+import 'rolestarter/list_rolestarter_page.dart';
import 'starters/create_starter_page.dart';
import 'starters/edit_starter_page.dart';
import 'starters/delete_starter_page.dart';
case '/RoleStarter/mapping':
rc = MappingRoleStarterPage();
break;
+ case '/RoleStarter/list':
+ rc = ListRoleStarterPage();
+ break;
case '/Starters/create':
rc = CreateStarterPage();
break;
class CreateRoleCustom extends State<CreateRolePage> with MessageLine {
final globalData = GlobalData();
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'CreateRole');
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Roles/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
'sql': 'insert',
};
_fieldData.toMap(parameters);
- globalData.restPersistence!
+ globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {
if (answer.startsWith('id:')) {
setError(i18n.tr('Saving data failed: $answer'));
setState(() => 1);
} else {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Roles/edit;$id');
}
}
}
void onVerifyAndStore() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
onStore();
}
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
final int primaryKey;
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'EditRole');
child: FutureBuilder<DbData>(
future: _futureDbData,
builder: (context, snapshot) {
- final rc = attendedPage!.loadRecord(snapshot, (record) {
+ final rc = attendedPage.loadRecord(snapshot, (record) {
_fieldData.fromMap(record);
return buildFrame();
});
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Roles/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
super.initState();
}
- void requestRecord() => _futureDbData = globalData.restPersistence!.query(
+ void requestRecord() => _futureDbData = globalData.restPersistence.query(
what: 'query',
data: {'module': 'Users', 'sql': 'byId', ':id': primaryKey});
':id': primaryKey
};
_fieldData.toMap(parameters);
- globalData.restPersistence!
+ globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {
requestRecord();
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
setState(() => 1);
});
}
void onVerifyAndStore() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
onStore();
}
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
class ListRoleCustom extends State<ListRolePage> {
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'CreateRole');
rc = const CircularProgressIndicator();
} else {
if (snapshot.hasData) {
- final rows = attendedPage!.getRows(
+ final rows = attendedPage.getRows(
dbData: snapshot.data!,
columnList: 'role_id;role_name',
onDone: () => setState(() => 1),
padding: EdgeInsets.symmetric(
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding))));
final table = DataTable(
columns: <DataColumn>[
],
rows: rows as List<DataRow>,
);
- Widget? tabBar = attendedPage!.buildChipBar(
+ Widget? tabBar = attendedPage.buildChipBar(
totalCount: totalCount,
offset: _fieldData.theOffset,
pageSize: _fieldData.thePageSize,
}
void requestRecords() =>
- _futureDbData = globalData.restPersistence!.query(what: 'query', data: {
+ _futureDbData = globalData.restPersistence.query(what: 'query', data: {
'module': 'Roles',
'sql': 'list',
'offset': _fieldData.theOffset,
});
void search() {
- attendedPage!.pageStates.dbDataState.clear();
- if (_formKey.currentState!.validate()) {
+ attendedPage.pageStates.dbDataState.clear();
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
requestRecords();
setState(() => 1);
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
--- /dev/null
+// 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_rolestarter_page.dart';
+
+final i18n = I18N();
+
+class ListRoleStarterCustom extends State<ListRoleStarterPage> {
+ final globalData = GlobalData();
+ late Future<DbData> _futureDbData;
+ late AttendedPage attendedPage;
+ final _fieldData = _FieldData();
+ final GlobalKey<FormState> _formKey =
+ GlobalKey<FormState>(debugLabel: 'CreateRoleStarter');
+ ListRoleStarterCustom();
+ @override
+ Widget build(BuildContext context) {
+ final rc = Scaffold(
+ appBar: globalData.appBarBuilder(i18n.tr('Overview rolestarter')),
+ drawer: globalData.drawerBuilder(context),
+ floatingActionButton: FloatingActionButton(
+ onPressed: () {
+ globalData.navigate(context, '/RoleStarter/create');
+ },
+ child: const Icon(Icons.add),
+ tooltip: null),
+ body: SafeArea(
+ child: FutureBuilder<DbData>(
+ 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:
+ 'rolestarter_id;rolestarter_position;role;starter',
+ onDone: () => setState(() => 1),
+ routeEdit: '/RoleStarter/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>[
+ 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>[
+ DataColumn(
+ label: Text(i18n.tr('Id')),
+ ),
+ DataColumn(
+ label: Text(i18n.tr('Position')),
+ ),
+ DataColumn(
+ label: Text(i18n.tr('Role')),
+ ),
+ DataColumn(
+ label: Text(i18n.tr('Starter')),
+ ),
+ ],
+ rows: rows as List<DataRow>,
+ );
+ 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();
+ super.dispose();
+ }
+
+ @override
+ void initState() {
+ super.initState();
+ }
+
+ void requestRecords() =>
+ _futureDbData = globalData.restPersistence.query(what: 'query', data: {
+ 'module': 'RoleStarter',
+ 'sql': 'list',
+ 'offset': _fieldData.theOffset,
+ 'size': _fieldData.thePageSize,
+ });
+
+ void search() {
+ attendedPage.pageStates.dbDataState.clear();
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
+ _formKey.currentState!.save();
+ requestRecords();
+ setState(() => 1);
+ }
+ }
+}
+
+class _FieldData {
+ int thePageSize = 10;
+ int theOffset = 0;
+}
--- /dev/null
+// DO NOT CHANGE. This file is created by the meta_tool!
+import 'package:flutter/material.dart';
+
+import '../../meta/rolestarter_meta.dart';
+import '../../setting/global_data.dart';
+import '../../widget/attended_page.dart';
+import 'list_rolestarter_custom.dart';
+
+class ListRoleStarterPage extends StatefulWidget {
+ final PageStates pageStates = PageStates();
+ ListRoleStarterPage() : super();
+ @override
+ _ListRoleStarterPageState createState() {
+ final rc = _ListRoleStarterPageState();
+ rc.attendedPage = AttendedPage(
+ this,
+ rc,
+ GlobalData(),
+ RoleStarterMeta.instance.pageByName('list')!,
+ RoleStarterMeta.instance,
+ pageStates,
+ (afterReload, rebuild) =>
+ rc.reload(afterReload: afterReload, rebuild: rebuild));
+ pageStates.attendedPage = rc.attendedPage;
+ return rc;
+ }
+}
+
+class _ListRoleStarterPageState extends ListRoleStarterCustom {
+ _ListRoleStarterPageState() : 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();
+ }
+ });
+ }
+ }
+}
--- /dev/null
+// 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 '../../persistence/persistence.dart';
+import '../../services/global_widget.dart';
+import '../../setting/global_data.dart';
+import '../../widget/attended_page.dart';
+import '../../widget/widget_form.dart';
+import 'mapping_rolestarter_page.dart';
+
+final i18n = I18N();
+
+class CommonInfo {
+ final List<String> columns;
+ final List<MemberInfo> members = [];
+ CommonInfo({required this.columns});
+}
+
+class MappingRoleStarterCustom extends State<MappingRoleStarterPage> {
+ final globalData = GlobalData();
+ late Future<DbData> _futureDbDataCommon;
+ late Future<DbData> _futureDbDataMember;
+ late Future<DbData> _futureDbDataConnection;
+ var membersOfCommon = <int, List<int>>{};
+ late AttendedPage attendedPage;
+ final _fieldData = _FieldData();
+ final GlobalKey<FormState> _formKey =
+ GlobalKey<FormState>(debugLabel: 'CreateRole');
+ final textController = TextEditingController();
+ final commonColumns = ['role_name'];
+ final memberColumns = ['starter_name', 'starter_route'];
+ final commonInfos = <int, CommonInfo>{};
+
+ /// Members of the current common module:
+ final memberInfos = <MemberInfo>[];
+
+ final notMemberInfos = <MemberInfo>[];
+ JsonList membersRows = [];
+ JsonList commonRows = [];
+ JsonList connectionRows = [];
+ MappingRoleStarterCustom();
+
+ @override
+ Widget build(BuildContext context) {
+ final rc = Scaffold(
+ appBar: globalData.appBarBuilder(i18n.tr('Role/Starter Assignment')),
+ drawer: globalData.drawerBuilder(context),
+ body: SafeArea(
+ child: FutureBuilder<List<DbData>>(
+ future: Future.wait([
+ _futureDbDataMember,
+ _futureDbDataCommon,
+ _futureDbDataConnection
+ ]),
+ builder: (context, AsyncSnapshot<List<DbData>> snapshot) {
+ Widget rc;
+ if (snapshot.connectionState != ConnectionState.done) {
+ rc = const CircularProgressIndicator();
+ } else {
+ if (snapshot.hasData) {
+ commonRows = snapshot.data![0].recordList ?? [];
+ membersRows = snapshot.data![1].recordList ?? [];
+ connectionRows = snapshot.data![2].recordList ?? [];
+ handleConnectionRows();
+ rc = buildFrame();
+ } else if (snapshot.hasError) {
+ rc = Text('Backend problem: ${snapshot.error}');
+ } else {
+ rc = const CircularProgressIndicator();
+ }
+ }
+ return rc;
+ },
+ )),
+ );
+ return rc;
+ }
+
+ /// Builds the items of the common module combobox from the database records.
+ List<DropdownMenuItem<int>> buildCommonItems() {
+ final rc = <DropdownMenuItem<int>>[];
+ for (var record in commonRows) {
+ rc.add(DropdownMenuItem<int>(
+ value: record['role_id'], child: Text(record['role_name'])));
+ }
+ return rc;
+ }
+
+ Widget buildFrame() {
+ final padding = GlobalThemeData.padding;
+ final itemsRoles = <DropdownMenuItem<int>>[];
+ final formItems = <FormItem>[
+ FormItem(
+ DropdownButtonFormField<int>(
+ value: itemsRoles.length == 1 ? 0 : _fieldData.role,
+ items: buildCommonItems(),
+ isExpanded: true,
+ decoration: InputDecoration(labelText: i18n.tr('Role')),
+ onChanged: (value) => _fieldData.role = value ?? 0,
+ ),
+ weight: 6),
+ FormItem(
+ ElevatedButton(onPressed: () => save(), child: Text(i18n.tr('Save'))),
+ 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 tableMembers = buildMemberTable();
+ final tableNotMembers = buildNotMemberTable();
+ final frameWidget = ListView(children: [
+ form,
+ Text(i18n.tr('The following items are assigned. Click it to remove.')),
+ SizedBox(height: padding),
+ tableMembers,
+ SizedBox(height: padding),
+ Text(
+ i18n.tr('The following items are not assigned. Click it to assign.')),
+ SizedBox(height: padding),
+ tableNotMembers,
+ ]);
+ return frameWidget;
+ }
+
+ buildMemberTable() {
+ final rows = buildTableItems(
+ commonInfos[_fieldData.role]!.members, 'rolestarter_id');
+ final headers = <DataColumn>[];
+ for (var column in commonInfos[_fieldData.role]!.columns) {
+ final label =
+ attendedPage.moduleMetaData.propertyByColumnName(column)?.label ??
+ i18n.tr('Info');
+ headers.add(DataColumn(label: Text(label)));
+ }
+ final rc = DataTable(
+ columns: headers,
+ rows: rows,
+ );
+ return rc;
+ }
+
+ buildNotMemberTable() {
+ final rows = buildTableItems(
+ commonInfos[_fieldData.role]!.members, 'rolestarter_id');
+ final headers = <DataColumn>[];
+ for (var column in commonInfos[_fieldData.role]!.columns) {
+ final label =
+ attendedPage.moduleMetaData.propertyByColumnName(column)?.label ??
+ i18n.tr('Info');
+ headers.add(DataColumn(label: Text(label)));
+ }
+ final rc = DataTable(
+ columns: headers,
+ rows: rows,
+ );
+ return rc;
+ }
+
+ /// Build the [notMemberInfos] list of items not being members of the common
+ /// module with [commonId].
+ void buildNotMembers(int commonId) {
+ notMemberInfos.clear();
+ int order = 10;
+ for (var record in membersRows) {
+ final id = record['rolestarter_starter'];
+ if (record['rolestarter_role'] == commonId && !hasMember(id)) {
+ notMemberInfos.add(MemberInfo(
+ memberId: id, position: order++, columns: memberColumns));
+ }
+ }
+ }
+
+ buildTableItems(List<MemberInfo> members, String primary) {
+ members.map((MemberInfo element) {
+ final cells = <DataCell>[];
+ final record = findRecord(membersRows, primary, element.memberId);
+ if (record != null) {
+ for (var column in element.columns) {
+ cells.add(DataCell(Text(record[column])));
+ }
+ }
+ return DataRow(cells: cells);
+ });
+ }
+
+ @override
+ void didChangeDependencies() {
+ super.didChangeDependencies();
+ requestRecords();
+ }
+
+ @override
+ void dispose() {
+ helperDummyUsage(DataType.string);
+ globalWidgetDummyUsage();
+ textController.dispose();
+ super.dispose();
+ }
+
+ /// Finds a record in a list of records by a given [id] in a given [column].
+ JsonMap? findRecord(JsonList rows, String column, int id) {
+ JsonMap? rc;
+ for (var record in rows) {
+ if (record[column] == id) {
+ rc = record;
+ break;
+ }
+ }
+ return rc;
+ }
+
+ /// Inspects the [connectionRows] and build the internal structures.
+ void handleConnectionRows() {
+ commonInfos.clear();
+ for (var record in commonRows) {
+ int common = record['role_id'];
+ commonInfos[common] = CommonInfo(columns: commonColumns);
+ }
+ for (var record in connectionRows) {
+ int common = record['rolestarter_role'];
+ if (!commonInfos.containsKey(common)) {
+ commonInfos[common] = CommonInfo(columns: commonColumns);
+ }
+ commonInfos[common]!.members.add(MemberInfo(
+ memberId: record['rolestarter_starter'],
+ columns: memberColumns,
+ position: record['rolestarter_position']));
+ }
+ for (var key in commonInfos.keys) {
+ commonInfos[key]!.members.sort((a, b) => a.position - b.position);
+ }
+ }
+
+ /// Returns whether the given [memberId] is part of [memberInfos].
+ bool hasMember(int memberId) {
+ bool rc = false;
+ for (var item in memberInfos) {
+ if (item.memberId == memberId) {
+ rc = true;
+ break;
+ }
+ }
+ return rc;
+ }
+
+ @override
+ void initState() {
+ super.initState();
+ }
+
+ void requestRecords() {
+ _futureDbDataMember =
+ globalData.restPersistence.query(what: 'query', data: {
+ 'module': 'Starters',
+ 'sql': 'all',
+ });
+ _futureDbDataCommon =
+ globalData.restPersistence.query(what: 'query', data: {
+ 'module': 'Roles',
+ 'sql': 'all',
+ });
+ _futureDbDataConnection =
+ globalData.restPersistence.query(what: 'query', data: {
+ 'module': 'RoleStarter',
+ 'sql': 'all',
+ });
+ }
+
+ void save() {
+ attendedPage.pageStates.dbDataState.clear();
+ if (_formKey.currentState!.validate()) {
+ _formKey.currentState!.save();
+ requestRecords();
+ setState(() => 1);
+ }
+ }
+}
+
+class MemberInfo {
+ final int memberId;
+ final int position;
+ final List<String> columns;
+ MemberInfo(
+ {required this.memberId, required this.position, required this.columns});
+}
+
+class _FieldData {
+ int role = 0;
+}
--- /dev/null
+// DO NOT CHANGE. This file is created by the meta_tool!
+import 'package:flutter/material.dart';
+
+import '../../meta/rolestarter_meta.dart';
+import '../../setting/global_data.dart';
+import '../../widget/attended_page.dart';
+import 'mapping_rolestarter_custom.dart';
+
+class MappingRoleStarterPage extends StatefulWidget {
+ final PageStates pageStates = PageStates();
+ MappingRoleStarterPage() : super();
+ @override
+ _MappingRoleStarterPageState createState() {
+ final rc = _MappingRoleStarterPageState();
+ rc.attendedPage = AttendedPage(
+ this,
+ rc,
+ GlobalData(),
+ RoleStarterMeta.instance.pageByName('mapping')!,
+ RoleStarterMeta.instance,
+ pageStates,
+ (afterReload, rebuild) =>
+ rc.reload(afterReload: afterReload, rebuild: rebuild));
+ pageStates.attendedPage = rc.attendedPage;
+ return rc;
+ }
+}
+
+class _MappingRoleStarterPageState extends MappingRoleStarterCustom {
+ _MappingRoleStarterPageState() : 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();
+ }
+ });
+ }
+ }
+}
--- /dev/null
+// 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 RoleStarterData extends DataRecord<int> {
+ int? id;
+ int? role;
+ int? starter;
+ int? order;
+ DateTime? createdAt;
+ String? createdBy;
+ DateTime? changedAt;
+ String? changedBy;
+ RoleStarterData(
+ {this.id,
+ this.role,
+ this.starter,
+ this.order,
+ this.createdAt,
+ this.createdBy,
+ this.changedAt,
+ this.changedBy});
+ RoleStarterData.createFromMap(DataMap map) {
+ fromMap(map);
+ }
+ @override
+ void fromMap(DataMap map) {
+ id = map.containsKey('rolestarter_id')
+ ? fromString(map['rolestarter_id'], dataType: DataType.reference)
+ : null;
+ role = map.containsKey('rolestarter_role')
+ ? fromString(map['rolestarter_role'], dataType: DataType.reference)
+ : null;
+ starter = map.containsKey('rolestarter_starter')
+ ? fromString(map['rolestarter_starter'], dataType: DataType.reference)
+ : null;
+ order = map.containsKey('rolestarter_order')
+ ? fromString(map['rolestarter_order'], dataType: DataType.int)
+ : null;
+ createdAt = map.containsKey('rolestarter_createdat')
+ ? fromString(map['rolestarter_createdat'], dataType: DataType.datetime)
+ : null;
+ createdBy = map.containsKey('rolestarter_createdby')
+ ? fromString(map['rolestarter_createdby'], dataType: DataType.string)
+ : null;
+ changedAt = map.containsKey('rolestarter_changedat')
+ ? fromString(map['rolestarter_changedat'], dataType: DataType.datetime)
+ : null;
+ changedBy = map.containsKey('rolestarter_changedby')
+ ? fromString(map['rolestarter_changedby'], dataType: DataType.string)
+ : null;
+ }
+
+ @override
+ int keyOf() {
+ return id ?? 0;
+ }
+
+ @override
+ String nameOfKey() {
+ return 'rolestarter_id';
+ }
+
+ static DataType? dataTypeOf(String name) {
+ DataType? rc;
+ switch (name) {
+ case 'id':
+ rc = DataType.reference;
+ break;
+ case 'role':
+ rc = DataType.reference;
+ break;
+ case 'starter':
+ rc = DataType.reference;
+ break;
+ case 'order':
+ rc = DataType.int;
+ 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['rolestarter_id'] = id;
+ map['rolestarter_role'] = role;
+ map['rolestarter_starter'] = starter;
+ map['rolestarter_order'] = order;
+ map['rolestarter_createdat'] = createdAt;
+ map['rolestarter_createdby'] = createdBy;
+ map['rolestarter_changedat'] = changedAt;
+ map['rolestarter_changedby'] = changedBy;
+ return map;
+ }
+}
RestPersistence.fromConfig(configuration, logger),
logger);
globalData.initializeAsync().then((value) {
- globalData.navigate(context, '/Starters/list');
+ globalData.navigate(context, '/RoleStarter/mapping');
});
}
});
class CreateStarterCustom extends State<CreateStarterPage> with MessageLine {
final globalData = GlobalData();
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'CreateStarter');
final nameController = TextEditingController();
- final linkController = TextEditingController();
+ final routeController = TextEditingController();
final iconController = TextEditingController();
CreateStarterCustom();
@override
Widget buildFrame() {
final padding = GlobalThemeData.padding;
nameController.text = _fieldData.name;
- linkController.text = _fieldData.link;
+ routeController.text = _fieldData.route;
iconController.text = _fieldData.icon;
final formItems = <FormItem>[
FormItem(
weight: 6),
FormItem(
TextFormField(
- controller: linkController,
- decoration: InputDecoration(labelText: i18n.tr('Link')),
+ controller: routeController,
+ decoration: InputDecoration(labelText: i18n.tr('Route')),
validator: (input) => notEmpty(input),
- onSaved: (value) => _fieldData.link = value ?? ''),
+ onSaved: (value) => _fieldData.route = value ?? ''),
weight: 6),
FormItem(
TextFormField(
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Starters/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
helperDummyUsage(DataType.int);
globalWidgetDummyUsage();
nameController.dispose();
- linkController.dispose();
+ routeController.dispose();
iconController.dispose();
super.dispose();
}
'sql': 'insert',
};
_fieldData.toMap(parameters);
- globalData.restPersistence!
+ globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {
if (answer.startsWith('id:')) {
setError(i18n.tr('Saving data failed: $answer'));
setState(() => 1);
} else {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Starters/edit;$id');
}
}
}
void onVerifyAndStore() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
onStore();
}
class _FieldData {
String name = '';
- String link = '';
+ String route = '';
String icon = '';
void toMap(Map<String, dynamic> map) {
map[':name'] = name;
- map[':link'] = link;
+ map[':route'] = route;
map[':icon'] = icon;
map[':createdBy'] = GlobalData.loginUserName;
}
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
final int primaryKey;
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'DeleteStarter');
final nameController = TextEditingController();
- final linkController = TextEditingController();
+ final routeController = TextEditingController();
final iconController = TextEditingController();
DeleteStarterCustom(this.primaryKey);
@override
child: FutureBuilder<DbData>(
future: _futureDbData,
builder: (context, snapshot) {
- final rc = attendedPage!.loadRecord(snapshot, (record) {
+ final rc = attendedPage.loadRecord(snapshot, (record) {
_fieldData.fromMap(record);
return buildFrame();
});
Widget buildFrame() {
final padding = GlobalThemeData.padding;
nameController.text = _fieldData.name;
- linkController.text = _fieldData.link;
+ routeController.text = _fieldData.route;
iconController.text = _fieldData.icon;
final formItems = <FormItem>[
FormItem(
weight: 6),
FormItem(
TextFormField(
- controller: linkController,
- decoration: InputDecoration(labelText: i18n.tr('Link')),
+ controller: routeController,
+ decoration: InputDecoration(labelText: i18n.tr('Route')),
validator: (input) => notEmpty(input),
- onSaved: (value) => _fieldData.link = value ?? ''),
+ onSaved: (value) => _fieldData.route = value ?? ''),
weight: 6),
FormItem(
TextFormField(
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Starters/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
helperDummyUsage(DataType.int);
globalWidgetDummyUsage();
nameController.dispose();
- linkController.dispose();
+ routeController.dispose();
iconController.dispose();
super.dispose();
}
super.initState();
}
- void requestRecord() => _futureDbData = globalData.restPersistence!.query(
+ void requestRecord() => _futureDbData = globalData.restPersistence.query(
what: 'query',
data: {'module': 'Users', 'sql': 'byId', ':id': primaryKey});
'sql': 'delete',
':id': primaryKey
};
- globalData.restPersistence!
+ globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {
globalData.navigate(context, '/Starters/list');
}
void onVerifyAndDelete() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
onDelete();
}
class _FieldData {
String name = '';
- String link = '';
+ String route = '';
String icon = '';
void fromMap(Map<String, dynamic> map) {
name = map['starter_name'];
- link = map['starter_link'];
+ route = map['starter_route'];
icon = map['starter_icon'];
}
}
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
final int primaryKey;
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'EditStarter');
final nameController = TextEditingController();
- final linkController = TextEditingController();
+ final routeController = TextEditingController();
final iconController = TextEditingController();
EditStarterCustom(this.primaryKey);
@override
child: FutureBuilder<DbData>(
future: _futureDbData,
builder: (context, snapshot) {
- final rc = attendedPage!.loadRecord(snapshot, (record) {
+ final rc = attendedPage.loadRecord(snapshot, (record) {
_fieldData.fromMap(record);
return buildFrame();
});
Widget buildFrame() {
final padding = GlobalThemeData.padding;
nameController.text = _fieldData.name;
- linkController.text = _fieldData.link;
+ routeController.text = _fieldData.route;
iconController.text = _fieldData.icon;
final formItems = <FormItem>[
FormItem(
weight: 6),
FormItem(
TextFormField(
- controller: linkController,
- decoration: InputDecoration(labelText: i18n.tr('Link')),
+ controller: routeController,
+ decoration: InputDecoration(labelText: i18n.tr('Route')),
validator: (input) => notEmpty(input),
- onSaved: (value) => _fieldData.link = value ?? ''),
+ onSaved: (value) => _fieldData.route = value ?? ''),
weight: 6),
FormItem(
TextFormField(
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Starters/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
helperDummyUsage(DataType.int);
globalWidgetDummyUsage();
nameController.dispose();
- linkController.dispose();
+ routeController.dispose();
iconController.dispose();
super.dispose();
}
super.initState();
}
- void requestRecord() => _futureDbData = globalData.restPersistence!.query(
+ void requestRecord() => _futureDbData = globalData.restPersistence.query(
what: 'query',
data: {'module': 'Users', 'sql': 'byId', ':id': primaryKey});
':id': primaryKey
};
_fieldData.toMap(parameters);
- globalData.restPersistence!
+ globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {
requestRecord();
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
setState(() => 1);
});
}
void onVerifyAndStore() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
onStore();
}
class _FieldData {
String name = '';
- String link = '';
+ String route = '';
String icon = '';
void fromMap(Map<String, dynamic> map) {
name = map['starter_name'];
- link = map['starter_link'];
+ route = map['starter_route'];
icon = map['starter_icon'];
}
void toMap(Map<String, dynamic> map) {
// please set outside: map[':id'] = primaryKey;
map[':name'] = name;
- map[':link'] = link;
+ map[':route'] = route;
map[':icon'] = icon;
map[':changedBy'] = GlobalData.loginUserName;
}
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
class ListStarterCustom extends State<ListStarterPage> {
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'CreateStarter');
rc = const CircularProgressIndicator();
} else {
if (snapshot.hasData) {
- final rows = attendedPage!.getRows(
+ final rows = attendedPage.getRows(
dbData: snapshot.data!,
columnList:
- 'starter_id;starter_name;starter_link;starter_icon',
+ 'starter_id;starter_name;starter_route;starter_icon',
onDone: () => setState(() => 1),
routeEdit: '/Starters/edit',
context: context);
padding: EdgeInsets.symmetric(
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding))));
final table = DataTable(
columns: <DataColumn>[
label: Text(i18n.tr('Name')),
),
DataColumn(
- label: Text(i18n.tr('Link')),
+ label: Text(i18n.tr('Route')),
),
DataColumn(
label: Text(i18n.tr('Icon')),
],
rows: rows as List<DataRow>,
);
- Widget? tabBar = attendedPage!.buildChipBar(
+ Widget? tabBar = attendedPage.buildChipBar(
totalCount: totalCount,
offset: _fieldData.theOffset,
pageSize: _fieldData.thePageSize,
}
void requestRecords() =>
- _futureDbData = globalData.restPersistence!.query(what: 'query', data: {
+ _futureDbData = globalData.restPersistence.query(what: 'query', data: {
'module': 'Starters',
'sql': 'list',
'offset': _fieldData.theOffset,
});
void search() {
- attendedPage!.pageStates.dbDataState.clear();
- if (_formKey.currentState!.validate()) {
+ attendedPage.pageStates.dbDataState.clear();
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
requestRecords();
setState(() => 1);
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
class StarterData extends DataRecord<int> {
int? id;
String? name;
- String? link;
+ String? route;
String? icon;
DateTime? createdAt;
String? createdBy;
StarterData(
{this.id,
this.name,
- this.link,
+ this.route,
this.icon,
this.createdAt,
this.createdBy,
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)
+ route = map.containsKey('starter_route')
+ ? fromString(map['starter_route'], dataType: DataType.string)
: null;
icon = map.containsKey('starter_icon')
? fromString(map['starter_icon'], dataType: DataType.string)
case 'name':
rc = DataType.string;
break;
- case 'link':
+ case 'route':
rc = DataType.string;
break;
case 'icon':
}
map['starter_id'] = id;
map['starter_name'] = name;
- map['starter_link'] = link;
+ map['starter_route'] = route;
map['starter_icon'] = icon;
map['starter_createdat'] = createdAt;
map['starter_createdby'] = createdBy;
class CreateStructureCustom extends State<CreateStructurePage>
with MessageLine {
final globalData = GlobalData();
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'CreateStructure');
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Structures/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
'sql': 'insert',
};
_fieldData.toMap(parameters);
- globalData.restPersistence!
+ globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {
if (answer.startsWith('id:')) {
setError(i18n.tr('Saving data failed: $answer'));
setState(() => 1);
} else {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Structures/edit;$id');
}
}
}
void onVerifyAndStore() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
onStore();
}
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
final int primaryKey;
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'DeleteStructure');
child: FutureBuilder<DbData>(
future: _futureDbData,
builder: (context, snapshot) {
- final rc = attendedPage!.loadRecord(snapshot, (record) {
+ final rc = attendedPage.loadRecord(snapshot, (record) {
_fieldData.fromMap(record);
return buildFrame();
});
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Structures/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
super.initState();
}
- void requestRecord() => _futureDbData = globalData.restPersistence!.query(
+ void requestRecord() => _futureDbData = globalData.restPersistence.query(
what: 'query',
data: {'module': 'Users', 'sql': 'byId', ':id': primaryKey});
'sql': 'delete',
':id': primaryKey
};
- globalData.restPersistence!
+ globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {
globalData.navigate(context, '/Structures/list');
}
void onVerifyAndDelete() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
onDelete();
}
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
final int primaryKey;
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'EditStructure');
child: FutureBuilder<DbData>(
future: _futureDbData,
builder: (context, snapshot) {
- final rc = attendedPage!.loadRecord(snapshot, (record) {
+ final rc = attendedPage.loadRecord(snapshot, (record) {
_fieldData.fromMap(record);
return buildFrame();
});
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Structures/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
super.initState();
}
- void requestRecord() => _futureDbData = globalData.restPersistence!.query(
+ void requestRecord() => _futureDbData = globalData.restPersistence.query(
what: 'query',
data: {'module': 'Users', 'sql': 'byId', ':id': primaryKey});
':id': primaryKey
};
_fieldData.toMap(parameters);
- globalData.restPersistence!
+ globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {
requestRecord();
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
setState(() => 1);
});
}
void onVerifyAndStore() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
onStore();
}
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
class ListStructureCustom extends State<ListStructurePage> {
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'CreateStructure');
rc = const CircularProgressIndicator();
} else {
if (snapshot.hasData) {
- final rows = attendedPage!.getRows(
+ final rows = attendedPage.getRows(
dbData: snapshot.data!,
columnList:
'structure_id;structure_scope;structure_name;structure_value;structure_position',
padding: EdgeInsets.symmetric(
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding))));
final table = DataTable(
columns: <DataColumn>[
],
rows: rows as List<DataRow>,
);
- Widget? tabBar = attendedPage!.buildChipBar(
+ Widget? tabBar = attendedPage.buildChipBar(
totalCount: totalCount,
offset: _fieldData.theOffset,
pageSize: _fieldData.thePageSize,
}
void requestRecords() =>
- _futureDbData = globalData.restPersistence!.query(what: 'query', data: {
+ _futureDbData = globalData.restPersistence.query(what: 'query', data: {
'module': 'Structures',
'sql': 'list',
'offset': _fieldData.theOffset,
});
void search() {
- attendedPage!.pageStates.dbDataState.clear();
- if (_formKey.currentState!.validate()) {
+ attendedPage.pageStates.dbDataState.clear();
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
requestRecords();
setState(() => 1);
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
class CreateUserCustom extends State<CreateUserPage> with MessageLine {
final globalData = GlobalData();
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'CreateUser');
Widget buildFrame() {
final padding = GlobalThemeData.padding;
comboRolesFromBackend(
- attendedPage: attendedPage!, onDone: () => setState(() => 1));
- final itemsRoles = comboRoles(
- i18n.trDyn(GlobalTranslations.comboboxSelect), attendedPage!);
+ attendedPage: attendedPage, onDone: () => setState(() => 1));
+ final itemsRoles =
+ comboRoles(i18n.trDyn(GlobalTranslations.comboboxSelect), attendedPage);
nameController.text = _fieldData.name;
displayNameController.text = _fieldData.displayName;
emailController.text = _fieldData.email;
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Users/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
'sql': 'insert',
};
_fieldData.toMap(parameters);
- globalData.restPersistence!
+ globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {
if (answer.startsWith('id:')) {
setError(i18n.tr('Saving data failed: $answer'));
setState(() => 1);
} else {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Users/edit;$id');
}
}
}
void onVerifyAndStore() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
onStore();
}
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
final int primaryKey;
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'DeleteUser');
child: FutureBuilder<DbData>(
future: _futureDbData,
builder: (context, snapshot) {
- final rc = attendedPage!.loadRecord(snapshot, (record) {
+ final rc = attendedPage.loadRecord(snapshot, (record) {
_fieldData.fromMap(record);
return buildFrame();
});
Widget buildFrame() {
final padding = GlobalThemeData.padding;
comboRolesFromBackend(
- attendedPage: attendedPage!, onDone: () => setState(() => 1));
- final itemsRoles = comboRoles(
- i18n.trDyn(GlobalTranslations.comboboxSelect), attendedPage!);
+ attendedPage: attendedPage, onDone: () => setState(() => 1));
+ final itemsRoles =
+ comboRoles(i18n.trDyn(GlobalTranslations.comboboxSelect), attendedPage);
nameController.text = _fieldData.name;
displayNameController.text = _fieldData.displayName;
emailController.text = _fieldData.email;
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Users/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
super.initState();
}
- void requestRecord() => _futureDbData = globalData.restPersistence!.query(
+ void requestRecord() => _futureDbData = globalData.restPersistence.query(
what: 'query',
data: {'module': 'Users', 'sql': 'byId', ':id': primaryKey});
'sql': 'delete',
':id': primaryKey
};
- globalData.restPersistence!
+ globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {
globalData.navigate(context, '/Users/list');
}
void onVerifyAndDelete() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
onDelete();
}
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
final int primaryKey;
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'EditUser');
child: FutureBuilder<DbData>(
future: _futureDbData,
builder: (context, snapshot) {
- final rc = attendedPage!.loadRecord(snapshot, (record) {
+ final rc = attendedPage.loadRecord(snapshot, (record) {
_fieldData.fromMap(record);
return buildFrame();
});
Widget buildFrame() {
final padding = GlobalThemeData.padding;
comboRolesFromBackend(
- attendedPage: attendedPage!, onDone: () => setState(() => 1));
- final itemsRoles = comboRoles(
- i18n.trDyn(GlobalTranslations.comboboxSelect), attendedPage!);
+ attendedPage: attendedPage, onDone: () => setState(() => 1));
+ final itemsRoles =
+ comboRoles(i18n.trDyn(GlobalTranslations.comboboxSelect), attendedPage);
nameController.text = _fieldData.name;
displayNameController.text = _fieldData.displayName;
emailController.text = _fieldData.email;
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Users/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
super.initState();
}
- void requestRecord() => _futureDbData = globalData.restPersistence!.query(
+ void requestRecord() => _futureDbData = globalData.restPersistence.query(
what: 'query',
data: {'module': 'Users', 'sql': 'byId', ':id': primaryKey});
':id': primaryKey
};
_fieldData.toMap(parameters);
- globalData.restPersistence!
+ globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {
requestRecord();
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
setState(() => 1);
});
}
void onVerifyAndStore() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
onStore();
}
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
class ListUserCustom extends State<ListUserPage> {
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'CreateUser');
rc = const CircularProgressIndicator();
} else {
if (snapshot.hasData) {
- final rows = attendedPage!.getRows(
+ final rows = attendedPage.getRows(
dbData: snapshot.data!,
columnList:
'user_id;user_name;user_displayname;user_email;role',
Widget buildFrame({required JsonList rows, required int totalCount}) {
final padding = GlobalThemeData.padding;
comboRolesFromBackend(
- attendedPage: attendedPage!, onDone: () => setState(() => 1));
+ attendedPage: attendedPage, onDone: () => setState(() => 1));
final itemsRoles = comboRoles(
- i18n.trDyn(GlobalTranslations.comboboxItemAll), attendedPage!);
+ i18n.trDyn(GlobalTranslations.comboboxItemAll), attendedPage);
final formItems = <FormItem>[
FormItem(
TextFormField(
padding: EdgeInsets.symmetric(
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding))));
final table = DataTable(
columns: <DataColumn>[
],
rows: rows as List<DataRow>,
);
- Widget? tabBar = attendedPage!.buildChipBar(
+ Widget? tabBar = attendedPage.buildChipBar(
totalCount: totalCount,
offset: _fieldData.theOffset,
pageSize: _fieldData.thePageSize,
}
void requestRecords() =>
- _futureDbData = globalData.restPersistence!.query(what: 'query', data: {
+ _futureDbData = globalData.restPersistence.query(what: 'query', data: {
'module': 'Users',
'sql': 'list',
'offset': _fieldData.theOffset,
});
void search() {
- attendedPage!.pageStates.dbDataState.clear();
- if (_formKey.currentState!.validate()) {
+ attendedPage.pageStates.dbDataState.clear();
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
requestRecords();
setState(() => 1);
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
if (!attendedPage.pageStates.dbDataState.hasEntry(name)) {
attendedPage.pageStates.dbDataState.addRequest(name).then((_) =>
GlobalData()
- .restPersistence!
+ .restPersistence
.query(what: 'query', data: parameters)
.then((value) {
attendedPage.pageStates.dbDataState
/// Storage for global resources. This is a singleton.
class GlobalData {
static const version = '2021.08.24.00';
- static GlobalData? _instance;
+ static late GlobalData _instance;
static String baseDirectory = '';
static var serverEnvironment = ServerEnvironment.productive;
static final String applicationName = theApplicationName;
final DrawerBuilder drawerBuilder;
final FooterBuilder footerBuilder;
final BaseConfiguration configuration;
- final RestPersistence? restPersistence;
+ late final RestPersistence restPersistence;
late HomeDirectories homeDirectories;
final navigatorStack = NavigatorStack();
- factory GlobalData() => _instance ?? GlobalData();
+ factory GlobalData() => _instance;
/// [configuration]: general settings.
/// [appBarBuilder]: a factory to create the Hamburger menu.
/// This allows to access the calling page from the current page,
/// e.g. to inform about changes.
class NavigatorStack {
- GlobalData? globalData;
+ late GlobalData globalData;
final stack = <NavigatorStackEntry>[];
/// Switches the page given by a [route].
}
}
if (parent == null) {
- globalData!.logger
+ globalData.logger
.error('informAboutChanges(): parent ${route!} not found');
} else {
// parent.noticeChange();
/// [context]: the context of the calling page.
void pop(BuildContext context) {
if (stack.isEmpty) {
- globalData!.logger.error('NavigatorStack.pop(): empty stack');
+ globalData.logger.error('NavigatorStack.pop(): empty stack');
} else {
stack.removeLast();
Navigator.pop(context);
?.addListener(() => attendedPage.reload(rebuild: true));
}
} else {
- globalData!.logger.error(
+ globalData.logger.error(
'supplyTopOfStack(): route $route not found. TOS: ' +
(last == null ? '<none>' : last.route));
}
/// Manages a list of [Structure] items.
class Structures {
- static Structures? _instance;
- GlobalData? globalData;
+ static late Structures _instance;
+ late GlobalData globalData;
final structures = <Structure>[];
final scopes = <String, List<Structure>>{};
/// Returns the singleton instance.
- factory Structures() => _instance!;
+ factory Structures() => _instance;
/// Builds the singleton instance with items from a JSon file.
///
this.globalData = GlobalData();
final file = File(filename);
if (!file.existsSync()) {
- globalData!.logger.error('cannot read structures from $filename');
+ globalData.logger.error('cannot read structures from $filename');
} else {
final content = file.readAsStringSync();
final data = convert.jsonDecode(content);
String name = 'record';
if (!pageStates.dbDataState.hasEntry(name)) {
pageStates.dbDataState.addRequest(name).then((_) => globalData
- .restPersistence!
+ .restPersistence
.query(what: what, data: parameters)
.then((value) {
pageStates.dbDataState
child: FutureBuilder<DbData>(
future: _futureDbData,
builder: (context, snapshot) {
- final rc = attendedPage!.loadRecord(snapshot, (record) {
+ final rc = attendedPage.loadRecord(snapshot, (record) {
_fieldData.fromMap(record);
return buildFrame();
});
@override
void didChangeDependencies() {
final size = MediaQuery.of(context).size;
- attendedPage!.pageStates.screenWidth = size.width;
- attendedPage!.pageStates.screenHeight = size.height;
+ attendedPage.pageStates.screenWidth = size.width;
+ attendedPage.pageStates.screenHeight = size.height;
super.didChangeDependencies();
}
}''';
static final templateGlobalComboBox = ''' comboRolesFromBackend(
- attendedPage: attendedPage!, onDone: () => setState(() => 1));
+ attendedPage: attendedPage, onDone: () => setState(() => 1));
final itemsRoles = comboRoles(
- i18n.trDyn(GlobalTranslations.combobox#UNDEF), attendedPage!);''';
+ i18n.trDyn(GlobalTranslations.combobox#UNDEF), attendedPage);''';
static final templateListCustom =
'''// This file is created by the meta_tool. But it can be customized.
class ListUserCustom extends State<ListUserPage> {
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'CreateUser');
rc = const CircularProgressIndicator();
} else {
if (snapshot.hasData) {
- final rows = attendedPage!.getRows(dbData: snapshot.data!,
+ final rows = attendedPage.getRows(dbData: snapshot.data!,
columnList: '#ROW_COLUMNS',
onDone: () => setState(() => 1),
route#EDIT1: '/Users/#EDIT2',
padding: EdgeInsets.symmetric(
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding))));
final table = DataTable(
columns: <DataColumn>[
#TABLE_HEADER ],
rows: rows as List<DataRow>,
);
- Widget? tabBar = attendedPage!.buildChipBar(
+ Widget? tabBar = attendedPage.buildChipBar(
totalCount: totalCount,
offset: _fieldData.theOffset,
pageSize: _fieldData.thePageSize,
super.initState();
}
- void requestRecords() => _futureDbData = globalData.restPersistence!.query(
+ void requestRecords() => _futureDbData = globalData.restPersistence.query(
what: 'query', data: {
'module': 'Users',
'sql': 'list',
#PARAM_DEF });
void search() {
- attendedPage!.pageStates.dbDataState.clear();
- if (_formKey.currentState!.validate()) {
+ attendedPage.pageStates.dbDataState.clear();
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
requestRecords();
setState(() => 1);
class MappingUserCustom extends State<MappingUserPage> {
final globalData = GlobalData();
late Future<DbData> _futureDbData;
- AttendedPage? attendedPage;
+ late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'CreateUser');
rc = const CircularProgressIndicator();
} else {
if (snapshot.hasData) {
- final rows = attendedPage!.getRows(dbData: snapshot.data!,
+ final rows = attendedPage.getRows(dbData: snapshot.data!,
columnList: '#ROW_COLUMNS',
onDone: () => setState(() => 1),
route#EDIT1: '/Users/#EDIT2',
padding: EdgeInsets.symmetric(
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding))));
final table = DataTable(
columns: <DataColumn>[
#TABLE_HEADER ],
rows: rows as List<DataRow>,
);
- Widget? tabBar = attendedPage!.buildChipBar(
+ Widget? tabBar = attendedPage.buildChipBar(
totalCount: totalCount,
offset: _fieldData.theOffset,
pageSize: _fieldData.thePageSize,
super.initState();
}
- void requestRecords() => _futureDbData = globalData.restPersistence!.query(
+ void requestRecords() => _futureDbData = globalData.restPersistence.query(
what: 'query', data: {
'module': 'Users',
'sql': 'list',
#PARAM_DEF });
void search() {
- attendedPage!.pageStates.dbDataState.clear();
- if (_formKey.currentState!.validate()) {
+ attendedPage.pageStates.dbDataState.clear();
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
requestRecords();
setState(() => 1);
class EditUserCustom extends State<EditUserPage> with MessageLine {
#DEF_PRIMARY final globalData = GlobalData();
-#DEF_FUTURE AttendedPage? attendedPage;
+#DEF_FUTURE late AttendedPage attendedPage;
final _fieldData = _FieldData();
final GlobalKey<FormState> _formKey =
GlobalKey<FormState>(debugLabel: 'EditUser');
FormItem(
ElevatedButton(
onPressed: () {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/Users/list');
},
child: Text(i18n.tr('Cancel')),
vertical: padding, horizontal: padding),
child: WidgetForm.flexibleGrid(
formItems,
- screenWidth: attendedPage!.pageStates.screenWidth,
+ screenWidth: attendedPage.pageStates.screenWidth,
padding: padding,
))));
return rc;
'module': 'Users',
'sql': '#SQL_TYPE',
#SET_PRIMARY };
-#CALL_TO_MAP globalData.restPersistence!
+#CALL_TO_MAP globalData.restPersistence
.store(what: 'store', map: parameters)
.then((answer) {#STORAGE_DONE});
}
void #ACTION2() {
- if (_formKey.currentState!.validate()) {
+ if (_formKey.currentState != null && _formKey.currentState!.validate()) {
_formKey.currentState!.save();
#ACTION1();
}
#FROM_MAP#TO_MAP}
''';
static final templateRequestRecord = '''
- void requestRecord() => _futureDbData = globalData.restPersistence!.query(
+ void requestRecord() => _futureDbData = globalData.restPersistence.query(
what: 'query',
data: {'module': 'Users', 'sql': 'byId', ':id': primaryKey});
setError(i18n.tr('Saving data failed: \$answer'));
setState(() => 1);
} else {
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
globalData.navigate(context, '/#MODULE/edit;\$id');
}
}
static final templateStorageDoneEdit = '''
requestRecord();
- attendedPage!.pageStates.dbDataState.clear();
+ attendedPage.pageStates.dbDataState.clear();
setState(() => 1);
''';
static final templateStorageDoneDelete =
var didChangeDependencies = templateDidChangeDependencies;
var definitionFuture = ' late Future<DbData> _futureDbData;';
var importPersistence = "import '../../persistence/persistence.dart';\n";
- var informAboutChanges = ' attendedPage!.informAboutChanges();';
+ var informAboutChanges = ' attendedPage.informAboutChanges();';
var requestRecord = templateRequestRecord;
page.pageType == PageType.edit
? 'update'
/// Creates the sections for pages with PageType.list of the [module].
String createListSections(ModuleMetaData module) {
final buffer = StringBuffer();
- List<PageMetaData>? listPages;
- try {
- listPages = module.pageList
- .where((element) => element.pageType == PageType.list)
- .toList(growable: false);
- } on Exception catch (exc) {
- logger.error('no page with list type: $exc');
- listPages = null;
+ final listPages = module.pagesByType(PageType.list);
+ final tableName = module.tableName;
+ for (var page in listPages) {
+ if (page is ListPageMetaData) {
+ var whereCondition = page.whereCondition;
+ if (whereCondition.endsWith('\n')) {
+ whereCondition =
+ whereCondition.substring(0, whereCondition.length - 1);
+ }
+ addListSql(page.name, page, whereCondition, tableName, buffer);
+ }
}
- if (listPages != null) {
- final tableName = module.tableName;
- for (var page in listPages) {
- if (page is ListPageMetaData) {
- var whereCondition = page.whereCondition;
- if (whereCondition.endsWith('\n')) {
- whereCondition =
- whereCondition.substring(0, whereCondition.length - 1);
- }
- String selectItems2 = '';
- var selectItems =
- page.selectItems.isEmpty ? '' : indent(page.selectItems, ' ');
- var joins = findReferences(module, (x) => selectItems2 = x);
- if (page.joinItems.isNotEmpty) {
- joins += indent(page.joinItems, ' ');
- if (!joins.endsWith('\n')) {
- joins += '\n';
- }
- }
- var parameters = '';
- if (whereCondition.isNotEmpty) {
- parameters = findParameters(whereCondition, page.fields);
- whereCondition = ' WHERE\n' + indent(whereCondition, ' ');
- }
- final order = page.orderBy.isNotEmpty
- ? page.orderBy
- : module.primaryOf()!.columnName;
- buffer.writeln(page.name + ':');
- buffer.writeln(''' type: list
+ if (module.needsSqlAll) {
+ PageMetaData? page = module.pageByName('list');
+ if (page != null) {
+ addListSql('all', page as ListPageMetaData, '1', tableName, buffer);
+ }
+ }
+ return buffer.toString();
+ }
+
+ void addListSql(String sqlName, ListPageMetaData page, String whereCondition,
+ String tableName, StringBuffer buffer) {
+ String selectItems2 = '';
+ var selectItems =
+ page.selectItems.isEmpty ? '' : indent(page.selectItems, ' ');
+ var joins = findReferences(page.module, (x) => selectItems2 = x);
+ if (page.joinItems.isNotEmpty) {
+ joins += indent(page.joinItems, ' ');
+ if (!joins.endsWith('\n')) {
+ joins += '\n';
+ }
+ }
+ var parameters = '';
+ if (whereCondition.isNotEmpty) {
+ parameters = findParameters(whereCondition, page.fields);
+ whereCondition = ' WHERE\n' + indent(whereCondition, ' ');
+ }
+ final order = page.orderBy.isNotEmpty
+ ? page.orderBy
+ : page.module.primaryOf()!.columnName;
+ buffer.writeln(sqlName + ':');
+ buffer.writeln(''' type: list
parameters: [$parameters]
order: "$order"
sql: |
SELECT''');
- if (selectItems.isNotEmpty) {
- addToBuffer(selectItems, maxLength: 80, buffer: buffer, indent: 6);
- }
- addToBuffer(' t0.*$selectItems2',
- maxLength: 80, buffer: buffer, indent: 6);
- buffer.writeln(' FROM $tableName t0');
- buffer.write('$joins$whereCondition');
- }
- }
+ if (selectItems.isNotEmpty) {
+ addToBuffer(selectItems, maxLength: 80, buffer: buffer, indent: 6);
}
- return buffer.toString();
+ addToBuffer(' t0.*$selectItems2',
+ maxLength: 80, buffer: buffer, indent: 6);
+ buffer.writeln('\n FROM $tableName t0');
+ buffer.write('$joins$whereCondition');
}
/// Returns the SQL statements for insert, update, delete...
}
}
parameters.write(']');
- if (! module.properties.containsKey('changedAt')){
+ if (!module.properties.containsKey('changedAt')) {
logger.error('Module $moduleName misses changedAt');
}
var item = module.properties['changedAt']!;
buffer.writeln(parameters);
buffer.writeln(sql1);
buffer.writeln(sql2);
+ for (var page in module.pagesByType(PageType.mapping)) {
+ final sql = sqlOfMapping(page as MappingPageMetaData);
+ buffer.write(sql);
+ }
return buffer.toString();
}
.map((element) => element.group(1))
.toSet()
.toList();
- return '"' + names.join('","') + '"';
+ return names.isEmpty ? '' : ('"' + names.join('","') + '"');
}
/// Creates the joins and select items the foreign keys of the given [module].
}
}
}
+
+ /// Returns the sql statement definitions of a page with type PageType.mapping.
+ String sqlOfMapping(MappingPageMetaData page) {
+ String rc = '';
+ return rc;
+ }
}
order: "benchmark_id"
sql: |
SELECT
- t0.* FROM benchmarks t0
+ t0.*
+ FROM benchmarks t0
WHERE
(:text='' OR benchmark_lastname like :text
OR benchmark_firstname like :text)
order: "role_id"
sql: |
SELECT
- t0.* FROM roles t0
+ t0.*
+ FROM roles t0
+all:
+ type: list
+ parameters: []
+ order: "role_id"
+ sql: |
+ SELECT
+ t0.*
+ FROM roles t0
+ WHERE
+ 1
byId:
type: record
parameters: [ ":id" ]
--- /dev/null
+---
+# DO NOT CHANGE. This file is created by the meta_tool
+# SQL statements of the module "RoleStarter":
+
+module: RoleStarter
+list:
+ type: list
+ parameters: []
+ order: "rolestarter_id"
+ sql: |
+ SELECT
+ t0.*,t1.role_name AS role,t2.starter_name AS starter
+ FROM rolestarter t0
+ JOIN roles t1 ON t1.role_id=t0.rolestarter_role
+ JOIN starters t2 ON t2.starter_id=t0.rolestarter_starter
+all:
+ type: list
+ parameters: []
+ order: "rolestarter_id"
+ sql: |
+ SELECT
+ t0.*,t1.role_name AS role,t2.starter_name AS starter
+ FROM rolestarter t0
+ JOIN roles t1 ON t1.role_id=t0.rolestarter_role
+ JOIN starters t2 ON t2.starter_id=t0.rolestarter_starter
+ WHERE
+ 1
+byId:
+ type: record
+ parameters: [ ":id" ]
+ sql: "SELECT * FROM rolestarter WHERE rolestarter_id=:id;"
+delete:
+ type: delete
+ parameters: [ ":id" ]
+ sql: "DELETE * FROM rolestarter WHERE rolestarter_id=:id;"
+update:
+ type: update
+ parameters: [":id",":role",":starter",":order"]
+ sql: |
+ UPDATE rolestarter SET
+ rolestarter_role=:role,
+ rolestarter_starter=:starter,
+ rolestarter_order=:order,
+ rolestarter_changedat=NOW()
+ WHERE rolestarter_id=:id;
+insert:
+ type: insert
+ parameters: [":role",":starter",":order",":createdBy"]
+ sql: |
+ INSERT INTO rolestarter(rolestarter_role,rolestarter_starter,
+ rolestarter_order,rolestarter_createdby,rolestarter_createdat)
+ VALUES(:role,:starter,:order,:createdBy,NOW());
order: "starter_id"
sql: |
SELECT
- t0.* FROM starters t0
+ t0.*
+ FROM starters t0
+all:
+ type: list
+ parameters: []
+ order: "starter_id"
+ sql: |
+ SELECT
+ t0.*
+ FROM starters t0
+ WHERE
+ 1
byId:
type: record
parameters: [ ":id" ]
sql: "DELETE * FROM starters WHERE starter_id=:id;"
update:
type: update
- parameters: [":id",":name",":link",":icon"]
+ parameters: [":id",":name",":route",":icon"]
sql: |
UPDATE starters SET
starter_name=:name,
- starter_link=:link,
+ starter_route=:route,
starter_icon=:icon,
starter_changedat=NOW()
WHERE starter_id=:id;
insert:
type: insert
- parameters: [":name",":link",":icon",":createdBy"]
+ parameters: [":name",":route",":icon",":createdBy"]
sql: |
- INSERT INTO starters(starter_name,starter_link,starter_icon,
+ INSERT INTO starters(starter_name,starter_route,starter_icon,
starter_createdby,starter_createdat)
- VALUES(:name,:link,:icon,:createdBy,NOW());
+ VALUES(:name,:route,:icon,:createdBy,NOW());
order: "structure_id"
sql: |
SELECT
- t0.* FROM structures t0
+ t0.*
+ FROM structures t0
byId:
type: record
parameters: [ ":id" ]
order: "user_id"
sql: |
SELECT
- t0.*,t1.role_name AS role FROM users t0
+ t0.*,t1.role_name AS role
+ FROM users t0
JOIN roles t1 ON t1.role_id=t0.user_role
WHERE
(:text='' OR user_name like :text
static const _version = 'V2021.08.19.00';
static BaseLogger? unittestLogger;
BaseLogger logger = MemoryLogger(LEVEL_FINE);
- BaseConfiguration configuration = BaseConfiguration({}, globalLogger);
+ late BaseConfiguration configuration;
var clientSessionTimeout = 15 * 60;
String serviceName = 'exhibition';
RestServer(
configuration.asInt('logLevel', section: 'service') ?? LEVEL_SUMMERY;
logger = unittestLogger ?? Logger(logFile, level);
globalLogger = logger;
+ logger.log('configuration read from $filename');
ProcessSync(logger);
FileSync.initialize(logger);
logger.log(
final int threadId;
final String serviceName;
int clientSessionTimeout = 30;
- BaseLogger logger = globalLogger;
+ late BaseLogger logger;
bool requestedCodecIsLatin1 = false;
HttpRequest? currentRequest;
String what = '';
MySqlDb? db;
String restVersion = '';
FileSync? _fileSync = FileSync();
- SqlStorage sqlStorage = SqlStorage(globalLogger);
+ late SqlStorage sqlStorage;
String sqlTestPrimaryTable = '';
ServiceWorker(this.threadId, this.configuration, this.serviceName) {
modules[moduleName] = SqlModule(moduleName, this);
}
final module = modules[moduleName];
- for (var name in map.keys) {
+ final keys = map.keys.toList();
+ for (var name in keys) {
switch (name) {
case 'module':
// already done.