Index: VerpakkingsDefinitie/ApplicationContext.pas =================================================================== diff -u -r581 -r582 --- VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 581) +++ VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 582) @@ -9,8 +9,7 @@ uses ObserverPattern, - System.Generics.Collections, SysUtils, - OptiServerService; + System.Generics.Collections, SysUtils; // SUB CONTEXTS: klassen die overeenkomen met bepaalde sub-context (bv. alles gerelateerd met authenticatie). @@ -34,15 +33,6 @@ end; // - UI instellingen -// TPair = class -// private -// FKey: string; -// FValue: string; -// public -// property Key: string read FKey write FKey; -// property Value: string read FValue write FValue; -// end; - TUiInstellingenContext = class(TSubject) private FPositie: TDictionary; @@ -97,30 +87,74 @@ constructor Create(); procedure Reset(); procedure NotifyChanged(); - property Producten: TList read FProducten write FProducten; + property Producten: TList read FProducten; property IsOK: Boolean read FIsOK write FIsOK; property ErrorMessage: string read FErrorMessage write FErrorMessage; property InternalErrorMessage: string read FInternalErrorMessage write FInternalErrorMessage; end; // - Product Detail - // TProductDetailInformatie = class() - // end; + TProductVerpakking = class + private + FRawData: TObject; + FID: string; + FMetaCaption: string; + FCutOrder: Integer; + FBreedte: string; + FDefaultBreedte: string; + FDiepte: string; + FDefaultDiepte: string; + FHoogte: string; + FDefaultHoogte: string; + FAantal: string; + FMaxCombinAantal: string; + FPlaatsing: string; + FPositie: string; + FRichting: string; + + FDeelVanID: string; + FDeelVan: TProductVerpakking; + public + property RawData: TObject read FRawData write FRawData; + + property ID: string read FID write FID; + property MetaCaption: string read FMetaCaption write FMetaCaption; + property CutOrder: Integer read FCutOrder write FCutOrder; + property Breedte: string read FBreedte write FBreedte; + property DefaultBreedte: string read FDefaultBreedte write FDefaultBreedte; + property Diepte: string read FDiepte write FDiepte; + property DefaultDiepte: string read FDefaultDiepte write FDefaultDiepte; + property Hoogte: string read FHoogte write FHoogte; + property DefaultHoogte: string read FDefaultHoogte write FDefaultHoogte; + property Aantal: string read FAantal write FAantal; + property MaxCombinAantal: string read FMaxCombinAantal write FMaxCombinAantal; + property Plaatsing: string read FPlaatsing write FPlaatsing; + property Positie: string read FPositie write FPositie; + property Richting: string read FRichting write FRichting; + + property DeelVanID: string read FDeelVanID write FDeelVanID; + property DeelVan: TProductVerpakking read FDeelVan write FDeelVan; + + function Equals(Obj: TObject): Boolean; override; + end; + TProductDetailContext = class(TSubject) private FGeselecteerdProduct: TProductInformatie; - FProductDetailInformatie: OptiServerService.pxBoxData; + FProductVerpakkingen: TList; FIsOK: Boolean; FErrorMessage: string; FInternalErrorMessage: string; public + constructor Create(); procedure NotifyChanged(); procedure Reset(); property GeselecteerdProduct: TProductInformatie read FGeselecteerdProduct write FGeselecteerdProduct; - property ProductDetailInformatie: OptiServerService.pxBoxData read FProductDetailInformatie write FProductDetailInformatie; + property ProductVerpakkingen: TList read FProductVerpakkingen; + function GetDeelVanOpties(ProductVerpakking: TProductVerpakking): TList; property IsOK: Boolean read FIsOK write FIsOK; property ErrorMessage: string read FErrorMessage write FErrorMessage; @@ -172,6 +206,11 @@ FProducten := TList.Create(); end; +procedure TProductsContext.NotifyChanged(); +begin + self.Change(); +end; + // Enkel updaten wanneer nog niet op nil stond. procedure TProductsContext.Reset(); begin @@ -217,12 +256,13 @@ end; end; -procedure TProductsContext.NotifyChanged(); +// PRODUCT DETAIL +constructor TProductDetailContext.Create; begin - self.Change(); + inherited Create(); + FProductVerpakkingen := TList.Create(); end; -// PRODUCT DETAIL procedure TProductDetailContext.NotifyChanged(); begin self.Change(); @@ -231,14 +271,42 @@ // Enkel updaten wanneer nog niet op nil stond. procedure TProductDetailContext.Reset(); begin - if (GeselecteerdProduct <> nil) or (ProductDetailInformatie <> nil) then + if (GeselecteerdProduct <> nil) or (ProductVerpakkingen.Count > 0) then begin GeselecteerdProduct := nil; - ProductDetailInformatie := nil; + ProductVerpakkingen.Clear(); NotifyChanged(); end; end; +function TProductDetailContext.GetDeelVanOpties(ProductVerpakking: TProductVerpakking): TList; +var + ProductVerpakkingTeZoeken: TProductVerpakking; + Namen: TList; +begin + Namen := TList.Create(); + for ProductVerpakkingTeZoeken in FProductVerpakkingen do + begin + if ProductVerpakkingTeZoeken.Equals(ProductVerpakking) then + Namen.Add(intToStr(ProductVerpakkingTeZoeken.CutOrder) + ': ' + ProductVerpakkingTeZoeken.MetaCaption) + end; + + Result := Namen; +end; + +// Product verpakking +function TProductVerpakking.Equals(Obj: TObject): Boolean; +begin + if Obj <> nil then + Result := false + else if not(Obj is TProductVerpakking) then + Result := false + else if (Obj as TProductVerpakking).ID = self.ID then + Result := true + else + Result := false; +end; + // APPLICATION CONTEXT constructor TApplicationContext.Create(); begin