Merge remote-tracking branch 'upstream/develop' into recipe_description

This commit is contained in:
smilerz
2021-03-18 15:33:50 -05:00
126 changed files with 8261 additions and 5838 deletions

View File

@@ -0,0 +1,34 @@
{% extends "base.html" %}
{% load render_bundle from webpack_loader %}
{% load static %}
{% load i18n %}
{% load l10n %}
{% block title %}{% trans 'Import' %}{% endblock %}
{% block content %}
<div id="app">
<import-response-view></import-response-view>
</div>
{% endblock %}
{% block script %}
<script src="{% url 'javascript-catalog' %}"></script>
{% if debug %}
<script src="{% url 'js_reverse' %}"></script>
{% else %}
<script src="{% static 'django_js_reverse/reverse.js' %}"></script>
{% endif %}
<script type="application/javascript">
window.IMPORT_ID = {{pk}};
</script>
{% render_bundle 'chunk-vendors' %}
{% render_bundle 'import_response_view' %}
{% endblock %}

View File

@@ -2,7 +2,7 @@
{% load static %}
{% load i18n %}
{% block title %}{% trans "Offline" %}{% endblock %}
{% block title %}{% trans "No Permissions" %}{% endblock %}
{% block content %}
@@ -12,7 +12,12 @@
<h1 class="">{% trans 'No Permissions' %}</h1>
<br/>
<span>{% trans 'You do not have any groups and therefor cannot use this application. Please contact your administrator.' %}</span> <br/>
<span>
{% trans 'You do not have any groups and therefor cannot use this application.' %}
{% trans 'Please contact your administrator.' %}
</span>
<br/>
</div>

View File

@@ -0,0 +1,20 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}
{% block title %}{% trans "No Permission" %}{% endblock %}
{% block content %}
<div style="text-align: center">
<h1 class="">{% trans 'No Permission' %}</h1>
<br/>
<span>{% trans 'You do not have the required permissions to view this page or perform this action.' %} {% trans 'Please contact your administrator.' %}</span> <br/>
</div>
{% endblock %}

View File

@@ -0,0 +1,20 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}
{% block title %}{% trans "No Space" %}{% endblock %}
{% block content %}
<div style="text-align: center">
<h1 class="">{% trans 'No Space' %}</h1>
<br/>
<span>{% trans 'You are not a member of any space.' %} {% trans 'Please contact your administrator.' %}</span> <br/>
</div>
{% endblock %}

View File

