Skip to content

Commit

Permalink
Feat add cocktail row action dialog and more cocktails (#411)
Browse files Browse the repository at this point in the history
* feat: add cocktail list item action dialog on long press

* fix

* chore: add cocktail

* chore: more cocktails
  • Loading branch information
anton-gustafsson authored Oct 23, 2023
1 parent 6dea0f1 commit 0bda4c7
Show file tree
Hide file tree
Showing 22 changed files with 194 additions and 73 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"@typescript-eslint/consistent-type-definitions": [1, "type"],
"@typescript-eslint/no-unused-vars": [1],
"@typescript-eslint/no-empty-function": [1],
"@typescript-eslint/no-inferrable-types": [1]
"@typescript-eslint/no-inferrable-types": [1],
"@typescript-eslint/no-extraneous-class": [1]
},

"overrides": [
Expand Down
7 changes: 7 additions & 0 deletions src/components/copy-to-clipboard/copy-to-clipboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template class="block">
<button click.delegate="copyToClipboard()" class="btn w-full" data-cy="copy-to-clipboard-button">
<p if.bind="!textCopied" t="copy-name-to-clipboard"></p>
<p else class="text-success" t="copied-to-clipboard"></p>
<icon-clipboard class="h-6 w-6 ${textCopied ? 'text-success' : ''}"></icon-clipboard>
</button>
</template>
23 changes: 23 additions & 0 deletions src/components/copy-to-clipboard/copy-to-clipboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { autoinject, bindable } from 'aurelia-framework';
import { Clipboard } from '@capacitor/clipboard';
@autoinject
export class CopyToClipboard {
@bindable public name: string;
public textCopied = false;

async copyToClipboard() {
if (this.textCopied === true) {
return;
}

await Clipboard.write({
string: this.name
});

this.textCopied = true;

setTimeout(() => {
this.textCopied = false;
}, 3000);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ <h3 class="text-lg font-bold">${name}</h3>
<p else t="add-to-bar"></p>
</button>

<button click.delegate="copyToClipboard()" class="btn w-full mt-4" data-cy="copy-to-clipboard-button">
<p if.bind="!textCopied" t="copy-ingredient-name-to-clipboard"></p>
<p else class="text-success" t="copied-to-clipboard"></p>
<icon-clipboard class="h-6 w-6 ${textCopied ? 'text-success' : ''}"></icon-clipboard>
</button>
<copy-to-clipboard class="mt-4" name.bind="name"></copy-to-clipboard>
</div>
</div>
</ux-dialog>
Expand Down
19 changes: 1 addition & 18 deletions src/components/dialogs/cocktail-dialog/manage-ingredient-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { DialogController } from 'aurelia-dialog';
import { autoinject } from 'aurelia-framework';
import { ExtendedIngredientGroup } from 'domain/entities/cocktail';
import { LocalStorageService } from 'services/local-storage-service';
import { Clipboard } from '@capacitor/clipboard';

@autoinject
export class ManageIngredientRow {
Expand All @@ -15,7 +14,7 @@ export class ManageIngredientRow {
public isInStorage: boolean;
public selectedBarName: string;
public showBarName: boolean;
public textCopied = false;

private _ingredientId: string;
private _savedIngredientIds: string[] = [];

Expand Down Expand Up @@ -53,22 +52,6 @@ export class ManageIngredientRow {

this.dialogController.ok(response);
}

async copyToClipboard() {
if (this.textCopied === true) {
return;
}

await Clipboard.write({
string: this.name
});

this.textCopied = true;

setTimeout(() => {
this.textCopied = false;
}, 3000);
}
}

export type ManageIngredientRowResponse = {
Expand Down
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function configure(config: FrameworkConfiguration) {
PLATFORM.moduleName('./icons/icon-clipboard.html'),
PLATFORM.moduleName('./tag-component.html'),
PLATFORM.moduleName('./add-ingredient-component/add-ingredient-component'),
PLATFORM.moduleName('./copy-to-clipboard/copy-to-clipboard'),
PLATFORM.moduleName('./icons/icon-arrow-forward.html')
]);
}
48 changes: 48 additions & 0 deletions src/data/cocktail-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2465,5 +2465,53 @@ const cocktails: StaticCocktail[] = [
{ amount: '60', ingredientId: '10', unit: Unit.ML }
],
tags: []
},
{
id: '180',
imageSrc: 'images/mulled_wine.jpg',
isImagePortrait: false,
translation: 'mulled-wine',
category: DrinkCategory.Cocktail,
ingredientGroups: [
{ amount: '7.5', ingredientId: '91', unit: Unit.DL },
{ amount: '2.5', ingredientId: '42', unit: Unit.DL },
{ amount: '12', ingredientId: '102', unit: '' },
{ amount: '2', ingredientId: '103', unit: '' },
{ amount: '1', ingredientId: '105', unit: '' },
{ amount: '750', ingredientId: '101', unit: Unit.ML },
{ amount: '60', ingredientId: '50', unit: Unit.ML }
],
tags: [Tag.Christmas]
},
{
id: '181',
imageSrc: 'images/captain_kidds_punch.jpg',
isImagePortrait: false,
translation: 'captain-kidds-punch',
category: DrinkCategory.Cocktail,
ingredientGroups: [
{ amount: '60', ingredientId: '54', unit: Unit.ML },
{ amount: '30', ingredientId: '2', unit: Unit.ML },
{ amount: '30', ingredientId: '3', unit: Unit.ML },
{ amount: '1', ingredientId: '23', unit: '' },
{ amount: '1', ingredientId: '27', unit: Unit.DASH },
{ amount: '', ingredientId: '141', unit: '' }
],
tags: []
},
{
id: '182',
imageSrc: 'images/pure_passion.jpg',
isImagePortrait: false,
translation: 'pure-passion',
category: DrinkCategory.Cocktail,
ingredientGroups: [
{ amount: '45', ingredientId: '54', unit: Unit.ML },
{ amount: '15', ingredientId: '96', unit: Unit.ML },
{ amount: '30', ingredientId: '2', unit: Unit.ML },
{ amount: '15', ingredientId: '157', unit: Unit.ML },
{ amount: '1', ingredientId: '58', unit: Unit.DASH }
],
tags: []
}
];
3 changes: 2 additions & 1 deletion src/data/ingredient-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,5 +225,6 @@ const currentIngredients: StaticIngredient[] = [
{ id: '153', translation: 'calvados', spiritType: SpiritType.CognacBrandy, abv: 42, replacementIds: ['65'] },
{ id: '154', translation: 'wheat-beer', spiritType: SpiritType.None, abv: 5 },
{ id: '155', translation: 'apple-schnapps', spiritType: SpiritType.None, abv: 18 },
{ id: '156', translation: '7-up', spiritType: SpiritType.None, replacementIds: ['45'] }
{ id: '156', translation: '7-up', spiritType: SpiritType.None, replacementIds: ['45'] },
{ id: '157', translation: 'passion-fruit-syrup', spiritType: SpiritType.None }
];
6 changes: 4 additions & 2 deletions src/data/tags-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export enum Tag {
ContemporaryClassics = '4',
NewEraDrinks = '5',
Halloween = '6',
Punch = '7'
Punch = '7',
Christmas = '8'
}

const tags: StaticTagModel[] = [
Expand All @@ -17,7 +18,8 @@ const tags: StaticTagModel[] = [
{ id: Tag.ContemporaryClassics, translation: 'tag-list.contemporary-classics' },
{ id: Tag.NewEraDrinks, translation: 'tag-list.new-era-drinks' },
{ id: Tag.Punch, translation: 'tag-list.punch' },
{ id: Tag.Halloween, translation: 'tag-list.halloween' }
{ id: Tag.Halloween, translation: 'tag-list.halloween' },
{ id: Tag.Christmas, translation: 'tag-list.christmas' }
];

export function getTags() {
Expand Down
5 changes: 4 additions & 1 deletion src/locales/en/cocktails.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,8 @@
"pumpkin-pie-spice": "Pumpkin Pie Spice",
"apple-highball": "Apple Highball",
"apple-slammer": "Apple Slammer",
"vodka-lemon": "Vodka Lemon"
"vodka-lemon": "Vodka Lemon",
"mulled-wine": "Mulled Wine",
"captain-kidds-punch": "Captain Kidd’s Punch",
"pure-passion": "Pure Passion"
}
3 changes: 2 additions & 1 deletion src/locales/en/ingredients.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,6 @@
"calvados": "Calvados",
"wheat-beer": "Wheat Beer",
"apple-schnapps": "Apple Schnapps",
"7-up": "7 Up"
"7-up": "7 Up",
"passion-fruit-syrup": "Passion Fruit Syrup"
}
5 changes: 4 additions & 1 deletion src/locales/en/instructions.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,8 @@
"pumpkin-pie-spice": "Combine all ingredients in a spice jar and shake! Keeps for up to 6 months.",
"apple-highball": "Add ice in a highball glass.\nRub a wedge of fresh lime around rim and place it in the glass.\nAdd a shot of Apple schnapps, a shot of Courvoisier and top up with ginger ale.",
"apple-slammer": "Pour into a shot glass and present to consumer, they are expected to cover the top of the shotglass with thier palm, raise the glass, slam it on the bar and the swallow quickly.",
"vodka-lemon": "The vodka lemon is prepared directly in a highball glass or in a large tumbler: put 6-7 ice cubes in the glass, pour the vodka, lemonade and mix with a bar spoon.\nFinally decorate with a slice of lemon and, if you prefer, add a few mint leaves.\nYour vodka lemon is ready to be served."
"vodka-lemon": "The vodka lemon is prepared directly in a highball glass or in a large tumbler: put 6-7 ice cubes in the glass, pour the vodka, lemonade and mix with a bar spoon.\nFinally decorate with a slice of lemon and, if you prefer, add a few mint leaves.\nYour vodka lemon is ready to be served.",
"mulled-wine": "Simmer 3 cups water with, sugar, cloves, cinnamon sticks, and lemon peel in a stainless steel pot for 10 minutes.\nAdd wine heat to a 'coffee temperature' (DO NOT BOIL) then add the brandy.",
"captain-kidds-punch": "Mix all ingredients together in a shaker and strain into a collins glass.\nUse Caribbean dark Rum for a sweeter taste. Top with nutmeg",
"pure-passion": "Mix up all ingredients with a cocktail stirrer and serve with crushed ice with mint and edible flour if available."
}
9 changes: 6 additions & 3 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@
"contemporary-classics": "Contemporary Classics",
"new-era-drinks": "New Era Drinks",
"halloween": "Halloween",
"punch": "Punch"
"punch": "Punch",
"christmas": "Christmas"
},
"user": {
"created-data": "Manage",
Expand Down Expand Up @@ -162,6 +163,8 @@
"halloween-subtitle": "Explore halloween themed cocktails",
"remove-from-bar": "Remove from Bar",
"add-to-bar": "Add to Bar",
"copy-ingredient-name-to-clipboard": "Copy name to Clipboard",
"copied-to-clipboard": "Copied to Clipboard"
"copy-name-to-clipboard": "Copy name to Clipboard",
"copied-to-clipboard": "Copied to Clipboard",
"add-to-favorites": "Add to Favorites",
"remove-from-favorites": "Remove from Favorites"
}
1 change: 1 addition & 0 deletions src/modules/cocktails/all-cocktails/all-cocktails.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<cocktail-list-item
repeat.for="cocktail of filteredCocktails"
click.delegate="openCocktailDialog(cocktail)"
long-click.delegate="openCocktailRowDialog(cocktail)"
cocktail.bind="cocktail">
</cocktail-list-item>
</div>
Expand Down
14 changes: 12 additions & 2 deletions src/modules/cocktails/all-cocktails/all-cocktails.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { inject } from 'aurelia-framework';
import { autoinject } from 'aurelia-framework';
import { Cocktail } from 'domain/entities/cocktail';
import { CocktailDialog } from 'components/dialogs/cocktail-dialog/cocktail-dialog';
import { DialogService } from 'aurelia-dialog';
Expand All @@ -10,8 +10,9 @@ import { CocktailsParams } from '../cocktails';
import { filterCocktailList } from '../filter-cocktails-helper';
import { CocktailFilterCallbackData } from '../cocktail-filter-component';
import { Tag } from 'data/tags-data';
import { ManageCocktailRowDialog } from '../dialogs/manage-cocktail-row-dialog';

