Index: VerpakkingsDefinitie/WS/ProductsAgent.pas =================================================================== diff -u -r586 -r587 --- VerpakkingsDefinitie/WS/ProductsAgent.pas (.../ProductsAgent.pas) (revision 586) +++ VerpakkingsDefinitie/WS/ProductsAgent.pas (.../ProductsAgent.pas) (revision 587) @@ -456,6 +456,8 @@ pxBoxDataObj: OptiServerService.pxBoxData); var Verpakking: TProductVerpakking; + I: Integer; + NieuweVerpakkingParameter: TProductVerpakkingParameter; begin // Andere velden juist zetten ProductDetailContext.IsOK := True; @@ -483,6 +485,20 @@ Richtingen.AddRange(SplitString(pxBoxDataObj.Rotatie, '')); DefaultRichtingen.AddRange(SplitString(pxBoxDataObj.DefaultData.Rotatie, ';')); + // Verpakking parameters. haal waarden uit gewone data en default data. + Parameters.Clear(); + if (High(pxBoxDataObj.Params) = High(pxBoxDataObj.DefaultData.Params)) then + for I := 0 to High(pxBoxDataObj.Params) do + begin + NieuweVerpakkingParameter := TProductVerpakkingParameter.Create(); + NieuweVerpakkingParameter.ID := pxBoxDataObj.Params[I].ID; + NieuweVerpakkingParameter.ProgLabel := pxBoxDataObj.Params[I].ProgLabel; + NieuweVerpakkingParameter.ToolTip := pxBoxDataObj.Params[I].ToolTip; + NieuweVerpakkingParameter.Waarde := pxBoxDataObj.Params[I].Waarde; + NieuweVerpakkingParameter.DefaultWaarde := pxBoxDataObj.DefaultData.Params[I].Waarde; + Parameters.Add(NieuweVerpakkingParameter); + end; + DeelVanID := pxBoxDataObj.DeelVanID; DeelVanCaption := pxBoxDataObj.DeelVanCaption; Index: VerpakkingsDefinitie/UI/CustomPanelVerpakkingParameter.pas =================================================================== diff -u --- VerpakkingsDefinitie/UI/CustomPanelVerpakkingParameter.pas (revision 0) +++ VerpakkingsDefinitie/UI/CustomPanelVerpakkingParameter.pas (revision 587) @@ -0,0 +1,74 @@ +unit CustomPanelVerpakkingParameter; + +interface + +uses + Vcl.StdCtrls, Vcl.ExtCtrls, System.Classes, Vcl.Graphics, Vcl.Controls, + ApplicationContext; + +type + TCustomPanelVerpakkingParameter = class(TCustomPanel) + private + FLabelControl: TLabel; + FEditControl: TEdit; + FProductVerpakkingParameter: TProductVerpakkingParameter; + procedure PreparePanel(); + procedure CreateControls(); + procedure SetProductVerpakkingParameter(Parameter: TProductVerpakkingParameter); + public + constructor Create(AOwner: TComponent); override; + property ProductVerpakkingParameter: TProductVerpakkingParameter read FProductVerpakkingParameter + write SetProductVerpakkingParameter; + end; + +implementation + +constructor TCustomPanelVerpakkingParameter.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + PreparePanel(); +end; + +procedure TCustomPanelVerpakkingParameter.PreparePanel(); +begin + Align := alTop; + Height := 45; + Self.ParentBackground := false; + Self.Color := clWhite; + AlignWithMargins := True; +end; + +procedure TCustomPanelVerpakkingParameter.SetProductVerpakkingParameter(Parameter: TProductVerpakkingParameter); +begin + CreateControls(); + FLabelControl.Caption := Parameter.ToolTip; + FEditControl.TextHint := Parameter.DefaultWaarde; + FEditControl.Text := Parameter.Waarde; +end; + +procedure TCustomPanelVerpakkingParameter.CreateControls(); +begin + FLabelControl := TLabel.Create(Self); + with FLabelControl do + begin + Parent := Self; + top := 2; + Left := 5; + AlignWithMargins := True; // Spacing tussen de controls + end; + + FEditControl := TEdit.Create(Self); + with FEditControl do + begin + Parent := Self; + Left := 5; + top := 20; + width := 100; + Constraints.MaxWidth := 100; + Anchors := [akLeft, akRight]; + AlignWithMargins := True; // Spacing tussen de controls + end; +end; + +end. Index: VerpakkingsDefinitie/ApplicationContext.pas =================================================================== diff -u -r586 -r587 --- VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 586) +++ VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 587) @@ -3,7 +3,6 @@ // Dit is een klasse bedoeld om data te delen over de applicatie heen. // Dit kan bijvoorbeeld usernaam, login token, computernaam, ... // Informatie die elk component/klasse kan gebruiken. -// Voor schaalbaarheid en isolatie worden interfaces gebruikt die deze klasse implementeert. interface @@ -102,6 +101,21 @@ end; // - Product Detail + TProductVerpakkingParameter = class + private + FID: string; + FProgLabel: string; + FToolTip: string; + FWaarde: string; + FDefaultWaarde: string; + public + property ID: string read FID write FID; + property ProgLabel: string read FProgLabel write FProgLabel; + property ToolTip: string read FToolTip write FToolTip; + property Waarde: string read FWaarde write FWaarde; + property DefaultWaarde: string read FDefaultWaarde write FDefaultWaarde; + end; + TProductVerpakking = class private FRawData: TObject; @@ -127,6 +141,8 @@ FRichtingen: TList; FDefaultRichtingen: TList; + FParameters: TList; + FDeelVanID: string; FDeelVanCaption: string; FDeelVan: TProductVerpakking; @@ -157,6 +173,8 @@ property Richtingen: TList read FRichtingen; property DefaultRichtingen: TList read FDefaultRichtingen; + property Parameters: TList read FParameters; + property DeelVanID: string read FDeelVanID write FDeelVanID; property DeelVanCaption: string read FDeelVanCaption write FDeelVanCaption; property DeelVan: TProductVerpakking read FDeelVan write FDeelVan; @@ -334,6 +352,8 @@ FDefaultPosities := TList.Create(); FRichtingen := TList.Create(); FDefaultRichtingen := TList.Create(); + + FParameters := TList.Create(); end; function TProductVerpakking.Equals(Obj: TObject): Boolean; Index: VerpakkingsDefinitie/UI/Util.pas =================================================================== diff -u -r583 -r587 --- VerpakkingsDefinitie/UI/Util.pas (.../Util.pas) (revision 583) +++ VerpakkingsDefinitie/UI/Util.pas (.../Util.pas) (revision 587) @@ -3,13 +3,13 @@ interface uses - Vcl.Controls, // Free control children + Vcl.Controls, System.SysUtils, // Free control children System.Types, Vcl.Graphics; // Color lightener type TUtil = class class procedure VervangControl(OudeControl: TControl; NieuweControl: TControl); - class procedure FreeControlChildrenRec(AControl: TControl); + class procedure FreeControlChildrenDeep(AControl: TControl); class function LightenColor(RGB: Cardinal; Percentage: Integer): Cardinal; static; end; @@ -34,26 +34,34 @@ OudeControl.visible := False; end; +procedure FreeControlChildrenRec(AControl: TControl); +begin + if not Assigned(AControl) then + exit; + if AControl is TWinControl then + begin + // Tijden het free-en kan zijn dat er elementen verdwijnen uit de lijst. + // Het aantal elementen moet dus steeds opnieuw gecontroleerd worden (een for-lus berekent dit eenmalig) + while TWinControl(AControl).ControlCount > 0 do + FreeControlChildrenRec(TWinControl(AControl).Controls[0]); + end; + FreeAndNil(AControl); +end; + // FREE CONTROL CHILDREN // Recursieve methode om de kinderen van een TWinControl te free-en (hanging pointers voorkomen) // Gebaseerd op: https://stackoverflow.com/questions/414928/is-there-any-way-to-get-all-the-controls-on-a-container-control -class procedure TUtil.FreeControlChildrenRec(AControl: TControl); -var - i: Integer; +class procedure TUtil.FreeControlChildrenDeep(AControl: TControl); begin - if AControl = nil then + if not Assigned(AControl) then exit; if AControl is TWinControl then begin - i := 0; - // Tijden het free-en kan zijn dat er elementen verdwijnen uit de lijst. - // Het aantal elementen moet dus steeds opnieuw gecontroleerd worden (een for-lus berekent dit eenmalig) - while TWinControl(AControl).ControlCount < i do - begin - FreeControlChildrenRec(TWinControl(AControl).Controls[i]); - end; + // // Tijden het free-en kan zijn dat er elementen verdwijnen uit de lijst. + // // Het aantal elementen moet dus steeds opnieuw gecontroleerd worden (een for-lus berekent dit eenmalig) + while TWinControl(AControl).ControlCount > 0 do + FreeControlChildrenRec(TWinControl(AControl).Controls[0]); end; - AControl.Free(); end; // COLOR LIGHTENER Index: VerpakkingsDefinitie/UI/ProductDetailScherm.dfm =================================================================== diff -u -r586 -r587 --- VerpakkingsDefinitie/UI/ProductDetailScherm.dfm (.../ProductDetailScherm.dfm) (revision 586) +++ VerpakkingsDefinitie/UI/ProductDetailScherm.dfm (.../ProductDetailScherm.dfm) (revision 587) @@ -2,8 +2,8 @@ Left = 0 Top = 0 Caption = 'FormProductDetail' - ClientHeight = 677 - ClientWidth = 808 + ClientHeight = 679 + ClientWidth = 802 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText @@ -14,8 +14,8 @@ OnCreate = FormCreate OnDestroy = FormDestroy DesignSize = ( - 808 - 677) + 802 + 679) PixelsPerInch = 96 TextHeight = 13 object LabelOmschrijving1: TLabel @@ -65,9 +65,9 @@ ParentFont = False end object LabelProductNummer: TLabel - Left = 736 + Left = 730 Top = 64 - Width = 64 + Width = 122 Height = 13 Anchors = [akTop, akRight] BiDiMode = bdLeftToRight @@ -81,149 +81,123 @@ ParentFont = False end object Label17: TLabel - Left = 676 + Left = 670 Top = 64 Width = 54 Height = 13 Anchors = [akTop, akRight] Caption = 'Product nr.' + ExplicitLeft = 676 end object PanelVerpakkingControls: TPanel Left = 8 Top = 257 Width = 792 Height = 416 - Anchors = [akLeft, akRight, akBottom] TabOrder = 1 - DesignSize = ( - 792 - 416) object Label10: TLabel Left = 8 - Top = 279 + Top = 271 Width = 55 Height = 13 - Anchors = [akLeft, akBottom] Caption = 'Parameters' - ExplicitTop = 275 end object Label11: TLabel - Left = 368 - Top = 15 + Left = 360 + Top = 79 Width = 43 Height = 13 - Anchors = [akLeft, akBottom] Caption = 'Plaatsing' end object Label12: TLabel - Left = 368 - Top = 47 + Left = 360 + Top = 111 Width = 31 Height = 13 - Anchors = [akLeft, akBottom] Caption = 'Positie' end object Label13: TLabel - Left = 368 - Top = 79 + Left = 360 + Top = 143 Width = 38 Height = 13 - Anchors = [akLeft, akBottom] Caption = 'Richting' end object Label2: TLabel Left = 8 Top = 15 Width = 24 Height = 13 - Anchors = [akLeft, akBottom] Caption = 'Meta' - ExplicitTop = 11 end object Label4: TLabel Left = 8 Top = 79 Width = 42 Height = 13 - Anchors = [akLeft, akBottom] Caption = 'Deel van' - ExplicitTop = 75 end object Label5: TLabel Left = 8 Top = 111 Width = 38 Height = 13 - Anchors = [akLeft, akBottom] Caption = 'Breedte' - ExplicitTop = 107 end object Label6: TLabel Left = 8 Top = 143 Width = 31 Height = 13 - Anchors = [akLeft, akBottom] Caption = 'Diepte' - ExplicitTop = 139 end object Label7: TLabel Left = 8 - Top = 173 + Top = 175 Width = 35 Height = 13 - Anchors = [akLeft, akBottom] Caption = 'Hoogte' - ExplicitTop = 169 end object Label8: TLabel Left = 8 - Top = 223 + Top = 207 Width = 85 Height = 13 - Anchors = [akLeft, akBottom] Caption = 'Max comb. aantal' - ExplicitTop = 219 end object Label9: TLabel Left = 8 - Top = 252 + Top = 239 Width = 31 Height = 13 - Anchors = [akLeft, akBottom] Caption = 'Aantal' - ExplicitTop = 248 end object Label3: TLabel Left = 8 Top = 47 Width = 55 Height = 13 - Anchors = [akLeft, akBottom] Caption = 'Volume van' end object Label14: TLabel - Left = 368 - Top = 143 + Left = 360 + Top = 207 Width = 44 Height = 13 - Anchors = [akLeft, akBottom] Caption = 'OptiType' end object Label15: TLabel - Left = 368 - Top = 173 + Left = 360 + Top = 237 Width = 47 Height = 13 - Anchors = [akLeft, akBottom] Caption = 'BoxSelect' end object ButtonMeta: TButton Left = 272 Top = 12 Width = 40 Height = 21 - Anchors = [akLeft, akBottom] Caption = '...' TabOrder = 0 end @@ -233,148 +207,131 @@ Width = 200 Height = 21 Style = csDropDownList - Anchors = [akLeft, akBottom] TabOrder = 1 end object ComboBoxPlaatsing: TComboBox - Left = 446 - Top = 12 + Left = 464 + Top = 76 Width = 162 Height = 21 Style = csDropDownList - Anchors = [akLeft, akBottom] TabOrder = 2 end object ComboBoxPositie: TComboBox - Left = 446 - Top = 44 + Left = 464 + Top = 108 Width = 162 Height = 21 Style = csDropDownList - Anchors = [akLeft, akBottom] TabOrder = 3 end object ComboBoxRichting: TComboBox - Left = 446 - Top = 76 + Left = 464 + Top = 140 Width = 162 Height = 21 Style = csDropDownList - Anchors = [akLeft, akBottom] TabOrder = 4 end object EditAantal: TEdit Left = 112 - Top = 252 + Top = 236 Width = 200 Height = 21 - Anchors = [akLeft, akBottom] TabOrder = 5 end object EditBreedte: TEdit Left = 112 Top = 108 Width = 200 Height = 21 - Anchors = [akLeft, akBottom] TabOrder = 6 end object EditDiepte: TEdit Left = 112 Top = 140 Width = 200 Height = 21 - Anchors = [akLeft, akBottom] TabOrder = 7 end object EditHoogte: TEdit Left = 112 Top = 172 Width = 200 Height = 21 - Anchors = [akLeft, akBottom] TabOrder = 8 end object EditMaxCombAantal: TEdit Left = 112 - Top = 220 + Top = 204 Width = 200 Height = 21 - Anchors = [akLeft, akBottom] TabOrder = 9 end object EditMeta: TEdit Left = 112 Top = 12 Width = 154 Height = 21 - Anchors = [akLeft, akBottom] Enabled = False TabOrder = 10 end - object MemoParameters: TMemo - Left = 112 - Top = 282 - Width = 200 - Height = 125 - Anchors = [akLeft, akBottom] - Lines.Strings = ( - '') - TabOrder = 11 - end object Button1: TButton Left = 272 Top = 44 Width = 40 Height = 21 - Anchors = [akLeft, akBottom] Caption = '...' - TabOrder = 12 + TabOrder = 11 end object EditVolumeVan: TEdit Left = 112 Top = 44 Width = 154 Height = 21 - Anchors = [akLeft, akBottom] Enabled = False - TabOrder = 13 + TabOrder = 12 end object ComboBoxOptiType: TComboBox - Left = 446 - Top = 140 + Left = 464 + Top = 204 Width = 162 Height = 21 Style = csDropDownList - Anchors = [akLeft, akBottom] - TabOrder = 14 + TabOrder = 13 end object ComboBoxBoxSelect: TComboBox - Left = 446 - Top = 172 + Left = 464 + Top = 236 Width = 162 Height = 21 Style = csDropDownList - Anchors = [akLeft, akBottom] + TabOrder = 14 + end + object ScrollBoxParameters: TScrollBox + Left = 112 + Top = 268 + Width = 295 + Height = 125 TabOrder = 15 end end object GroupBox1: TGroupBox Left = 8 Top = 83 - Width = 792 - Height = 168 + Width = 786 + Height = 170 Anchors = [akLeft, akTop, akRight, akBottom] Caption = 'Dozen' TabOrder = 0 DesignSize = ( - 792 - 168) + 786 + 170) object ListViewVerpakkingen: TListView Left = 3 Top = 16 - Width = 669 - Height = 149 + Width = 663 + Height = 151 Anchors = [akLeft, akTop, akRight, akBottom] Columns = < item @@ -422,17 +379,17 @@ OnSelectItem = ListViewVerpakkingenSelectItem end object ButtonNieuw: TButton - Left = 688 - Top = 47 + Left = 682 + Top = 49 Width = 101 Height = 25 Anchors = [akRight, akBottom] Caption = 'Nieuw' TabOrder = 1 end object ButtonVerwijder: TButton - Left = 688 - Top = 86 + Left = 682 + Top = 88 Width = 101 Height = 25 Anchors = [akRight, akBottom] Index: VerpakkingsDefinitie/Main.pas =================================================================== diff -u -r583 -r587 --- VerpakkingsDefinitie/Main.pas (.../Main.pas) (revision 583) +++ VerpakkingsDefinitie/Main.pas (.../Main.pas) (revision 587) @@ -78,8 +78,7 @@ // Volgende subscherm laden in panel // PanelMain behouden we altijd, the children can be free. - for i := 0 to PanelMain.ControlCount - 1 do - TUtil.FreeControlChildrenRec(PanelMain.Controls[i]); + TUtil.FreeControlChildrenDeep(PanelMain); case schermId of NAVHOME, NAVZOEKPRODUCTEN: Index: VerpakkingsDefinitie/UI/ProductDetailScherm.pas =================================================================== diff -u -r586 -r587 --- VerpakkingsDefinitie/UI/ProductDetailScherm.pas (.../ProductDetailScherm.pas) (revision 586) +++ VerpakkingsDefinitie/UI/ProductDetailScherm.pas (.../ProductDetailScherm.pas) (revision 587) @@ -45,7 +45,6 @@ ComboBoxPositie: TComboBox; ComboBoxRichting: TComboBox; ButtonMeta: TButton; - MemoParameters: TMemo; PanelVerpakkingControls: TPanel; Label3: TLabel; Button1: TButton; @@ -56,6 +55,7 @@ ComboBoxBoxSelect: TComboBox; LabelProductNummer: TLabel; Label17: TLabel; + ScrollBoxParameters: TScrollBox; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); @@ -80,7 +80,7 @@ implementation uses - OptiServerService, Util, System.StrUtils; + OptiServerService, Util, System.StrUtils, CustomPanelVerpakkingParameter; {$R *.dfm} Constructor TFormProductDetail.Create(AOwner: TComponent; Navigator: INavigator; ApplicationContext: TApplicationContext; @@ -181,9 +181,10 @@ procedure TFormProductDetail.ToonProductVerpakking(ProductVerpakking: TProductVerpakking); var - I: Integer; TempStr: string; Item: string; + Parameter: TProductVerpakkingParameter; + NieuweParameterControl: TCustomPanelVerpakkingParameter; begin // Linkerhelft @@ -222,6 +223,18 @@ EditMaxCombAantal.Text := ProductVerpakking.MaxCombinAantal; EditAantal.Text := ProductVerpakking.Aantal; + // Parameters + TUtil.FreeControlChildrenDeep(ScrollBoxParameters); + for Parameter in ProductVerpakking.Parameters do + begin + NieuweParameterControl := TCustomPanelVerpakkingParameter.Create(ScrollBoxParameters); + with NieuweParameterControl do + begin + Parent := ScrollBoxParameters; + ProductVerpakkingParameter := Parameter; + end; + end; + // Rechterhelft // Plaatsing @@ -241,6 +254,7 @@ // Positie CheckComboBoxPositie.Items.Clear(); // CheckComboBox vullen en items selecteren. Als waarde niet aanwezig is, uit default halen. + { TODO : Bug fixen als item niet bestaat in dictionary } for Item in ApplicationContext.UiInstellingenContext.Posities.keys do CheckComboBoxPositie.Items.AddObject(ApplicationContext.UiInstellingenContext.Posities[Item], TObject(Item)); if ProductVerpakking.Posities.Count > 0 then