diff --git a/cookbook/templates/edit_internal_recipe_v2.html b/cookbook/templates/edit_internal_recipe_v2.html new file mode 100644 index 00000000..92f5f679 --- /dev/null +++ b/cookbook/templates/edit_internal_recipe_v2.html @@ -0,0 +1,38 @@ +{% extends "base.html" %} +{% load render_bundle from webpack_loader %} +{% load static %} +{% load i18n %} +{% load l10n %} + +{% block title %}{% trans 'Edit Recipe' %}{% endblock %} + +{% block extra_head %} + +{% endblock %} + +{% block content %} + +
+ +
+ + +{% endblock %} + + +{% block script %} + {% if debug %} + + {% else %} + + {% endif %} + + + + {% render_bundle 'edit_internal_recipe' %} +{% endblock %} \ No newline at end of file diff --git a/cookbook/views/api.py b/cookbook/views/api.py index 72188250..20bdd7a3 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -548,9 +548,7 @@ class RecipeViewSet(viewsets.ModelViewSet): if obj.get_space() != request.space: raise PermissionDenied(detail='You do not have the required permission to perform this action', code=403) - serializer = self.serializer_class( - obj, data=request.data, partial=True - ) + serializer = self.serializer_class(obj, data=request.data, partial=True) if self.request.space.demo: raise PermissionDenied(detail='Not available in demo', code=None) @@ -558,8 +556,11 @@ class RecipeViewSet(viewsets.ModelViewSet): if serializer.is_valid(): serializer.save() - img, filetype = handle_image(request, obj.image) - obj.image = File(img, name=f'{uuid.uuid4()}_{obj.pk}{filetype}') + if serializer.validated_data == {}: + obj.image = None + else: + img, filetype = handle_image(request, obj.image) + obj.image = File(img, name=f'{uuid.uuid4()}_{obj.pk}{filetype}') obj.save() return Response(serializer.data) diff --git a/cookbook/views/edit.py b/cookbook/views/edit.py index 767c18ea..c0785d38 100644 --- a/cookbook/views/edit.py +++ b/cookbook/views/edit.py @@ -57,7 +57,7 @@ def internal_recipe_update(request, pk): recipe_instance = get_object_or_404(Recipe, pk=pk, space=request.space) return render( - request, 'forms/edit_internal_recipe.html', {'recipe': recipe_instance} + request, 'edit_internal_recipe_v2.html', {'recipe': recipe_instance} ) diff --git a/vue/package.json b/vue/package.json index 9c1537e8..64a1b977 100644 --- a/vue/package.json +++ b/vue/package.json @@ -9,6 +9,7 @@ }, "dependencies": { "@babel/eslint-parser": "^7.13.14", + "@kangc/v-md-editor": "^1.7.7", "@kevinfaguiar/vue-twemoji-picker": "^5.7.4", "@riophae/vue-treeselect": "^0.4.0", "axios": "^0.21.1", @@ -16,6 +17,7 @@ "core-js": "^3.14.0", "lodash": "^4.17.21", "moment": "^2.29.1", + "prismjs": "^1.24.1", "vue": "^2.6.14", "vue-class-component": "^7.2.3", "vue-clickaway": "^2.2.2", diff --git a/vue/src/apps/RecipeEditView/RecipeEditView.vue b/vue/src/apps/RecipeEditView/RecipeEditView.vue new file mode 100644 index 00000000..fae66c2e --- /dev/null +++ b/vue/src/apps/RecipeEditView/RecipeEditView.vue @@ -0,0 +1,826 @@ + + + + + + + diff --git a/vue/src/apps/RecipeEditView/main.js b/vue/src/apps/RecipeEditView/main.js new file mode 100644 index 00000000..c07b4ee6 --- /dev/null +++ b/vue/src/apps/RecipeEditView/main.js @@ -0,0 +1,10 @@ +import Vue from 'vue' +import App from './RecipeEditView' +import i18n from '@/i18n' + +Vue.config.productionTip = false + +new Vue({ + i18n, + render: h => h(App), +}).$mount('#app') diff --git a/vue/src/locales/en.json b/vue/src/locales/en.json index 896baa24..53250055 100644 --- a/vue/src/locales/en.json +++ b/vue/src/locales/en.json @@ -7,6 +7,8 @@ "success_creating_resource": "Successfully created a resource!", "success_updating_resource": "Successfully updated a resource!", "success_deleting_resource": "Successfully deleted a resource!", + "step_time_minutes": "Step time in minutes", + "confirm_delete": "Are you sure you want to delete this {object}?", "import_running": "Import running, please wait!", "all_fields_optional": "All fields are optional and can be left empty.", @@ -21,6 +23,10 @@ "Step_start_time": "Step start time", "Sort_by_new": "Sort by new", "Recipes_per_page": "Recipes per Page", + "Show_as_header": "Show as header", + "Hide_as_header": "Hide as header", + "Copy_template_reference": "Copy template reference", + "Save_and_View": "Save & View", "Manage_Books": "Manage Books", "Meal_Plan": "Meal Plan", @@ -37,10 +43,20 @@ "New_Keyword": "New Keyword", "Delete_Keyword": "Delete Keyword", "Edit_Keyword": "Edit Keyword", + "Edit_Recipe": "Edit Recipe", "Move_Keyword": "Move Keyword", "Merge_Keyword": "Merge Keyword", "Hide_Keywords": "Hide Keywords", "Hide_Recipes": "Hide Recipes", + "Move_Up": "Move up", + "Move_Down": "Move down", + "Step_Name": "Step Name", + "Step_Type": "Step Type", + "Make_Header": "Make_Header", + "Make_Ingredient": "Make_Ingredient", + "Enable_Amount": "Enable Amount", + "Disable_Amount": "Disable Amount", + "Add_Step": "Add Step", "Keywords": "Keywords", "Books": "Books", @@ -59,6 +75,7 @@ "Link": "Link", "Add": "Add", "New": "New", + "Note": "Note", "Success": "Success", "Failure": "Failure", "Ingredients": "Ingredients", @@ -131,5 +148,8 @@ "Create_New_Keyword": "Add New Keyword", "Create_New_Unit": "Add New Unit", "and_up": "& Up", - "Unrated": "Unrated" + "Instructions": "Instructions", + "Unrated": "Unrated", + "Time": "Time", + "Text": "Text" } diff --git a/vue/vue.config.js b/vue/vue.config.js index f0ecbc8a..ecf2dd7d 100644 --- a/vue/vue.config.js +++ b/vue/vue.config.js @@ -29,10 +29,14 @@ const pages = { entry: './src/apps/ModelListView/main.js', chunks: ['chunk-vendors'] }, + 'edit_internal_recipe': { + entry: './src/apps/RecipeEditView/main.js', + chunks: ['chunk-vendors'] + }, 'cookbook_view': { entry: './src/apps/CookbookView/main.js', chunks: ['chunk-vendors'] - }, + } } module.exports = { @@ -112,4 +116,4 @@ module.exports = { .headers({"Access-Control-Allow-Origin": ["*"]}) } -}; \ No newline at end of file +}; diff --git a/vue/webpack-stats.json b/vue/webpack-stats.json index 6d6a4f2f..e9d41494 100644 --- a/vue/webpack-stats.json +++ b/vue/webpack-stats.json @@ -1,137 +1,130 @@ { "status": "done", "assets": { - "../../templates/sw.js": { - "name": "../../templates/sw.js", - "path": "..\\..\\templates\\sw.js" - }, - "css/chunk-vendors.css": { - "name": "css/chunk-vendors.css", - "path": "css\\chunk-vendors.css" - }, "js/chunk-vendors.js": { "name": "js/chunk-vendors.js", - "path": "js\\chunk-vendors.js" + "path": "js\\chunk-vendors.js", + "publicPath": "http://localhost:8080/js/chunk-vendors.js" }, - "css/cookbook_view.css": { - "name": "css/cookbook_view.css", - "path": "css\\cookbook_view.css" - }, - "js/cookbook_view.js": { - "name": "js/cookbook_view.js", - "path": "js\\cookbook_view.js" + "js/edit_internal_recipe.js": { + "name": "js/edit_internal_recipe.js", + "path": "js\\edit_internal_recipe.js", + "publicPath": "http://localhost:8080/js/edit_internal_recipe.js" }, "js/import_response_view.js": { "name": "js/import_response_view.js", - "path": "js\\import_response_view.js" - }, - "css/model_list_view.css": { - "name": "css/model_list_view.css", - "path": "css\\model_list_view.css" + "path": "js\\import_response_view.js", + "publicPath": "http://localhost:8080/js/import_response_view.js" }, "js/model_list_view.js": { "name": "js/model_list_view.js", - "path": "js\\model_list_view.js" + "path": "js\\model_list_view.js", + "publicPath": "http://localhost:8080/js/model_list_view.js" }, "js/offline_view.js": { "name": "js/offline_view.js", - "path": "js\\offline_view.js" + "path": "js\\offline_view.js", + "publicPath": "http://localhost:8080/js/offline_view.js" }, "js/recipe_search_view.js": { "name": "js/recipe_search_view.js", - "path": "js\\recipe_search_view.js" + "path": "js\\recipe_search_view.js", + "publicPath": "http://localhost:8080/js/recipe_search_view.js" }, "js/recipe_view.js": { "name": "js/recipe_view.js", - "path": "js\\recipe_view.js" + "path": "js\\recipe_view.js", + "publicPath": "http://localhost:8080/js/recipe_view.js" }, "js/supermarket_view.js": { "name": "js/supermarket_view.js", - "path": "js\\supermarket_view.js" + "path": "js\\supermarket_view.js", + "publicPath": "http://localhost:8080/js/supermarket_view.js" }, "js/user_file_view.js": { "name": "js/user_file_view.js", - "path": "js\\user_file_view.js" + "path": "js\\user_file_view.js", + "publicPath": "http://localhost:8080/js/user_file_view.js" }, "recipe_search_view.html": { "name": "recipe_search_view.html", - "path": "recipe_search_view.html" + "path": "recipe_search_view.html", + "publicPath": "http://localhost:8080/recipe_search_view.html" }, "recipe_view.html": { "name": "recipe_view.html", - "path": "recipe_view.html" + "path": "recipe_view.html", + "publicPath": "http://localhost:8080/recipe_view.html" }, "offline_view.html": { "name": "offline_view.html", - "path": "offline_view.html" + "path": "offline_view.html", + "publicPath": "http://localhost:8080/offline_view.html" }, "import_response_view.html": { "name": "import_response_view.html", - "path": "import_response_view.html" + "path": "import_response_view.html", + "publicPath": "http://localhost:8080/import_response_view.html" }, "supermarket_view.html": { "name": "supermarket_view.html", - "path": "supermarket_view.html" + "path": "supermarket_view.html", + "publicPath": "http://localhost:8080/supermarket_view.html" }, "user_file_view.html": { "name": "user_file_view.html", - "path": "user_file_view.html" + "path": "user_file_view.html", + "publicPath": "http://localhost:8080/user_file_view.html" }, "model_list_view.html": { "name": "model_list_view.html", - "path": "model_list_view.html" + "path": "model_list_view.html", + "publicPath": "http://localhost:8080/model_list_view.html" }, - "cookbook_view.html": { - "name": "cookbook_view.html", - "path": "cookbook_view.html" + "edit_internal_recipe.html": { + "name": "edit_internal_recipe.html", + "path": "edit_internal_recipe.html", + "publicPath": "http://localhost:8080/edit_internal_recipe.html" }, "manifest.json": { "name": "manifest.json", - "path": "manifest.json" + "path": "manifest.json", + "publicPath": "http://localhost:8080/manifest.json" } }, "chunks": { "recipe_search_view": [ - "css/chunk-vendors.css", "js/chunk-vendors.js", "js/recipe_search_view.js" ], "recipe_view": [ - "css/chunk-vendors.css", "js/chunk-vendors.js", "js/recipe_view.js" ], "offline_view": [ - "css/chunk-vendors.css", "js/chunk-vendors.js", "js/offline_view.js" ], "import_response_view": [ - "css/chunk-vendors.css", "js/chunk-vendors.js", "js/import_response_view.js" ], "supermarket_view": [ - "css/chunk-vendors.css", "js/chunk-vendors.js", "js/supermarket_view.js" ], "user_file_view": [ - "css/chunk-vendors.css", "js/chunk-vendors.js", "js/user_file_view.js" ], "model_list_view": [ - "css/chunk-vendors.css", "js/chunk-vendors.js", - "css/model_list_view.css", "js/model_list_view.js" ], - "cookbook_view": [ - "css/chunk-vendors.css", + "edit_internal_recipe": [ "js/chunk-vendors.js", - "css/cookbook_view.css", - "js/cookbook_view.js" + "js/edit_internal_recipe.js" ] - } + }, + "publicPath": "http://localhost:8080/" } \ No newline at end of file