mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 22:43:34 -07:00
drag and drop ingredients
This commit is contained in:
parent
c8e239bd81
commit
40b78e427d
3 changed files with 58 additions and 30 deletions
|
@ -67,27 +67,43 @@
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col cols="12" sm="12" md="4" lg="4">
|
<v-col cols="12" sm="12" md="4" lg="4">
|
||||||
<h2 class="mb-4">{{ $t("recipe.ingredients") }}</h2>
|
<h2 class="mb-4">{{ $t("recipe.ingredients") }}</h2>
|
||||||
|
<draggable
|
||||||
|
v-model="value.recipeIngredient"
|
||||||
|
@start="drag = true"
|
||||||
|
@end="drag = false"
|
||||||
|
>
|
||||||
|
<transition-group
|
||||||
|
type="transition"
|
||||||
|
:name="!drag ? 'flip-list' : null"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
v-for="(ingredient, index) in value.recipeIngredient"
|
v-for="(ingredient, index) in value.recipeIngredient"
|
||||||
:key="generateKey('ingredient', index)"
|
:key="generateKey('ingredient', index)"
|
||||||
>
|
>
|
||||||
<v-row align="center">
|
<v-row align="center">
|
||||||
<v-btn
|
|
||||||
fab
|
|
||||||
x-small
|
|
||||||
color="white"
|
|
||||||
class="mr-2"
|
|
||||||
elevation="0"
|
|
||||||
@click="removeIngredient(index)"
|
|
||||||
>
|
|
||||||
<v-icon color="error">mdi-delete</v-icon>
|
|
||||||
</v-btn>
|
|
||||||
<v-text-field
|
<v-text-field
|
||||||
|
class="mr-2"
|
||||||
:label="$t('recipe.ingredient')"
|
:label="$t('recipe.ingredient')"
|
||||||
v-model="value.recipeIngredient[index]"
|
v-model="value.recipeIngredient[index]"
|
||||||
></v-text-field>
|
append-outer-icon="mdi-menu"
|
||||||
|
mdi-move-resize
|
||||||
|
solo
|
||||||
|
dense
|
||||||
|
>
|
||||||
|
<v-icon
|
||||||
|
class="mr-n1"
|
||||||
|
slot="prepend"
|
||||||
|
color="error"
|
||||||
|
@click="removeIngredient(index)"
|
||||||
|
>
|
||||||
|
mdi-delete
|
||||||
|
</v-icon>
|
||||||
|
</v-text-field>
|
||||||
</v-row>
|
</v-row>
|
||||||
</div>
|
</div>
|
||||||
|
</transition-group>
|
||||||
|
</draggable>
|
||||||
|
|
||||||
<v-btn color="secondary" fab dark small @click="addIngredient">
|
<v-btn color="secondary" fab dark small @click="addIngredient">
|
||||||
<v-icon>mdi-plus</v-icon>
|
<v-icon>mdi-plus</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
@ -103,6 +119,7 @@
|
||||||
v-model="value.categories"
|
v-model="value.categories"
|
||||||
hide-selected
|
hide-selected
|
||||||
:items="categories"
|
:items="categories"
|
||||||
|
text="name"
|
||||||
:search-input.sync="categoriesSearchInput"
|
:search-input.sync="categoriesSearchInput"
|
||||||
@change="categoriesSearchInput = ''"
|
@change="categoriesSearchInput = ''"
|
||||||
>
|
>
|
||||||
|
@ -232,6 +249,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import draggable from "vuedraggable";
|
||||||
import api from "../../../api";
|
import api from "../../../api";
|
||||||
import utils from "../../../utils";
|
import utils from "../../../utils";
|
||||||
import BulkAdd from "./BulkAdd";
|
import BulkAdd from "./BulkAdd";
|
||||||
|
@ -240,17 +258,21 @@ export default {
|
||||||
components: {
|
components: {
|
||||||
BulkAdd,
|
BulkAdd,
|
||||||
ExtrasEditor,
|
ExtrasEditor,
|
||||||
|
draggable,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
value: Object,
|
value: Object,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
drag: false,
|
||||||
fileObject: null,
|
fileObject: null,
|
||||||
rules: {
|
rules: {
|
||||||
required: v => !!v || this.$i18n.t("recipe.key-name-required"),
|
required: (v) => !!v || this.$i18n.t("recipe.key-name-required"),
|
||||||
whiteSpace: v =>
|
whiteSpace: (v) =>
|
||||||
!v || v.split(" ").length <= 1 || this.$i18n.t("recipe.no-white-space-allowed"),
|
!v ||
|
||||||
|
v.split(" ").length <= 1 ||
|
||||||
|
this.$i18n.t("recipe.no-white-space-allowed"),
|
||||||
},
|
},
|
||||||
categoriesSearchInput: "",
|
categoriesSearchInput: "",
|
||||||
tagsSearchInput: "",
|
tagsSearchInput: "",
|
||||||
|
@ -264,7 +286,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
async getCategories() {
|
async getCategories() {
|
||||||
let response = await api.categories.get_all();
|
let response = await api.categories.get_all();
|
||||||
this.categories = response.data.map((cat) => cat.name);
|
this.categories = response.map((cat) => cat.name);
|
||||||
},
|
},
|
||||||
uploadImage() {
|
uploadImage() {
|
||||||
this.$emit("upload", this.fileObject);
|
this.$emit("upload", this.fileObject);
|
||||||
|
|
|
@ -43,12 +43,12 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
open: {
|
open: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
Confirmation
|
Confirmation,
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -66,8 +66,8 @@ export default {
|
||||||
},
|
},
|
||||||
json() {
|
json() {
|
||||||
this.$emit("json");
|
this.$emit("json");
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
"
|
"
|
||||||
@save="saveRecipe"
|
@save="saveRecipe"
|
||||||
@delete="deleteRecipe"
|
@delete="deleteRecipe"
|
||||||
|
class="sticky"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<RecipeViewer
|
<RecipeViewer
|
||||||
|
@ -144,7 +145,7 @@ export default {
|
||||||
},
|
},
|
||||||
async saveRecipe() {
|
async saveRecipe() {
|
||||||
if (this.$refs.recipeEditor.validateRecipe()) {
|
if (this.$refs.recipeEditor.validateRecipe()) {
|
||||||
console.log("Thank you")
|
console.log("Thank you");
|
||||||
}
|
}
|
||||||
let slug = await api.recipes.update(this.recipeDetails);
|
let slug = await api.recipes.update(this.recipeDetails);
|
||||||
|
|
||||||
|
@ -177,4 +178,9 @@ export default {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
}
|
}
|
||||||
|
.sticky {
|
||||||
|
position: sticky !important;
|
||||||
|
top: 0;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
Loading…
Add table
Add a link
Reference in a new issue