From 3621971e0586cb2e16d26bd89cc260391074ae5a Mon Sep 17 00:00:00 2001 From: Lars Saalbach Date: Thu, 24 Oct 2024 20:17:05 +0200 Subject: [PATCH] #825 - Add the open date of a bean bag if the parameter is set --- src/app/brew/brew-add/brew-add.component.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/app/brew/brew-add/brew-add.component.ts b/src/app/brew/brew-add/brew-add.component.ts index c075f219..615cb82e 100644 --- a/src/app/brew/brew-add/brew-add.component.ts +++ b/src/app/brew/brew-add/brew-add.component.ts @@ -317,6 +317,8 @@ export class BrewAddComponent implements OnInit, OnDestroy { this.manageCaffeineConsumption(); + await this.manageOpenDateForBean(addedBrewObj); + if (!this.hide_toast_message) { this.uiToast.showInfoToast('TOAST_BREW_ADDED_SUCCESSFULLY'); } @@ -381,6 +383,24 @@ export class BrewAddComponent implements OnInit, OnDestroy { } } + private async manageOpenDateForBean(addedBrewObj: Brew) { + //#825 + try { + this.uiLog.log('Brew add - Step OpenDateForBean'); + const bean = this.data.getBean(); + if (bean && !bean.openDate) { + if (this.settings.bean_manage_parameters.openDate === true) { + if (this.brewBrewing.customCreationDate) { + bean.openDate = this.brewBrewing.customCreationDate; + } else { + bean.openDate = moment(new Date()).toISOString(); + } + await this.uiBeanStorage.update(bean); + } + } + } catch (ex) {} + } + private manageUploadToVisualizer(addedBrewObj: Brew): void { if ( this.settings.visualizer_active &&