@@ -47,7 +47,7 @@ <h3 class="stepper-title">Setup dataset type</h3>
4747 </ div >
4848 <!--end::Step 1-->
4949 <!--begin::Step 2-->
50- < div class ="stepper-item " data-kt-stepper-element ="nav ">
50+ < div class ="stepper-item " data-kt-stepper-element ="nav " {% if is_edit %}style =" display:none " {% endif %} >
5151 <!--begin::Wrapper-->
5252 < div class ="stepper-wrapper ">
5353 <!--begin::Icon-->
@@ -335,8 +335,9 @@ <h2 class="fw-bold text-gray-900">{% if is_edit %}Save dataset{% else %}Upload d
335335</ div >
336336
337337< script >
338- var isEditMode = { { 'true' if is_edit else 'false' } } ;
338+ window . isEditMode = { { 'true' if is_edit else 'false' } } ;
339339 window . initialDropzoneFiles = { { preloaded_temp_files | default ( [ ] , true ) | tojson } } ;
340+ window . initialAuthorIndex = { { dataset . ds_meta_data . authors | length if dataset and dataset . ds_meta_data and dataset . ds_meta_data . authors else 0 } } ;
340341
341342 /**
342343 * CORRECCIÓN 1: Prevenir errores de "myDropzone is not defined"
@@ -361,11 +362,19 @@ <h2 class="fw-bold text-gray-900">{% if is_edit %}Save dataset{% else %}Upload d
361362 if ( uvlNavItem ) {
362363 var observer = new MutationObserver ( function ( ) {
363364 if ( ! uvlNavItem . classList . contains ( 'current' ) ) return ;
364- var goingForward = navItems [ 0 ] . classList . contains ( 'completed' ) ;
365365 setTimeout ( function ( ) {
366366 var instance = KTStepper . getInstance ( stepperEl ) ;
367367 if ( ! instance ) return ;
368- goingForward ? instance . goNext ( ) : instance . goPrevious ( ) ;
368+ var currentStep = typeof instance . getCurrentStepIndex === 'function'
369+ ? instance . getCurrentStepIndex ( )
370+ : null ;
371+ var previousStep = typeof instance . getPreviousStepIndex === 'function'
372+ ? instance . getPreviousStepIndex ( )
373+ : null ;
374+ var goingForward = previousStep === null || currentStep === null
375+ ? true
376+ : previousStep < currentStep ;
377+ goingForward ? instance . goTo ( 3 ) : instance . goTo ( 1 ) ;
369378 } , 0 ) ;
370379 } ) ;
371380 observer . observe ( uvlNavItem , { attributes : true , attributeFilter : [ 'class' ] } ) ;
@@ -375,6 +384,7 @@ <h2 class="fw-bold text-gray-900">{% if is_edit %}Save dataset{% else %}Upload d
375384 // ── 2. Interceptar submit para edición ──────────────────────────────
376385 var submitBtn = document . querySelector ( '[data-kt-stepper-action="submit"]' ) ;
377386 var continueBtn = document . querySelector ( '[data-kt-stepper-action="next"]' ) ;
387+ var previousBtn = document . querySelector ( '[data-kt-stepper-action="previous"]' ) ;
378388 var errorContainer = document . getElementById ( 'upload-error' ) ;
379389 var datasetId = { { dataset . id | tojson if dataset else 'null' } } ;
380390 var editUrl = { { url_for ( 'dataset.edit_metadata' , dataset_id = dataset . id ) | tojson if dataset else 'null' } } ;
@@ -480,6 +490,36 @@ <h2 class="fw-bold text-gray-900">{% if is_edit %}Save dataset{% else %}Upload d
480490 return '' ;
481491 }
482492
493+ function getStepperInstance ( ) {
494+ return stepperEl ? KTStepper . getInstance ( stepperEl ) : null ;
495+ }
496+
497+ if ( continueBtn ) {
498+ continueBtn . addEventListener ( 'click' , function ( e ) {
499+ var stepperInstance = getStepperInstance ( ) ;
500+ var currentStep = stepperInstance ? stepperInstance . getCurrentStepIndex ( ) : null ;
501+
502+ if ( stepperInstance && currentStep === 1 ) {
503+ e . preventDefault ( ) ;
504+ e . stopImmediatePropagation ( ) ;
505+ stepperInstance . goTo ( 3 ) ;
506+ }
507+ } , true ) ;
508+ }
509+
510+ if ( previousBtn ) {
511+ previousBtn . addEventListener ( 'click' , function ( e ) {
512+ var stepperInstance = getStepperInstance ( ) ;
513+ var currentStep = stepperInstance ? stepperInstance . getCurrentStepIndex ( ) : null ;
514+
515+ if ( stepperInstance && currentStep === 3 ) {
516+ e . preventDefault ( ) ;
517+ e . stopImmediatePropagation ( ) ;
518+ stepperInstance . goTo ( 1 ) ;
519+ }
520+ } , true ) ;
521+ }
522+
483523 if ( submitBtn && datasetId ) {
484524 var authorsContainer = document . getElementById ( 'authors-container' ) ;
485525 if ( authorsContainer && existingAuthors . length ) {
@@ -659,19 +699,19 @@ <h2 class="fw-bold text-gray-900">{% if is_edit %}Save dataset{% else %}Upload d
659699 < div class = "row mb-3" >
660700 < div class = "col-md-6" >
661701 < label class = "form-label" > Name *</ label >
662- < input type = "text" name = "authors[[index]][name ]" class = "form-control author-name" value = "[[name]]" required >
702+ < input type = "text" name = "[[nameField] ]" class = "form-control author-name" value = "[[name]]" required >
663703 < div class = "invalid-feedback" > </ div >
664704 </ div >
665705 < div class = "col-md-6" >
666706 < label class = "form-label" > Affiliation</ label >
667- < input type = "text" name = "authors[[index]][affiliation ]" class = "form-control author-affiliation" value = "[[affiliation]]" >
707+ < input type = "text" name = "[[affiliationField] ]" class = "form-control author-affiliation" value = "[[affiliation]]" >
668708 < div class = "invalid-feedback" > </ div >
669709 </ div >
670710 </ div >
671711 < div class = "row mb-3" >
672712 < div class = "col-md-12" >
673713 < label class = "form-label" > ORCID</ label >
674- < input type = "text" name = "authors[[index]][orcid ]" class = "form-control orcid-input" value = "[[orcid]]" >
714+ < input type = "text" name = "[[orcidField] ]" class = "form-control orcid-input" value = "[[orcid]]" >
675715 < div class = "invalid-feedback" > </ div >
676716 </ div >
677717 </ div >
0 commit comments