Refactor getSignatureNavState for robustness
Updated `getSignatureNavState` to handle cases where the global signature list (`_allSignatures`) is unavailable or empty by introducing an early return with a default state. Revised the logic to calculate `total`, `signed`, and `unsigned` using the global signature list, simplifying the `currentIndex` calculation to use the `signed` count. Updated `canGoPrev` and `canGoNext` to reflect the presence of signed or unsigned signatures. Removed outdated logic relying on `signatureButtons` and added Turkish comments to clarify the new implementation.
This commit is contained in:
@@ -462,23 +462,30 @@ window.pdfViewer = {
|
|||||||
* @returns {object} { total, signed, unsigned, currentIndex, canGoPrev, canGoNext }
|
* @returns {object} { total, signed, unsigned, currentIndex, canGoPrev, canGoNext }
|
||||||
*/
|
*/
|
||||||
getSignatureNavState() {
|
getSignatureNavState() {
|
||||||
const total = this.signatureButtons.length + this.appliedSignatures.length;
|
// Global imza listesi yoksa bo? state dön
|
||||||
const signed = this.appliedSignatures.length;
|
if (!this._allSignatures || this._allSignatures.length === 0) {
|
||||||
const unsigned = this.signatureButtons.length;
|
return {
|
||||||
|
total: 0,
|
||||||
// Find index of first unsigned signature button (if any)
|
signed: 0,
|
||||||
let currentIndex = -1;
|
unsigned: 0,
|
||||||
if (unsigned > 0) {
|
currentIndex: -1,
|
||||||
currentIndex = signed; // 0-based index of next signature to sign
|
canGoPrev: false,
|
||||||
|
canGoNext: false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TÜM sayfalardaki imzalar? say (database'den gelen global liste)
|
||||||
|
const total = this._allSignatures.length; // Global: Toplam imza say?s?
|
||||||
|
const signed = this.appliedSignatures.length; // ?mzalananlar
|
||||||
|
const unsigned = total - signed; // Hesaplanan: ?mzalanmayanlar
|
||||||
|
|
||||||
return {
|
return {
|
||||||
total: total,
|
total: total,
|
||||||
signed: signed,
|
signed: signed,
|
||||||
unsigned: unsigned,
|
unsigned: unsigned,
|
||||||
currentIndex: currentIndex,
|
currentIndex: signed, // Sonraki imzan?n index'i
|
||||||
canGoPrev: signed > 0, // Can go to previous applied signature
|
canGoPrev: signed > 0, // En az 1 imza uygulanm?? m??
|
||||||
canGoNext: unsigned > 0 // Can go to next unsigned signature
|
canGoNext: unsigned > 0 // Hala imzalanmam?? var m??
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user