@fluxhub/fluxhub-lib 19.0.221 → 19.0.223

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32289,6 +32289,36 @@ class FHWorkflowForm {
32289
32289
  step_tasks = [];
32290
32290
  tasks_all_done = false;
32291
32291
  b_tasks_loading = false;
32292
+ /**
32293
+ * Editabilita' dei campi legati a un task, indicizzata per `check_key`.
32294
+ *
32295
+ * <FHTextInput [enabled]="task_edit['100_ATTESA_ACCONTO']" ...>
32296
+ *
32297
+ * E' una MAPPA e non un metodo perche' i template la interrogano a ogni change
32298
+ * detection: un metodo verrebbe rieseguito ogni volta (vedi la regola sui getter
32299
+ * dinamici). Viene ricalcolata da `load_step_tasks()`, cioe' all'apertura del documento
32300
+ * e dopo ogni presa in carico, chiusura o riapertura: esattamente gli eventi che possono
32301
+ * cambiare la risposta.
32302
+ *
32303
+ * Chiave assente = false (nessun task con quella `check_key` nello step corrente).
32304
+ */
32305
+ task_edit = {};
32306
+ /**
32307
+ * Avanzamento innescato dalla chiusura dell'ultimo task, non da un click su Procedi.
32308
+ *
32309
+ * L'utente ha gia' confermato nel pannello delle attivita' ("questa e' l'ultima
32310
+ * attivita' obbligatoria: vuoi procedere?"), quindi il dialog "Conferma Avanzamento"
32311
+ * del motore sarebbe una seconda domanda sulla stessa cosa: lo saltiamo, come se
32312
+ * l'utente avesse premuto OK. Consumato (rimesso a false) al primo uso.
32313
+ */
32314
+ auto_advance = false;
32315
+ /**
32316
+ * L'utente ha appena chiuso un task dal pannello (dove ha gia' confermato). Distingue
32317
+ * l'avanzamento "appena confermato" da quello di RECUPERO che scatta riaprendo un
32318
+ * documento rimasto fermo con tutti i task chiusi: li' nessuno ha confermato nulla, e
32319
+ * il dialog del motore va mostrato.
32320
+ */
32321
+ advance_confirmed = false;
32292
32322
  /**
32293
32323
  * Validazione applicativa alla chiusura di un task.
32294
32324
  * La libreria non conosce i campi della pratica: il componente concreto fa
@@ -32835,6 +32865,14 @@ class FHWorkflowForm {
32835
32865
  sp = sp + ';';
32836
32866
  sp = sp + arrAutori[i].nc;
32837
32867
  }
32868
+ // Avanzamento automatico: l'utente ha gia' confermato chiudendo l'ultimo task.
32869
+ // Facciamo cio' che farebbe l'OK del dialog, senza mostrarlo.
32870
+ if (this.auto_advance) {
32871
+ this.auto_advance = false;
32872
+ UtilityService.dlog('[TASK] auto_advance: salto Conferma Avanzamento, exec_wkf()');
32873
+ this.exec_wkf(o, this.nlevel, arrAutori, '', this.transizione_info.create_ver, arr_aut_all);
32874
+ return;
32875
+ }
32838
32876
  let dialogRef = this.m_dialog.open(win_conferma_v2, {
32839
32877
  disableClose: true,
32840
32878
  width: '500px',
@@ -32879,6 +32917,17 @@ class FHWorkflowForm {
32879
32917
  this.app_s.getState().wkf_doc_info.utenti = sp;
32880
32918
  this.app_s.getState().wkf_doc_info.comm_notrequired = this.transizione_info.comments_opt;
32881
32919
 
32920
+ // Vedi sopra: con l'avanzamento automatico l'utente ha gia' confermato.
32921
+ if (this.auto_advance) {
32922
+ this.auto_advance = false;
32923
+ this.app_s.temp_var4 = '';
32924
+ UtilityService.dlog('[TASK] auto_advance: salto Conferma Avanzamento, OKCOM()');
32925
+ this.arrUsersSelected = arrAutori;
32926
+ this.nota = '';
32927
+ this.OKCOM();
32928
+ return;
32929
+ }
32930
+
32882
32931
  let dialogRef = this.m_dialog.open(win_conferma_v2, {
32883
32932
  disableClose: true,
32884
32933
  width: '500px',
@@ -34428,6 +34477,7 @@ class FHWorkflowForm {
34428
34477
  return;
34429
34478
  this.step_tasks = (data.result_data || []).map((t) => ({
34430
34479
  ...t,
34480
+ step: Number(t.step || 0),
34431
34481
  stato: Number(t.stato || 0),
34432
34482
  required: Number(t.required || 0),
34433
34483
  note_required: Number(t.note_required || 0),
@@ -34436,6 +34486,7 @@ class FHWorkflowForm {
34436
34486
  mine: Number(t.mine || 0),
34437
34487
  }));
34438
34488
  this.recompute_tasks_done();
34489
+ this.recompute_task_edit();
34439
34490
  // I portali che denormalizzano lo stato dei task in colonne proprie si
34440
34491
  // riallineano qui: apertura documento, presa in carico, chiusura, riapertura.
34441
34492
  this.after_task_change();
@@ -34454,19 +34505,29 @@ class FHWorkflowForm {
34454
34505
  b_saving: this.b_saving,
34455
34506
  btnprocedi: this.btnprocedi,
34456
34507
  });
34508
+ // NB: non si guarda `btnprocedi`. Quel flag dice "avanzamento gia' tentato" e
34509
+ // viene azzerato solo da evt_salv(): se un tentativo precedente non e' arrivato
34510
+ // in fondo (es. dialog di scelta transizione chiuso con la X) resta true per
34511
+ // sempre e bloccherebbe ogni tentativo successivo -- cioe' proprio il caso che
34512
+ // questo avanzamento automatico deve sbloccare. Il vero "in volo" e' b_saving.
34513
+ // Consumato comunque: se il task chiuso non era l'ultimo, non deve restare acceso
34514
+ // per un avanzamento futuro (magari il recupero all'apertura).
34515
+ const confermato = this.advance_confirmed;
34516
+ this.advance_confirmed = false;
34457
34517
  if (this.step_mode == 'T' &&
34458
34518
  this.tasks_all_done &&
34459
34519
  this.b_edit &&
34460
- !this.b_saving &&
34461
- !this.btnprocedi) {
34462
- UtilityService.dlog('[TASK] -> avanzamento automatico: chiamo procedi()');
34520
+ !this.b_saving) {
34521
+ UtilityService.dlog('[TASK] -> avanzamento automatico', {
34522
+ gia_confermato_dall_utente: confermato,
34523
+ });
34524
+ this.auto_advance = confermato;
34463
34525
  this.procedi();
34464
34526
  }
34465
34527
  else if (this.step_mode == 'T' && this.tasks_all_done) {
34466
34528
  UtilityService.dlog('[TASK] tutti i task chiusi ma NON avanzo', {
34467
34529
  b_edit: this.b_edit,
34468
34530
  b_saving: this.b_saving,
34469
- btnprocedi: this.btnprocedi,
34470
34531
  });
34471
34532
  }
34472
34533
  },
@@ -34475,6 +34536,45 @@ class FHWorkflowForm {
34475
34536
  },
34476
34537
  });
34477
34538
  }
34539
+ /**
34540
+ * Un campo legato a questo task e' editabile adesso, da questo utente?
34541
+ *
34542
+ * Vero solo se TUTTE queste condizioni reggono:
34543
+ * - lo step corrente e' in modalita' task;
34544
+ * - esiste un task con quella `check_key` E APPARTIENE ALLO STEP CORRENTE: due step
34545
+ * diversi possono avere task con la stessa chiave, e la lista in memoria potrebbe
34546
+ * essere di uno step gia' lasciato (l'avanzamento e' asincrono);
34547
+ * - il task e' ANCORA APERTO (chiuso = dati congelati; per correggere si riapre);
34548
+ * - il task e' PRESO IN CARICO DA TE (`mine`): chi non l'ha preso non tocca i campi,
34549
+ * nemmeno se ha il ruolo giusto -- e' il senso della presa in carico;
34550
+ * - il task non e' BLOCCATO da una dipendenza ancora aperta;
34551
+ * - il documento non e' in uno stato finale (>= 900).
34552
+ *
34553
+ * Non richiede `b_edit`: l'autore dello step e l'esecutore di un task possono essere
34554
+ * persone diverse. E' la presa in carico a dare il diritto di scrittura sui campi
34555
+ * di quel task.
34556
+ */
34557
+ task_editable(check_key) {
34558
+ if (this.step_mode != 'T' || !check_key)
34559
+ return false;
34560
+ const stato = Number(this.m_obj?.stato);
34561
+ if (!isNaN(stato) && stato >= 900)
34562
+ return false;
34563
+ const t = this.step_tasks.find((x) => x.check_key === check_key && Number(x.step) === stato);
34564
+ if (t == null)
34565
+ return false;
34566
+ return t.stato == 0 && Number(t.mine || 0) == 1 && !t.locked;
34567
+ }
34568
+ /** Ricostruisce la mappa `task_edit` (una entry per ogni task con `check_key`). */
34569
+ recompute_task_edit() {
34570
+ const m = {};
34571
+ for (const t of this.step_tasks) {
34572
+ if (!t.check_key)
34573
+ continue;
34574
+ m[t.check_key] = this.task_editable(t.check_key);
34575
+ }
34576
+ this.task_edit = m;
34577
+ }
34478
34578
  /** Tutti i task OBBLIGATORI chiusi? I facoltativi non bloccano l'avanzamento. */
34479
34579
  recompute_tasks_done() {
34480
34580
  const req = this.step_tasks.filter((t) => t.required == 1);
@@ -34577,6 +34677,9 @@ class FHWorkflowForm {
34577
34677
  UtilityService.dlog('[TASK] close_task: STOP, ck_task', errs);
34578
34678
  return false;
34579
34679
  }
34680
+ // La chiusura parte dal pannello, dove l'utente ha gia' confermato se era l'ultima
34681
+ // attivita' obbligatoria. Se ne segue un avanzamento, non gli si richiede conferma.
34682
+ this.advance_confirmed = true;
34580
34683
  const p = new QParam();
34581
34684
  p.sql = 'CLOSE_WKF_DOC_TASK';
34582
34685
  p.values = [
@@ -34664,6 +34767,10 @@ class FHWorkflowForm {
34664
34767
  s_uto = '';
34665
34768
  b_respingi_button = false;
34666
34769
  return_edit() {
34770
+ // Il documento e' stato caricato in modifica: nessun avanzamento e' in volo.
34771
+ // `btnprocedi` viene altrimenti azzerato solo da evt_salv(), quindi un procedi()
34772
+ // interrotto a meta' (dialog chiuso con la X) lo lascerebbe true per sempre.
34773
+ this.btnprocedi = false;
34667
34774
  this.respingi_enabled = false;
34668
34775
  this.b_respingi_button = false;
34669
34776
  if ((this.app_info.proceed_mode || 'P') == 'R')
@@ -34724,6 +34831,7 @@ class FHWorkflowForm {
34724
34831
  else {
34725
34832
  this.step_tasks = [];
34726
34833
  this.tasks_all_done = false;
34834
+ this.task_edit = {};
34727
34835
  }
34728
34836
  }
34729
34837
  });