Move SignRequestStatus from lib/Db/ to lib/Enum/ to follow project
convention of keeping all enums in a dedicated folder alongside
CRLStatus, CRLReason, CertificateType, and DocMdpLevel.
Updated namespace from OCA\Libresign\Db to OCA\Libresign\Enum and
adjusted all imports and references across:
- SignRequest entity (added import)
- ValidateHelper (updated FQN references)
- RequestSignatureService (updated FQN references)
- SequentialSigningService (updated import)
- SignFileService (updated FQN reference)
This improves code organization by consolidating all enum types in
one location.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add FileStatus backed enum to provide compile-time type safety for file
status values. This replaces the previous int-based approach with a
proper enum that:
- Eliminates the need for default fallback in match expressions
- Provides IDE autocomplete for all valid status values
- Throws ValueError for invalid status codes instead of silently
returning unknown status
- Accepts both int and FileStatus for backward compatibility
Updated getTextOfStatus() to use FileStatus enum with automatic
conversion from int via FileStatus::from(). Removed null return type
as status column is NOT NULL in database, ensuring statusText is
always a string.
This improves code maintainability and prevents invalid status values
from being used throughout the codebase.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Update OpenAPI spec and TypeScript types to reflect changes in
LibresignNextcloudFile response type with status, statusText, and
created_at fields.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Update psalm type to reflect the actual fields returned by the
file upload endpoint: status, statusText, and created_at instead
of etag, path, and type.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Return status, statusText and created_at in the API response after
file upload to display immediately in the files list without needing
to reload. Also removed unused etag, path and type fields.
Uses FileMapper to get status text and returns FileEntity directly
from save() method instead of additional database query.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
- Add postSchemaChange method to migrate existing data
- Set status = 2 (SIGNED) when signed IS NOT NULL
- Set status = 1 (ABLE_TO_SIGN) when signed IS NULL and file.status = 1
- Status 0 (DRAFT) remains as default
- Only update records with status = 0 to avoid overwriting
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Since the 'libresign:visible-elements-saved' event is no longer
emitted on draft saves, the event listeners and related methods
in Request.vue and FilesList.vue are no longer needed.
- Removed subscribe/unsubscribe calls
- Removed closeSidebar() methods
- Removed unused imports from @nextcloud/event-bus
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
The 'libresign:visible-elements-saved' event was being emitted when
saving draft signatures, causing the sidebar to close unexpectedly.
This event should only be emitted when sending signature requests,
not when saving drafts.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
When filters are applied but return no results, the empty state
now displays 'No documents found' without the request button or
'Choose the file to request signatures' text.
This provides better UX by distinguishing between:
- No documents in the system (shows request button)
- Filters with no matches (shows only message)
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
When clicking directly on the toggle button icon, the event was
not properly triggering the expand/collapse action. This fix adds
@click.stop to the NcButton to ensure the toggle action is executed
and prevents event bubbling issues.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add test cases for Portuguese text with accents to verify that the
multibyte-safe wordwrap implementation correctly handles text with
diacritical marks and other Unicode characters in signature images.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
The native PHP wordwrap() function does not handle multibyte characters
correctly, causing text with accents, CJK characters, or emojis to be
wrapped at incorrect positions.
This commit introduces mbWordwrap(), a custom implementation that uses
mb_strlen() and mb_substr() to properly handle UTF-8 and multibyte
text wrapping in signature images.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Auto-generated update of OpenAPI schemas to include the signingOrder
field in NewSigner and Signer types.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
When multiple signers have the same signingOrder value, they should
maintain their insertion order (defined by signRequestId) rather than
being sorted alphabetically by displayName.
This change ensures that when signingOrder is equal, signers are
sorted by signRequestId (which is auto-incrementing) instead of
displayName, preserving the order in which they were originally added.
Fixes Behat integration test failures where tests expected signers
to appear in insertion order.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add signingOrder field to LibresignSigner and LibresignNewSigner
schemas to support ordered signature flow in API documentation.
This fixes OpenAPI validation errors in API tests that were failing
because the signingOrder field was being returned but not defined
in the schema.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Update Behat test to use correct endpoint URL and parameter name:
- Changed from '/api/v1/admin/signature-flow' to '/api/v1/admin/signature-flow/config'
- Changed parameter from 'flow' to 'mode'
This aligns with the actual AdminController endpoint implementation.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
In ordered_numeric signature flow, all signers were receiving
notifications regardless of their status. This caused signers
with signing_order > 1 (status DRAFT) to be notified immediately.
Changes:
- Update SignRequest status on PATCH operations, not just INSERT
- Only notify signers when status is ABLE_TO_SIGN
- Ensure signers with order > 1 remain in DRAFT status until
previous orders are completed
This ensures notifications are sent only to signers who can
actually sign at that moment.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add NcActionInput for manual signing order entry with dual-mode
behavior: updateSigningOrder for visual reordering during typing,
confirmSigningOrder for normalization and persistence on submit/blur.
Implement debounced auto-save (1000ms) after drag-and-drop or manual
order changes. Listen to signing-order-changed event from Signers
component using Vue $emit pattern.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Integrate vuedraggable to enable drag-and-drop reordering when in
ordered_numeric mode. Track originalOrders during drag operations,
recalculate signingOrder using shared mixin logic, emit
signing-order-changed event to trigger auto-save. Include CSS
animations and visual feedback for drag states.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Display counter-number badge with highlighted style when in
ordered_numeric mode. Show DragVertical icon handle when drag-and-drop
is enabled. Add closeActions method to programmatically close action
menu after input submission.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Auto-assign incrementing signingOrder to new signers in ordered_numeric
mode. When deleting a signer, decrement signingOrder of subsequent
signers to close gaps and maintain sequential ordering.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add signingOrderMixin.js with recalculateSigningOrders and
normalizeSigningOrders methods to centralize signing order
calculations and normalization logic used by both drag-and-drop
and manual input components.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Include signingOrder field in signer data returned by FileService.
Sort signers by signingOrder (ascending) and displayName as secondary
sort to maintain consistent ordering in the UI.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add signature_flow to initial state in PageController and
TemplateLoader to enable frontend components to access the
current signature flow mode (parallel or ordered_numeric).
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Install vuedraggable v2.24.3 to enable drag-and-drop
functionality for signing order management in sequential
signature flows.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Regenerate OpenAPI documentation files to include the new
signature flow configuration endpoint.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Create SignatureFlow.vue component for admin settings to configure
signing order mode. Administrators can choose between:
- Simultaneous (Parallel): all signers receive at the same time
- Sequential: signers organized by order number
The component follows the same pattern as other admin settings
(DocMDP) with radio buttons, loading states, and error handling.
Integrated into Settings.vue admin panel.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add setSignatureFlowConfig() method to AdminController to allow
administrators to configure the signature flow mode (parallel or
ordered_numeric). The endpoint validates the mode using the
SignatureFlow enum and deletes the config key when parallel mode
is selected (as it's the default).
Endpoint: POST /api/v1/admin/signature-flow/config
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add __call callbacks to SignRequest mocks in both tests to properly return
fileId and signingOrder values. Without these callbacks, the mocks were
returning null when these magic methods were called, causing
SequentialSigningService::releaseNextOrder() to fail with a TypeError.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
- Add reorderAfterDeletion method to SequentialSigningService
- Automatically activate next order when a signer is deleted
- Prevents gaps in signing sequence that would block workflow
- Call reorderAfterDeletion in unassociateToUser after deletion
- Ensures sequential flow continues even when signers are removed
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
- Add getFileId and getSigningOrder to __call callback mocks
- Return 1 for both methods in tests
- Fixes TypeError when releaseNextOrder is called with null fileId
- All 12 affected tests now pass
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
- Add SequentialSigningService mock in RequestSignatureServiceTest
- Add SequentialSigningService mock in SignFileServiceTest
- Update constructor calls in both test files to include new dependency
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>