3131 < div class ="tab-content " id ="monthTabsContent ">
3232 {% for month in months %}
3333 < div class ="tab-pane fade{% if forloop.first %} show active{% endif %} " id ="month_pane_{{ month.id }} " role ="tabpanel " aria-labelledby ="month_tab_{{ month.id }} " tabindex ="0 ">
34- < input type ="hidden " name ="date_{{ month.id }} " value ="{{ month.date }} " />
34+ < input type ="hidden " name ="id_{{ month.id }} " value ="{{ month.id }} " />
35+ < input type ="hidden " name ="name_{{ month.id }} " value ="{{ month.name }} " />
36+ < input type ="hidden " name ="date_{{ month.id }} " value ="{{ month.date | date:'Y-m-d' }} " />
3537
3638 < div class ="container-fluid pt-3 ">
3739 < div class ="row mb-3 ">
7981 -->
8082
8183 < div class ="btn-group ">
82- < button type ="button " id ="button-save-{{ month.id }} " class ="btn btn-primary " title ="Projekt Speichern " data-bs-toggle ="modal " data-bs-target ="#upload-images-modal " onclick ="uploadImages(true) " disabled >
84+ < button type ="button " id ="button-save-{{ month.id }} " class ="btn btn-primary " title ="Projekt Speichern " data-bs-toggle ="modal " data-bs-target ="#upload-images-modal " onclick ="uploadImages(true) ">
8385 < span class ="fa fa-floppy-disk "> </ span > Speichern
8486 </ button >
8587 </ div >
@@ -112,7 +114,7 @@ <h5 class="mb-3">Termine</h5>
112114
113115 < div class ="row pt-3 ">
114116 < div class ="col docs-buttons ">
115- < button type ="button " class ="btn btn-primary " onclick ="addEvent({{ month.id }}, '{{ month.date }}', '') " >
117+ < button type ="button " class ="btn btn-primary " onclick ="addEvent({{ month.id }}, '{{ month.date | date:'Y-m-d' }}', '') " >
116118 < span class ="fa fa-calendar-plus "> </ span > Termin hinzufügen
117119 </ button >
118120 </ div >
@@ -250,14 +252,13 @@ <h1 class="modal-title fs-5" id="upload-images-modal-label">Lade Bilder zum Serv
250252
251253 xhr . onload = function ( ) {
252254 if ( xhr . status == 200 ) {
253- closeModal ( "upload-images-modal" , function ( ) {
254- if ( saveProject ) {
255- showBlob ( xhr . response , "kalender.calendaronline" )
256- }
257- else {
258- showBlob ( xhr . response , "kalender.pdf" )
259- }
260- } )
255+ if ( saveProject ) {
256+ showBlob ( xhr . response , "kalender.calendaronline" )
257+ }
258+ else {
259+ showBlob ( xhr . response , "kalender.pdf" )
260+ }
261+ closeModal ( "upload-images-modal" )
261262 } else {
262263 closeModal ( "upload-images-modal" )
263264 console . error ( "Hochladen der Bilder ist mit Status " + xhr . status + " fehlgeschlagen:" , xhr . response ) ;
@@ -311,6 +312,7 @@ <h1 class="modal-title fs-5" id="upload-images-modal-label">Lade Bilder zum Serv
311312
312313function closeModal ( modalId , onClosed ) {
313314 var modalEl = document . getElementById ( modalId ) ;
315+ const myModalAlternative = new bootstrap . Modal ( '#myModal' , options )
314316 console . log ( "Hiding modal with Id " + modalId + " and element " , modalEl )
315317
316318 if ( modalEl != null ) {
@@ -333,28 +335,30 @@ <h1 class="modal-title fs-5" id="upload-images-modal-label">Lade Bilder zum Serv
333335}
334336
335337function updatePreview ( input , id , aspectRatio ) {
338+ let file = input . files [ 0 ] ;
339+ let key = "{{ format }}-" + file . name + "-" + file . size
340+ let reader = new FileReader ( ) ;
341+ reader . readAsDataURL ( file ) ;
342+ reader . onload = function ( ) {
343+ setCropperImage ( id , aspectRatio , key , reader . result )
344+ }
345+ }
346+
347+ function setCropperImage ( id , aspectRatio , key , imageData ) {
336348 let img = document . getElementById ( "image-preview-" + id ) ;
337349
338350 if ( cropper [ id ] ) {
339351 cropper [ id ] . destroy ( ) ;
340352 }
341353
342- let file = input . files [ 0 ] ;
343- key = "{{ format }}-" + file . name + "-" + file . size
344-
345354 cropper [ id ] = enableCropper ( img , id , key , aspectRatio ) ;
346-
347- let reader = new FileReader ( ) ;
348- reader . readAsDataURL ( file ) ;
349- reader . onload = function ( ) {
350- cropper [ id ] . imageReplaced = true ;
351- cropper [ id ] . replace ( reader . result ) ;
352- }
355+ cropper [ id ] . imageReplaced = true ;
356+ cropper [ id ] . replace ( imageData ) ;
353357}
354358
355359function enableCropper ( img , id , storedCropperKey , aspectRatio ) {
356360 var storedCropperData = false
357- if ( localStorage . getItem ( storedCropperKey ) ) {
361+ if ( storedCropperKey && localStorage . getItem ( storedCropperKey ) ) {
358362 storedCropperData = JSON . parse ( localStorage . getItem ( storedCropperKey ) )
359363 }
360364
@@ -383,6 +387,7 @@ <h1 class="modal-title fs-5" id="upload-images-modal-label">Lade Bilder zum Serv
383387 { % for event in month . events % }
384388 addEvent ( { { month . id } } , '{{ event.date }}' , '{{ event.text }}' , true ) ;
385389 { % endfor % }
390+ { % if month . image % } setCropperImage ( '{{ month.id }}' , '{{month.image_aspect_ratio}}' , false , 'data:image/jpeg;base64,{{ month.image }}' ) { % endif % }
386391 { % endfor % }
387392} ) ;
388393{ % endif % }
0 commit comments