From 636ad27a838b884431f4d168a0a3f3f953933d70 Mon Sep 17 00:00:00 2001 From: Daniele Teti Date: Sun, 9 Jun 2024 23:53:25 +0200 Subject: [PATCH] Added Wizard support for MVCNameCaseDefault --- ideexpert/DMVC.Expert.CodeGen.Commands.pas | 2 +- ideexpert/DMVC.Expert.Commons.pas | 1 + .../DMVC.Expert.Forms.NewProjectWizard.dfm | 57 ++++++++++++------- .../DMVC.Expert.Forms.NewProjectWizard.pas | 12 ++-- ideexpert/DMVC.Expert.Forms.NewUnitWizard.pas | 6 +- sources/MVCFramework.Serializer.Commons.pas | 2 +- 6 files changed, 48 insertions(+), 32 deletions(-) diff --git a/ideexpert/DMVC.Expert.CodeGen.Commands.pas b/ideexpert/DMVC.Expert.CodeGen.Commands.pas index d70530c5..e650a939 100644 --- a/ideexpert/DMVC.Expert.CodeGen.Commands.pas +++ b/ideexpert/DMVC.Expert.CodeGen.Commands.pas @@ -1001,7 +1001,7 @@ begin .AppendLine() .AppendLine(' // MVCNameCaseDefault defines the name case of property names generated by the serializers.') .AppendLine(' // Possibile values are: ncAsIs, ncUpperCase, ncLowerCase (default), ncCamelCase, ncPascalCase, ncSnakeCase') - .AppendLine(' MVCNameCaseDefault := TMVCNameCase.ncLowerCase;') + .AppendLine(' MVCNameCaseDefault := TMVCNameCase.' + Model.S[TConfigKey.serializer_name_case] + ';') .AppendLine() .AppendLine(' // UseConsoleLogger defines if logs must be emitted to also the console (if available).') .AppendLine(' UseConsoleLogger := True;') diff --git a/ideexpert/DMVC.Expert.Commons.pas b/ideexpert/DMVC.Expert.Commons.pas index 09ddec8a..4ec79af1 100644 --- a/ideexpert/DMVC.Expert.Commons.pas +++ b/ideexpert/DMVC.Expert.Commons.pas @@ -74,6 +74,7 @@ type jsonrpc_generate= 'jsonrpc.generate'; jsonrpc_classname= 'jsonrpc.classname'; jsonrpc_unit_name='jsonrpc.unit_name'; + serializer_name_case= 'serializer.name_case'; webmodule_classname= 'webmodule.classname'; webmodule_unit_name= 'webmodule.unit_name'; webmodule_middleware_analytics= 'webmodule.middleware.analytics'; diff --git a/ideexpert/DMVC.Expert.Forms.NewProjectWizard.dfm b/ideexpert/DMVC.Expert.Forms.NewProjectWizard.dfm index 30cc9c06..cfbb9498 100644 --- a/ideexpert/DMVC.Expert.Forms.NewProjectWizard.dfm +++ b/ideexpert/DMVC.Expert.Forms.NewProjectWizard.dfm @@ -435,7 +435,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject end object lblPATREON: TLabel Left = 452 - Top = 495 + Top = 549 Width = 257 Height = 16 Cursor = crHandPoint @@ -455,7 +455,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject OnMouseLeave = lblPATREONMouseLeave end object btnOK: TButton - Left = 549 + Left = 561 Top = 580 Width = 77 Height = 27 @@ -467,7 +467,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject OnClick = btnOKClick end object btnCancel: TButton - Left = 632 + Left = 644 Top = 580 Width = 77 Height = 27 @@ -609,13 +609,13 @@ object frmDMVCNewProject: TfrmDMVCNewProject object GroupBox1: TGroupBox Left = 314 Top = 135 - Width = 405 - Height = 214 + Width = 407 + Height = 210 Caption = 'Middlewares' TabOrder = 6 DesignSize = ( - 405 - 214) + 407 + 210) object Label4: TLabel Left = 161 Top = 112 @@ -647,7 +647,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject TabOrder = 0 end object chkCompression: TCheckBox - Left = 27 + Left = 28 Top = 24 Width = 153 Height = 17 @@ -665,7 +665,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject TabOrder = 2 end object chkTrace: TCheckBox - Left = 192 + Left = 193 Top = 50 Width = 150 Height = 17 @@ -675,7 +675,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject TabOrder = 3 end object chkCORS: TCheckBox - Left = 192 + Left = 193 Top = 24 Width = 135 Height = 17 @@ -684,7 +684,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject TabOrder = 4 end object chkETAG: TCheckBox - Left = 192 + Left = 193 Top = 76 Width = 202 Height = 17 @@ -704,7 +704,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject object EdtFDConnDefFileName: TEdit Left = 161 Top = 129 - Width = 228 + Width = 230 Height = 21 Anchors = [akLeft, akTop, akRight] TabOrder = 7 @@ -713,7 +713,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject object EdtConnDefName: TEdit Left = 161 Top = 175 - Width = 228 + Width = 230 Height = 21 Anchors = [akLeft, akTop, akRight] TabOrder = 8 @@ -722,14 +722,14 @@ object frmDMVCNewProject: TfrmDMVCNewProject end object GroupBoxJSONRPC: TGroupBox Left = 314 - Top = 388 - Width = 396 + Top = 438 + Width = 407 Height = 105 Anchors = [akLeft, akRight, akBottom] - Caption = 'JSON-RPC 2.0' + Caption = 'JSON-RPC end-point Options' TabOrder = 7 DesignSize = ( - 396 + 407 105) object Label3: TLabel Left = 16 @@ -741,7 +741,7 @@ object frmDMVCNewProject: TfrmDMVCNewProject object EdtJSONRPCClassName: TEdit Left = 16 Top = 72 - Width = 365 + Width = 376 Height = 21 Anchors = [akLeft, akTop, akRight] TabOrder = 0 @@ -750,10 +750,10 @@ object frmDMVCNewProject: TfrmDMVCNewProject object chkJSONRPC: TCheckBox Left = 16 Top = 22 - Width = 358 + Width = 369 Height = 17 Anchors = [akLeft, akTop, akRight] - Caption = 'Create JSONRPC 2.0 end-point' + Caption = 'Create JSON-RPC 2.0 end-point' Checked = True State = cbChecked TabOrder = 1 @@ -808,6 +808,23 @@ object frmDMVCNewProject: TfrmDMVCNewProject State = cbChecked TabOrder = 12 end + object rgNameCase: TRadioGroup + Left = 314 + Top = 351 + Width = 407 + Height = 81 + Caption = 'Default style for serialized property names (MVCNameCaseDefault)' + Columns = 3 + ItemIndex = 2 + Items.Strings = ( + 'AsIs (as declared)' + 'UpperCase (FOOBAR)' + 'LowerCase (foobar)' + 'CamelCase (fooBar)' + 'PascalCase (FooBar)' + 'SnakeCase (foo_bar)') + TabOrder = 13 + end object ApplicationEvents: TApplicationEvents OnIdle = ApplicationEventsIdle Left = 264 diff --git a/ideexpert/DMVC.Expert.Forms.NewProjectWizard.pas b/ideexpert/DMVC.Expert.Forms.NewProjectWizard.pas index 7c829e2e..25d145c3 100644 --- a/ideexpert/DMVC.Expert.Forms.NewProjectWizard.pas +++ b/ideexpert/DMVC.Expert.Forms.NewProjectWizard.pas @@ -50,7 +50,8 @@ uses VCL.ExtCtrls, System.Actions, Vcl.ActnList, - Vcl.AppEvnts, JsonDataObjects; + Vcl.AppEvnts, + JsonDataObjects; type TfrmDMVCNewProject = class(TForm) @@ -100,6 +101,7 @@ type chkMustache: TCheckBox; chkServicesContainer: TCheckBox; chkSqids: TCheckBox; + rgNameCase: TRadioGroup; procedure chkCreateControllerUnitClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Image1Click(Sender: TObject); @@ -143,15 +145,13 @@ type function GetConfigModel: TJSONObject; end; -var - frmDMVCNewProject: TfrmDMVCNewProject; - implementation uses MVCFramework.Commons, + MVCFramework.Serializer.Commons, System.StrUtils, - DMVC.Expert.Commons; + DMVC.Expert.Commons, System.TypInfo; {$R *.dfm} @@ -357,7 +357,7 @@ begin fModel.B[TConfigKey.jsonrpc_generate] := GetCreateJSONRPCInterface; fModel.S[TConfigKey.jsonrpc_classname] := GetJSONRPCClassName; fModel.S[TConfigKey.jsonrpc_unit_name] := 'TBA'; - + fModel.S[TConfigKey.serializer_name_case] := GetEnumName(TypeInfo(TMVCNameCase), rgNameCase.ItemIndex + 1); //webmodule fModel.S[TConfigKey.webmodule_classname] := GetWebModuleClassName; diff --git a/ideexpert/DMVC.Expert.Forms.NewUnitWizard.pas b/ideexpert/DMVC.Expert.Forms.NewUnitWizard.pas index e65e359b..5a723cb9 100644 --- a/ideexpert/DMVC.Expert.Forms.NewUnitWizard.pas +++ b/ideexpert/DMVC.Expert.Forms.NewUnitWizard.pas @@ -44,7 +44,8 @@ uses VCL.Controls, VCL.Forms, VCL.Dialogs, - VCL.StdCtrls, JsonDataObjects; + VCL.StdCtrls, + JsonDataObjects; type TfrmDMVCNewUnit = class(TForm) @@ -76,9 +77,6 @@ type function GetConfigModel: TJSONObject; end; -var - frmDMVCNewUnit: TfrmDMVCNewUnit; - implementation uses diff --git a/sources/MVCFramework.Serializer.Commons.pas b/sources/MVCFramework.Serializer.Commons.pas index f85961c6..fd53b53e 100644 --- a/sources/MVCFramework.Serializer.Commons.pas +++ b/sources/MVCFramework.Serializer.Commons.pas @@ -60,7 +60,7 @@ type TMVCSerializationType = (stUnknown, stDefault, stProperties, stFields); - TMVCNameCase = (ncUseDefault, ncAsIs, ncUpperCase, ncLowerCase, ncCamelCase, ncPascalCase, ncSnakeCase); + TMVCNameCase = (ncUseDefault {ncUseDefault must be the first item}, ncAsIs, ncUpperCase, ncLowerCase, ncCamelCase, ncPascalCase, ncSnakeCase); TMVCDataType = (dtObject, dtArray);