Index: VerpakkingsDefinitie/UI/ZoekProductenScherm.pas =================================================================== diff -u -r570 -r571 --- VerpakkingsDefinitie/UI/ZoekProductenScherm.pas (.../ZoekProductenScherm.pas) (revision 570) +++ VerpakkingsDefinitie/UI/ZoekProductenScherm.pas (.../ZoekProductenScherm.pas) (revision 571) @@ -63,16 +63,17 @@ ComboBoxAt.AddItem('', nil); // Default value ComboBoxAt.ItemIndex := 0; + + // Vorige opzoeking is ongeldig + self.ApplicationContext.ProductsContext.reset() end; procedure TFormZoekProducten.ButtonZoekViaKortTekstClick(Sender: TObject); var ErrorMessage: string; begin - // FProductAgent.ZoekOpMetKortTekst(EditZoek.Text, EditKlantNr.Text, ComboBoxAt.Text, self.ApplicationContext.UserContext, - // self.ApplicationContext.ProductsContext); - FProductAgent.ZoekOpMetKortTekst('TA # ERINGS01CUBIMAX R XX', EditKlantNr.Text, ComboBoxAt.Text, - self.ApplicationContext.UserContext, self.ApplicationContext.ProductsContext); + FProductAgent.ZoekOpMetKortTekst(EditZoek.Text, EditKlantNr.Text, ComboBoxAt.Text, self.ApplicationContext.UserContext, + self.ApplicationContext.ProductsContext); if ApplicationContext.ProductsContext.IsOK = false then begin Index: VerpakkingsDefinitie/UI/ProductDetailScherm.pas =================================================================== diff -u -r569 -r571 --- VerpakkingsDefinitie/UI/ProductDetailScherm.pas (.../ProductDetailScherm.pas) (revision 569) +++ VerpakkingsDefinitie/UI/ProductDetailScherm.pas (.../ProductDetailScherm.pas) (revision 571) @@ -66,6 +66,7 @@ CheckComboBoxRichting: TCheckedComboBox; procedure UpdateGui(Sender: TObject); + procedure UpdateGuiDataAanwezigheid(Aanwezig: boolean); public Constructor Create(AOwner: TComponent; Navigator: INavigator; ApplicationContext: TApplicationContext; ProductDetailsSubject: TSubject); @@ -110,38 +111,16 @@ var ProductDetailInformatie: OptiServerService.pxBoxData; PPSPrioriteitEl: OptiServerService.pxemPPSPrioriteit; - SchermControl: TControl; - I: Integer; TempStr: string; begin - { TODO : Als er geen product is om detail van te tonen, verberg alle componenten en toon een bericht in het midden van het scherm } if (ApplicationContext.ProductDetailContext.GeselecteerdProduct = nil) or (ApplicationContext.ProductDetailContext.ProductDetailInformatie = nil) then begin - // Geen resultaten, verberg kinderen, toon melding (label) en stop. - for I := 0 to self.ControlCount - 1 do - self.Controls[I].Visible := false; - // Label tonen - LabelGeenData := TLabel.Create(self); - with LabelGeenData do - begin - Parent := self; - Caption := GEEN_DATA_CAPTION; - Font.Size := 15; - // Centreren: https://stackoverflow.com/questions/18545937/make-a-component-appear-in-the-middle-of-form-no-matter-what-screen-resolution - Left := (self.Width - Width) div 2; - Top := (self.Height - Height) div 2; - Anchors := []; // Relatief tegenover parent - end; + UpdateGuiDataAanwezigheid(False); exit; end else - begin - // Wel resultaten, toon alles en ga verder. - for I := 0 to self.ControlCount - 1 do - self.Controls[I].Visible := true; - LabelGeenData.Free(); - end; + UpdateGuiDataAanwezigheid(True); // Update with data from ApplicationContext LabelOmschrijving1.Caption := ApplicationContext.ProductDetailContext.GeselecteerdProduct.Omschrijving1; @@ -203,7 +182,7 @@ CheckComboBoxPositie.Items.Add(TempStr); end; if CheckComboBoxPositie.Items.IndexOf(ProductDetailInformatie.Positie) >= 0 then - CheckComboBoxPositie.Checked[CheckComboBoxPositie.Items.IndexOf(ProductDetailInformatie.Positie)] := true; + CheckComboBoxPositie.Checked[CheckComboBoxPositie.Items.IndexOf(ProductDetailInformatie.Positie)] := True; // Richting CheckComboBoxRichting.Items.Clear(); @@ -213,10 +192,52 @@ CheckComboBoxRichting.Items.Add(TempStr); end; if CheckComboBoxRichting.Items.IndexOf(ProductDetailInformatie.Rotatie) >= 0 then - CheckComboBoxRichting.Checked[CheckComboBoxRichting.Items.IndexOf(ProductDetailInformatie.Rotatie)] := true + CheckComboBoxRichting.Checked[CheckComboBoxRichting.Items.IndexOf(ProductDetailInformatie.Rotatie)] := True else if CheckComboBoxRichting.Items.IndexOf(ProductDetailInformatie.DefaultData.Rotatie) >= 0 then - CheckComboBoxRichting.Checked[CheckComboBoxRichting.Items.IndexOf(ProductDetailInformatie.DefaultData.Rotatie)] := true + CheckComboBoxRichting.Checked[CheckComboBoxRichting.Items.IndexOf(ProductDetailInformatie.DefaultData.Rotatie)] := True end; end; +procedure TFormProductDetail.UpdateGuiDataAanwezigheid(Aanwezig: boolean); +var + I: Integer; +begin + if Aanwezig then + begin + // Skip update als alles al zichtbaar staat. + if Assigned(LabelGeenData) = False then + exit; + + // Wel resultaten, toon alles. + for I := 0 to self.ControlCount - 1 do + if Assigned(self.Controls[I]) then + self.Controls[I].Visible := True; + + FreeAndNil(LabelGeenData); + end + else + begin + // Skip update als melding al getoond wordt en alles onzichtbaar staat. + if Assigned(LabelGeenData) then + exit; + + // Geen resultaten, verberg kinderen, toon melding (label) en stop. + for I := 0 to self.ControlCount - 1 do + if Assigned(self.Controls[I]) then + self.Controls[I].Visible := False; + // Label tonen + LabelGeenData := TLabel.Create(self); + with LabelGeenData do + begin + Parent := self; + Caption := GEEN_DATA_CAPTION; + Font.Size := 15; + // Centreren: https://stackoverflow.com/questions/18545937/make-a-component-appear-in-the-middle-of-form-no-matter-what-screen-resolution + Left := (self.Width - Width) div 2; + Top := (self.Height - Height) div 2; + Anchors := []; // Relatief tegenover parent + end; + end +end; + end. Index: VerpakkingsDefinitie/ApplicationContext.pas =================================================================== diff -u -r570 -r571 --- VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 570) +++ VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 571) @@ -65,6 +65,7 @@ FInternalErrorMessage: string; public constructor Create(); + procedure Reset(); procedure NotifyChanged(); property Producten: TList read FProducten write FProducten; @@ -87,7 +88,7 @@ FInternalErrorMessage: string; public procedure NotifyChanged(); - procedure ResetSelectie(); + procedure Reset(); property GeselecteerdProduct: TProductInformatie read FGeselecteerdProduct write FGeselecteerdProduct; property ProductDetailInformatie: OptiServerService.pxBoxData read FProductDetailInformatie write FProductDetailInformatie; @@ -125,6 +126,16 @@ FProducten := TList.Create(); end; +// Enkel updaten wanneer nog niet op nil stond. +procedure TProductsContext.Reset(); +begin + if FProducten.Count > 0 then + begin + FProducten.Clear(); + NotifyChanged(); + end; +end; + function TProductInformatie.GetOmschrijving1(): string; var S: string; @@ -174,7 +185,7 @@ end; // Enkel updaten wanneer nog niet op nil stond. -procedure TProductDetailContext.ResetSelectie(); +procedure TProductDetailContext.Reset(); begin if (GeselecteerdProduct <> nil) or (ProductDetailInformatie <> nil) then begin Index: VerpakkingsDefinitie/UI/GevondenProductenScherm.pas =================================================================== diff -u -r570 -r571 --- VerpakkingsDefinitie/UI/GevondenProductenScherm.pas (.../GevondenProductenScherm.pas) (revision 570) +++ VerpakkingsDefinitie/UI/GevondenProductenScherm.pas (.../GevondenProductenScherm.pas) (revision 571) @@ -88,7 +88,7 @@ end; // Bij opnieuw inladen is de selectie verloren gegaan. - self.ApplicationContext.ProductDetailContext.ResetSelectie(); + self.ApplicationContext.ProductDetailContext.Reset(); end; end. Index: VerpakkingsDefinitie/UI/LogInScherm.pas =================================================================== diff -u -r570 -r571 --- VerpakkingsDefinitie/UI/LogInScherm.pas (.../LogInScherm.pas) (revision 570) +++ VerpakkingsDefinitie/UI/LogInScherm.pas (.../LogInScherm.pas) (revision 571) @@ -95,8 +95,7 @@ var ErrorMessage: string; begin - // FUserAgent.GebruikerAanmelden(EditGebruikersnaam.Text, EditWachtwoord.Text, self.ApplicationContext.UserContext); - FUserAgent.GebruikerAanmelden('tve', 'tve1502', self.ApplicationContext.UserContext); + FUserAgent.GebruikerAanmelden(EditGebruikersnaam.Text, EditWachtwoord.Text, self.ApplicationContext.UserContext); if ApplicationContext.UserContext.IsOK then begin