mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
added ignore duplication option in import again
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<link rel="stylesheet" href="{% static 'css/vue-multiselect.min.css' %}">
|
||||
<style>
|
||||
.tree-anchor {
|
||||
width:90%;
|
||||
width: 90%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -25,40 +25,45 @@
|
||||
<div id="app">
|
||||
<div class="row px-3" style="justify-content:space-between;">
|
||||
<h2> {% trans 'Import' %}</h2>
|
||||
<a class="btn btn-outline-info btn-sm"
|
||||
style="height:50%"
|
||||
href="{% bookmarklet request %}"
|
||||
title="{% trans 'Drag me to your bookmarks to import recipes from anywhere' %}">
|
||||
<img src="{% static 'assets/favicon-16x16.png' %}">{% trans 'Bookmark Me!' %} </a>
|
||||
<a class="btn btn-outline-info btn-sm"
|
||||
style="height:50%"
|
||||
href="{% bookmarklet request %}"
|
||||
title="{% trans 'Drag me to your bookmarks to import recipes from anywhere' %}">
|
||||
<img src="{% static 'assets/favicon-16x16.png' %}">{% trans 'Bookmark Me!' %} </a>
|
||||
</div>
|
||||
<nav class="nav nav-pills flex-sm-row" style="margin-bottom:10px">
|
||||
<a class="nav-link active" href="#nav-url" data-toggle="tab" role="tab" aria-controls="nav-url" aria-selected="true" @click="mode='url'">URL</a>
|
||||
<a class="nav-link" href="#nav-app" data-toggle="tab" role="tab" aria-controls="nav-app" @click="mode='app'">App</a>
|
||||
<a class="nav-link" href="#nav-source" data-toggle="tab" role="tab" aria-controls="nav-source" @click="mode='source'">Source</a>
|
||||
<a class="nav-link disabled" href="#nav-text" data-toggle="tab" role="tab" aria-controls="nav-text" @click="mode='text'">Text</a>
|
||||
<a class="nav-link disabled" href="#nav-file" data-toggle="tab" role="tab" aria-controls="nav-file" @click="mode='file'">File</a>
|
||||
<a class="nav-link active" href="#nav-url" data-toggle="tab" role="tab" aria-controls="nav-url"
|
||||
aria-selected="true" @click="mode='url'">URL</a>
|
||||
<a class="nav-link" href="#nav-app" data-toggle="tab" role="tab" aria-controls="nav-app"
|
||||
@click="mode='app'">App</a>
|
||||
<a class="nav-link" href="#nav-source" data-toggle="tab" role="tab" aria-controls="nav-source"
|
||||
@click="mode='source'">Source</a>
|
||||
<a class="nav-link disabled" href="#nav-text" data-toggle="tab" role="tab" aria-controls="nav-text"
|
||||
@click="mode='text'">Text</a>
|
||||
<a class="nav-link disabled" href="#nav-file" data-toggle="tab" role="tab" aria-controls="nav-file"
|
||||
@click="mode='file'">File</a>
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="tab-content" id="nav-tabContent">
|
||||
<!-- Import URL -->
|
||||
<div class="tab-pane fade show active" id="nav-url" role="tabpanel">
|
||||
<div class="btn-group btn-group-toggle" data-toggle="buttons">
|
||||
<label class="btn btn-outline-info btn-sm active" @click="automatic=true">
|
||||
<input type="radio" autocomplete="off" checked> Automatic
|
||||
<input type="radio" autocomplete="off" checked> Automatic
|
||||
</label>
|
||||
|
||||
<label class="btn btn-outline-info btn-sm" @click="automatic=false">
|
||||
<input type="radio" autocomplete="off"> Manual
|
||||
<input type="radio" autocomplete="off"> Manual
|
||||
</label>
|
||||
</div>
|
||||
<div class="input-group my-2">
|
||||
<input class="form-control" v-model="remote_url" placeholder="{% trans 'Enter website URL' %}">
|
||||
<div class="input-group-append">
|
||||
<button @click="loadRecipe()" class="btn btn-primary shadow-none" type="button"
|
||||
id="id_btn_search"><i class="fas fa-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
<input class="form-control" v-model="remote_url" placeholder="{% trans 'Enter website URL' %}">
|
||||
<div class="input-group-append">
|
||||
<button @click="loadRecipe()" class="btn btn-primary shadow-none" type="button"
|
||||
id="id_btn_search"><i class="fas fa-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -66,56 +71,61 @@
|
||||
<div class=" tab-pane fade show" id="nav-app" role="tabpanel">
|
||||
<div class="btn-group btn-group-toggle" data-toggle="buttons">
|
||||
<label class="btn btn-outline-info btn-sm active" @click="recipe_app='DEFAULT'">
|
||||
<input type="radio" autocomplete="off" checked> Tandoor
|
||||
<input type="radio" autocomplete="off" checked> Tandoor
|
||||
</label>
|
||||
<label class="btn btn-outline-info btn-sm" @click="recipe_app='PAPRIKA'">
|
||||
<input type="radio" autocomplete="off"> Paprika
|
||||
<input type="radio" autocomplete="off"> Paprika
|
||||
</label>
|
||||
<label class="btn btn-outline-info btn-sm" @click="recipe_app='NEXTCLOUD'">
|
||||
<input type="radio" autocomplete="off"> Nextcloud Cookbook
|
||||
<input type="radio" autocomplete="off"> Nextcloud Cookbook
|
||||
</label>
|
||||
<label class="btn btn-outline-info btn-sm" @click="recipe_app='MEALIE'">
|
||||
<input type="radio" autocomplete="off"> Mealie
|
||||
<input type="radio" autocomplete="off"> Mealie
|
||||
</label>
|
||||
<label class="btn btn-outline-info btn-sm" @click="recipe_app='CHOWDOWN'">
|
||||
<input type="radio" autocomplete="off"> Chowdown
|
||||
<input type="radio" autocomplete="off"> Chowdown
|
||||
</label>
|
||||
<label class="btn btn-outline-info btn-sm" @click="recipe_app='SAFRON'">
|
||||
<input type="radio" autocomplete="off"> Safron
|
||||
<input type="radio" autocomplete="off"> Safron
|
||||
</label>
|
||||
<label class="btn btn-outline-info btn-sm" @click="recipe_app='CHEFTAP'">
|
||||
<input type="radio" autocomplete="off"> Cheftap
|
||||
<input type="radio" autocomplete="off"> Cheftap
|
||||
</label>
|
||||
<label class="btn btn-outline-info btn-sm" @click="recipe_app='PEPPERPLATE'">
|
||||
<input type="radio" autocomplete="off"> Pepperplate
|
||||
<input type="radio" autocomplete="off"> Pepperplate
|
||||
</label>
|
||||
<label class="btn btn-outline-info btn-sm" @click="recipe_app='RECIPESAGE'">
|
||||
<input type="radio" autocomplete="off"> Recipesage
|
||||
<input type="radio" autocomplete="off"> Recipesage
|
||||
</label>
|
||||
<label class="btn btn-outline-info btn-sm" @click="recipe_app='DOMESTICA'">
|
||||
<input type="radio" autocomplete="off"> Domestica
|
||||
<input type="radio" autocomplete="off"> Domestica
|
||||
</label>
|
||||
<label class="btn btn-outline-info btn-sm" @click="recipe_app='MEALMASTER'">
|
||||
<input type="radio" autocomplete="off"> Mealmaster
|
||||
<input type="radio" autocomplete="off"> Mealmaster
|
||||
</label>
|
||||
<label class="btn btn-outline-info btn-sm" @click="recipe_app='REZKONV'">
|
||||
<input type="radio" autocomplete="off"> Rezkonv
|
||||
<input type="radio" autocomplete="off"> Rezkonv
|
||||
</label>
|
||||
<label class="btn btn-outline-info btn-sm" @click="recipe_app='RECETTETEK'">
|
||||
<input type="radio" autocomplete="off"> RecetteTek
|
||||
<input type="radio" autocomplete="off"> RecetteTek
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
<b-form-checkbox v-model="import_duplicates" name="check-button" switch style="margin-top: 1vh">
|
||||
{% trans 'To prevent duplicates recipes with the same name as existing ones are ignored. Check this box to import everything.' %}
|
||||
</b-form-checkbox>
|
||||
|
||||
<b-form-file
|
||||
class="my-2"
|
||||
accept=".zip"
|
||||
multiple
|
||||
v-model="recipe_files"
|
||||
placeholder="{% trans 'Select recipe files to import or drop them here...' %}"
|
||||
drop-placeholder="Drop recipe files here...">
|
||||
class="my-2"
|
||||
accept=".zip"
|
||||
multiple
|
||||
v-model="recipe_files"
|
||||
placeholder="{% trans 'Select recipe files to import or drop them here...' %}"
|
||||
drop-placeholder="Drop recipe files here...">
|
||||
</b-form-file>
|
||||
<button @click="importAppRecipe()" class="btn btn-primary shadow-none" type="button"
|
||||
id="id_btn_app"><i class="fas fa-file-archive"></i> {% trans 'Import' %}
|
||||
id="id_btn_app"><i class="fas fa-file-archive"></i> {% trans 'Import' %}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -123,36 +133,38 @@
|
||||
<div class=" tab-pane fade show" id="nav-source" role="tabpanel">
|
||||
<div class="btn-group btn-group-toggle" data-toggle="buttons">
|
||||
<label class="btn btn-outline-info btn-sm active" @click="automatic=true">
|
||||
<input type="radio" autocomplete="off" checked> Automatic
|
||||
<input type="radio" autocomplete="off" checked> Automatic
|
||||
</label>
|
||||
|
||||
<label class="btn btn-outline-info btn-sm" @click="automatic=false">
|
||||
<input type="radio" autocomplete="off"> Manual
|
||||
<input type="radio" autocomplete="off"> Manual
|
||||
</label>
|
||||
</div>
|
||||
<div class="input-group my-2">
|
||||
<textarea class="form-control input-group-append" v-model="source_data" rows=10 placeholder="{% trans 'Paste json or html source here to load recipe.' %}" style="font-size: 12px">
|
||||
<textarea class="form-control input-group-append" v-model="source_data" rows=10
|
||||
placeholder="{% trans 'Paste json or html source here to load recipe.' %}"
|
||||
style="font-size: 12px">
|
||||
</textarea>
|
||||
</div>
|
||||
<button @click="loadRecipe()" class="btn btn-primary shadow-none" type="button"
|
||||
id="id_btn_app"><i class="fas fa-code"></i> {% trans 'Import' %}
|
||||
id="id_btn_app"><i class="fas fa-code"></i> {% trans 'Import' %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
<div v-if="loading" class="text-center">
|
||||
<br/>
|
||||
<i class="fas fa-spinner fa-spin fa-8x"></i>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- recipe preview before Import -->
|
||||
<div class="container-fluid" v-if="preview" id="manage_tree">
|
||||
<div class="row">
|
||||
<div class="col" style="max-width:50%">
|
||||
<!-- start of preview card -->
|
||||
<div class="card card-border-primary" >
|
||||
<div class="card card-border-primary">
|
||||
<div class="card-header">
|
||||
<h3>{% trans 'Preview Recipe Data' %}</h3>
|
||||
<div class='small text-muted'>{% trans 'Drag recipe attributes from the right into the appropriate box below.' %} </div>
|
||||
@@ -163,12 +175,14 @@
|
||||
<div class="card-header" v-b-toggle.collapse-name>
|
||||
<div class="row px-3" style="justify-content:space-between;">
|
||||
{% trans 'Name' %}
|
||||
<i class="fas fa-eraser" style="cursor:pointer;" @click="recipe_json.name=''" title="{% trans 'Clear Contents'%}"></i>
|
||||
<i class="fas fa-eraser" style="cursor:pointer;" @click="recipe_json.name=''"
|
||||
title="{% trans 'Clear Contents' %}"></i>
|
||||
</div>
|
||||
<div class="small text-muted">{% trans 'Text dragged here will be appended to the name.'%}</div>
|
||||
<div class="small text-muted">{% trans 'Text dragged here will be appended to the name.' %}</div>
|
||||
</div>
|
||||
<b-collapse id="collapse-name" visible class="mt-2">
|
||||
<div class="card-body drop-zone" @drop="replacePreview('name', $event)" @dragover.prevent @dragenter.prevent>
|
||||
<div class="card-body drop-zone" @drop="replacePreview('name', $event)"
|
||||
@dragover.prevent @dragenter.prevent>
|
||||
<div class="card-text">[[recipe_json.name]]</div>
|
||||
</div>
|
||||
</b-collapse>
|
||||
@@ -178,12 +192,14 @@
|
||||
<div class="card-header" v-b-toggle.collapse-description>
|
||||
<div class="row px-3" style="justify-content:space-between;">
|
||||
{% trans 'Description' %}
|
||||
<i class="fas fa-eraser" style="cursor:pointer;" @click="recipe_json.description=''" title="{% trans 'Clear Contents'%}"></i>
|
||||
<i class="fas fa-eraser" style="cursor:pointer;"
|
||||
@click="recipe_json.description=''" title="{% trans 'Clear Contents' %}"></i>
|
||||
</div>
|
||||
<div class="small text-muted">{% trans 'Text dragged here will be appended to the description.'%}</div>
|
||||
<div class="small text-muted">{% trans 'Text dragged here will be appended to the description.' %}</div>
|
||||
</div>
|
||||
<b-collapse id="collapse-description" visible class="mt-2">
|
||||
<div class="card-body drop-zone" @drop="replacePreview('description', $event)" @dragover.prevent @dragenter.prevent>
|
||||
<div class="card-body drop-zone" @drop="replacePreview('description', $event)"
|
||||
@dragover.prevent @dragenter.prevent>
|
||||
<div class="card-text">[[recipe_json.description]]</div>
|
||||
</div>
|
||||
</b-collapse>
|
||||
@@ -193,61 +209,78 @@
|
||||
<div class="card-header" v-b-toggle.collapse-kw>
|
||||
<div class="row px-3" style="justify-content:space-between;">
|
||||
{% trans 'Keywords' %}
|
||||
<i class="fas fa-eraser" style="cursor:pointer;" @click="recipe_json.keywords=[]" title="{% trans 'Clear Contents'%}"></i>
|
||||
<i class="fas fa-eraser" style="cursor:pointer;"
|
||||
@click="recipe_json.keywords=[]" title="{% trans 'Clear Contents' %}"></i>
|
||||
</div>
|
||||
<div class="small text-muted">{% trans 'Keywords dragged here will be appended to current list'%}</div>
|
||||
<div class="small text-muted">{% trans 'Keywords dragged here will be appended to current list' %}</div>
|
||||
</div>
|
||||
<b-collapse id="collapse-kw" visible class="mt-2">
|
||||
<div class="card-body drop-zone" @drop="replacePreview('keywords', $event)" @dragover.prevent @dragenter.prevent>
|
||||
<div class="card-body drop-zone" @drop="replacePreview('keywords', $event)"
|
||||
@dragover.prevent @dragenter.prevent>
|
||||
<div v-for="kw in recipe_json.keywords">
|
||||
<div class="card-text">[[kw.text]] </div>
|
||||
<div class="card-text">[[kw.text]]</div>
|
||||
</div>
|
||||
</div>
|
||||
</b-collapse>
|
||||
</div>
|
||||
|
||||
<div class="card mb-2">
|
||||
<div class="card-header" v-b-toggle.collapse-image style="display:flex; justify-content:space-between;">
|
||||
<div class="card-header" v-b-toggle.collapse-image
|
||||
style="display:flex; justify-content:space-between;">
|
||||
{% trans 'Image' %}
|
||||
<i class="fas fa-eraser" style="cursor:pointer;" @click="recipe_json.image=''" title="{% trans 'Clear Contents'%}"></i>
|
||||
<i class="fas fa-eraser" style="cursor:pointer;" @click="recipe_json.image=''"
|
||||
title="{% trans 'Clear Contents' %}"></i>
|
||||
</div>
|
||||
<b-collapse id="collapse-image" visible class="mt-2">
|
||||
<div class="card-body m-0 p-0 drop-zone" @drop="replacePreview('image', $event)" @dragover.prevent @dragenter.prevent>
|
||||
<div class="card-body m-0 p-0 drop-zone" @drop="replacePreview('image', $event)"
|
||||
@dragover.prevent @dragenter.prevent>
|
||||
<img class="card-img" v-bind:src="[[recipe_json.image]]" alt="Recipe Image">
|
||||
</div>
|
||||
</b-collapse>
|
||||
</div>
|
||||
|
||||
<div class = "row mb-2">
|
||||
<div class="row mb-2">
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<div class="card-header p-1" style="display:flex; justify-content:space-between;">
|
||||
<div class="card-header p-1"
|
||||
style="display:flex; justify-content:space-between;">
|
||||
{% trans 'Servings' %}
|
||||
<i class="fas fa-eraser" style="cursor:pointer;" @click="recipe_json.servings=''" title="{% trans 'Clear Contents'%}"></i>
|
||||
<i class="fas fa-eraser" style="cursor:pointer;"
|
||||
@click="recipe_json.servings=''"
|
||||
title="{% trans 'Clear Contents' %}"></i>
|
||||
</div>
|
||||
<div class="card-body p-2 drop-zone" @drop="replacePreview('servings', $event)" @dragover.prevent @dragenter.prevent>
|
||||
<div class="card-body p-2 drop-zone" @drop="replacePreview('servings', $event)"
|
||||
@dragover.prevent @dragenter.prevent>
|
||||
<div class="card-text">[[recipe_json.servings]]</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<div class="card-header p-1" style="display:flex; justify-content:space-between;">
|
||||
<div class="card-header p-1"
|
||||
style="display:flex; justify-content:space-between;">
|
||||
{% trans 'Prep Time' %}
|
||||
<i class="fas fa-eraser" style="cursor:pointer;" @click="recipe_json.prepTime=''" title="{% trans 'Clear Contents'%}"></i>
|
||||
<i class="fas fa-eraser" style="cursor:pointer;"
|
||||
@click="recipe_json.prepTime=''"
|
||||
title="{% trans 'Clear Contents' %}"></i>
|
||||
</div>
|
||||
<div class="card-body p-2 drop-zone" @drop="replacePreview('prepTime', $event)" @dragover.prevent @dragenter.prevent>
|
||||
<div class="card-body p-2 drop-zone" @drop="replacePreview('prepTime', $event)"
|
||||
@dragover.prevent @dragenter.prevent>
|
||||
<div class="card-text">[[recipe_json.prepTime]]</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<div class="card-header p-1" style="display:flex; justify-content:space-between;">
|
||||
<div class="card-header p-1"
|
||||
style="display:flex; justify-content:space-between;">
|
||||
{% trans 'Cook Time' %}
|
||||
<i class="fas fa-eraser" style="cursor:pointer;" @click="recipe_json.cookTime=''" title="{% trans 'Clear Contents'%}"></i>
|
||||
<i class="fas fa-eraser" style="cursor:pointer;"
|
||||
@click="recipe_json.cookTime=''"
|
||||
title="{% trans 'Clear Contents' %}"></i>
|
||||
</div>
|
||||
<div class="card-body p-2 drop-zone" @drop="replacePreview('cookTime', $event)" @dragover.prevent @dragenter.prevent>
|
||||
<div class="card-body p-2 drop-zone" @drop="replacePreview('cookTime', $event)"
|
||||
@dragover.prevent @dragenter.prevent>
|
||||
<div class="card-text">[[recipe_json.cookTime]]</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -258,15 +291,18 @@
|
||||
<div class="card-header" v-b-toggle.collapse-ing>
|
||||
<div class="row px-3" style="display:flex; justify-content:space-between;">
|
||||
{% trans 'Ingredients' %}
|
||||
<i class="fas fa-eraser" style="cursor:pointer;" @click="recipe_json.recipeIngredient=[]" title="{% trans 'Clear Contents'%}"></i>
|
||||
<i class="fas fa-eraser" style="cursor:pointer;"
|
||||
@click="recipe_json.recipeIngredient=[]"
|
||||
title="{% trans 'Clear Contents' %}"></i>
|
||||
</div>
|
||||
<div class="small text-muted">{% trans 'Ingredients dragged here will be appended to current list.'%}</div>
|
||||
<div class="small text-muted">{% trans 'Ingredients dragged here will be appended to current list.' %}</div>
|
||||
</div>
|
||||
<b-collapse id="collapse-ing" visible class="mt-2">
|
||||
<div class="card-body drop-zone" @drop="replacePreview('ingredients', $event)" @dragover.prevent @dragenter.prevent>
|
||||
<div class="card-body drop-zone" @drop="replacePreview('ingredients', $event)"
|
||||
@dragover.prevent @dragenter.prevent>
|
||||
<ul class="list-group list-group">
|
||||
<div v-for="i in recipe_json.recipeIngredient">
|
||||
<li class="row border-light" >
|
||||
<li class="row border-light">
|
||||
<div class="col-sm-1 border">[[i.amount]]</div>
|
||||
<div class="col-sm border">[[i.unit.text]]</div>
|
||||
<div class="col-sm border">[[i.ingredient.text]]</div>
|
||||
@@ -280,14 +316,17 @@
|
||||
|
||||
<div class="card mb-2">
|
||||
<div class="card-header" v-b-toggle.collapse-instructions>
|
||||
<div class="row px-3" style="justify-content:space-between;">
|
||||
<div class="row px-3" style="justify-content:space-between;">
|
||||
{% trans 'Instructions' %}
|
||||
<i class="fas fa-eraser" style="cursor:pointer;" @click="recipe_json.recipeInstructions=''" title="{% trans 'Clear Contents'%}"></i>
|
||||
<i class="fas fa-eraser" style="cursor:pointer;"
|
||||
@click="recipe_json.recipeInstructions=''"
|
||||
title="{% trans 'Clear Contents' %}"></i>
|
||||
</div>
|
||||
<div class="small text-muted">{% trans 'Recipe instructions dragged here will be appended to current instructions.'%}</div>
|
||||
<div class="small text-muted">{% trans 'Recipe instructions dragged here will be appended to current instructions.' %}</div>
|
||||
</div>
|
||||
<b-collapse id="collapse-instructions" visible class="mt-2">
|
||||
<div class="card-body drop-zone" @drop="replacePreview('instructions', $event)" @dragover.prevent @dragenter.prevent>
|
||||
<div class="card-body drop-zone" @drop="replacePreview('instructions', $event)"
|
||||
@dragover.prevent @dragenter.prevent>
|
||||
<div class="card-text">[[recipe_json.recipeInstructions]]</div>
|
||||
</div>
|
||||
</b-collapse>
|
||||
@@ -296,11 +335,12 @@
|
||||
</div>
|
||||
<br/>
|
||||
<!-- end of preview card -->
|
||||
<button @click="showRecipe()" class="btn btn-primary shadow-none" type="button" style="margin-bottom: 2vh"
|
||||
id="id_btn_json"><i class="fas fa-code"></i> {% trans 'Import' %}
|
||||
<button @click="showRecipe()" class="btn btn-primary shadow-none" type="button"
|
||||
style="margin-bottom: 2vh"
|
||||
id="id_btn_json"><i class="fas fa-code"></i> {% trans 'Import' %}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- start of source data -->
|
||||
<div class="col" style="max-width:50%;">
|
||||
<div class="card card-border-primary sticky-top" style="z-index: 100;">
|
||||
@@ -312,55 +352,58 @@
|
||||
</div>
|
||||
<div class="btn-group btn-group-toggle" data-toggle="buttons">
|
||||
<label class="btn btn-outline-info btn-sm active" @click="preview_type='json'">
|
||||
<input type="radio" autocomplete="off" checked> json
|
||||
<input type="radio" autocomplete="off" checked> json
|
||||
</label>
|
||||
<label class="btn btn-outline-info btn-sm" @click="preview_type='html'">
|
||||
<input type="radio" autocomplete="off"> html
|
||||
<input type="radio" autocomplete="off"> html
|
||||
</label>
|
||||
<label class="btn btn-outline-info btn-sm" @click="preview_type='image'">
|
||||
<input type="radio" autocomplete="off"> images
|
||||
<input type="radio" autocomplete="off"> images
|
||||
</label>
|
||||
</div>
|
||||
<i :class="[show_blank ? 'fa-chevron-up' : 'fa-chevron-down', 'fas']"
|
||||
style="cursor:pointer;"
|
||||
@click="show_blank=!show_blank"
|
||||
title="{% trans 'Show Blank Field' %}"></i>
|
||||
style="cursor:pointer;"
|
||||
@click="show_blank=!show_blank"
|
||||
title="{% trans 'Show Blank Field' %}"></i>
|
||||
<div class="card-body p-1">
|
||||
<div class="card card-border-primary" v-if="show_blank">
|
||||
<div class="card-header">
|
||||
<div class="row px-3" style="justify-content:space-between;">
|
||||
{% trans 'Blank Field' %}
|
||||
<i class="fas fa-eraser justify-content-end" style="cursor:pointer;" @click="blank_field=''" title="{% trans 'Clear Contents'%}"></i>
|
||||
<i class="fas fa-eraser justify-content-end" style="cursor:pointer;"
|
||||
@click="blank_field=''" title="{% trans 'Clear Contents' %}"></i>
|
||||
</div>
|
||||
<div class="small text-muted">{% trans 'Items dragged to Blank Field will be appended.'%}</div>
|
||||
<div class="small text-muted">{% trans 'Items dragged to Blank Field will be appended.' %}</div>
|
||||
</div>
|
||||
<div class="card-body drop-zone"
|
||||
@drop="replacePreview('blank', $event)"
|
||||
@dragover.prevent
|
||||
@dragenter.prevent
|
||||
draggable
|
||||
@dragstart="htmlDragStart($event)">
|
||||
@drop="replacePreview('blank', $event)"
|
||||
@dragover.prevent
|
||||
@dragenter.prevent
|
||||
draggable
|
||||
@dragstart="htmlDragStart($event)">
|
||||
[[blank_field]]
|
||||
</div>
|
||||
</div>
|
||||
<!-- start of json data -->
|
||||
<v-jstree v-if="preview_type=='json'" :data="recipe_tree"
|
||||
text-field-name="name"
|
||||
collapse:true
|
||||
draggable
|
||||
@item-drag-start="itemDragStart"
|
||||
@item-click="itemClick">
|
||||
text-field-name="name"
|
||||
collapse:true
|
||||
draggable
|
||||
@item-drag-start="itemDragStart"
|
||||
@item-click="itemClick">
|
||||
<template scope="_">
|
||||
<div class="col" @click.ctrl="customItemClickWithCtrl">
|
||||
<div class="row clearfix" style="width:100%" >
|
||||
<div class="col" @click.ctrl="customItemClickWithCtrl">
|
||||
<div class="row clearfix" style="width:100%">
|
||||
<div class="col-es" style="align-right">
|
||||
<button style="border: 0px; background-color: transparent; cursor: pointer;"
|
||||
@click="deleteNode(_.vm, _.model, $event)"><i class="fas fa-minus-square" style="color:red"></i></button>
|
||||
@click="deleteNode(_.vm, _.model, $event)"><i
|
||||
class="fas fa-minus-square" style="color:red"></i></button>
|
||||
</div>
|
||||
<div class="col overflow-hidden">
|
||||
<i :class="_.vm.themeIconClasses" role="presentation" v-if="!_.model.loading"></i>
|
||||
<i :class="_.vm.themeIconClasses" role="presentation"
|
||||
v-if="!_.model.loading"></i>
|
||||
{% verbatim %}
|
||||
[[_.model.name]]
|
||||
[[_.model.name]]
|
||||
{% endverbatim %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -371,25 +414,27 @@
|
||||
<!-- start of html data -->
|
||||
<div v-if="preview_type=='html'">
|
||||
<ul class="list-group list-group-flush" v-for="(txt, key) in recipe_html">
|
||||
<div class="list-group-item bg-light m-0 small"
|
||||
draggable
|
||||
@dragstart="htmlDragStart($event)"
|
||||
style="display:flex; justify-content:space-between;">
|
||||
<div class="list-group-item bg-light m-0 small"
|
||||
draggable
|
||||
@dragstart="htmlDragStart($event)"
|
||||
style="display:flex; justify-content:space-between;">
|
||||
[[txt]]
|
||||
<i class="fas fa-minus-square" style="cursor:pointer; color:red" @click="$delete(recipe_html, key)" title="{% trans 'Delete Text'%}"></i>
|
||||
</div>
|
||||
<i class="fas fa-minus-square" style="cursor:pointer; color:red"
|
||||
@click="$delete(recipe_html, key)" title="{% trans 'Delete Text' %}"></i>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- start of images -->
|
||||
<div v-if="preview_type=='image'">
|
||||
<ul class="list-group list-group-flush" v-for="(img, key) in images">
|
||||
<div class="list-group-item bg-light m-0 small"
|
||||
draggable
|
||||
@dragstart="imageDragStart($event)"
|
||||
style="display:flex; justify-content:space-between;">
|
||||
<div class="list-group-item bg-light m-0 small"
|
||||
draggable
|
||||
@dragstart="imageDragStart($event)"
|
||||
style="display:flex; justify-content:space-between;">
|
||||
<img class="card-img" v-bind:src=[[img]] alt="Image">
|
||||
<i class="fas fa-minus-square" style="cursor:pointer; color:red" @click="$delete(images, key)" title="{% trans 'Delete image'%}"></i>
|
||||
</div>
|
||||
<i class="fas fa-minus-square" style="cursor:pointer; color:red"
|
||||
@click="$delete(images, key)" title="{% trans 'Delete image' %}"></i>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -409,7 +454,8 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="id_description">{% trans 'Recipe Description' %}</label>
|
||||
<textarea id="id_description" class="form-control" rows="3" v-model="recipe_data.description"></textarea>
|
||||
<textarea id="id_description" class="form-control" rows="3"
|
||||
v-model="recipe_data.description"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
@@ -660,6 +706,7 @@
|
||||
show_blank: false,
|
||||
blank_field: '',
|
||||
recipe_app: 'DEFAULT',
|
||||
import_duplicates: false,
|
||||
recipe_files: [],
|
||||
images: [],
|
||||
mode: 'url'
|
||||
@@ -675,7 +722,7 @@
|
||||
this.searchKeywords('')
|
||||
this.searchUnits('')
|
||||
this.searchIngredients('')
|
||||
let uri = window.location.search.substring(1);
|
||||
let uri = window.location.search.substring(1);
|
||||
let params = new URLSearchParams(uri);
|
||||
q = params.get("id")
|
||||
if (q) {
|
||||
@@ -701,10 +748,11 @@
|
||||
this.loading = true
|
||||
this.preview = false
|
||||
this.$http.post("{% url 'api_recipe_from_source' %}", {
|
||||
'url': this.remote_url,
|
||||
'data': this.source_data,
|
||||
'auto':this.automatic,
|
||||
'mode':this.mode}, {emulateJSON: true}).then((response) => {
|
||||
'url': this.remote_url,
|
||||
'data': this.source_data,
|
||||
'auto': this.automatic,
|
||||
'mode': this.mode
|
||||
}, {emulateJSON: true}).then((response) => {
|
||||
this.recipe_json = response.data['recipe_json'];
|
||||
this.recipe_tree = response.data['recipe_tree'];
|
||||
this.recipe_html = response.data['recipe_html'];
|
||||
@@ -730,7 +778,7 @@
|
||||
this.makeToast(gettext('Error'), msg, 'danger')
|
||||
})
|
||||
},
|
||||
loadBookmarklet: function(id_bkmk) {
|
||||
loadBookmarklet: function (id_bkmk) {
|
||||
this.error = undefined
|
||||
this.loading = true
|
||||
this.$http.get("{% url 'api:bookmarkletimport-detail' 1237654 %}".replace('1237654', id_bkmk)).then((response) => {
|
||||
@@ -745,16 +793,16 @@
|
||||
this.makeToast(gettext('Error'), gettext('There was an error loading bookmarklet!') + err.bodyText, 'danger')
|
||||
})
|
||||
},
|
||||
deleteBookmarklet: function(id_bkmk) {
|
||||
deleteBookmarklet: function (id_bkmk) {
|
||||
this.error = undefined
|
||||
this.$http.delete("{% url 'api:bookmarkletimport-list' %}" + id_bkmk +"/").then((response) => {
|
||||
this.$http.delete("{% url 'api:bookmarkletimport-list' %}" + id_bkmk + "/").then((response) => {
|
||||
}).catch((err) => {
|
||||
this.error = err.data
|
||||
console.log(err)
|
||||
this.makeToast(gettext('Error'), gettext('There was an error deleting bookmarklet!') + err.bodyText, 'danger')
|
||||
})
|
||||
},
|
||||
showRecipe: function() {
|
||||
showRecipe: function () {
|
||||
this.preview = false
|
||||
this.recipe_data = this.recipe_json
|
||||
},
|
||||
@@ -774,7 +822,7 @@
|
||||
this.importing_recipe = true
|
||||
this.$set(this.recipe_data, 'all_keywords', this.all_keywords)
|
||||
this.$http.post(`{% url 'data_import_url' %}`, this.recipe_data).then((response) => {
|
||||
let uri = window.location.search.substring(1);
|
||||
let uri = window.location.search.substring(1);
|
||||
let params = new URLSearchParams(uri);
|
||||
q = params.get("id")
|
||||
if (q) {
|
||||
@@ -787,16 +835,17 @@
|
||||
this.makeToast(gettext('Error'), gettext('An error occurred while trying to import this recipe!') + err.bodyText, 'danger')
|
||||
})
|
||||
},
|
||||
importAppRecipe: function() {
|
||||
importAppRecipe: function () {
|
||||
this.error = undefined
|
||||
this.preview = false
|
||||
this.loading = true
|
||||
let formData = new FormData();
|
||||
let files = []
|
||||
formData.append('type', this.recipe_app);
|
||||
for( var i = 0; i < this.recipe_files.length; i++ ){
|
||||
formData.append('duplicates', this.import_duplicates)
|
||||
for (var i = 0; i < this.recipe_files.length; i++) {
|
||||
formData.append('files', this.recipe_files[i]);
|
||||
}
|
||||
}
|
||||
this.$http.post("{% url 'view_import' %}", formData, {headers: {'Content-Type': 'multipart/form-data'}}).then((response) => {
|
||||
window.location.href = "{% url 'view_import_response' 1237654 %}".replace('1237654', response.data['import_id'])
|
||||
}).catch((err) => {
|
||||
@@ -891,7 +940,7 @@
|
||||
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger')
|
||||
})
|
||||
},
|
||||
deleteNode: function (node ,item, e) {
|
||||
deleteNode: function (node, item, e) {
|
||||
e.stopPropagation()
|
||||
var index = node.parentItem.indexOf(item)
|
||||
node.parentItem.splice(index, 1)
|
||||
@@ -899,12 +948,12 @@
|
||||
itemClick: function (node, item, e) {
|
||||
this.makeToast(gettext('Details'), node.model.value, 'info')
|
||||
},
|
||||
itemDragStart (node,item,e) {
|
||||
itemDragStart(node, item, e) {
|
||||
if (node.model.children.length > 0) {
|
||||
e.dataTransfer.setData('hasChildren', true)
|
||||
}
|
||||
e.dataTransfer.setData('value', node.model.value)
|
||||
|
||||
|
||||
},
|
||||
htmlDragStart: function (e) {
|
||||
e.dataTransfer.setData('value', e.target.innerText)
|
||||
@@ -912,10 +961,10 @@
|
||||
imageDragStart: function (e) {
|
||||
e.dataTransfer.setData('value', e.target.src)
|
||||
},
|
||||
replacePreview: function(field, e) {
|
||||
replacePreview: function (field, e) {
|
||||
v = e.dataTransfer.getData('value')
|
||||
if (e.dataTransfer.getData('hasChildren')) {
|
||||
this.makeToast(gettext('Error'), gettext('Items with children cannot be dropped here!') , 'danger')
|
||||
this.makeToast(gettext('Error'), gettext('Items with children cannot be dropped here!'), 'danger')
|
||||
return
|
||||
}
|
||||
switch (field) {
|
||||
@@ -926,31 +975,31 @@
|
||||
this.recipe_json.description = [this.recipe_json.description, v].filter(Boolean).join(" ");
|
||||
break;
|
||||
case 'image':
|
||||
this.recipe_json.image=v
|
||||
this.recipe_json.image = v
|
||||
break;
|
||||
case 'keywords':
|
||||
let new_keyword = {'text': v, 'id': null}
|
||||
this.recipe_json.keywords.push(new_keyword)
|
||||
break;
|
||||
case 'servings':
|
||||
this.recipe_json.servings=parseInt(v.match(/\b\d+\b/)[0])
|
||||
this.recipe_json.servings = parseInt(v.match(/\b\d+\b/)[0])
|
||||
break;
|
||||
case 'prepTime':
|
||||
this.recipe_json.prepTime=v
|
||||
this.recipe_json.prepTime = v
|
||||
break;
|
||||
case 'cookTime':
|
||||
this.recipe_json.cookTime=v
|
||||
this.recipe_json.cookTime = v
|
||||
break;
|
||||
case 'ingredients':
|
||||
this.$http.post('{% url 'api_ingredient_from_string' %}', {text: v}, {emulateJSON: true}).then((response) => {
|
||||
let new_ingredient={
|
||||
unit: {id: Math.random() * 1000, text: response.body.unit},
|
||||
amount: String(response.body.amount),
|
||||
ingredient: {id: Math.random() * 1000, text: response.body.food},
|
||||
note: response.body.note,
|
||||
original: v
|
||||
}
|
||||
this.recipe_json.recipeIngredient.push(new_ingredient)
|
||||
let new_ingredient = {
|
||||
unit: {id: Math.random() * 1000, text: response.body.unit},
|
||||
amount: String(response.body.amount),
|
||||
ingredient: {id: Math.random() * 1000, text: response.body.food},
|
||||
note: response.body.note,
|
||||
original: v
|
||||
}
|
||||
this.recipe_json.recipeIngredient.push(new_ingredient)
|
||||
}).catch((err) => {
|
||||
console.log(err)
|
||||
this.makeToast(gettext('Error'), gettext('Something went wrong.'), 'danger')
|
||||
|
||||
Reference in New Issue
Block a user