@inject(CocktailService, DialogService, IngredientService)
@autoinject
export class AllCocktails {
public filteredCocktails: Cocktail[] = [];
private _cocktails: Cocktail[] = [];
Expand Down Expand Up @@ -70,4 +71,13 @@ export class AllCocktails {
this.bind();
});
}

openCocktailRowDialog(cocktail: Cocktail) {
this._dialogService
.open({ viewModel: ManageCocktailRowDialog, model: cocktail, lock: false })
.whenClosed(() => {
this.params.filter = undefined;
this.bind();
});
}
}
22 changes: 22 additions & 0 deletions src/modules/cocktails/dialogs/manage-cocktail-row-dialog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<ux-dialog class="small-dialog" data-cy="manage-cocktail-row-dialog">
<div click.delegate="cancel()">
<div click.delegate="$event.stopPropagation()" class="bg-base-100 modal-box relative m-auto p-4">
<label class="btn btn-sm btn-circle absolute right-2 top-2" click.trigger="cancel()"></label>
<h3 class="text-lg font-bold">${cocktail.name}</h3>
<p if.bind="showBarName" class="text-sm text-base-content text-opacity-75">${barName}</p>

<div class="divider mt-2"></div>

<button click.delegate="toggleIsFavorite()" class="btn w-full" data-cy="toggle-favorite-button">
<p if.bind="cocktail.isFavorite" t="remove-from-favorites"></p>
<p else t="add-to-favorites"></p>
<icon-heart
class="h-6 w-6 ${cocktail.isFavorite ? 'text-error fill-error' : 'fill-none'}"></icon-heart>
</button>

