diff --git a/lib/core/widgets/dialog_utils/unsaved_changes_warning_dialog.dart b/lib/core/widgets/dialog_utils/unsaved_changes_warning_dialog.dart index 8846031..fc80bd9 100644 --- a/lib/core/widgets/dialog_utils/unsaved_changes_warning_dialog.dart +++ b/lib/core/widgets/dialog_utils/unsaved_changes_warning_dialog.dart @@ -9,14 +9,12 @@ class UnsavedChangesWarningDialog extends StatelessWidget { @override Widget build(BuildContext context) { return AlertDialog( - title: Text("Discard changes?"), - content: Text( - "You have unsaved changes. Do you want to continue without saving? Your changes will be discarded.", - ), + title: Text(S.of(context)!.discardChanges), + content: Text(S.of(context)!.discardChangesWarning), actions: [ - DialogCancelButton(), + const DialogCancelButton(), DialogConfirmButton( - label: S.of(context)!.continueLabel, + label: S.of(context)!.discard, ), ], ); diff --git a/lib/features/document_details/cubit/document_details_cubit.dart b/lib/features/document_details/cubit/document_details_cubit.dart index d17b5d4..66ab41c 100644 --- a/lib/features/document_details/cubit/document_details_cubit.dart +++ b/lib/features/document_details/cubit/document_details_cubit.dart @@ -44,7 +44,6 @@ class DocumentDetailsCubit extends Cubit { ), ), ); - loadMetaData(); } Future delete(DocumentModel document) async { @@ -60,13 +59,10 @@ class DocumentDetailsCubit extends Cubit { } Future loadFullContent() async { + await Future.delayed(const Duration(seconds: 5)); final doc = await _api.find(state.document.id); - emit( - state.copyWith( - isFullContentLoaded: true, - fullContent: doc.content, - ), - ); + _notifier.notifyUpdated(doc); + emit(state.copyWith(isFullContentLoaded: true)); } Future assignAsn( diff --git a/lib/features/document_details/cubit/document_details_state.dart b/lib/features/document_details/cubit/document_details_state.dart index 6bcf0e7..d24a593 100644 --- a/lib/features/document_details/cubit/document_details_state.dart +++ b/lib/features/document_details/cubit/document_details_state.dart @@ -6,7 +6,6 @@ class DocumentDetailsState with _$DocumentDetailsState { required DocumentModel document, DocumentMetaData? metaData, @Default(false) bool isFullContentLoaded, - String? fullContent, @Default({}) Map correspondents, @Default({}) Map documentTypes, @Default({}) Map tags, diff --git a/lib/features/document_details/view/pages/document_details_page.dart b/lib/features/document_details/view/pages/document_details_page.dart index fa8cb07..650fd6e 100644 --- a/lib/features/document_details/view/pages/document_details_page.dart +++ b/lib/features/document_details/view/pages/document_details_page.dart @@ -239,7 +239,6 @@ class _DocumentDetailsPageState extends State { DocumentContentWidget( isFullContentLoaded: state.isFullContentLoaded, document: state.document, - fullContent: state.fullContent, queryString: widget.titleAndContentQueryString, ), ], @@ -302,22 +301,16 @@ class _DocumentDetailsPageState extends State { if (!canEdit) { return const SizedBox.shrink(); } - return BlocBuilder( - builder: (context, state) { - // final _filteredSuggestions = - // state.suggestions?.documentDifference(state.document); - - return Tooltip( - message: S.of(context)!.editDocumentTooltip, - preferBelow: false, - verticalOffset: 40, - child: FloatingActionButton( - heroTag: "fab_document_details", - child: const Icon(Icons.edit), - onPressed: () => EditDocumentRoute(state.document).push(context), - ), - ); - }, + final document = context.read().state.document; + return Tooltip( + message: S.of(context)!.editDocumentTooltip, + preferBelow: false, + verticalOffset: 40, + child: FloatingActionButton( + heroTag: "fab_document_details", + child: const Icon(Icons.edit), + onPressed: () => EditDocumentRoute(document).push(context), + ), ); } diff --git a/lib/features/document_details/view/widgets/document_content_widget.dart b/lib/features/document_details/view/widgets/document_content_widget.dart index 82f34f4..6516658 100644 --- a/lib/features/document_details/view/widgets/document_content_widget.dart +++ b/lib/features/document_details/view/widgets/document_content_widget.dart @@ -2,44 +2,50 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:paperless_api/paperless_api.dart'; import 'package:paperless_mobile/core/widgets/highlighted_text.dart'; +import 'package:paperless_mobile/core/widgets/shimmer_placeholder.dart'; +import 'package:paperless_mobile/extensions/flutter_extensions.dart'; import 'package:paperless_mobile/features/document_details/cubit/document_details_cubit.dart'; import 'package:paperless_mobile/generated/l10n/app_localizations.dart'; class DocumentContentWidget extends StatelessWidget { final bool isFullContentLoaded; - final String? fullContent; final String? queryString; final DocumentModel document; const DocumentContentWidget({ super.key, required this.isFullContentLoaded, - this.fullContent, required this.document, this.queryString, }); @override Widget build(BuildContext context) { + final screenWidth = MediaQuery.sizeOf(context).width; return SliverToBoxAdapter( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ HighlightedText( - text: (isFullContentLoaded ? fullContent : document.content) ?? "", + text: document.content ?? '', highlights: queryString != null ? queryString!.split(" ") : [], style: Theme.of(context).textTheme.bodyMedium, caseSensitive: false, ), - if (!isFullContentLoaded && (document.content ?? '').isNotEmpty) - Align( - alignment: Alignment.bottomCenter, - child: TextButton( - child: Text(S.of(context)!.loadFullContent), - onPressed: () { - context.read().loadFullContent(); - }, + if (!isFullContentLoaded) + ShimmerPlaceholder( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + for (var scale in [0.5, 0.9, 0.5, 0.8, 0.9, 0.9]) + Container( + margin: const EdgeInsets.symmetric(vertical: 4), + width: screenWidth * scale, + height: 14, + color: Colors.white, + ), + ], ), - ), + ).paddedOnly(top: 4), ], ), ); diff --git a/lib/features/document_edit/cubit/document_edit_cubit.dart b/lib/features/document_edit/cubit/document_edit_cubit.dart index 84195dd..3003264 100644 --- a/lib/features/document_edit/cubit/document_edit_cubit.dart +++ b/lib/features/document_edit/cubit/document_edit_cubit.dart @@ -25,12 +25,19 @@ class DocumentEditCubit extends Cubit { _notifier.addListener(this, onUpdated: replace); _labelRepository.addListener( this, - onChanged: (labels) => emit(state.copyWith( - correspondents: labels.correspondents, - documentTypes: labels.documentTypes, - storagePaths: labels.storagePaths, - tags: labels.tags, - )), + onChanged: (labels) { + if (isClosed) { + return; + } + emit( + state.copyWith( + correspondents: labels.correspondents, + documentTypes: labels.documentTypes, + storagePaths: labels.storagePaths, + tags: labels.tags, + ), + ); + }, ); } diff --git a/lib/features/document_edit/view/document_edit_page.dart b/lib/features/document_edit/view/document_edit_page.dart index 976d4bb..2b6d98e 100644 --- a/lib/features/document_edit/view/document_edit_page.dart +++ b/lib/features/document_edit/view/document_edit_page.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; @@ -8,18 +9,18 @@ import 'package:go_router/go_router.dart'; import 'package:intl/intl.dart'; import 'package:paperless_api/paperless_api.dart'; import 'package:paperless_mobile/core/database/tables/local_user_account.dart'; -import 'package:paperless_mobile/core/repository/label_repository.dart'; +import 'package:paperless_mobile/core/notifier/document_changed_notifier.dart'; +import 'package:paperless_mobile/core/widgets/dialog_utils/dialog_cancel_button.dart'; import 'package:paperless_mobile/core/widgets/dialog_utils/pop_with_unsaved_changes.dart'; import 'package:paperless_mobile/core/workarounds/colored_chip.dart'; import 'package:paperless_mobile/extensions/flutter_extensions.dart'; import 'package:paperless_mobile/features/document_edit/cubit/document_edit_cubit.dart'; -import 'package:paperless_mobile/features/edit_label/view/impl/add_correspondent_page.dart'; -import 'package:paperless_mobile/features/edit_label/view/impl/add_document_type_page.dart'; -import 'package:paperless_mobile/features/edit_label/view/impl/add_storage_path_page.dart'; import 'package:paperless_mobile/features/labels/tags/view/widgets/tags_form_field.dart'; import 'package:paperless_mobile/features/labels/view/widgets/label_form_field.dart'; import 'package:paperless_mobile/generated/l10n/app_localizations.dart'; import 'package:paperless_mobile/helpers/message_helpers.dart'; +import 'package:paperless_mobile/routes/typed/branches/labels_route.dart'; +import 'package:paperless_mobile/routes/typed/shells/authenticated_route.dart'; class DocumentEditPage extends StatefulWidget { const DocumentEditPage({ @@ -39,18 +40,79 @@ class _DocumentEditPageState extends State { static const fkStoragePath = 'storagePath'; static const fkContent = 'content'; - final GlobalKey _formKey = GlobalKey(); + final _formKey = GlobalKey(); + + @override + void didUpdateWidget(covariant DocumentEditPage oldWidget) { + super.didUpdateWidget(oldWidget); + print("WIDGET CONFIGURATION CHANGED?!?!?"); + } @override Widget build(BuildContext context) { final currentUser = context.watch().paperlessUser; - return PopWithUnsavedChanges( - hasChangesPredicate: () => _formKey.currentState?.isDirty ?? false, - child: BlocBuilder( - builder: (context, state) { - final filteredSuggestions = state.suggestions?.documentDifference( - context.read().state.document); - return DefaultTabController( + return BlocConsumer( + listenWhen: (previous, current) => + previous.document.content != current.document.content, + listener: (context, state) { + final contentField = _formKey.currentState?.fields[fkContent]; + if (contentField == null) { + return; + } + if (contentField.isDirty) { + showDialog( + context: context, + builder: (context) => AlertDialog( + //TODO: INTL + title: Text("Content has changed!"), + content: Text( + "The content of this document has changed. This can happen if the full content was not yet loaded. By accepting the incoming changes, your changes will be overwritten and therefore lost! Do you want to discard your changes in favor of the full content?", + ), + actions: [ + DialogCancelButton(), + ElevatedButton( + onPressed: () { + contentField.didChange(state.document.content); + Navigator.of(context).pop(); + }, + child: Text(S.of(context)!.discard), + ), + ], + ), + ); + } else { + contentField.didChange(state.document.content); + } + }, + builder: (context, state) { + final filteredSuggestions = state.suggestions; + return PopWithUnsavedChanges( + hasChangesPredicate: () { + final fkState = _formKey.currentState; + if (fkState == null) { + return false; + } + final doc = state.document; + final ( + title, + correspondent, + documentType, + storagePath, + tags, + createdAt, + content + ) = _currentValues; + final isContentTouched = + _formKey.currentState?.fields[fkContent]?.isDirty ?? false; + return doc.title != title || + doc.correspondent != correspondent || + doc.documentType != documentType || + doc.storagePath != storagePath || + !const UnorderedIterableEquality().equals(doc.tags, tags) || + doc.created != createdAt || + (doc.content != content && isContentTouched); + }, + child: DefaultTabController( length: 2, child: Scaffold( resizeToAvoidBottomInset: false, @@ -95,13 +157,11 @@ class _DocumentEditPageState extends State { LabelFormField( showAnyAssignedOption: false, showNotAssignedOption: false, - addLabelPageBuilder: (initialValue) => - RepositoryProvider.value( - value: context.read(), - child: AddCorrespondentPage( - initialName: initialValue, - ), - ), + onAddLabel: (currentInput) => + CreateLabelRoute( + LabelType.correspondent, + name: currentInput, + ).push(context), addLabelText: S.of(context)!.addCorrespondent, labelText: S.of(context)!.correspondent, @@ -121,26 +181,10 @@ class _DocumentEditPageState extends State { allowSelectUnassigned: true, canCreateNewLabel: currentUser.canCreateCorrespondents, + suggestions: + filteredSuggestions?.correspondents ?? + [], ), - if (filteredSuggestions - ?.hasSuggestedCorrespondents ?? - false) - _buildSuggestionsSkeleton( - suggestions: - filteredSuggestions!.correspondents, - itemBuilder: (context, itemData) => - ActionChip( - label: Text(state - .correspondents[itemData]!.name), - onPressed: () { - _formKey.currentState - ?.fields[fkCorrespondent] - ?.didChange( - SetIdQueryParameter(id: itemData), - ); - }, - ), - ), ], ).padded(), // DocumentType form field @@ -150,13 +194,11 @@ class _DocumentEditPageState extends State { LabelFormField( showAnyAssignedOption: false, showNotAssignedOption: false, - addLabelPageBuilder: (currentInput) => - RepositoryProvider.value( - value: context.read(), - child: AddDocumentTypePage( - initialName: currentInput, - ), - ), + onAddLabel: (currentInput) => + CreateLabelRoute( + LabelType.documentType, + name: currentInput, + ).push(context), canCreateNewLabel: currentUser.canCreateDocumentTypes, addLabelText: @@ -172,24 +214,10 @@ class _DocumentEditPageState extends State { prefixIcon: const Icon(Icons.description_outlined), allowSelectUnassigned: true, + suggestions: + filteredSuggestions?.documentTypes ?? + [], ), - if (filteredSuggestions - ?.hasSuggestedDocumentTypes ?? - false) - _buildSuggestionsSkeleton( - suggestions: - filteredSuggestions!.documentTypes, - itemBuilder: (context, itemData) => - ActionChip( - label: Text(state - .documentTypes[itemData]!.name), - onPressed: () => _formKey.currentState - ?.fields[fkDocumentType] - ?.didChange( - SetIdQueryParameter(id: itemData), - ), - ), - ), ], ).padded(), // StoragePath form field @@ -199,12 +227,11 @@ class _DocumentEditPageState extends State { LabelFormField( showAnyAssignedOption: false, showNotAssignedOption: false, - addLabelPageBuilder: (initialValue) => - RepositoryProvider.value( - value: context.read(), - child: AddStoragePathPage( - initialName: initialValue), - ), + onAddLabel: (currentInput) => + CreateLabelRoute( + LabelType.storagePath, + name: currentInput, + ).push(context), canCreateNewLabel: currentUser.canCreateStoragePaths, addLabelText: S.of(context)!.addStoragePath, @@ -230,6 +257,7 @@ class _DocumentEditPageState extends State { allowOnlySelection: true, allowCreation: true, allowExclude: false, + suggestions: filteredSuggestions?.tags ?? [], initialValue: IdsTagsQuery( include: state.document.tags.toList(), ), @@ -239,40 +267,7 @@ class _DocumentEditPageState extends State { .difference(state.document.tags.toSet()) .isNotEmpty ?? false) - _buildSuggestionsSkeleton( - suggestions: - (filteredSuggestions?.tags.toSet() ?? {}), - itemBuilder: (context, itemData) { - final tag = state.tags[itemData]!; - return ActionChip( - label: Text( - tag.name, - style: TextStyle(color: tag.textColor), - ), - backgroundColor: tag.color, - onPressed: () { - final currentTags = _formKey.currentState - ?.fields[fkTags]?.value as TagsQuery; - _formKey.currentState?.fields[fkTags] - ?.didChange( - switch (currentTags) { - IdsTagsQuery( - include: var i, - exclude: var e - ) => - IdsTagsQuery( - include: [...i, itemData], - exclude: e, - ), - _ => IdsTagsQuery(include: [itemData]) - }, - ); - }, - ); - }, - ), - // Prevent tags from being hidden by fab - const SizedBox(height: 64), + const SizedBox(height: 64), ], ), SingleChildScrollView( @@ -295,45 +290,104 @@ class _DocumentEditPageState extends State { ), ), )), - ); - }, - ), + ), + ); + }, + ); + } + + bool _isFieldDirty(DocumentModel document) { + final fkState = _formKey.currentState; + if (fkState == null) { + return false; + } + fkState.save(); + final ( + title, + correspondent, + documentType, + storagePath, + tags, + createdAt, + content + ) = _currentValues; + return document.title != title || + document.correspondent != correspondent || + document.documentType != documentType || + document.storagePath != storagePath || + const UnorderedIterableEquality().equals(document.tags, tags) || + document.created != createdAt || + document.content != content; + } + + ( + String? title, + int? correspondent, + int? documentType, + int? storagePath, + List? tags, + DateTime? createdAt, + String? content, + ) get _currentValues { + final fkState = _formKey.currentState!; + + final correspondentParam = + fkState.getRawValue(fkCorrespondent); + final documentTypeParam = + fkState.getRawValue(fkDocumentType); + final storagePathParam = + fkState.getRawValue(fkStoragePath); + final tagsParam = fkState.getRawValue(fkTags); + final title = fkState.getRawValue(fkTitle); + final created = fkState.getRawValue(fkCreatedDate); + final correspondent = switch (correspondentParam) { + SetIdQueryParameter(id: var id) => id, + _ => null, + }; + final documentType = switch (documentTypeParam) { + SetIdQueryParameter(id: var id) => id, + _ => null, + }; + final storagePath = switch (storagePathParam) { + SetIdQueryParameter(id: var id) => id, + _ => null, + }; + final tags = switch (tagsParam) { + IdsTagsQuery(include: var i) => i, + _ => null, + }; + final content = fkState.getRawValue(fkContent); + + return ( + title, + correspondent, + documentType, + storagePath, + tags, + created, + content ); } Future _onSubmit(DocumentModel document) async { if (_formKey.currentState?.saveAndValidate() ?? false) { - final values = _formKey.currentState!.value; - - final correspondentParam = values[fkCorrespondent] as IdQueryParameter?; - final documentTypeParam = values[fkDocumentType] as IdQueryParameter?; - final storagePathParam = values[fkStoragePath] as IdQueryParameter?; - final tagsParam = values[fkTags] as TagsQuery?; - - final correspondent = switch (correspondentParam) { - SetIdQueryParameter(id: var id) => id, - _ => null, - }; - final documentType = switch (documentTypeParam) { - SetIdQueryParameter(id: var id) => id, - _ => null, - }; - final storagePath = switch (storagePathParam) { - SetIdQueryParameter(id: var id) => id, - _ => null, - }; - final tags = switch (tagsParam) { - IdsTagsQuery(include: var i) => i, - _ => null, - }; + final ( + title, + correspondent, + documentType, + storagePath, + tags, + createdAt, + content + ) = _currentValues; var mergedDocument = document.copyWith( - title: values[fkTitle], - created: values[fkCreatedDate], + title: title, + created: createdAt, correspondent: () => correspondent, documentType: () => documentType, storagePath: () => storagePath, tags: tags, - content: values[fkContent], + content: content, ); try { diff --git a/lib/features/document_upload/view/document_upload_preparation_page.dart b/lib/features/document_upload/view/document_upload_preparation_page.dart index 7f136bf..5770464 100644 --- a/lib/features/document_upload/view/document_upload_preparation_page.dart +++ b/lib/features/document_upload/view/document_upload_preparation_page.dart @@ -24,6 +24,8 @@ import 'package:paperless_mobile/features/labels/view/widgets/label_form_field.d import 'package:paperless_mobile/features/sharing/view/widgets/file_thumbnail.dart'; import 'package:paperless_mobile/generated/l10n/app_localizations.dart'; import 'package:paperless_mobile/helpers/message_helpers.dart'; +import 'package:paperless_mobile/routes/typed/branches/labels_route.dart'; +import 'package:paperless_mobile/routes/typed/shells/authenticated_route.dart'; import 'package:provider/provider.dart'; class DocumentUploadResult { @@ -251,19 +253,10 @@ class _DocumentUploadPreparationPageState LabelFormField( showAnyAssignedOption: false, showNotAssignedOption: false, - addLabelPageBuilder: (initialName) => - MultiProvider( - providers: [ - Provider.value( - value: context.read(), - ), - Provider.value( - value: context.read(), - ) - ], - child: AddCorrespondentPage( - initialName: initialName), - ), + onAddLabel: (initialName) => CreateLabelRoute( + LabelType.correspondent, + name: initialName, + ).push(context), addLabelText: S.of(context)!.addCorrespondent, labelText: S.of(context)!.correspondent + " *", name: DocumentModel.correspondentKey, @@ -283,19 +276,10 @@ class _DocumentUploadPreparationPageState LabelFormField( showAnyAssignedOption: false, showNotAssignedOption: false, - addLabelPageBuilder: (initialName) => - MultiProvider( - providers: [ - Provider.value( - value: context.read(), - ), - Provider.value( - value: context.read(), - ) - ], - child: AddDocumentTypePage( - initialName: initialName), - ), + onAddLabel: (initialName) => CreateLabelRoute( + LabelType.documentType, + name: initialName, + ).push(context), addLabelText: S.of(context)!.addDocumentType, labelText: S.of(context)!.documentType + " *", name: DocumentModel.documentTypeKey, diff --git a/lib/features/labels/tags/view/widgets/fullscreen_tags_form.dart b/lib/features/labels/tags/view/widgets/fullscreen_tags_form.dart index f9811ec..1fee66e 100644 --- a/lib/features/labels/tags/view/widgets/fullscreen_tags_form.dart +++ b/lib/features/labels/tags/view/widgets/fullscreen_tags_form.dart @@ -1,8 +1,11 @@ +import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:paperless_api/paperless_api.dart'; import 'package:paperless_mobile/extensions/flutter_extensions.dart'; import 'package:paperless_mobile/features/edit_label/view/impl/add_tag_page.dart'; import 'package:paperless_mobile/generated/l10n/app_localizations.dart'; +import 'package:paperless_mobile/routes/typed/branches/labels_route.dart'; +import 'package:paperless_mobile/routes/typed/shells/authenticated_route.dart'; class FullscreenTagsForm extends StatefulWidget { final TagsQuery? initialValue; @@ -46,7 +49,7 @@ class _FullscreenTagsFormState extends State { final value = widget.initialValue; if (value is IdsTagsQuery) { _include = value.include.toList(); - _exclude = value.include.toList(); + _exclude = value.exclude.toList(); } else if (value is AnyAssignedTagsQuery) { _include = value.tagIds.toList(); _anyAssigned = true; @@ -116,16 +119,26 @@ class _FullscreenTagsFormState extends State { icon: const Icon(Icons.done), onPressed: () { if (widget.allowOnlySelection) { - widget.onSubmit(returnValue: IdsTagsQuery(include: _include)); + widget.onSubmit( + returnValue: IdsTagsQuery( + include: + _include.sortedBy((id) => widget.options[id]!.name), + ), + ); return; } late final TagsQuery query; if (_notAssigned) { query = const NotAssignedTagsQuery(); } else if (_anyAssigned) { - query = AnyAssignedTagsQuery(tagIds: _include); + query = AnyAssignedTagsQuery( + tagIds: _include.sortedBy((id) => widget.options[id]!.name), + ); } else { - query = IdsTagsQuery(include: _include, exclude: _exclude); + query = IdsTagsQuery( + include: _include.sortedBy((id) => widget.options[id]!.name), + exclude: _exclude.sortedBy((id) => widget.options[id]!.name), + ); } widget.onSubmit(returnValue: query); }, @@ -191,13 +204,9 @@ class _FullscreenTagsFormState extends State { } void _onAddTag() async { - final createdTag = await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => AddTagPage( - initialName: _textEditingController.text, - ), - ), - ); + final createdTag = + await CreateLabelRoute(LabelType.tag, name: _textEditingController.text) + .push(context); _textEditingController.clear(); if (createdTag != null) { setState(() { @@ -308,21 +317,21 @@ class SelectableTagWidget extends StatelessWidget { @override Widget build(BuildContext context) { + final includeColor = Colors.green.withOpacity(0.3); + final excludeColor = Colors.red.withOpacity(0.3); return ListTile( title: Text(tag.name), - trailing: excluded - ? const Icon(Icons.close) - : (selected ? const Icon(Icons.done) : null), + trailing: Text(S.of(context)!.documentsAssigned(tag.documentCount ?? 0)), leading: CircleAvatar( backgroundColor: tag.color, - child: (tag.isInboxTag) - ? Icon( - Icons.inbox, - color: tag.textColor, - ) - : null, + child: tag.isInboxTag ? Icon(Icons.inbox, color: tag.textColor) : null, ), onTap: onTap, + tileColor: excluded + ? excludeColor + : selected + ? includeColor + : null, ); } } diff --git a/lib/features/labels/tags/view/widgets/tags_form_field.dart b/lib/features/labels/tags/view/widgets/tags_form_field.dart index f85b590..fc554f7 100644 --- a/lib/features/labels/tags/view/widgets/tags_form_field.dart +++ b/lib/features/labels/tags/view/widgets/tags_form_field.dart @@ -6,6 +6,7 @@ import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:paperless_api/paperless_api.dart'; import 'package:paperless_mobile/core/database/tables/local_user_account.dart'; import 'package:paperless_mobile/core/workarounds/colored_chip.dart'; +import 'package:paperless_mobile/extensions/flutter_extensions.dart'; import 'package:paperless_mobile/features/labels/tags/view/widgets/fullscreen_tags_form.dart'; import 'package:paperless_mobile/generated/l10n/app_localizations.dart'; @@ -16,6 +17,7 @@ class TagsFormField extends StatelessWidget { final bool allowOnlySelection; final bool allowCreation; final bool allowExclude; + final Iterable suggestions; const TagsFormField({ super.key, @@ -25,63 +27,120 @@ class TagsFormField extends StatelessWidget { required this.allowOnlySelection, required this.allowCreation, required this.allowExclude, + this.suggestions = const [], }); @override Widget build(BuildContext context) { + final enabled = options.values.isNotEmpty || allowCreation; + return FormBuilderField( initialValue: initialValue, + enabled: enabled, builder: (field) { final values = _generateOptions(context, field.value, field).toList(); final isEmpty = (field.value is IdsTagsQuery && (field.value as IdsTagsQuery).include.isEmpty) || field.value == null; bool anyAssigned = field.value is AnyAssignedTagsQuery; - return OpenContainer( - middleColor: Theme.of(context).colorScheme.background, - closedColor: Theme.of(context).colorScheme.background, - openColor: Theme.of(context).colorScheme.background, - closedShape: InputBorder.none, - openElevation: 0, - closedElevation: 0, - closedBuilder: (context, openForm) => Container( - margin: const EdgeInsets.only(top: 6), - child: GestureDetector( - onTap: openForm, - child: InputDecorator( - isEmpty: isEmpty, - decoration: InputDecoration( - contentPadding: const EdgeInsets.all(12), - labelText: - '${S.of(context)!.tags}${anyAssigned ? ' (${S.of(context)!.anyAssigned})' : ''}', - prefixIcon: const Icon(Icons.label_outline), - ), - child: SizedBox( - height: 32, - child: ListView.separated( - scrollDirection: Axis.horizontal, - separatorBuilder: (context, index) => - const SizedBox(width: 4), - itemBuilder: (context, index) => values[index], - itemCount: values.length, + + final displayedSuggestions = switch (field.value) { + IdsTagsQuery(include: var include) => + suggestions.toSet().difference(include.toSet()).toList(), + _ => [], + }; + return Column( + children: [ + OpenContainer( + middleColor: Theme.of(context).colorScheme.background, + closedColor: Theme.of(context).colorScheme.background, + openColor: Theme.of(context).colorScheme.background, + closedShape: InputBorder.none, + openElevation: 0, + closedElevation: 0, + tappable: enabled, + closedBuilder: (context, openForm) => Container( + margin: const EdgeInsets.only(top: 6), + child: GestureDetector( + onTap: openForm, + child: InputDecorator( + isEmpty: isEmpty, + decoration: InputDecoration( + contentPadding: const EdgeInsets.all(12), + labelText: + '${S.of(context)!.tags}${anyAssigned ? ' (${S.of(context)!.anyAssigned})' : ''}', + prefixIcon: const Icon(Icons.label_outline), + enabled: enabled, + ), + child: SizedBox( + height: 32, + child: ListView.separated( + scrollDirection: Axis.horizontal, + separatorBuilder: (context, index) => + const SizedBox(width: 4), + itemBuilder: (context, index) => values[index], + itemCount: values.length, + ), ), ), ), - )), - openBuilder: (context, closeForm) => FullscreenTagsForm( - options: options, - onSubmit: closeForm, - initialValue: field.value, - allowOnlySelection: allowOnlySelection, - allowCreation: allowCreation && - context.watch().paperlessUser.canCreateTags, - allowExclude: allowExclude, - ), - onClosed: (data) { - if (data != null) { - field.didChange(data); - } - }, + ), + openBuilder: (context, closeForm) => FullscreenTagsForm( + options: options, + onSubmit: closeForm, + initialValue: field.value, + allowOnlySelection: allowOnlySelection, + allowCreation: allowCreation && + context + .watch() + .paperlessUser + .canCreateTags, + allowExclude: allowExclude, + ), + onClosed: (data) { + if (data != null) { + field.didChange(data); + } + }, + ), + if (displayedSuggestions.isNotEmpty) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + S.of(context)!.suggestions, + style: Theme.of(context).textTheme.bodySmall, + ), + SizedBox( + height: kMinInteractiveDimension, + child: ListView.separated( + scrollDirection: Axis.horizontal, + itemCount: displayedSuggestions.length, + itemBuilder: (context, index) { + final suggestion = + options[displayedSuggestions.elementAt(index)]!; + return ColoredChipWrapper( + child: ActionChip( + label: Text(suggestion.name), + onPressed: () { + field.didChange(switch (field.value) { + IdsTagsQuery(include: var include) => + IdsTagsQuery( + include: [...include, suggestion.id!], + ), + _ => IdsTagsQuery(include: [suggestion.id!]), + }); + }, + ), + ); + }, + separatorBuilder: (BuildContext context, int index) => + const SizedBox(width: 4.0), + ), + ), + ], + ).padded(), + ], ); }, name: name, diff --git a/lib/features/labels/view/widgets/fullscreen_label_form.dart b/lib/features/labels/view/widgets/fullscreen_label_form.dart index bdc26e2..7c2d0c8 100644 --- a/lib/features/labels/view/widgets/fullscreen_label_form.dart +++ b/lib/features/labels/view/widgets/fullscreen_label_form.dart @@ -5,7 +5,8 @@ import 'package:paperless_mobile/extensions/flutter_extensions.dart'; import 'package:paperless_mobile/generated/l10n/app_localizations.dart'; class FullscreenLabelForm extends StatefulWidget { - final IdQueryParameter? initialValue; + /// If null, this will resolve to [UnsetIdQueryParameter]. + final IdQueryParameter initialValue; final Map options; final Future Function(String? initialName)? onCreateNewLabel; @@ -20,7 +21,7 @@ class FullscreenLabelForm extends StatefulWidget { FullscreenLabelForm({ super.key, - this.initialValue, + this.initialValue = const UnsetIdQueryParameter(), required this.options, required this.onCreateNewLabel, this.showNotAssignedOption = true, @@ -31,12 +32,8 @@ class FullscreenLabelForm extends StatefulWidget { this.autofocus = true, this.allowSelectUnassigned = true, required this.canCreateNewLabel, - }) : assert( - !(initialValue?.isOnlyAssigned ?? false) || showAnyAssignedOption, - ), - assert( - !(initialValue?.isOnlyNotAssigned ?? false) || showNotAssignedOption, - ), + }) : assert(!(initialValue.isOnlyAssigned) || showAnyAssignedOption), + assert(!(initialValue.isOnlyNotAssigned) || showNotAssignedOption), assert((addNewLabelText != null) == (onCreateNewLabel != null)); @override @@ -52,9 +49,9 @@ class _FullscreenLabelFormState @override void initState() { super.initState(); - _textEditingController.addListener(() => setState(() { - _showClearIcon = _textEditingController.text.isNotEmpty; - })); + _textEditingController.addListener(() { + setState(() => _showClearIcon = _textEditingController.text.isNotEmpty); + }); if (widget.autofocus) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) { //Delay keyboard popup to ensure open animation is finished before. @@ -130,36 +127,42 @@ class _FullscreenLabelFormState child: const Icon(Icons.add), ) : null, - body: Builder( - builder: (context) { - return Column( - children: [ - Expanded( - child: ListView.builder( - padding: EdgeInsets.zero, - shrinkWrap: true, - itemCount: options.length, - itemBuilder: (BuildContext context, int index) { - final option = options.elementAt(index); - final highlight = - AutocompleteHighlightedOption.of(context) == index; - if (highlight) { - SchedulerBinding.instance - .addPostFrameCallback((Duration timeStamp) { - Scrollable.ensureVisible( - context, - alignment: 0, - ); - }); - } - return _buildOptionWidget(option, highlight); - }, - ), + body: Builder(builder: (context) { + return Column( + children: [ + Expanded( + child: ListView.builder( + padding: EdgeInsets.zero, + shrinkWrap: true, + itemCount: options.length, + itemBuilder: (BuildContext context, int index) { + final option = options.elementAt(index); + final shouldHighlight = switch (option) { + NotAssignedIdQueryParameter() => true, + AnyAssignedIdQueryParameter() => true, + SetIdQueryParameter(id: var id) => + (widget.options[id]?.documentCount ?? 0) > 0, + _ => false, + }; + final highlight = + AutocompleteHighlightedOption.of(context) == index; + if (highlight && shouldHighlight) { + SchedulerBinding.instance + .addPostFrameCallback((Duration timeStamp) { + Scrollable.ensureVisible( + context, + alignment: 0, + ); + }); + } + return _buildOptionWidget( + option, highlight && shouldHighlight); + }, ), - ], - ); - }, - ), + ), + ], + ); + }), ); } @@ -179,8 +182,12 @@ class _FullscreenLabelFormState Iterable _filterOptionsByQuery(String query) sync* { final normalizedQuery = query.trim().toLowerCase(); if (normalizedQuery.isEmpty) { - if (widget.initialValue == null) { - // If nothing is selected yet, show all options first. + if ((widget.initialValue.isUnset)) { + if (widget.options.isEmpty) { + yield const UnsetIdQueryParameter(); + return; + } + // If nothing is selected yet (==> UnsetIdQueryParameter), show all options first. for (final option in widget.options.values) { yield SetIdQueryParameter(id: option.id!); } @@ -243,12 +250,17 @@ class _FullscreenLabelFormState AnyAssignedIdQueryParameter() => S.of(context)!.anyAssigned, SetIdQueryParameter(id: var id) => widget.options[id]?.name ?? S.of(context)!.startTyping, - _ => null, }; } Widget _buildOptionWidget(IdQueryParameter option, bool highlight) { void onTap() => widget.onSubmit(returnValue: option); + final hasNoAssignedDocumentsTextStyle = Theme.of(context) + .textTheme + .labelMedium + ?.apply(color: Theme.of(context).disabledColor); + final hasAssignedDocumentsTextStyle = + Theme.of(context).textTheme.labelMedium; return switch (option) { NotAssignedIdQueryParameter() => ListTile( @@ -266,11 +278,20 @@ class _FullscreenLabelFormState SetIdQueryParameter(id: var id) => ListTile( selected: highlight, selectedTileColor: Theme.of(context).focusColor, - title: Text(widget.options[id]!.name), + title: Text( + widget.options[id]!.name, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), onTap: onTap, - enabled: widget.allowSelectUnassigned - ? true - : widget.options[id]!.documentCount != 0, + trailing: Text( + S + .of(context)! + .documentsAssigned(widget.options[id]!.documentCount ?? 0), + style: (widget.options[id]!.documentCount ?? 0) > 0 + ? hasAssignedDocumentsTextStyle + : hasNoAssignedDocumentsTextStyle, + ), ), UnsetIdQueryParameter() => Center( child: Column( diff --git a/lib/features/labels/view/widgets/label_form_field.dart b/lib/features/labels/view/widgets/label_form_field.dart index d2fff42..d660dcb 100644 --- a/lib/features/labels/view/widgets/label_form_field.dart +++ b/lib/features/labels/view/widgets/label_form_field.dart @@ -19,11 +19,11 @@ class LabelFormField extends StatelessWidget { final String name; final String labelText; final FormFieldValidator? validator; - final Widget Function(String? initialName)? addLabelPageBuilder; + final Future Function(String? initialName)? onAddLabel; final void Function(IdQueryParameter?)? onChanged; final bool showNotAssignedOption; final bool showAnyAssignedOption; - final List suggestions; + final Iterable suggestions; final String? addLabelText; final bool allowSelectUnassigned; final bool canCreateNewLabel; @@ -36,7 +36,7 @@ class LabelFormField extends StatelessWidget { required this.prefixIcon, this.initialValue, this.validator, - this.addLabelPageBuilder, + this.onAddLabel, this.onChanged, this.showNotAssignedOption = true, this.showAnyAssignedOption = true, @@ -58,21 +58,21 @@ class LabelFormField extends StatelessWidget { @override Widget build(BuildContext context) { - final isEnabled = options.values.any((e) => (e.documentCount ?? 0) > 0) || - addLabelPageBuilder != null; + final enabled = options.values.isNotEmpty || onAddLabel != null; + return FormBuilderField( name: name, initialValue: initialValue, onChanged: onChanged, - enabled: isEnabled, + enabled: enabled, builder: (field) { final controller = TextEditingController( text: _buildText(context, field.value), ); final displayedSuggestions = suggestions .whereNot( - (e) => - e.id == + (id) => + id == switch (field.value) { SetIdQueryParameter(id: var id) => id, _ => -1, @@ -89,13 +89,14 @@ class LabelFormField extends StatelessWidget { closedShape: InputBorder.none, openElevation: 0, closedElevation: 0, + tappable: enabled, closedBuilder: (context, openForm) => Container( margin: const EdgeInsets.only(top: 6), child: TextField( controller: controller, onTap: openForm, readOnly: true, - enabled: isEnabled, + enabled: enabled, decoration: InputDecoration( prefixIcon: prefixIcon, labelText: labelText, @@ -114,19 +115,10 @@ class LabelFormField extends StatelessWidget { canCreateNewLabel: canCreateNewLabel, addNewLabelText: addLabelText, leadingIcon: prefixIcon, - onCreateNewLabel: addLabelPageBuilder != null - ? (initialName) { - return Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => - addLabelPageBuilder!(initialName), - ), - ); - } - : null, + onCreateNewLabel: onAddLabel, options: options, onSubmit: closeForm, - initialValue: field.value, + initialValue: field.value ?? const UnsetIdQueryParameter(), showAnyAssignedOption: showAnyAssignedOption, showNotAssignedOption: showNotAssignedOption, ), @@ -151,7 +143,8 @@ class LabelFormField extends StatelessWidget { itemCount: displayedSuggestions.length, itemBuilder: (context, index) { final suggestion = - displayedSuggestions.elementAt(index); + options[displayedSuggestions.elementAt(index)]!; + return ColoredChipWrapper( child: ActionChip( label: Text(suggestion.name), diff --git a/lib/l10n/intl_ca.arb b/lib/l10n/intl_ca.arb index 498a448..3491bbf 100644 --- a/lib/l10n/intl_ca.arb +++ b/lib/l10n/intl_ca.arb @@ -996,5 +996,13 @@ "restoringSession": "Restoring session...", "@restoringSession": { "description": "Message shown when the user opens the app and the previous user is tried to be authenticated and logged in" + }, + "documentsAssigned": "{count, plural, zero{No documents} one{1 document} other{{count} documents}}", + "@documentsAssigned": { + "description": "Text shown with a correspondent, document type etc. to indicate the number of documents this filter will maximally yield." + }, + "discardChangesWarning": "You have unsaved changes. By continuing, all changes will be lost. Do you want to discard these changes?", + "@discardChangesWarning": { + "description": "Warning message shown when the user tries to close a route without saving the changes." } } \ No newline at end of file diff --git a/lib/l10n/intl_cs.arb b/lib/l10n/intl_cs.arb index c631625..1189722 100644 --- a/lib/l10n/intl_cs.arb +++ b/lib/l10n/intl_cs.arb @@ -996,5 +996,13 @@ "restoringSession": "Restoring session...", "@restoringSession": { "description": "Message shown when the user opens the app and the previous user is tried to be authenticated and logged in" + }, + "documentsAssigned": "{count, plural, zero{No documents} one{1 document} other{{count} documents}}", + "@documentsAssigned": { + "description": "Text shown with a correspondent, document type etc. to indicate the number of documents this filter will maximally yield." + }, + "discardChangesWarning": "You have unsaved changes. By continuing, all changes will be lost. Do you want to discard these changes?", + "@discardChangesWarning": { + "description": "Warning message shown when the user tries to close a route without saving the changes." } } \ No newline at end of file diff --git a/lib/l10n/intl_de.arb b/lib/l10n/intl_de.arb index 5f947a6..b6c45a2 100644 --- a/lib/l10n/intl_de.arb +++ b/lib/l10n/intl_de.arb @@ -996,5 +996,13 @@ "restoringSession": "Sitzung wird wiederhergestellt...", "@restoringSession": { "description": "Message shown when the user opens the app and the previous user is tried to be authenticated and logged in" + }, + "documentsAssigned": "{count, plural, zero{Keine Dokumente} one{1 Dokument} other{{count} Dokumente}}", + "@documentsAssigned": { + "description": "Text shown with a correspondent, document type etc. to indicate the number of documents this filter will maximally yield." + }, + "discardChangesWarning": "Du hast ungespeicherte Änderungen. Diese gehen verloren, falls du fortfährst. Möchtest du die Änderungen verwerfen?", + "@discardChangesWarning": { + "description": "Warning message shown when the user tries to close a route without saving the changes." } } \ No newline at end of file diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index a89ae96..bcee327 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -348,49 +348,49 @@ "@after": {}, "before": "Before", "@before": {}, - "days": "{count, plural, one{day} other{days}}", + "days": "{count, plural, zero{days} one{day} other{days}}", "@days": { "placeholders": { "count": {} } }, - "lastNDays": "{count, plural, one{Yesterday} other{Last {count} days}}", + "lastNDays": "{count, plural, zero{} one{Yesterday} other{Last {count} days}}", "@lastNDays": { "placeholders": { "count": {} } }, - "lastNMonths": "{count, plural, one{Last month} other{Last {count} months}}", + "lastNMonths": "{count, plural, zero{} one{Last month} other{Last {count} months}}", "@lastNMonths": { "placeholders": { "count": {} } }, - "lastNWeeks": "{count, plural, one{Last week} other{Last {count} weeks}}", + "lastNWeeks": "{count, plural, zero{} one{Last week} other{Last {count} weeks}}", "@lastNWeeks": { "placeholders": { "count": {} } }, - "lastNYears": "{count, plural, one{Last year} other{Last {count} years}}", + "lastNYears": "{count, plural, zero{} one{Last year} other{Last {count} years}}", "@lastNYears": { "placeholders": { "count": {} } }, - "months": "{count, plural, one{month} other{months}}", + "months": "{count, plural, zero{} one{month} other{months}}", "@months": { "placeholders": { "count": {} } }, - "weeks": "{count, plural, one{week} other{weeks}}", + "weeks": "{count, plural, zero{} one{week} other{weeks}}", "@weeks": { "placeholders": { "count": {} } }, - "years": "{count, plural, one{year} other{years}}", + "years": "{count, plural, zero{} one{year} other{years}}", "@years": { "placeholders": { "count": {} @@ -588,7 +588,7 @@ "@createsASavedViewBasedOnTheCurrentFilterCriteria": {}, "createViewsToQuicklyFilterYourDocuments": "Create views to quickly filter your documents.", "@createViewsToQuicklyFilterYourDocuments": {}, - "nFiltersSet": "{count, plural, one{{count} filter set} other{{count} filters set}}", + "nFiltersSet": "{count, plural, zero{{count} filters set} one{{count} filter set} other{{count} filters set}}", "@nFiltersSet": { "placeholders": { "count": {} @@ -996,5 +996,13 @@ "restoringSession": "Restoring session...", "@restoringSession": { "description": "Message shown when the user opens the app and the previous user is tried to be authenticated and logged in" + }, + "documentsAssigned": "{count, plural, zero{No documents} one{1 document} other{{count} documents}}", + "@documentsAssigned": { + "description": "Text shown with a correspondent, document type etc. to indicate the number of documents this filter will maximally yield." + }, + "discardChangesWarning": "You have unsaved changes. By continuing, all changes will be lost. Do you want to discard these changes?", + "@discardChangesWarning": { + "description": "Warning message shown when the user tries to close a route without saving the changes." } } \ No newline at end of file diff --git a/lib/l10n/intl_es.arb b/lib/l10n/intl_es.arb index 068a86f..cfa5fc0 100644 --- a/lib/l10n/intl_es.arb +++ b/lib/l10n/intl_es.arb @@ -865,7 +865,7 @@ "@missingPermissions": { "description": "Message shown in a snackbar when a user without the reequired permissions performs an action." }, - "editView": "Edit View", + "editView": "Editar Vista", "@editView": { "description": "Title of the edit saved view page" }, @@ -873,128 +873,136 @@ "@donate": { "description": "Label of the in-app donate button" }, - "donationDialogContent": "Thank you for considering to support this app! Due to both Google's and Apple's Payment Policies, no links leading to donations may be displayed in-app. Not even linking to the project's repository page appears to be allowed in this context. Therefore, maybe have a look at the 'Donations' section in the project's README. Your support is much appreciated and keeps the development of this app alive. Thanks!", + "donationDialogContent": "¡Gracias por querer apoyar esta aplicación!\nDebido a las políticas de pago, tanto de Google como de Apple, no se puede mostrar ningún enlace que lo dirija a las donaciones. En este contexto, ni siquiera es posible enlazar la página del repositorio del proyecto. Por lo tanto, puedes visitar la sección \"Donations\" en el archivo README de este proyecto. Tu apoyo es valorado gratamente y ayuda a mantener con vida el desarrollo de esta aplicación.\n¡Muchas gracias!", "@donationDialogContent": { "description": "Text displayed in the donation dialog" }, - "noDocumentsFound": "No documents found.", + "noDocumentsFound": "No se han encontrado documentos.", "@noDocumentsFound": { "description": "Message shown when no documents were found." }, - "couldNotDeleteCorrespondent": "Could not delete correspondent, please try again.", + "couldNotDeleteCorrespondent": "No se pudo remover el interlocutor, intente nuevamente.", "@couldNotDeleteCorrespondent": { "description": "Message shown in snackbar when a correspondent could not be deleted." }, - "couldNotDeleteDocumentType": "Could not delete document type, please try again.", + "couldNotDeleteDocumentType": "No se pudo remover el tipo de documento, intente nuevamente.", "@couldNotDeleteDocumentType": { "description": "Message shown when a document type could not be deleted" }, - "couldNotDeleteTag": "Could not delete tag, please try again.", + "couldNotDeleteTag": "No se pudo borrar la etiqueta, intente nuevamente.", "@couldNotDeleteTag": { "description": "Message shown when a tag could not be deleted" }, - "couldNotDeleteStoragePath": "Could not delete storage path, please try again.", + "couldNotDeleteStoragePath": "No se pudo remover la ruta de almacenamiento, intente nuevamente.", "@couldNotDeleteStoragePath": { "description": "Message shown when a storage path could not be deleted" }, - "couldNotUpdateCorrespondent": "Could not update correspondent, please try again.", + "couldNotUpdateCorrespondent": "No se pudo actualizar el interlocutor, intente nuevamente.", "@couldNotUpdateCorrespondent": { "description": "Message shown when a correspondent could not be updated" }, - "couldNotUpdateDocumentType": "Could not update document type, please try again.", + "couldNotUpdateDocumentType": "No se pudo actualizar el tipo de documento, intente nuevamente.", "@couldNotUpdateDocumentType": { "description": "Message shown when a document type could not be updated" }, - "couldNotUpdateTag": "Could not update tag, please try again.", + "couldNotUpdateTag": "No se pudo actualizar la etiqueta, intente nuevamente.", "@couldNotUpdateTag": { "description": "Message shown when a tag could not be updated" }, - "couldNotLoadServerInformation": "Could not load server information.", + "couldNotLoadServerInformation": "No se pudo cargar la información del servidor.", "@couldNotLoadServerInformation": { "description": "Message shown when the server information could not be loaded" }, - "couldNotLoadStatistics": "Could not load server statistics.", + "couldNotLoadStatistics": "No se pudieron cargar las estadísticas del servidor.", "@couldNotLoadStatistics": { "description": "Message shown when the server statistics could not be loaded" }, - "couldNotLoadUISettings": "Could not load UI settings.", + "couldNotLoadUISettings": "No se pudieron cargar los ajustes de UI.", "@couldNotLoadUISettings": { "description": "Message shown when the UI settings could not be loaded" }, - "couldNotLoadTasks": "Could not load tasks.", + "couldNotLoadTasks": "No se pudieron cargar tareas.", "@couldNotLoadTasks": { "description": "Message shown when the tasks (e.g. document consumed) could not be loaded" }, - "userNotFound": "User could not be found.", + "userNotFound": "Usuario no encontrado.", "@userNotFound": { "description": "Message shown when the specified user (e.g. by id) could not be found" }, - "couldNotUpdateSavedView": "Could not update saved view, please try again.", + "couldNotUpdateSavedView": "No se pudo actualizar la vista guardada, intente nuevamente.", "@couldNotUpdateSavedView": { "description": "Message shown when a saved view could not be updated" }, - "couldNotUpdateStoragePath": "Could not update storage path, please try again.", - "savedViewSuccessfullyUpdated": "Saved view successfully updated.", + "couldNotUpdateStoragePath": "No se pudo actualizar la ruta de almacenamiento, intente nuevamente.", + "savedViewSuccessfullyUpdated": "La vista guardada se actualizó correctamente.", "@savedViewSuccessfullyUpdated": { "description": "Message shown when a saved view was successfully updated." }, - "discardChanges": "Discard changes?", + "discardChanges": "¿Descartar cambios?", "@discardChanges": { "description": "Title of the alert dialog shown when a user tries to close a view with unsaved changes." }, - "savedViewChangedDialogContent": "The filter conditions of the active view have changed. By resetting the filter, these changes will be lost. Do you still wish to continue?", + "savedViewChangedDialogContent": "Han cambiado las condiciones de filtrado de la vista activa. Al reiniciar el filtro se perderán estos cambios. ¿Desea continuar?", "@savedViewChangedDialogContent": { "description": "Content of the alert dialog shown when all of the following applies:\r\n* User has saved view selected\r\n* User has performed changes to the current document filter\r\n* User now tries to reset this filter without having saved the changes to the view." }, - "createFromCurrentFilter": "Create from current filter", + "createFromCurrentFilter": "Crear desde el filtro actual", "@createFromCurrentFilter": { "description": "Tooltip of the \"New saved view\" button" }, - "home": "Home", + "home": "Inicio", "@home": { "description": "Label of the \"Home\" route" }, - "welcomeUser": "Welcome, {name}!", + "welcomeUser": "¡Bienvenido, {name}!", "@welcomeUser": { "description": "Top message shown on the home page" }, - "noSavedViewOnHomepageHint": "Configure a saved view to be displayed on your home page and it will show up here.", + "noSavedViewOnHomepageHint": "Configure una vista guardada para que sea mostrada en su página de inicio y aparecerá aquí.", "@noSavedViewOnHomepageHint": { "description": "Message shown when there is no saved view to display on the home page." }, - "statistics": "Statistics", - "documentsInInbox": "Documents in inbox", - "totalDocuments": "Total documents", - "totalCharacters": "Total characters", - "showAll": "Show all", + "statistics": "Estadísticas", + "documentsInInbox": "Documentos en el buzón", + "totalDocuments": "Total de documentos", + "totalCharacters": "Total de caracteres", + "showAll": "Mostrar todo", "@showAll": { "description": "Button label shown on a saved view preview to open this view in the documents page" }, - "userAlreadyExists": "This user already exists.", + "userAlreadyExists": "Este usuario ya existe.", "@userAlreadyExists": { "description": "Error message shown when the user tries to add an already existing account." }, - "youDidNotSaveAnyViewsYet": "You did not save any views yet, create one and it will be shown here.", + "youDidNotSaveAnyViewsYet": "Aún no guardaste ninguna vista, crea una y aparecerá aquí.", "@youDidNotSaveAnyViewsYet": { "description": "Message shown when there are no saved views yet." }, - "tryAgain": "Try again", - "discardFile": "Discard file?", - "discard": "Discard", - "backToLogin": "Back to login", - "skipEditingReceivedFiles": "Skip editing received files", - "uploadWithoutPromptingUploadForm": "Always upload without prompting the upload form when sharing files with the app.", - "authenticatingDots": "Authenticating...", + "tryAgain": "Intente nuevamente", + "discardFile": "¿Descartar archivo?", + "discard": "Descartar", + "backToLogin": "Volver al inicio de sesión", + "skipEditingReceivedFiles": "Omitir edición de archivos recibidos", + "uploadWithoutPromptingUploadForm": "Subir automáticamente sin mostrar el formulario de subida al compartir archivos con la app.", + "authenticatingDots": "Autenticando...", "@authenticatingDots": { "description": "Message shown when the app is authenticating the user" }, - "persistingUserInformation": "Persisting user information...", - "fetchingUserInformation": "Fetching user information...", + "persistingUserInformation": "Manteniendo información del usuario...", + "fetchingUserInformation": "Obteniendo información del usuario...", "@fetchingUserInformation": { "description": "Message shown when the app loads user data from the server" }, - "restoringSession": "Restoring session...", + "restoringSession": "Restaurando sesión...", "@restoringSession": { "description": "Message shown when the user opens the app and the previous user is tried to be authenticated and logged in" + }, + "documentsAssigned": "{count, plural, zero{No documents} one{1 document} other{{count} documents}}", + "@documentsAssigned": { + "description": "Text shown with a correspondent, document type etc. to indicate the number of documents this filter will maximally yield." + }, + "discardChangesWarning": "You have unsaved changes. By continuing, all changes will be lost. Do you want to discard these changes?", + "@discardChangesWarning": { + "description": "Warning message shown when the user tries to close a route without saving the changes." } } \ No newline at end of file diff --git a/lib/l10n/intl_fr.arb b/lib/l10n/intl_fr.arb index da7ec87..b5ff5bf 100644 --- a/lib/l10n/intl_fr.arb +++ b/lib/l10n/intl_fr.arb @@ -996,5 +996,13 @@ "restoringSession": "Restoring session...", "@restoringSession": { "description": "Message shown when the user opens the app and the previous user is tried to be authenticated and logged in" + }, + "documentsAssigned": "{count, plural, zero{No documents} one{1 document} other{{count} documents}}", + "@documentsAssigned": { + "description": "Text shown with a correspondent, document type etc. to indicate the number of documents this filter will maximally yield." + }, + "discardChangesWarning": "You have unsaved changes. By continuing, all changes will be lost. Do you want to discard these changes?", + "@discardChangesWarning": { + "description": "Warning message shown when the user tries to close a route without saving the changes." } } \ No newline at end of file diff --git a/lib/l10n/intl_pl.arb b/lib/l10n/intl_pl.arb index 151cf85..a3f0e82 100644 --- a/lib/l10n/intl_pl.arb +++ b/lib/l10n/intl_pl.arb @@ -996,5 +996,13 @@ "restoringSession": "Restoring session...", "@restoringSession": { "description": "Message shown when the user opens the app and the previous user is tried to be authenticated and logged in" + }, + "documentsAssigned": "{count, plural, zero{No documents} one{1 document} other{{count} documents}}", + "@documentsAssigned": { + "description": "Text shown with a correspondent, document type etc. to indicate the number of documents this filter will maximally yield." + }, + "discardChangesWarning": "You have unsaved changes. By continuing, all changes will be lost. Do you want to discard these changes?", + "@discardChangesWarning": { + "description": "Warning message shown when the user tries to close a route without saving the changes." } } \ No newline at end of file diff --git a/lib/l10n/intl_ru.arb b/lib/l10n/intl_ru.arb index 96e417e..789ef83 100644 --- a/lib/l10n/intl_ru.arb +++ b/lib/l10n/intl_ru.arb @@ -996,5 +996,13 @@ "restoringSession": "Restoring session...", "@restoringSession": { "description": "Message shown when the user opens the app and the previous user is tried to be authenticated and logged in" + }, + "documentsAssigned": "{count, plural, zero{No documents} one{1 document} other{{count} documents}}", + "@documentsAssigned": { + "description": "Text shown with a correspondent, document type etc. to indicate the number of documents this filter will maximally yield." + }, + "discardChangesWarning": "You have unsaved changes. By continuing, all changes will be lost. Do you want to discard these changes?", + "@discardChangesWarning": { + "description": "Warning message shown when the user tries to close a route without saving the changes." } } \ No newline at end of file diff --git a/lib/l10n/intl_tr.arb b/lib/l10n/intl_tr.arb index 0fb7f09..a61c670 100644 --- a/lib/l10n/intl_tr.arb +++ b/lib/l10n/intl_tr.arb @@ -996,5 +996,13 @@ "restoringSession": "Restoring session...", "@restoringSession": { "description": "Message shown when the user opens the app and the previous user is tried to be authenticated and logged in" + }, + "documentsAssigned": "{count, plural, zero{No documents} one{1 document} other{{count} documents}}", + "@documentsAssigned": { + "description": "Text shown with a correspondent, document type etc. to indicate the number of documents this filter will maximally yield." + }, + "discardChangesWarning": "You have unsaved changes. By continuing, all changes will be lost. Do you want to discard these changes?", + "@discardChangesWarning": { + "description": "Warning message shown when the user tries to close a route without saving the changes." } } \ No newline at end of file diff --git a/lib/routes/typed/branches/documents_route.dart b/lib/routes/typed/branches/documents_route.dart index a48ebcc..8fc0640 100644 --- a/lib/routes/typed/branches/documents_route.dart +++ b/lib/routes/typed/branches/documents_route.dart @@ -52,7 +52,9 @@ class DocumentDetailsRoute extends GoRouteData { context.read(), context.read(), initialDocument: $extra, - ), + ) + ..loadFullContent() + ..loadMetaData(), lazy: false, child: DocumentDetailsPage( isLabelClickable: isLabelClickable, diff --git a/packages/paperless_api/lib/src/models/field_suggestions.dart b/packages/paperless_api/lib/src/models/field_suggestions.dart index 4a6ce9f..95f9187 100644 --- a/packages/paperless_api/lib/src/models/field_suggestions.dart +++ b/packages/paperless_api/lib/src/models/field_suggestions.dart @@ -1,3 +1,4 @@ +import 'package:equatable/equatable.dart'; import 'package:json_annotation/json_annotation.dart'; import 'package:paperless_api/src/converters/local_date_time_json_converter.dart'; import 'package:paperless_api/src/models/document_model.dart'; @@ -6,7 +7,7 @@ part 'field_suggestions.g.dart'; @LocalDateTimeJsonConverter() @JsonSerializable(fieldRename: FieldRename.snake) -class FieldSuggestions { +class FieldSuggestions with EquatableMixin { final int? documentId; final Iterable correspondents; final Iterable tags; @@ -95,4 +96,13 @@ class FieldSuggestions { _$FieldSuggestionsFromJson(json); Map toJson() => _$FieldSuggestionsToJson(this); + + @override + List get props => [ + documentId, + correspondents, + tags, + documentTypes, + dates, + ]; } diff --git a/packages/paperless_api/lib/src/models/labels/label_model.dart b/packages/paperless_api/lib/src/models/labels/label_model.dart index ab4c49e..917a099 100644 --- a/packages/paperless_api/lib/src/models/labels/label_model.dart +++ b/packages/paperless_api/lib/src/models/labels/label_model.dart @@ -203,7 +203,7 @@ class StoragePath extends Label { const StoragePath({ super.id, required super.name, - required this.path, + this.path = '', super.slug, super.match, super.matchingAlgorithm, diff --git a/scripts/update_translations.sh b/scripts/update_translations.sh index 6790ac6..2035a79 100644 --- a/scripts/update_translations.sh +++ b/scripts/update_translations.sh @@ -1,5 +1,8 @@ #!/bin/bash echo "Updating source language..." -crowdin download sources --identity=../crowdin_credentials.yml --config ../crowdin.yml --no-preserve-hierarchy +crowdin download sources --identity=../crowdin_credentials.yml --config ../crowdin.yml --preserve-hierarchy echo "Updating translations..." -crowdin download --identity=../crowdin_credentials.yml --config ../crowdin.yml \ No newline at end of file +crowdin download --identity=../crowdin_credentials.yml --config ../crowdin.yml +pushd .. +flutter gen-l10n +popd \ No newline at end of file