From 0858a26dc11ad128113f521a05b507380c9033f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thea=20Sch=C3=B6bl?= Date: Thu, 8 Feb 2024 14:25:54 +0100 Subject: [PATCH] fix: dish prices sometimes go missing --- .../data/elements/offers-in-list.component.ts | 20 +++--- .../modules/data/elements/offers-in-list.html | 20 ++---- .../modules/data/elements/offers-in-list.scss | 11 +++ .../app/modules/data/list/data-list-item.html | 28 +++----- .../app/modules/data/list/data-list-item.scss | 65 +++++++++++------- .../data/types/dish/dish-characteristics.html | 27 ++++---- .../data/types/dish/dish-characteristics.scss | 24 +++---- .../data/types/dish/dish-detail-content.html | 2 +- .../data/types/dish/dish-list-item.html | 25 +++---- .../types/place/place-list-item.component.ts | 14 +++- .../data/types/place/place-list-item.html | 68 +++++++------------ .../data/types/place/place-list-item.scss | 4 ++ 12 files changed, 154 insertions(+), 154 deletions(-) create mode 100644 frontend/app/src/app/modules/data/elements/offers-in-list.scss diff --git a/frontend/app/src/app/modules/data/elements/offers-in-list.component.ts b/frontend/app/src/app/modules/data/elements/offers-in-list.component.ts index 57281fe8..1ed8b1ad 100644 --- a/frontend/app/src/app/modules/data/elements/offers-in-list.component.ts +++ b/frontend/app/src/app/modules/data/elements/offers-in-list.component.ts @@ -13,20 +13,19 @@ * this program. If not, see . */ import {Component, Input} from '@angular/core'; -import {SCAcademicPriceGroup, SCThingThatCanBeOfferedOffer} from '@openstapps/core'; +import { + SCAcademicPriceGroup, + SCThingThatCanBeOfferedAvailability, + SCThingThatCanBeOfferedOffer, +} from '@openstapps/core'; import {SettingsProvider} from '../../settings/settings.provider'; -/** - * TODO - */ @Component({ selector: 'stapps-offers-in-list', templateUrl: 'offers-in-list.html', + styleUrls: ['offers-in-list.scss'], }) export class OffersInListComponent { - /** - * TODO - */ @Input() set offers(it: Array>) { this._offers = it; this.price = it[0].prices?.default; @@ -34,13 +33,14 @@ export class OffersInListComponent { this.price = it[0].prices?.[(group.value as string).replace(/s$/, '') as never]; }); - const availabilities = new Set(it.map(offer => offer.availability)); - this.soldOut = availabilities.has('out of stock') && availabilities.size === 1; + if (it.length === 1) { + this.availability = it[0].availability; + } } price?: number; - soldOut: boolean; + availability: SCThingThatCanBeOfferedAvailability; _offers: Array>; diff --git a/frontend/app/src/app/modules/data/elements/offers-in-list.html b/frontend/app/src/app/modules/data/elements/offers-in-list.html index 72fe6d1e..39723ebe 100644 --- a/frontend/app/src/app/modules/data/elements/offers-in-list.html +++ b/frontend/app/src/app/modules/data/elements/offers-in-list.html @@ -13,16 +13,10 @@ ~ this program. If not, see . --> -
- -

{{ price | currency : 'EUR' : 'symbol' : undefined : 'de' }}

-
- -

{{ 'data.detail.offers.sold_out' | translate }}

-
-

- {{ _offers[0].inPlace.name }}... -