<copy-to-clipboard class="mt-4" name.bind="cocktail.name"></copy-to-clipboard>
</div>
</div>
</ux-dialog>
</template>
37 changes: 37 additions & 0 deletions src/modules/cocktails/dialogs/manage-cocktail-row-dialog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { DialogController } from 'aurelia-dialog';
import { autoinject } from 'aurelia-framework';
import { Cocktail } from 'domain/entities/cocktail';
import { CocktailService } from 'services/cocktail-service';
import { LocalStorageService } from 'services/local-storage-service';

@autoinject
export class ManageCocktailRowDialog {
public cocktail: Cocktail;
public barName: string;
public showBarName: boolean;
constructor(
private dialogController: DialogController,
private localStorageService: LocalStorageService,
private cocktailService: CocktailService
) {}

activate(request: Cocktail) {
this.cocktail = request;
this.barName = this.localStorageService.getIngredientList().name;
this.showBarName = this.localStorageService.getIngredientLists().length > 1;
}

cancel() {
this.dialogController.cancel();
}

async toggleIsFavorite() {
this.cocktail.isFavorite = !this.cocktail.isFavorite;

if (this.cocktail.id.includes('x-')) {
await this.cocktailService.updateCocktail(this.cocktail);
} else {
await this.cocktailService.updateCocktailInformation(this.cocktail);
}
}
}
45 changes: 7 additions & 38 deletions src/modules/cocktails/from-ingredients/from-ingredients.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,20 @@
<cocktail-list-item
repeat.for="cocktail of cocktails"
click.delegate="openCocktailDialog($event, cocktail)"
long-click.delegate="openCocktailRowDialog($event, cocktail)"
cocktail.bind="cocktail">
</cocktail-list-item>

