From 3e083e21681ab8f3dbd447fa4a2436409757f46b Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sat, 2 Dec 2023 18:02:22 +0100 Subject: [PATCH] fully integrated property editor --- cookbook/templates/property_editor.html | 31 +++ cookbook/urls.py | 1 + cookbook/views/views.py | 13 +- .../PropertyEditorView/PropertyEditorView.vue | 209 ++++++++++++++++++ vue/src/apps/PropertyEditorView/main.js | 22 ++ vue/src/components/RecipeContextMenu.vue | 3 + vue/src/locales/en.json | 1 + vue/vue.config.js | 6 +- 8 files changed, 281 insertions(+), 5 deletions(-) create mode 100644 cookbook/templates/property_editor.html create mode 100644 vue/src/apps/PropertyEditorView/PropertyEditorView.vue create mode 100644 vue/src/apps/PropertyEditorView/main.js diff --git a/cookbook/templates/property_editor.html b/cookbook/templates/property_editor.html new file mode 100644 index 00000000..f24a133e --- /dev/null +++ b/cookbook/templates/property_editor.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} +{% load render_bundle from webpack_loader %} +{% load static %} +{% load i18n %} +{% load l10n %} + +{% block title %}{% trans 'Property Editor' %}{% endblock %} + +{% block content_fluid %} + +
+ +
+ + +{% endblock %} + + +{% block script %} + {% if debug %} + + {% else %} + + {% endif %} + + + + {% render_bundle 'property_editor_view' %} +{% endblock %} \ No newline at end of file diff --git a/cookbook/urls.py b/cookbook/urls.py index e8be5160..9db5d5de 100644 --- a/cookbook/urls.py +++ b/cookbook/urls.py @@ -91,6 +91,7 @@ urlpatterns = [ path('history/', views.history, name='view_history'), path('supermarket/', views.supermarket, name='view_supermarket'), path('ingredient-editor/', views.ingredient_editor, name='view_ingredient_editor'), + path('property-editor/', views.property_editor, name='view_property_editor'), path('abuse/', views.report_share_abuse, name='view_report_share_abuse'), path('api/import/', api.import_files, name='view_import'), diff --git a/cookbook/views/views.py b/cookbook/views/views.py index 58a610a2..92c55789 100644 --- a/cookbook/views/views.py +++ b/cookbook/views/views.py @@ -204,6 +204,11 @@ def ingredient_editor(request): return render(request, 'ingredient_editor.html', template_vars) +@group_required('user') +def property_editor(request, pk): + return render(request, 'property_editor.html', {'recipe_id': pk}) + + @group_required('guest') def shopping_settings(request): if request.space.demo: @@ -220,10 +225,10 @@ def shopping_settings(request): if not sp: sp = SearchPreferenceForm(user=request.user) fields_searched = ( - len(search_form.cleaned_data['icontains']) - + len(search_form.cleaned_data['istartswith']) - + len(search_form.cleaned_data['trigram']) - + len(search_form.cleaned_data['fulltext']) + len(search_form.cleaned_data['icontains']) + + len(search_form.cleaned_data['istartswith']) + + len(search_form.cleaned_data['trigram']) + + len(search_form.cleaned_data['fulltext']) ) if search_form.cleaned_data['preset'] == 'fuzzy': sp.search = SearchPreference.SIMPLE diff --git a/vue/src/apps/PropertyEditorView/PropertyEditorView.vue b/vue/src/apps/PropertyEditorView/PropertyEditorView.vue new file mode 100644 index 00000000..b785fa09 --- /dev/null +++ b/vue/src/apps/PropertyEditorView/PropertyEditorView.vue @@ -0,0 +1,209 @@ + + + + + + diff --git a/vue/src/apps/PropertyEditorView/main.js b/vue/src/apps/PropertyEditorView/main.js new file mode 100644 index 00000000..40e6a309 --- /dev/null +++ b/vue/src/apps/PropertyEditorView/main.js @@ -0,0 +1,22 @@ +import Vue from 'vue' +import App from './PropertyEditorView.vue' +import i18n from '@/i18n' +import {createPinia, PiniaVuePlugin} from "pinia"; + +Vue.config.productionTip = false + +// TODO move this and other default stuff to centralized JS file (verify nothing breaks) +let publicPath = localStorage.STATIC_URL + 'vue/' +if (process.env.NODE_ENV === 'development') { + publicPath = 'http://localhost:8080/' +} +export default __webpack_public_path__ = publicPath // eslint-disable-line + +Vue.use(PiniaVuePlugin) +const pinia = createPinia() + +new Vue({ + pinia, + i18n, + render: h => h(App), +}).$mount('#app') diff --git a/vue/src/components/RecipeContextMenu.vue b/vue/src/components/RecipeContextMenu.vue index 72db67f4..dee82fda 100644 --- a/vue/src/components/RecipeContextMenu.vue +++ b/vue/src/components/RecipeContextMenu.vue @@ -10,6 +10,9 @@ {{ $t("Edit") }} + + {{ $t("Property_Editor") }} + {{ $t("convert_internal") }} diff --git a/vue/src/locales/en.json b/vue/src/locales/en.json index ca8e7d42..0a4dfb09 100644 --- a/vue/src/locales/en.json +++ b/vue/src/locales/en.json @@ -185,6 +185,7 @@ "move_title": "Move {type}", "Food": "Food", "Property": "Property", + "Property_Editor": "Property Editor", "Conversion": "Conversion", "Original_Text": "Original Text", "Recipe_Book": "Recipe Book", diff --git a/vue/vue.config.js b/vue/vue.config.js index cfdd6b38..5b9d42fb 100644 --- a/vue/vue.config.js +++ b/vue/vue.config.js @@ -53,6 +53,10 @@ const pages = { entry: "./src/apps/IngredientEditorView/main.js", chunks: ["chunk-vendors","locales-chunk","api-chunk"], }, + property_editor_view: { + entry: "./src/apps/PropertyEditorView/main.js", + chunks: ["chunk-vendors","locales-chunk","api-chunk"], + }, shopping_list_view: { entry: "./src/apps/ShoppingListView/main.js", chunks: ["chunk-vendors","locales-chunk","api-chunk"], @@ -137,7 +141,7 @@ module.exports = { config.optimization.minimize(true) - //TODO somehow remov them as they are also added to the manifest config of the service worker + //TODO somehow remove them as they are also added to the manifest config of the service worker /* Object.keys(pages).forEach(page => { config.plugins.delete(`html-${page}`);