DROP TABLE IF EXISTS configuration;
CREATE TABLE configuration (
configuration_id INT(10) UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT,
- configuration_scope VARCHAR(64) UNIQUE NOT NULL,
+ configuration_scope VARCHAR(64) NOT NULL,
configuration_property VARCHAR(64),
configuration_order INT(10),
configuration_type VARCHAR(16),
---
# configuration of the bones backend for configuration:
-created: 2020.10.20 23:16:54
+created: 2020.10.29 22:35:03
author: flutter_bones.module_model.exportSqlBackend()
version: 1.0.0
modules:
- name: record
type: record
sql: "SELECT * from configuration WHERE configuration_id=:configuration_id;"
- - name: by_configuration_scope
- type: record
- sql: "SELECT * from configuration WHERE configuration_scope=:configuration_scope&&configuration_id!=:excluded;"
- name: list
type: list
- sql: "SELECT * from configuration
- WHERE configuration_property like :configuration_property AND configuration_scope like :configuration_scope;"
+ sql: "SELECT t0.* from configuration t0
+ WHERE configuration_scope like :configuration_scope AND configuration_property like :configuration_property;"
---
# configuration of the bones backend for role:
-created: 2020.10.20 23:16:54
+created: 2020.10.29 22:35:03
author: flutter_bones.module_model.exportSqlBackend()
version: 1.0.0
modules:
sql: "SELECT * from role WHERE role_name=:role_name&&role_id!=:excluded;"
- name: list
type: list
- sql: "SELECT * from role
+ sql: "SELECT t0.* from role t0
WHERE role_name like :role_name;"
---
# configuration of the bones backend for user:
-created: 2020.10.20 23:16:54
+created: 2020.10.29 22:35:03
author: flutter_bones.module_model.exportSqlBackend()
version: 1.0.0
modules:
sql: "SELECT * from user WHERE user_email=:user_email&&user_id!=:excluded;"
- name: list
type: list
- sql: "SELECT * from user
- WHERE user_name like :user_name AND (:user_role is null or user_role=:user_role);"
+ sql: "SELECT t0.*,t1.role_name as user_role from user t0
+ left join role t1 on t1.role_id=t0.user_role
+ WHERE user_name like :user_name AND (:user_role IS NULL OR t0.user_role=:user_role);"
import 'src/page/role/role_list_page.dart';
import 'src/page/user/user_create_page.dart';
import 'src/page/user/user_list_page.dart';
+import 'src/page/configuration/configuration_create_page.dart';
+import 'src/page/configuration/configuration_list_page.dart';
import 'src/private/bsettings.dart';
class BoneApp extends StatefulWidget {
case '/user/create':
page = UserCreatePage(BSettings.lastInstance.pageData);
break;
- /*
case '/configuration/list':
page = ConfigurationListPage(BSettings.lastInstance.pageData);
break;
case '/configuration/create':
page = ConfigurationCreatePage(BSettings.lastInstance.pageData);
break;
- */
default:
page = LoginPage(BSettings.lastInstance.pageData);
break;
r'^(undef|readonly|disabled|doStore|hidden|null|notnull|password|primary|required|unique)$');
static final regExprListDbOption =
RegExp(r'^\w+\.\w+;\w+ \w+(?:;(:? ?:\w+=[^ ]*?)+)?$');
+ static final regExprForeignKey = RegExp(r'^\w+\.\w+ \w+$');
int size;
int rows;
final TableModel table;
- final Map<String, dynamic> map;
String foreignKey;
/// A constructor used in the parser.
- ColumnModel(this.table, this.map, BaseLogger logger)
+ ColumnModel(this.table, Map map, BaseLogger logger)
: super(null, null, map, WidgetModelType.column, logger);
/// A constructor for columns created by the program.
@required String label,
@required DataType dataType,
@required List<String> options,
- String toolTip,
- String listOption,
- ComboboxListType listType,
+ String toolTip,
+ String listOption,
+ ComboboxListType listType,
this.size,
- this.map,
- List<String> texts,
- List<dynamic> values,
+ List<String> texts,
+ List<dynamic> values,
BaseLogger logger})
- : super.direct(section: null, page: null,
- map: null,
- name: name, label: label, toolTip: toolTip, texts: texts, values: values,
- listOption: listOption, listType: listType, options: options,
- widgetType: WidgetModelType.column, logger: logger);
+ : super.direct(
+ section: null,
+ page: null,
+ map: null,
+ name: name,
+ label: label,
+ toolTip: toolTip,
+ texts: texts,
+ dataType: dataType,
+ values: values,
+ listOption: listOption,
+ listType: listType,
+ options: options,
+ widgetType: WidgetModelType.column,
+ logger: logger);
/// Dumps the instance into a [StringBuffer]
StringBuffer dump(StringBuffer stringBuffer) {
parseEnum<DataType>('dataType', map, DataType.values, required: true);
size = parseInt('size', map, required: dataType == DataType.string);
rows = parseInt('rows', map);
-
+ foreignKey = parseString('foreignKey', map);
+ if (foreignKey != null &&
+ regExprForeignKey.firstMatch(foreignKey) == null) {
+ logger.error(
+ 'invalid foreign key: $foreignKey expected: "<table>.<primary> <colName>" e.g. "role.role_id role_name"');
+ }
checkOptionsByRegExpr(options, regExprOptions);
if (options.contains('primary')) {
if (!options.contains('notnull')) {
DbReferenceModel.fromColumn(SectionModel section, PageModel page,
ColumnModel column, BaseLogger logger)
: super.direct(
- section: section,
- page: page,
- map: null,
- widgetType: WidgetModelType.dbReference,
- name: column.name,
- label: column.label,
- toolTip: column.toolTip,
- dataType: column.dataType,
- options: column.options = <String>[],
- texts: column.texts,
- values: column.values,
- listOption: column.listOption,
- listType: column.listType,
- logger: logger) {
+ section: section,
+ page: page,
+ map: null,
+ widgetType: WidgetModelType.dbReference,
+ name: column.name,
+ label: column.label,
+ toolTip: column.toolTip,
+ dataType: column.dataType,
+ options: column.options ?? <String>[],
+ texts: column.texts,
+ values: column.values,
+ listOption: column.listOption,
+ listType: column.listType,
+ logger: logger) {
this.column = column;
maxSize = column.size;
rows = column.rows;
/// Tests whether a given [option] is part of [options].
bool hasOption(String option) {
- if (options == null){
+ if (options == null) {
return false;
}
bool rc = options.contains(option);
/// Parses the map and stores the data in the instance.
void parse() {
- name = parseString(widgetModelType == WidgetModelType.column ? 'column' : 'name', map, required: true);
+ name = parseString(
+ widgetModelType == WidgetModelType.column ? 'column' : 'name', map,
+ required: true);
label = parseString('label', map, required: false);
toolTip = parseString('toolTip', map, required: false);
filterType = parseEnum<FilterType>('filterType', map, FilterType.values);
import 'package:dart_bones/dart_bones.dart';
import 'package:meta/meta.dart';
-
+import '../helper/string_helper.dart';
import 'model_types.dart';
/// Base class of all models.
case DataType.reference:
rc2 = StringUtils.asInt(item);
break;
+ case DataType.bool:
+ case DataType.currency:
+ case DataType.date:
+ case DataType.dateTime:
+ case DataType.float:
+ rc2 = StringHelper.fromString(item, dataType);
+ break;
+ case DataType.string:
+ rc2 = item;
+ break;
default:
logger.error('unknown dataType in parseValueList()');
rc2 = item;
(element) => element.pageModelType == PageModelType.list,
orElse: () => null);
if (page != null) {
+ final buffer2 = StringBuffer();
+ var select = 't0.*';
+ var no = 0;
+ table.columns.forEach((column) {
+ if (column.foreignKey != null && column.foreignKey.isNotEmpty) {
+ no++;
+ final foreignName = column.foreignKey.split(' ');
+ final colName = foreignName[1];
+ final tableColumn = foreignName[0].split('.');
+ final table2 = tableColumn[0];
+ final col2 = tableColumn[1];
+ select += ',t$no.$colName as ${column.name}';
+ buffer2.write(
+ ' left join $table2 t$no on t$no.$col2=t0.${column.name}\n');
+ }
+ });
buffer.write(''' - name: list
type: list
- sql: "SELECT * from ${table.name}\n''');
+ sql: "SELECT $select from ${table.name} t0\n$buffer2''');
// @ToDo: joins
final fields = page.fields
.where((item) => item is FieldModel && item.filterType != null);
buffer.write('${field.name}<=:${field.name}');
break;
case FilterType.equals:
- buffer.write('${field.name} like :${field.name}');
+ buffer.write(
+ '(:${field.name} IS NULL OR ${field.name}=:${field.name})');
break;
case FilterType.pattern:
buffer.write('${field.name} like :${field.name}');
'dataType': 'string',
'label': 'Bereich',
'size': 64,
- 'options': 'unique notnull',
+ 'options': 'notnull',
},
{
'column': 'configuration_property',
'column': 'user_role',
'dataType': 'reference',
'label': 'Role',
- 'foreignKey': 'role.role_id',
+ 'foreignKey': 'role.role_id role_name',
'listType': 'explicite',
'texts': ';-;Administrator;Benutzer;Gast;Verwalter',
'values': ';;1;2;3;4',
final int primaryId;
final Map initialRow;
final GlobalKey<FormState> _formKey =
- GlobalKey<FormState>(debugLabel: 'configuration_change');
+ GlobalKey<FormState>(debugLabel: 'configuration_change');
ConfigurationController controller;
- ConfigurationChangePageState(this.primaryId, this.applicationData,
- this.initialRow);
+ ConfigurationChangePageState(
+ this.primaryId, this.applicationData, this.initialRow);
@override
Widget build(BuildContext context) {
if (controller == null) {
controller = ConfigurationController(
_formKey, this, 'change', context, applicationData, redrawCallback:
- (RedrawReason reason,
- {String customString,
- RedrawCallbackFunctionSimple callback}) {
+ (RedrawReason reason,
+ {String customString,
+ RedrawCallbackFunctionSimple callback}) {
switch (reason) {
case RedrawReason.callback:
callback(RedrawReason.custom, customString);
import 'package:dart_bones/dart_bones.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bones/flutter_bones.dart';
+import 'package:flutter_bones/src/model/combo_base_model.dart';
+import 'package:flutter_bones/src/widget/dropdown_button_form_bone.dart';
import 'package:flutter_bones/src/widget/page_controller_bones.dart';
import 'text_form_field_bone.dart';
/// Returns a list of widgets for the filter fields.
List<Widget> getWidgets() {
final rc = filters.map((filter) {
- Widget rc = TextFormFieldBone(
- filter.name,
- pageController,
- decoration: InputDecoration(labelText: filter.label),
- );
- if (filter.toolTip != null) {
- rc = Tooltip(message: filter.toolTip, child: rc);
+ final model = pageController.page.fieldByName(filter.name);
+ if (model is ComboBaseModel) {
+ Widget rc3 = View().combobox(model, pageController, null);
+ return rc3;
+ } else {
+ Widget rc2 = TextFormFieldBone(
+ filter.name,
+ pageController,
+ decoration: InputDecoration(labelText: filter.label),
+ );
+ if (filter.toolTip != null) {
+ rc2 = Tooltip(message: filter.toolTip, child: rc2);
+ }
+ return rc2;
}
- return rc;
}).toList();
return rc;
}
dynamic initialValue) {
var rc;
if (model.dataType == DataType.bool) {
- rc = checkbox(model, controller, StringHelper.fromString(initialValue, DataType.bool));
+ rc = checkbox(model, controller,
+ StringHelper.fromString(initialValue, DataType.bool));
} else if (model.listType != null) {
rc = combobox(model, controller, initialValue);
} else {