Skip to content

Save ShoppingCartItem.ValidUntil with 'user-inputted' time instead of forced 'end of day' time #255

Description

@NielsDeGroot

ValidUntil@ShoppingCartItem has the schema setting DateTimeDetail@DialogColumn (Date add-on) = 2 (End of Day)
The HTML application follows this by not letting you select a timepart on ValidUntil of your product request.
Image

In the old portal you can select and save a time of your likings.
Image

I tried to recreate the old portal behavior for ValidUntil@ShoppingCartItem in the HTML application by overwriting the dateFormat for certain columns. imxweb\projects\qbm\src\lib\cdr\edit-date\edit-date.component.ts

/**
   * Determines, if a time control should be added.
   */
  public get withTime(): boolean {
    // try to get the date format detail from metadata; defaulting to DateTime.
    let dateFormat = this.columnContainer.metaData?.GetDateFormat() ?? DateFormat.DateTime;
    const schemaKey = this.columnContainer.metaData?.GetSchemaKey() ?? '';

    // Default to DateTime for these columns
    const schemaKeys = ['ShoppingCartItem.ValidUntil', 'PersonWantsOrg.ValidUntil', 'Person.ExitDate'];
    if (schemaKeys.includes(schemaKey)) {
      dateFormat = DateFormat.DateTime;
    }

    return dateFormat === DateFormat.DateTime || dateFormat === DateFormat.UtcDateTime;
  }

Now you can select the time-part
Image
But when you [Save] it the time-part is still saved in the DB as: DateFormat.EndTime
Image
What would be the right way to do this?

I also added time-part for Renew product option.
imxweb\projects\qer\src\lib\request-history\request-action\request-action.service.ts

  public async prolongate(entities: TypedEntity[]): Promise<void> {
    const requests = entities as PortalItshopRequests[];
    const reason = this.createCdrReason();

    const prolongationProperty = this.requestHistoryService.PortalItshopRequestsSchema.Columns.ValidUntilProlongation;
    prolongationProperty.IsReadOnly = false;
    prolongationProperty.DateFormat = DateFormat.DateTime;
    const prolongation = new BaseCdr(
      this.entityService.createLocalEntityColumn(prolongationProperty, undefined, { ValueConstraint: { MinValue: new Date() } }),
      '#LDS#Renew until',
    );

This change works you can select the time-part and it's saved correctly with the user specified end-time

Regards,
Niels

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions