Skip to content

Commit

Permalink
Show base ingredient
Browse files Browse the repository at this point in the history
  • Loading branch information
karlomikus committed Jan 8, 2024
1 parent a2afe14 commit 9c25429
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/components/Cocktail/CocktailForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<div class="drag-handle"></div>
<div class="cocktail-form__ingredients__content">
<div class="form-group">
<label class="form-label">{{ $t('ingredient.title') }}:</label>
<label class="form-label">{{ $t('ingredient.title') }}<template v-if="ing.sort <= 1"> ({{ $t('ingredient.base') }})</template>:</label>
<p>
{{ ing.name }}
<span v-if="ing.note">&middot; {{ ing.note }}</span>
Expand Down Expand Up @@ -246,7 +246,10 @@ export default {
this.sortable = Sortable.create(document.querySelector('.cocktail-form__ingredients'), {
handle: '.drag-handle',
ghostClass: 'block-container--placeholder',
animation: 150
animation: 150,
onEnd: () => {
this.updateSortPosition()
},
})
const state = new AppState()
Expand Down Expand Up @@ -476,6 +479,15 @@ export default {
this.isLoading = false
})
}
},
updateSortPosition() {
const sortedIngredientList = this.sortable.toArray()
this.cocktail.ingredients.map((cIngredient) => {
cIngredient.sort = sortedIngredientList.findIndex(sortedId => sortedId == cIngredient.ingredient_id) + 1
return cIngredient
})
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"new-ingredient-success": "Created uncategorized ingredient \"{name}\".",
"new-ingredient-fail": "Unable to add ingredient.",
"select-substitutes-for": "Select substitute ingredients for \"{name}\"."
}
},
"base": "Base"
},
"share": {
"title": "Share",
Expand Down

0 comments on commit 9c25429

Please sign in to comment.