@@ -122,8 +122,9 @@
</tr>
</thead>
<tbody is="draggable" :list="c.entries" tag="tbody" group="people" @sort="sortEntries"
@change="dragChanged(c, $event)">
<tr v-for="(element, index) in c.entries" :key="element.id">
@change="dragChanged(c, $event)" handle=".handle">
<tr v-for="(element, index) in c.entries" :key="element.id"
v-bind:class="{ 'text-muted': element.checked }">
<td class="handle"><i class="fas fa-sort"></i></td>
<td>[[element.amount]]</td>
<td>[[element.unit.name]]</td>
@@ -154,7 +155,8 @@
<div class="input-group">
<input id="id_simple_entry" class="form-control" v-model="simple_entry">
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button"><i class="fa fa-plus"></i>
<button class="btn btn-outline-secondary" type="button" @click="addSimpleEntry()"><i
class="fa fa-plus"></i>
</button>
</div>
</div>
@@ -349,6 +351,8 @@
</div>
</div>
<br/>
<br/>
<b-modal id="id_modal_export" title="{% trans 'Copy/Export' %}">
<div class="row">
@@ -418,6 +422,8 @@
users_loading: false,
onLine: navigator.onLine,
simple_entry: '',
auto_sync_blocked: false,
auto_sync_running: false,
entry_mode_simple: $cookies.isKey('shopping_entry_mode_simple') ? ($cookies.get('shopping_entry_mode_simple') === 'true') : true,
},
directives: {
@@ -448,7 +454,7 @@
name: gettext('Uncategorized'),
id: -1,
entries: [],
order: 99999999
order: -1
}
}
@@ -557,7 +563,8 @@
{% if request.user.userpreference.shopping_auto_sync > 0 %}
setInterval(() => {
if ((this.shopping_list_id !== null) && !this.edit_mode && window.navigator.onLine) {
if ((this.shopping_list_id !== null) && !this.edit_mode && window.navigator.onLine && !this.auto_sync_blocked && !this.auto_sync_running) {
this.auto_sync_running = true
this.loadShoppingList(true)
}
}, {% widthratio request.user.userpreference.shopping_auto_sync 1 1000 %})
@@ -622,16 +629,19 @@
this.shopping_list = response.body
this.loading = false
} else {
let check_map = {}
for (let e of response.body.entries) {
check_map[e.id] = {checked: e.checked}
}
if (!this.auto_sync_blocked) {
let check_map = {}
for (let e of response.body.entries) {
check_map[e.id] = {checked: e.checked}
}
for (let se of this.shopping_list.entries) {
if (check_map[se.id] !== undefined) {
se.checked = check_map[se.id].checked
for (let se of this.shopping_list.entries) {
if (check_map[se.id] !== undefined) {
se.checked = check_map[se.id].checked
}
}
}
this.auto_sync_running = false
}
if (this.shopping_list.entries.length === 0) {
this.edit_mode = true
@@ -745,18 +755,24 @@
}
},
entryChecked: function (entry) {
this.auto_sync_blocked = true
let updates = []
this.shopping_list.entries.forEach((item) => {
if (entry.entries.includes(item.id)) {
item.checked = entry.checked
this.$http.put("{% url 'api:shoppinglistentry-detail' 123456 %}".replace('123456', item.id), item, {}).then((response) => {
updates.push(this.$http.put("{% url 'api:shoppinglistentry-detail' 123456 %}".replace('123456', item.id), item, {}).then((response) => {
}).catch((err) => {
console.log(err)
this.makeToast(gettext('Error'), gettext('There was an error updating a resource!') + err.bodyText, 'danger')
this.loading = false
})
}))
}
})
Promise.allSettled(updates).then(() => {
this.auto_sync_blocked = false
})
},
addEntry: function () {
if (this.new_entry.food !== undefined) {

File diff suppressed because one or more lines are too long

View File

@@ -22,23 +22,6 @@
<a href="{% url 'list_invite_link' %}" class="btn btn-success">{% trans 'Show Links' %}</a>
</div>
<!--
<div class="col-md-6">
<h3>{% trans 'Backup & Restore' %}</h3>
<a href="{% url 'api_backup' %}" class="btn btn-success">{% trans 'Download Backup' %}</a>
<br/> <br/>
<div class="alert alert-danger" role="alert">
⚠️ Backups simply create a so called fixture. Fixtures are json files containing all your data (WITHOUT
MEDIA FILES) <br>
They can be imported into django by running <code style="color: white">manage.py loaddata [fixture-name]</code> <br>
It is planned to provide a better way of backing up and restoring data but it is not yet implemented.<br><br>
⚠️<b>Please make sure to setup a solid backup strategy on your server to save the Database and the <code style="color: white">mediafiles</code>
directory</b>⚠️
</div>
</div>
-->
</div>
<br/>

View File

@@ -30,6 +30,19 @@
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="input-group mb-3">
<input class="form-control" v-model="json_data" placeholder="{% trans 'Enter json directly' %}">
<div class="input-group-append">
<button @click="loadRecipeJson()" class="btn btn-primary shadow-none" type="button"
id="id_btn_search"><i class="fas fa-search"></i>
</button>
</div>
</div>
</div>
</div>
<br/>
<div v-if="loading" class="text-center">
@@ -328,6 +341,21 @@
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger')
})
},
loadRecipeJson: function () {
this.recipe_data = undefined
this.error = undefined
this.loading = true
this.$http.post("{% url 'api_recipe_from_json' %}", {'json': this.json_data}, {emulateJSON: true}).then((response) => {
console.log(response.data)
this.recipe_data = response.data;
this.loading = false
}).catch((err) => {
this.error = err.data
this.loading = false
console.log(err)
this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger')
})
},
importRecipe: function () {
if (this.importing_recipe) {
this.makeToast(gettext('Error'), gettext('Already importing the selected recipe, please wait!'), 'danger')
@@ -367,7 +395,7 @@
this.recipe_data.recipeIngredient[index] = new_unit
},
addKeyword: function (tag) {
let new_keyword = {'text':tag,'id':null}
let new_keyword = {'text': tag, 'id': null}
this.recipe_data.keywords.push(new_keyword)
},
openUnitSelect: function (id) {