mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-24 02:39:20 -05:00
sorting and ingredient adding
This commit is contained in:
26
cookbook/migrations/0066_auto_20200626_1455.py
Normal file
26
cookbook/migrations/0066_auto_20200626_1455.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# Generated by Django 3.0.7 on 2020-06-26 12:55
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cookbook', '0065_auto_20200626_1444'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='ingredient',
|
||||
options={'ordering': ['order', 'pk']},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='step',
|
||||
options={'ordering': ['order', 'pk']},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='step',
|
||||
name='name',
|
||||
field=models.CharField(blank=True, default='', max_length=128),
|
||||
),
|
||||
]
|
||||
@@ -162,6 +162,7 @@ class Ingredient(models.Model):
|
||||
class Step(models.Model):
|
||||
TEXT = 'TEXT'
|
||||
|
||||
name = models.CharField(max_length=128, default='', blank=True)
|
||||
kind = models.CharField(choices=((TEXT, _('Text')),), default=TEXT, max_length=16)
|
||||
instruction = models.TextField(blank=True)
|
||||
ingredients = models.ManyToManyField(Ingredient, blank=True)
|
||||
|
||||
@@ -70,6 +70,13 @@
|
||||
<h3>Step</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<label :for="'id_step_' + step.id + 'name'">{% trans 'Step Name' %}</label>
|
||||
<input class="form-control" v-model="step.name" :id="'id_step_' + step.id + 'name'">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<draggable :list="step.ingredients" group="ingredients"
|
||||
@@ -129,6 +136,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</draggable>
|
||||
|
||||
<button class="btn btn-success" @click="addIngredient(step)"><i class="fa fa-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -209,6 +218,15 @@
|
||||
element.order = index
|
||||
});
|
||||
},
|
||||
addIngredient: function (step) { //TODO see if default can be generated from options request
|
||||
step.ingredients.push({
|
||||
'food': undefined,
|
||||
'unit': undefined,
|
||||
'amount': 0,
|
||||
'note': '',
|
||||
})
|
||||
this.sortStep(step)
|
||||
},
|
||||
searchKeywords: function (query) {
|
||||
this.keywords_loading = true
|
||||
this.$http.get("{% url 'api:keyword-list' %}" + '?query=' + query + '&limit=10').then((response) => {
|
||||
|
||||
Reference in New Issue
Block a user