From 3b1a9246fd0905a2598d68fa0e48674f84471dc8 Mon Sep 17 00:00:00 2001 From: Dan Elbert Date: Sun, 1 Apr 2018 22:32:13 -0500 Subject: [PATCH] recipe editing --- LICENSE | 2 +- app/javascript/components/AppAutocomplete.vue | 5 +++++ .../components/RecipeEditIngredientItem.vue | 7 +++++++ app/javascript/components/TheAboutPage.vue | 17 +++++++++++++++++ app/javascript/components/TheRecipe.vue | 4 ++-- app/javascript/components/TheRecipeCreator.vue | 14 ++++++++++++++ app/javascript/lib/Api.js | 13 ++++++++++--- app/javascript/styles/index.scss | 5 +++++ app/models/recipe.rb | 2 +- lib/unit_conversion/parsed_number.rb | 1 + 10 files changed, 63 insertions(+), 7 deletions(-) diff --git a/LICENSE b/LICENSE index 3d88d01..115e637 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 Dan Elbert +Copyright (c) 2018 Dan Elbert Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/app/javascript/components/AppAutocomplete.vue b/app/javascript/components/AppAutocomplete.vue index 25e3b60..7a9919e 100644 --- a/app/javascript/components/AppAutocomplete.vue +++ b/app/javascript/components/AppAutocomplete.vue @@ -11,6 +11,7 @@ :value="rawValue" :class="finalInputClass" + @click="clickHandler" @blur="blurHandler" @input="inputHandler" @keydown="keydownHandler" @@ -129,6 +130,10 @@ this.activeListIndex = idx; }, + clickHandler(evt) { + this.$emit("inputClick", evt); + }, + blurHandler(evt) { // blur fires before click. If the blur was fired because the user clicked a list item, immediately hiding the list here // would prevent the click event from firing diff --git a/app/javascript/components/RecipeEditIngredientItem.vue b/app/javascript/components/RecipeEditIngredientItem.vue index cb7c788..3b04797 100644 --- a/app/javascript/components/RecipeEditIngredientItem.vue +++ b/app/javascript/components/RecipeEditIngredientItem.vue @@ -22,6 +22,7 @@ valueAttribute="name" labelAttribute="name" placeholder="" + @inputClick="nameClick" @optionSelected="searchItemSelected" :onGetOptions="updateSearchItems" > @@ -72,6 +73,12 @@ this.ingredient.ingredient_id = ingredient.id; this.ingredient.ingredient = ingredient; this.ingredient.name = ingredient.name; + }, + + nameClick() { + if (this.ingredient.ingredient_id === null && this.ingredient.name !== null && this.ingredient.name.length > 2) { + this.$refs.autocomplete.updateOptions(this.ingredient.name); + } } }, diff --git a/app/javascript/components/TheAboutPage.vue b/app/javascript/components/TheAboutPage.vue index b49d99e..0488ece 100644 --- a/app/javascript/components/TheAboutPage.vue +++ b/app/javascript/components/TheAboutPage.vue @@ -1,5 +1,22 @@