Treenode Editor | pridano mazani textnode a castnode.
Priprava na autocomplete problemu, zatim pouze cast API.
This commit is contained in:
		
							parent
							
								
									e3bb6dac2a
								
							
						
					
					
						commit
						514eddcf01
					
				
					 9 changed files with 86 additions and 8 deletions
				
			
		|  | @ -7,4 +7,5 @@ router.register(r'ulohavzoraknode', vs.UlohaVzorakNodeViewSet,basename='ulohavzo | ||||||
| router.register(r'text', vs.TextViewSet) | router.register(r'text', vs.TextViewSet) | ||||||
| router.register(r'textnode', vs.TextNodeViewSet) | router.register(r'textnode', vs.TextNodeViewSet) | ||||||
| router.register(r'castnode', vs.CastNodeViewSet) | router.register(r'castnode', vs.CastNodeViewSet) | ||||||
|  | router.register(r'problem', vs.ProblemViewSet, basename='problem') | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										19
									
								
								seminar/migrations/0090_auto_20201110_1958.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								seminar/migrations/0090_auto_20201110_1958.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | ||||||
|  | # Generated by Django 2.2.12 on 2020-11-10 18:58 | ||||||
|  | 
 | ||||||
|  | from django.db import migrations, models | ||||||
|  | import django.db.models.deletion | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class Migration(migrations.Migration): | ||||||
|  | 
 | ||||||
|  |     dependencies = [ | ||||||
|  |         ('seminar', '0089_cislo_datum_preddeadline'), | ||||||
|  |     ] | ||||||
|  | 
 | ||||||
|  |     operations = [ | ||||||
|  |         migrations.AlterField( | ||||||
|  |             model_name='textnode', | ||||||
|  |             name='text', | ||||||
|  |             field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Text', verbose_name='text'), | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
|  | @ -1475,7 +1475,7 @@ class TextNode(TreeNode): | ||||||
| 		verbose_name = 'Text (Node)' | 		verbose_name = 'Text (Node)' | ||||||
| 		verbose_name_plural = 'Text (Node)' | 		verbose_name_plural = 'Text (Node)' | ||||||
| 	text = models.ForeignKey(Text, | 	text = models.ForeignKey(Text, | ||||||
| 		on_delete=models.PROTECT, | 		on_delete=models.CASCADE, | ||||||
| 		verbose_name = 'text') | 		verbose_name = 'text') | ||||||
| 	 | 	 | ||||||
| 	def aktualizuj_nazev(self): | 	def aktualizuj_nazev(self): | ||||||
|  |  | ||||||
|  | @ -11,7 +11,10 @@ class TextSerializer(serializers.ModelSerializer): | ||||||
| 		model = m.Text | 		model = m.Text | ||||||
| 		fields = '__all__' | 		fields = '__all__' | ||||||
| 
 | 
 | ||||||
| 
 | class ProblemSerializer(serializers.ModelSerializer): | ||||||
|  | 	class Meta: | ||||||
|  | 		model = m.Problem | ||||||
|  | 		fields = '__all__' | ||||||
| 
 | 
 | ||||||
| class UlohaVzorakNodeSerializer(serializers.ModelSerializer): | class UlohaVzorakNodeSerializer(serializers.ModelSerializer): | ||||||
| 	class Meta: | 	class Meta: | ||||||
|  |  | ||||||
|  | @ -1,4 +1,8 @@ | ||||||
| from rest_framework import viewsets,filters | from rest_framework import viewsets,filters | ||||||
|  | from rest_framework import status | ||||||
|  | from rest_framework.response import Response | ||||||
|  | from django.core.exceptions import PermissionDenied | ||||||
|  | 
 | ||||||
| from . import models as m | from . import models as m | ||||||
| from . import views | from . import views | ||||||
| 
 | 
 | ||||||
|  | @ -66,6 +70,14 @@ class CastNodeViewSet(ReadWriteSerializerMixin,viewsets.ModelViewSet): | ||||||
| 	write_serializer_class = views.CastNodeSerializer | 	write_serializer_class = views.CastNodeSerializer | ||||||
| 	create_serializer_class = views.CastNodeCreateSerializer | 	create_serializer_class = views.CastNodeCreateSerializer | ||||||
| 
 | 
 | ||||||
|  | 	def destroy(self, request, *args, **kwargs): | ||||||
|  | 		obj = self.get_object() | ||||||
|  | 		print(obj) | ||||||
|  | 		if obj.first_child is None: | ||||||
|  | 			return super().destroy(request,*args,**kwargs) | ||||||
|  | 		raise PermissionDenied('Nelze smazat CastNode, který má děti!') | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| class UlohaVzorakNodeViewSet(viewsets.ModelViewSet): | class UlohaVzorakNodeViewSet(viewsets.ModelViewSet): | ||||||
| 	serializer_class = views.UlohaVzorakNodeSerializer | 	serializer_class = views.UlohaVzorakNodeSerializer | ||||||
| 
 | 
 | ||||||
|  | @ -75,3 +87,10 @@ class UlohaVzorakNodeViewSet(viewsets.ModelViewSet): | ||||||
| 		if nazev is not None: | 		if nazev is not None: | ||||||
| 			queryset = queryset.filter(nazev__contains=nazev) | 			queryset = queryset.filter(nazev__contains=nazev) | ||||||
| 		return queryset | 		return queryset | ||||||
|  | 
 | ||||||
|  | class ProblemViewSet(viewsets.ModelViewSet): | ||||||
|  | 	serializer_class = views.ProblemSerializer | ||||||
|  | 
 | ||||||
|  | 	def get_queryset(self): | ||||||
|  | 		queryset = m.Problem.objects.all() | ||||||
|  | 		return queryset | ||||||
|  |  | ||||||
|  | @ -7,7 +7,9 @@ | ||||||
| 			<button v-on:click="currentText = originalText;editorShow=!editorShow;">Zahodit úpravy</button> | 			<button v-on:click="currentText = originalText;editorShow=!editorShow;">Zahodit úpravy</button> | ||||||
| 		</div> | 		</div> | ||||||
| 		<div v-else> | 		<div v-else> | ||||||
| 		<h4>{{ currentText }} </h4> <button v-if="editorMode" v-on:click="editorShow=!editorShow">Upravit</button> | 		<h4>{{ currentText }} </h4> | ||||||
|  | 		<button v-if="editorMode" v-on:click="editorShow = !editorShow">Upravit</button> | ||||||
|  | 		<button v-if="editorMode" v-on:click="deleteCast" class="delete">Smazat</button> | ||||||
| 		</div> | 		</div> | ||||||
| 	</div> | 	</div> | ||||||
| </template> | </template> | ||||||
|  | @ -25,6 +27,7 @@ export default { | ||||||
| 	props: { | 	props: { | ||||||
| 		item: Object, | 		item: Object, | ||||||
| 		editorShow: Boolean, | 		editorShow: Boolean, | ||||||
|  | 		editorMode: Boolean, | ||||||
| 		create: Boolean, | 		create: Boolean, | ||||||
| 		where: String, | 		where: String, | ||||||
| 		refnode: Object | 		refnode: Object | ||||||
|  | @ -76,11 +79,27 @@ export default { | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			this.editorShow = false; | 			this.editorShow = false; | ||||||
|  | 		}, | ||||||
|  | 		deleteCast: function() { | ||||||
|  | 			console.log("Deleting cast"); | ||||||
|  | 			axios.delete('/api/castnode/'+this.item.node.id+'/' | ||||||
|  | 			).then( () => { | ||||||
|  | 				this.loading = false; | ||||||
|  | 				this.$root.$emit('updateData',"castNode delete update"); | ||||||
|  | 			}).catch(e => { | ||||||
|  | 				this.errors.push(e); | ||||||
|  | 			}); | ||||||
| 		} | 		} | ||||||
| 		} | 	} | ||||||
| } | } | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <!-- Add "scoped" attribute to limit CSS to this component only --> | <!-- Add "scoped" attribute to limit CSS to this component only --> | ||||||
| <style scoped> | <style scoped> | ||||||
|  | .changed { | ||||||
|  | 	background-color: yellow; | ||||||
|  | } | ||||||
|  | .delete { | ||||||
|  | 	background-color:  #ff6666; | ||||||
|  | } | ||||||
| </style> | </style> | ||||||
|  |  | ||||||
|  | @ -23,7 +23,8 @@ | ||||||
| 
 | 
 | ||||||
| 		<template v-else v-bind:class="changedObject"> | 		<template v-else v-bind:class="changedObject"> | ||||||
| 			<p v-html="currentText"></p> | 			<p v-html="currentText"></p> | ||||||
| 			<button v-if="editorMode" v-on:click="editorShow=!editorShow">Upravit</button> | 			<button v-if="editorMode" v-on:click="editorShow = !editorShow">Upravit</button> | ||||||
|  | 			<button v-if="editorMode" v-on:click="deleteText" class="delete">Smazat</button> | ||||||
| 		</template> | 		</template> | ||||||
| 	</div> | 	</div> | ||||||
| </template> | </template> | ||||||
|  | @ -162,6 +163,16 @@ export default { | ||||||
| 			} | 			} | ||||||
| 			this.editorShow = false; | 			this.editorShow = false; | ||||||
| 		}, | 		}, | ||||||
|  | 		deleteText: function() { | ||||||
|  | 			console.log("Deleting text"); | ||||||
|  | 			axios.delete('/api/textnode/'+this.item.node.id+'/' | ||||||
|  | 			).then( () => { | ||||||
|  | 				this.loading = false; | ||||||
|  | 				this.$root.$emit('updateData',"textNode delete update"); | ||||||
|  | 			}).catch(e => { | ||||||
|  | 				this.errors.push(e); | ||||||
|  | 			}); | ||||||
|  | 		}, | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| </script> | </script> | ||||||
|  | @ -169,6 +180,9 @@ export default { | ||||||
| <!-- Add "scoped" attribute to limit CSS to this component only --> | <!-- Add "scoped" attribute to limit CSS to this component only --> | ||||||
| <style scoped> | <style scoped> | ||||||
| .changed { | .changed { | ||||||
| 	background-color: 'yellow'; | 	background-color: yellow; | ||||||
|  | } | ||||||
|  | .delete { | ||||||
|  | 	background-color:  #ff6666; | ||||||
| } | } | ||||||
| </style> | </style> | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ | ||||||
| 		<div id="loading" v-if="loading"> | 		<div id="loading" v-if="loading"> | ||||||
| 		Loading... | 		Loading... | ||||||
| 		</div> | 		</div> | ||||||
|  | 		<div v-else> | ||||||
| 		<!--pre> | 		<!--pre> | ||||||
| 		{{item}} | 		{{item}} | ||||||
| 		</pre--> | 		</pre--> | ||||||
|  | @ -11,6 +12,7 @@ | ||||||
| 		<button v-show="debugMode" v-on:click="debugMode = false">Vypnout ladicí mód</button> | 		<button v-show="debugMode" v-on:click="debugMode = false">Vypnout ladicí mód</button> | ||||||
| 		<button v-show="!debugMode" v-on:click="debugMode = true">Zapnout ladicí mód</button> | 		<button v-show="!debugMode" v-on:click="debugMode = true">Zapnout ladicí mód</button> | ||||||
| 		<TreeNode :item="item" :editorMode="editorMode" :debugMode="debugMode"/> | 		<TreeNode :item="item" :editorMode="editorMode" :debugMode="debugMode"/> | ||||||
|  | 		</div> | ||||||
| 	</div> | 	</div> | ||||||
| </template> | </template> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ const pages = { | ||||||
| module.exports = { | module.exports = { | ||||||
|     pages: pages, |     pages: pages, | ||||||
|     filenameHashing: false, |     filenameHashing: false, | ||||||
|     productionSourceMap: false, |     productionSourceMap: true, | ||||||
|     publicPath: process.env.NODE_ENV === 'production' |     publicPath: process.env.NODE_ENV === 'production' | ||||||
|         ? '/static/seminar/vue/' |         ? '/static/seminar/vue/' | ||||||
|         : 'http://localhost:8080/', |         : 'http://localhost:8080/', | ||||||
|  | @ -23,6 +23,7 @@ module.exports = { | ||||||
| 
 | 
 | ||||||
|     chainWebpack: config => { |     chainWebpack: config => { | ||||||
| 
 | 
 | ||||||
|  | 	config.optimization.minimize(false) | ||||||
|         config.optimization |         config.optimization | ||||||
|             .splitChunks({ |             .splitChunks({ | ||||||
|                 cacheGroups: { |                 cacheGroups: { | ||||||
|  | @ -33,7 +34,7 @@ module.exports = { | ||||||
|                         priority: 1 |                         priority: 1 | ||||||
|                     }, |                     }, | ||||||
|                 }, |                 }, | ||||||
|             }); |             }).minimize(false); | ||||||
| 
 | 
 | ||||||
|         Object.keys(pages).forEach(page => { |         Object.keys(pages).forEach(page => { | ||||||
|             config.plugins.delete(`html-${page}`); |             config.plugins.delete(`html-${page}`); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue