-<<<<<<< HEAD
DROP TABLE IF EXISTS role;
CREATE TABLE role (
role_id INT(10) UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT,
role_changedat TIMESTAMP NULL,
role_changedby VARCHAR(16),
PRIMARY KEY(role_id)
-=======
-drop table if exists role;
-create table role (
- role_id int(10) notnull unique,
- role_name varchar(32) unique notnull,
- role_priority int(10),
- role_active char(1),
- role_createdat timestamp null,
- role_createdby varchar(16),
- role_changedat timestamp null,
- role_changedby varchar(16),
- primary role_id
->>>>>>> origin/master
);
-<<<<<<< HEAD
DROP TABLE IF EXISTS user;
CREATE TABLE user (
user_id INT(10) UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT,
user_changedat TIMESTAMP NULL,
user_changedby VARCHAR(16),
PRIMARY KEY(user_id)
-=======
-drop table if exists user;
-create table user (
- user_id int(10) notnull unique,
- user_name varchar(64) unique notnull,
- user_displayname varchar(32) unique,
- user_email varchar(128) unique,
- user_password varchar(128),
- user_role int(10),
- user_createdat timestamp null,
- user_createdby varchar(16),
- user_changedat timestamp null,
- user_changedby varchar(16),
- primary user_id
->>>>>>> origin/master
);
--- /dev/null
+---
+# configuration of the bones backend for configuration:
+created: 2020.10.20 23:16:54
+author: flutter_bones.module_model.exportSqlBackend()
+version: 1.0.0
+modules:
+ - module: configuration
+ list:
+ - name: insert
+ type: insert
+ sql: "INSERT INTO configuration(configuration_scope,configuration_property,configuration_order,configuration_type,configuration_value,configuration_description,configuration_createdat,configuration_createdby)
+ VALUES(:configuration_scope,:configuration_property,:configuration_order,:configuration_type,:configuration_value,:configuration_description,NOW(),:configuration_createdby);"
+ - name: update
+ type: update
+ sql: "UPDATE configuration SET
+ configuration_scope=:configuration_scope,configuration_property=:configuration_property,configuration_order=:configuration_order,configuration_type=:configuration_type,configuration_value=:configuration_value,configuration_description=:configuration_description,configuration_changedat=NOW(),configuration_changedby=:configuration_changedby
+ WHERE configuration_id=:configuration_id;"
+ - name: delete
+ type: delete
+ sql: "DELETE from configuration WHERE configuration_id=:configuration_id;"
+ - 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_name like :configuration_name AND configuration_scope like :configuration_scope AND configuration_scope like :configuration_scope;"
---
# configuration of the bones backend for role:
-created: 2020.10.20 15:25:01
+created: 2020.10.20 23:16:54
author: flutter_bones.module_model.exportSqlBackend()
version: 1.0.0
modules:
---
# configuration of the bones backend for user:
-created: 2020.10.20 15:25:01
+created: 2020.10.20 23:16:54
author: flutter_bones.module_model.exportSqlBackend()
version: 1.0.0
modules:
+++ /dev/null
-import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter_bones/flutter_bones.dart';
-
-import 'src/model/standard/role_model.dart';
-import 'src/model/standard/user_model.dart';
-
-void main(List<String> argv) async {
- final logger = MemoryLogger(LEVEL_FINE);
- final dbHelper = DbHelper(logger);
- if (argv.isEmpty) {
- argv = ['export-sql'];
- }
- final mode = argv[0];
- argv.removeAt(0);
- final options = <String>[];
- argv = StringHelper.splitArgv(argv, options);
- switch (mode) {
- case 'export-sql':
- dbHelper.exportSql(argv, options);
- break;
- default:
- logger.error('unknown mode: $mode');
- break;
- }
-}
-
-class DbHelper {
- final BaseLogger logger;
-
- DbHelper(this.logger);
-
- void exportSql(List<String> args, List<String> options) {
- String directory;
- String value;
- for (var opt in options) {
- value = StringUtils.stringOption('directory', 'd', opt);
- if (value != null) {
- directory = value;
- }
- }
- directory ??= 'data';
- final dirDDL = FileSync.joinPaths(directory, 'ddl');
- final dirREST = FileSync.joinPaths(directory, 'rest');
- FileSync.ensureDirectory(dirDDL);
- FileSync.ensureDirectory(dirREST);
- if (args.isEmpty) {
- args = ['user', 'role', 'configuration'];
- }
- while (args.isNotEmpty) {
- final name = args[0];
- args.removeAt(0);
- ModuleModel module;
- switch (name) {
- case 'user':
- module = UserModel(logger);
- break;
- case 'role':
- module = RoleModel(logger);
- break;
- case 'configuration':
- module = ConfigurationModel(logger);
- break;
- default:
- logger.error('unknown table');
- break;
- }
- if (module != null) {
- module.parse();
- var filename = FileSync.joinPaths(dirDDL, '$name.sql');
- FileSync.toFile(filename, module.exportSqlCreateTable());
- print('exported: $filename');
- filename = FileSync.joinPaths(dirREST, '$name.yaml');
- FileSync.toFile(filename, module.exportSqlBackend());
- print('exported: $filename');
- }
- }
- }
-
- void usage(String error) {
- print('''usage: dbhelper <mode> [<args>]
-<mode>:
- create-sql [<module>] [<opt>]
- <module>: 'role', 'user' ...
- <opt>:
- -d<dir> or --directory=<dir>:
- the base directory used for the exported files.
-Examples:
-dbhelper create-sql role role.sql -d/tmp
-dbhelper create-sql --directory=/opt/sql-data
-''');
- }
-}
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter/material.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart';
+import 'package:meta/meta.dart';
+/// A replacement for dart_ui:Locale. This avoids a flutter dependency.
+/// Note: package:intl uses only a string for locale, e.g. 'en_US'.
+class SettingLocale {
+ String languageCode;
+ String countryCode;
+ SettingLocale({this.languageCode, this.countryCode});
+}
class BaseSettings {
- static Locale locale = Locale('US', 'en');
+ static var locale = SettingLocale(countryCode: 'US', languageCode: 'en');
static get language => locale.languageCode;
country = country.toUpperCase();
country = country == 'EN' ? 'US' : country;
language = language.toLowerCase();
- setLocale(Locale(language, country));
+ setLocale(SettingLocale(languageCode: language, countryCode: country));
}
/// Translates a [text] with a given translation [map].
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter_bones/flutter_bones.dart';
import 'package:intl/intl.dart';
+import '../model/model_types.dart';
class StringHelper {
static final regExpTrue = RegExp(r'^(true|yes)$', caseSensitive: false);
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter_bones/flutter_bones.dart';
import 'package:meta/meta.dart';
+import 'settings.dart';
/// Tests whether [input] is an valid email address.
/// Returns null if it is a valid email address, otherwise an error message.
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_bones/flutter_bones.dart';
-
-typedef ButtonOnPressed = void Function(String name);
+import 'widget_model.dart';
+import 'section_model.dart';
+import 'page_model.dart';
/// Describes a button widget.
class ButtonModel extends WidgetModel {
List<String> options;
ButtonModelType buttonModelType;
- VoidCallback onPressed;
-
- VoidCallback onLongPressed;
- ValueChanged<bool> onHighlightChanged;
-
ButtonModel(SectionModel section, PageModel page, this.map, BaseLogger logger)
: super(section, page, WidgetModelType.button, logger);
parseEnum<ButtonModelType>('buttonType', map, ButtonModelType.values);
buttonModelType ??= ButtonModelType.custom;
options = parseOptions('options', map);
- onPressed = () => logger.error('${fullName()}: missing onPressed');
checkOptionsByRegExpr(options, regExprOptions);
}
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter/cupertino.dart';
-
+import 'package:meta/meta.dart';
import 'model_base.dart';
import 'model_types.dart';
import 'table_model.dart';
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter/material.dart';
import 'field_model.dart';
import 'page_model.dart';
static final regExprOptions = RegExp(r'^(readonly|disabled|required|undef)$');
List<String> texts;
List<dynamic> values;
- FormFieldValidator<String> validator;
- FormFieldSetter onSaved;
final Map<String, dynamic> map;
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter/material.dart';
import 'column_model.dart';
import 'field_model.dart';
int rows;
var value;
ColumnModel column;
- FormFieldValidator<String> validator;
-
- FormFieldSetter onSaved;
-
final Map<String, dynamic> map;
DbReferenceModel(
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter/material.dart';
import '../helper/string_helper.dart';
import 'model_types.dart';
String label;
String toolTip;
DataType dataType;
- FormFieldSetter onSaved;
List<String> options;
FilterType filterType;
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
import 'model_types.dart';
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter/cupertino.dart';
-import 'package:flutter_bones/flutter_bones.dart';
-import 'package:flutter_bones/src/model/column_model.dart';
-import 'package:flutter_bones/src/model/table_model.dart';
+import 'column_model.dart';
+import 'table_model.dart';
import 'package:meta/meta.dart';
-
import 'model_base.dart';
import 'page_model.dart';
+import 'field_model.dart';
+import 'model_types.dart';
+import 'widget_model.dart';
+import '../helper/string_helper.dart';
/// Describes a module.
/// A module realizes a model of an entitiy which is normally related to one
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter_bones/src/model/all_db_fields_model.dart';
-import 'package:flutter_bones/src/model/db_reference_model.dart';
-
+import 'all_db_fields_model.dart';
+import 'db_reference_model.dart';
import 'button_model.dart';
import 'checkbox_model.dart';
import 'combobox_model.dart';
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter_bones/flutter_bones.dart';
+import '../module_model.dart';
///
class ConfigurationModel extends ModuleModel {
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter_bones/flutter_bones.dart';
+import '../module_model.dart';
class RoleModel extends ModuleModel {
static final yamlMap = <String, dynamic>{
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter_bones/flutter_bones.dart';
+import '../module_model.dart';
+import 'role_model.dart';
+import 'user_model.dart';
+import 'configuration_model.dart';
/// Returns an instance of a standard module given by [name].
ModuleModel standardModule(String name, BaseLogger logger) {
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter_bones/flutter_bones.dart';
+import '../module_model.dart';
class UserModel extends ModuleModel {
static final model = <String, dynamic>{
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter/foundation.dart';
-
+import 'package:meta/meta.dart';
import 'column_model.dart';
import 'model_base.dart';
import 'model_types.dart';
import 'package:dart_bones/dart_bones.dart';
-import 'package:flutter/material.dart';
import 'field_model.dart';
import 'model_types.dart';
int rows;
var value;
- FormFieldValidator<String> validator;
-
- FormFieldSetter onSaved;
-
final Map<String, dynamic> map;
TextFieldModel(
import 'package:dart_bones/dart_bones.dart';
-
import 'page_model.dart';
import 'section_model.dart';
import 'widget_model.dart';
Widget textField(TextFieldModel model) {
var rc = toolTip(
TextFormField(
- validator: model.validator,
+ //validator: model.validator,
decoration: InputDecoration(labelText: model.label),
onSaved: (input) => model.value(input),
),
--- /dev/null
+../data
\ No newline at end of file
--- /dev/null
+import 'package:dart_bones/dart_bones.dart';
+
+import 'src/model/module_model.dart';
+import 'src/model/standard/standard_modules.dart';
+import 'src/helper/string_helper.dart';
+
+void main(List<String> argv) async {
+ final logger = MemoryLogger(LEVEL_FINE);
+ final dbHelper = DbHelper(logger);
+ if (argv.isEmpty) {
+ argv = ['export-sql'];
+ }
+ final mode = argv[0];
+ argv.removeAt(0);
+ final options = <String>[];
+ argv = StringHelper.splitArgv(argv, options);
+ switch (mode) {
+ case 'export-sql':
+ dbHelper.exportSql(argv, options);
+ break;
+ default:
+ logger.error('unknown mode: $mode');
+ break;
+ }
+}
+
+class DbHelper {
+ final BaseLogger logger;
+
+ DbHelper(this.logger);
+
+ void exportSql(List<String> args, List<String> options) {
+ String directory;
+ String value;
+ for (var opt in options) {
+ value = StringUtils.stringOption('directory', 'd', opt);
+ if (value != null) {
+ directory = value;
+ }
+ }
+ directory ??= 'data';
+ final dirDDL = FileSync.joinPaths(directory, 'ddl');
+ final dirREST = FileSync.joinPaths(directory, 'rest');
+ FileSync.ensureDirectory(dirDDL);
+ FileSync.ensureDirectory(dirREST);
+ if (args.isEmpty) {
+ args = standardModules();
+ }
+ while (args.isNotEmpty) {
+ final name = args[0];
+ args.removeAt(0);
+ ModuleModel module = standardModule(name, logger);
+ if (module != null) {
+ module.parse();
+ var filename = FileSync.joinPaths(dirDDL, '$name.sql');
+ FileSync.toFile(filename, module.exportSqlCreateTable());
+ print('exported: $filename');
+ filename = FileSync.joinPaths(dirREST, '$name.yaml');
+ FileSync.toFile(filename, module.exportSqlBackend());
+ print('exported: $filename');
+ }
+ }
+ }
+
+ void usage(String error) {
+ print('''usage: dbhelper <mode> [<args>]
+<mode>:
+ create-sql [<module>] [<opt>]
+ <module>: 'role', 'user' ...
+ <opt>:
+ -d<dir> or --directory=<dir>:
+ the base directory used for the exported files.
+Examples:
+dbhelper create-sql role role.sql -d/tmp
+dbhelper create-sql --directory=/opt/sql-data
+''');
+ }
+}
--- /dev/null
+../../../lib/src/helper/
\ No newline at end of file
--- /dev/null
+../../../lib/src/model/
\ No newline at end of file
--- /dev/null
+name: flutter_bones_tool
+description: A tool round about the model defined in flutter_bones, e.g. export as yaml.
+
+# The following line prevents the package from being accidentally published to
+# pub.dev using `pub publish`. This is preferred for private packages.
+publish_to: 'none' # Remove this line if you wish to publish to pub.dev
+
+# The following defines the version and build number for your application.
+# A version number is three numbers separated by dots, like 1.2.43
+# followed by an optional build number separated by a +.
+# Both the version and the builder number may be overridden in flutter
+# build by specifying --build-name and --build-number, respectively.
+# In Android, build-name is used as versionName while build-number used as versionCode.
+# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
+# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
+# Read more about iOS versioning at
+# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
+version: 1.0.0+1
+
+environment:
+ sdk: ">=2.11.0-234.0.dev <3.0.0"
+
+dependencies:
+ dart_bones: "^0.4.6"
+
+
+ # The following adds the Cupertino Icons font to your application.
+ # Use with the CupertinoIcons class for iOS style icons.
+ # cupertino_icons: ^1.0.0
+
+dev_dependencies:
+
+# flutter_test:
+# sdk: flutter
+
+#flutter:
+
+# uses-material-design: true
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
- cupertino_icons: ^1.0.0
+ # cupertino_icons: ^1.0.0
dev_dependencies:
flutter_test: