-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
started work on supermarket edit view
- Loading branch information
1 parent
040af33
commit 6fc0c02
Showing
20 changed files
with
715 additions
and
51 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Vue App</title><link href="css/chunk-vendors.css" rel="preload" as="style"><link href="js/chunk-vendors.js" rel="preload" as="script"><link href="js/supermarket_view.js" rel="preload" as="script"><link href="css/chunk-vendors.css" rel="stylesheet"><link rel="icon" type="image/png" sizes="32x32" href="img/icons/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="img/icons/favicon-16x16.png"><link rel="manifest" href="manifest.json"><meta name="theme-color" content="#4DBA87"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><meta name="apple-mobile-web-app-title" content="Recipes"><link rel="apple-touch-icon" href="img/icons/apple-touch-icon-152x152.png"><link rel="mask-icon" href="img/icons/safari-pinned-tab.svg" color="#4DBA87"><meta name="msapplication-TileImage" content="img/icons/msapplication-icon-144x144.png"><meta name="msapplication-TileColor" content="#000000"></head><body><div id="app"></div><script src="js/chunk-vendors.js"></script></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{% extends "base.html" %} | ||
{% load render_bundle from webpack_loader %} | ||
{% load static %} | ||
{% load i18n %} | ||
{% load l10n %} | ||
|
||
{% block title %}{% trans 'Supermarket' %}{% endblock %} | ||
|
||
{% block extra_head %} | ||
<link rel="stylesheet" href="{% static 'css/vue-multiselect-bs4.min.css' %}"> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
|
||
<div id="app" > | ||
<supermarket-view></supermarket-view> | ||
</div> | ||
|
||
|
||
{% endblock %} | ||
|
||
|
||
{% block 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.CUSTOM_LOCALE = '{{ request.LANGUAGE_CODE }}' | ||
</script> | ||
|
||
{% render_bundle 'supermarket_view' %} | ||
{% endblock %} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
<template> | ||
|
||
<div id="app"> | ||
|
||
<div class="row"> | ||
|
||
<div class="col col-md-12"> | ||
<h2>{{ $t('Supermarket') }}</h2> | ||
|
||
<multiselect v-model="selected_supermarket" track-by="id" label="name" | ||
:options="supermarkets"> | ||
</multiselect> | ||
|
||
<b-button class="btn btn-primary btn-block" style="margin-top: 1vh" v-b-modal.modal-supermarket> | ||
{{ $t('Edit') }} | ||
</b-button> | ||
<b-button class="btn btn-success btn-block" @click="selected_supermarket = {new:true, name:''}" | ||
v-b-modal.modal-supermarket>{{ $t('New') }} | ||
</b-button> | ||
</div> | ||
</div> | ||
|
||
<hr> | ||
|
||
<div class="row"> | ||
<div class="col col-md-6"> | ||
<h4>{{ $t('Categories') }} | ||
<button class="btn btn-success btn-sm">{{ $t('New') }}</button> | ||
</h4> | ||
|
||
<draggable :list="categories" group="supermarket_categories" | ||
:empty-insert-threshold="10"> | ||
<div v-for="c in categories" :key="c.id"> | ||
<button class="btn btn-block btn-sm btn-primary" style="margin-top: 0.5vh">{{ c.name }}</button> | ||
|
||
</div> | ||
</draggable> | ||
|
||
|
||
</div> | ||
<div class="col col-md-6"> | ||
<h4>{{ $t('Selected') }} {{ $t('Categories') }}</h4> | ||
|
||
<draggable :list="selected_categories" group="supermarket_categories" | ||
:empty-insert-threshold="10"> | ||
<div v-for="c in selected_categories" :key="c.id"> | ||
<button class="btn btn-block btn-sm btn-primary" style="margin-top: 0.5vh">{{ c.name }}</button> | ||
|
||
</div> | ||
</draggable> | ||
</div> | ||
</div> | ||
|
||
<!-- EDIT MODALS --> | ||
<b-modal id="modal-supermarket" v-bind:title="$t('Supermarket')" @ok="supermarketModalOk()"> | ||
<label v-if="selected_supermarket !== undefined"> | ||
{{ $t('Name') }} | ||
<b-input v-model="selected_supermarket.name"></b-input> | ||
|
||
</label> | ||
</b-modal> | ||
|
||
<b-modal id="modal-category" v-bind:title="$t('Category')" @ok="categoryModalOk()"> | ||
<label v-if="selected_supermarket !== undefined"> | ||
{{ $t('Name') }} | ||
<b-input v-model="selected_supermarket.name"></b-input> | ||
|
||
</label> | ||
</b-modal> | ||
|
||
</div> | ||
</template> | ||
|
||
<script> | ||
import Vue from 'vue' | ||
import {BootstrapVue} from 'bootstrap-vue' | ||
import 'bootstrap-vue/dist/bootstrap-vue.css' | ||
import {ResolveUrlMixin, ToastMixin} from "@/utils/utils"; | ||
import {ApiApiFactory} from "@/utils/openapi/api.ts"; | ||
Vue.use(BootstrapVue) | ||
import draggable from 'vuedraggable' | ||
import axios from 'axios' | ||
import Multiselect from "vue-multiselect"; | ||
axios.defaults.xsrfHeaderName = 'X-CSRFToken' | ||
axios.defaults.xsrfCookieName = 'csrftoken' | ||
export default { | ||
name: 'SupermarketView', | ||
mixins: [ | ||
ResolveUrlMixin, | ||
ToastMixin, | ||
], | ||
components: { | ||
Multiselect, | ||
draggable | ||
}, | ||
data() { | ||
return { | ||
supermarkets: [], | ||
categories: [], | ||
selected_supermarket: {}, | ||
selected_categories: [], | ||
} | ||
}, | ||
mounted() { | ||
this.$i18n.locale = window.CUSTOM_LOCALE | ||
console.log('LOADED') | ||
this.loadInitial() | ||
}, | ||
methods: { | ||
loadInitial: function () { | ||
let apiClient = new ApiApiFactory() | ||
apiClient.listSupermarkets().then(results => { | ||
this.supermarkets = results.data | ||
}) | ||
apiClient.listSupermarketCategorys().then(results => { | ||
this.categories = results.data | ||
}) | ||
}, | ||
supermarketModalOk: function () { | ||
let apiClient = new ApiApiFactory() | ||
if (this.selected_supermarket.new) { | ||
apiClient.createSupermarket({name: this.selected_supermarket.name}).then(results => { | ||
this.selected_supermarket = undefined | ||
this.loadInitial() | ||
}) | ||
} else { | ||
apiClient.partialUpdateSupermarket(this.selected_supermarket.id, {name: this.selected_supermarket.name}) | ||
} | ||
}, | ||
categoryModalOk: function () { | ||
let apiClient = new ApiApiFactory() | ||
if (this.selected_supermarket.new) { | ||
apiClient.createSupermarket({name: this.selected_supermarket.name}).then(results => { | ||
this.selected_supermarket = undefined | ||
this.loadInitial() | ||
}) | ||
} else { | ||
apiClient.partialUpdateSupermarket(this.selected_supermarket.id, {name: this.selected_supermarket.name}) | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Vue from 'vue' | ||
import App from './SupermarketView.vue' | ||
import i18n from '@/i18n' | ||
|
||
Vue.config.productionTip = false | ||
|
||
new Vue({ | ||
i18n, | ||
render: h => h(App), | ||
}).$mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.