<div
if.bind="cocktailsWithMissingIngredient.length > 0"
click.delegate="toggleIsOpen()"
class="question-wrapper">
<div class="divider"></div>
<div class="question-row mb-4">
<h6 t="one-missing-ingredients"></h6>
<div class="flex items-center mr-4">
<svg
if.bind="!isOpen"
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
stroke="currentColor"
viewBox="0 0 512 512">
<title>Chevron Down</title>
<path
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="48"
d="M112 184l144 144 144-144" />
</svg>
<svg
if.bind="isOpen"
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
stroke="currentColor"
viewBox="0 0 512 512">
<title>Chevron Up</title>
<path
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="48"
d="M112 328l144-144 144 144" />
</svg>
</div>
<div click.delegate="toggleIsOpen()" class="collapse collapse-arrow bg-base-200 rounded-none my-4">
<input type="checkbox" checked.bind="isOpen" class="hidden" />
<div class="collapse-title font-medium flex items-center">
<p t="one-missing-ingredients"></p>
</div>
<div if.bind="isOpen">
<div class="collapse-content px-0">
<cocktail-list-item
repeat.for="cocktail of cocktailsWithMissingIngredient"
click.delegate="openCocktailDialog($event, cocktail)"
long-click.delegate="openCocktailRowDialog($event, cocktail)"
cocktail.bind="cocktail">
</cocktail-list-item>
</div>
Expand Down
Loading

0 comments on commit 0bda4c7

Please sign in to comment.