sorting and ingredient adding

This commit is contained in:
vabene1111
2020-06-26 15:00:41 +02:00
parent 3d4aebcd9d
commit 642224fec9
3 changed files with 45 additions and 0 deletions

View 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),
),
]

View File

@@ -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)

View File

@@ -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) => {