-
+ + {{ availability === 'out of stock' ? ('data.detail.offers.sold_out' | translate) : (price | currency : 'EUR' + : 'symbol' : undefined : 'de') }} + diff --git a/frontend/app/src/app/modules/data/elements/offers-in-list.scss b/frontend/app/src/app/modules/data/elements/offers-in-list.scss new file mode 100644 index 00000000..eef527f1 --- /dev/null +++ b/frontend/app/src/app/modules/data/elements/offers-in-list.scss @@ -0,0 +1,11 @@ +:host { + display: contents; +} + +ion-badge { + display: inline-block; + font-size: 0.8em; + margin-top: -0.25em; + translate: 0 0.25em; + padding: 0.25em; +} diff --git a/frontend/app/src/app/modules/data/list/data-list-item.html b/frontend/app/src/app/modules/data/list/data-list-item.html index 3824e5b7..434eeb58 100644 --- a/frontend/app/src/app/modules/data/list/data-list-item.html +++ b/frontend/app/src/app/modules/data/list/data-list-item.html @@ -20,33 +20,25 @@ detail="false" (click)="notifySelect()" > -
- -
- -
-
+
- - + + - -
- - -
-
+
+ + +
diff --git a/frontend/app/src/app/modules/data/list/data-list-item.scss b/frontend/app/src/app/modules/data/list/data-list-item.scss index cdc6012a..ce745bec 100644 --- a/frontend/app/src/app/modules/data/list/data-list-item.scss +++ b/frontend/app/src/app/modules/data/list/data-list-item.scss @@ -20,34 +20,25 @@ ion-item::part(native) { height: 100%; + padding: var(--spacing-sm); } ion-item { --border-color: transparent; --inner-padding-end: 0; - --padding-start: 0; @include border-radius-in-parallax(var(--border-radius-default)); overflow: hidden; margin: var(--spacing-sm); + height: 100%; ion-thumbnail { --ion-margin: var(--spacing-xs); - margin-inline-start: var(--spacing-md); + margin-inline: var(--spacing-md); + margin-block: auto; padding: 0; } - - ion-label { - width: 100%; - margin-right: 0; - padding-left: var(--spacing-sm); - - div { - display: flex; - flex-direction: column; - } - } } .ion-text-wrap ::ng-deep ion-label { @@ -58,9 +49,44 @@ ion-item { -webkit-line-clamp: 3; } +[slot='end'] { + margin-inline-start: 0; + margin-block: auto; +} + +stapps-action-chip-list { + float: bottom; +} + +ion-item ::ng-deep { + stapps-long-inline-text, + .title { + overflow: hidden; + display: -webkit-box; + + white-space: break-spaces; + + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + } + + .title-sub { + overflow: hidden; + display: -webkit-box; + + white-space: break-spaces; + + -webkit-box-orient: vertical; + -webkit-line-clamp: 1; + + margin-block: var(--spacing-xs); + } +} + :host.square ::ng-deep { ion-item { margin: 0; + align-items: flex-start; } ion-row { @@ -74,19 +100,12 @@ ion-item { flex-grow: 0; } - stapps-long-inline-text, .title { - overflow: hidden; - display: -webkit-box; - - white-space: break-spaces; - - -webkit-box-orient: vertical; - -webkit-line-clamp: 2; + height: 2.5em; } - .title-sub { - display: none; + .title ~ :last-child { + margin-right: 42px; } stapps-rating, diff --git a/frontend/app/src/app/modules/data/types/dish/dish-characteristics.html b/frontend/app/src/app/modules/data/types/dish/dish-characteristics.html index 89040309..4c52b115 100644 --- a/frontend/app/src/app/modules/data/types/dish/dish-characteristics.html +++ b/frontend/app/src/app/modules/data/types/dish/dish-characteristics.html @@ -13,19 +13,7 @@ ~ this program. If not, see . --> - - - - - - - -
+ {{ 'categories' | thingTranslate: item | join: ', ' | titlecase }} @@ -36,6 +24,15 @@ > -
- {{ 'categories' | thingTranslate: item | join: ', ' | titlecase }} + + + + + + +
diff --git a/frontend/app/src/app/modules/data/types/dish/dish-characteristics.scss b/frontend/app/src/app/modules/data/types/dish/dish-characteristics.scss index 0b3c4557..7a769fd6 100644 --- a/frontend/app/src/app/modules/data/types/dish/dish-characteristics.scss +++ b/frontend/app/src/app/modules/data/types/dish/dish-characteristics.scss @@ -12,13 +12,21 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ +:host { + display: contents; +} + $size: 16px; ion-note { + margin: inherit; + margin-right: inherit; + margin-block-end: inherit; display: flex; - flex-direction: row-reverse; - align-items: center; - justify-content: flex-end; + align-items: flex-start; + justify-content: flex-start; + gap: var(--spacing-xs) var(--spacing-sm); + flex-flow: row wrap; list-style: none; } @@ -41,15 +49,5 @@ abbr { } img { - height: 100%; background: var(--background-url); } - -.sep { - display: none; - margin-inline: var(--spacing-xs); -} - -abbr + .sep { - display: revert; -} diff --git a/frontend/app/src/app/modules/data/types/dish/dish-detail-content.html b/frontend/app/src/app/modules/data/types/dish/dish-detail-content.html index 7228e06f..b00de7f7 100644 --- a/frontend/app/src/app/modules/data/types/dish/dish-detail-content.html +++ b/frontend/app/src/app/modules/data/types/dish/dish-detail-content.html @@ -13,7 +13,7 @@ ~ this program. If not, see . --> - + . --> - - - -
- {{ 'name' | thingTranslate: item }} -

{{ 'description' | thingTranslate: item }}

- -
-
- -
- -
-
-
-
+ + + {{ 'name' | thingTranslate: item }} + +

{{ 'description' | thingTranslate: item | sentencecase }}

+ diff --git a/frontend/app/src/app/modules/data/types/place/place-list-item.component.ts b/frontend/app/src/app/modules/data/types/place/place-list-item.component.ts index 168eeff1..b15d6c01 100644 --- a/frontend/app/src/app/modules/data/types/place/place-list-item.component.ts +++ b/frontend/app/src/app/modules/data/types/place/place-list-item.component.ts @@ -14,9 +14,11 @@ */ import {ChangeDetectionStrategy, Component, Input} from '@angular/core'; import {PositionService} from '../../../map/position.service'; -import {filter, Observable, timer} from 'rxjs'; +import {filter, Observable} from 'rxjs'; import {hasValidLocation, isSCFloor, PlaceTypes, PlaceTypesWithDistance} from './place-types'; import {map} from 'rxjs/operators'; +import {LatLng, geoJSON} from 'leaflet'; +import {trigger, transition, style, animate} from '@angular/animations'; /** * Shows a place as a list item @@ -26,6 +28,7 @@ import {map} from 'rxjs/operators'; templateUrl: 'place-list-item.html', styleUrls: ['place-list-item.scss'], changeDetection: ChangeDetectionStrategy.OnPush, + animations: [trigger('fade', [transition(':enter', [style({opacity: 0}), animate(100)])])], }) export class PlaceListItemComponent { _item: PlaceTypesWithDistance; @@ -36,8 +39,13 @@ export class PlaceListItemComponent { @Input() set item(item: PlaceTypes) { this._item = item; if (!isSCFloor(item) && hasValidLocation(item)) { - this.distance = timer(0, 10_000).pipe( - map(() => this.positionService.getDistance(item.geo.point)), + this.distance = this.positionService.watchCurrentLocation().pipe( + map(position => + new LatLng(position.latitude, position.longitude).distanceTo( + geoJSON(item.geo.point).getBounds().getCenter(), + ), + ), + filter(it => it !== undefined), ); } diff --git a/frontend/app/src/app/modules/data/types/place/place-list-item.html b/frontend/app/src/app/modules/data/types/place/place-list-item.html index 56492e83..7fec92e8 100644 --- a/frontend/app/src/app/modules/data/types/place/place-list-item.html +++ b/frontend/app/src/app/modules/data/types/place/place-list-item.html @@ -12,45 +12,29 @@ ~ You should have received a copy of the GNU General Public License along with ~ this program. If not, see . --> - - - - -
- {{ 'name' | thingTranslate: _item }} - -

- - - -

-

- - {{ 'categories' | thingTranslate: _item | join: ', ' | titlecase }} - - - {{ distance | metersLocalized }} - - -

- - - {{ 'type' | thingTranslate: _item | titlecase }} - - - {{ distance | metersLocalized }} - - - -
-

{{ 'description' | thingTranslate: _item }}

-
-
- - - {{ 'name' | thingTranslate: _item.inPlace }} - - -
-
+ + + + {{ distance | metersLocalized }} + + +{{ 'name' | thingTranslate: _item }} + + + + {{ 'categories' | thingTranslate: _item | join: ', ' | titlecase }} + + + + + {{ 'type' | thingTranslate: _item | titlecase }} + + + + +

{{ 'description' | thingTranslate: _item }}

+ + + {{ 'name' | thingTranslate: _item.inPlace }} + + diff --git a/frontend/app/src/app/modules/data/types/place/place-list-item.scss b/frontend/app/src/app/modules/data/types/place/place-list-item.scss index 027b92cf..4667de0d 100644 --- a/frontend/app/src/app/modules/data/types/place/place-list-item.scss +++ b/frontend/app/src/app/modules/data/types/place/place-list-item.scss @@ -33,3 +33,7 @@ ion-label + ion-label.distance::before { align-items: center; justify-content: flex-end; } + +stapps-opening-hours ::ng-deep div { + padding-block: var(--spacing-xs); +}