fix: Update bulk edit string

This commit is contained in:
Anton Stubenbord
2023-04-13 23:01:54 +02:00
parent d621a3bbe7
commit c6264f6fc0
10 changed files with 76 additions and 86 deletions

View File

@@ -4,11 +4,9 @@ import 'package:paperless_mobile/core/widgets/dialog_utils/dialog_confirm_button
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
class ConfirmBulkModifyLabelDialog extends StatelessWidget {
final int selectionCount;
final String content;
const ConfirmBulkModifyLabelDialog({
super.key,
required this.selectionCount,
required this.content,
});

View File

@@ -1,10 +1,9 @@
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/widgets/dialog_utils/dialog_cancel_button.dart';
import 'package:paperless_mobile/core/widgets/dialog_utils/dialog_confirm_button.dart';
import 'package:paperless_mobile/core/widgets/form_fields/fullscreen_selection_form.dart';
import 'package:paperless_mobile/extensions/dart_extensions.dart';
import 'package:paperless_mobile/features/document_bulk_action/view/widgets/confirm_bulk_modify_label_dialog.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
class FullscreenBulkEditLabelPage extends StatefulWidget {
@@ -14,8 +13,8 @@ class FullscreenBulkEditLabelPage extends StatefulWidget {
final int? Function(DocumentModel document) labelMapper;
final Widget leadingIcon;
final void Function(int? id) onSubmit;
final Function(String name) Function(int count) removeStringFnBuilder;
final String Function(String name) Function(int count) assignStringFnBuilder;
final String Function(int count) removeMessageBuilder;
final String Function(int count, String name) assignMessageBuilder;
FullscreenBulkEditLabelPage({
super.key,
@@ -25,8 +24,8 @@ class FullscreenBulkEditLabelPage extends StatefulWidget {
required this.leadingIcon,
required this.hintText,
required this.onSubmit,
required this.removeStringFnBuilder,
required this.assignStringFnBuilder,
required this.removeMessageBuilder,
required this.assignMessageBuilder,
}) : assert(selection.isNotEmpty);
@override
@@ -87,45 +86,14 @@ class _FullscreenBulkEditLabelPageState<T extends Label>
selectionCount: _labels.length,
floatingActionButton: !hideFab
? FloatingActionButton.extended(
onPressed: () async {
if (_selection == null) {
Navigator.pop(context);
} else {
final shouldPerformAction = await showDialog<bool>(
context: context,
builder: (context) => _buildConfirmDialog(context),
// if _selection.labelId is null: show dialog asking to remove label from widget.selection.length documents
// else show dialog asking to assign label to widget.selection.length documents
) ??
false;
if (shouldPerformAction) {
widget.onSubmit(_selection!.label);
Navigator.pop(context);
}
}
},
onPressed: _onSubmit,
label: Text(S.of(context)!.apply),
icon: Icon(Icons.done),
icon: const Icon(Icons.done),
)
: null,
);
}
AlertDialog _buildConfirmDialog(BuildContext context) {
return AlertDialog(
title: Text(S.of(context)!.confirmAction),
content: Text(
S.of(context)!.areYouSureYouWantToContinue,
),
actions: const [
DialogCancelButton(),
DialogConfirmButton(
style: DialogConfirmButtonStyle.danger,
),
],
);
}
Widget _buildItem(Label label) {
Widget? trailingIcon;
if (_initialValues.length > 1 &&
@@ -151,6 +119,39 @@ class _FullscreenBulkEditLabelPageState<T extends Label>
},
);
}
void _onSubmit() async {
if (_selection == null) {
Navigator.pop(context);
} else {
bool shouldPerformAction;
if (_selection!.label == null) {
shouldPerformAction = await showDialog<bool>(
context: context,
builder: (context) => ConfirmBulkModifyLabelDialog(
content: widget.removeMessageBuilder(widget.selection.length),
),
) ??
false;
} else {
final labelName = widget.options[_selection!.label]!.name;
shouldPerformAction = await showDialog<bool>(
context: context,
builder: (context) => ConfirmBulkModifyLabelDialog(
content: widget.assignMessageBuilder(
widget.selection.length,
'"$labelName"',
),
),
) ??
false;
}
if (shouldPerformAction) {
widget.onSubmit(_selection!.label);
Navigator.pop(context);
}
}
}
}
class LabelSelection {

View File

@@ -88,21 +88,18 @@ class DocumentSelectionSliverAppBar extends StatelessWidget {
onSubmit: context
.read<DocumentBulkActionCubit>()
.bulkModifyCorrespondent,
assignStringFnBuilder: (int count) {
return (String name) => S
assignMessageBuilder: (int count, String name) {
return S
.of(context)!
.bulkEditCorrespondentAssignMessage(
name,
count,
);
},
removeStringFnBuilder: (int count) {
return (String name) => S
removeMessageBuilder: (int count) {
return S
.of(context)!
.bulkEditCorrespondentRemoveMessage(
name,
count,
);
.bulkEditCorrespondentRemoveMessage(count);
},
);
},
@@ -138,21 +135,18 @@ class DocumentSelectionSliverAppBar extends StatelessWidget {
onSubmit: context
.read<DocumentBulkActionCubit>()
.bulkModifyDocumentType,
assignStringFnBuilder: (int count) {
return (String name) => S
assignMessageBuilder: (int count, String name) {
return S
.of(context)!
.bulkEditDocumentTypeAssignMessage(
count,
name,
);
},
removeStringFnBuilder: (int count) {
return (String name) => S
removeMessageBuilder: (int count) {
return S
.of(context)!
.bulkEditDocumentTypeRemoveMessage(
count,
name,
);
.bulkEditDocumentTypeRemoveMessage(count);
},
);
},
@@ -187,21 +181,18 @@ class DocumentSelectionSliverAppBar extends StatelessWidget {
onSubmit: context
.read<DocumentBulkActionCubit>()
.bulkModifyStoragePath,
assignStringFnBuilder: (int count) {
return (String name) => S
assignMessageBuilder: (int count, String name) {
return S
.of(context)!
.bulkEditStoragePathAssignMessage(
count,
name,
);
},
removeStringFnBuilder: (int count) {
return (String name) => S
removeMessageBuilder: (int count) {
return S
.of(context)!
.bulkEditStoragePathRemoveMessage(
count,
name,
);
.bulkEditStoragePathRemoveMessage(count);
},
);
},

View File

@@ -719,9 +719,9 @@
"bulkEditCorrespondentAssignMessage": "{count, plural, one{This operation will assign the correspondent {correspondent} to the selected document.} other{This operation will assign the correspondent {correspondent} to {count} selected documents.}}",
"bulkEditDocumentTypeAssignMessage": "{count, plural, one{This operation will assign the document type {docType} to the selected document.} other{This operation will assign the documentType {docType} to {count} selected documents.}}",
"bulkEditStoragePathAssignMessage": "{count, plural, one{This operation will assign the storage path {path} to the selected document.} other{This operation will assign the storage path {path} to {count} selected documents.}}",
"bulkEditCorrespondentRemoveMessage": "{count, plural, one{This operation will remove the correspondent {correspondent} from the selected document.} other{This operation will remove the correspondent {correspondent} from {count} selected documents.}}",
"bulkEditDocumentTypeRemoveMessage": "{count, plural, one{This operation will remove the document type {docType} from the selected document.} other{This operation will remove the document type {docType} from {count} selected documents.}}",
"bulkEditStoragePathRemoveMessage": "{count, plural, one{This operation will remove the storage path {path} from the selected document.} other{This operation will remove the storage path {path} from {count} selected documents.}}",
"bulkEditCorrespondentRemoveMessage": "{count, plural, one{This operation will remove the correspondent from the selected document.} other{This operation will remove the correspondent from {count} selected documents.}}",
"bulkEditDocumentTypeRemoveMessage": "{count, plural, one{This operation will remove the document type from the selected document.} other{This operation will remove the document type from {count} selected documents.}}",
"bulkEditStoragePathRemoveMessage": "{count, plural, one{This operation will remove the storage path from the selected document.} other{This operation will remove the storage path from {count} selected documents.}}",
"anyTag": "Any",
"@anyTag": {
"description": "Label shown when any tag should be filtered"

View File

@@ -719,9 +719,9 @@
"bulkEditCorrespondentAssignMessage": "{count, plural, one{Diese Operation wird den Korrespondent {correspondent} dem ausgewählten Dokument zuweisen.} other{Diese Operation wird den Korrespondent {correspondent} den {count} ausgewählten Dokumenten zuweisen.}}",
"bulkEditDocumentTypeAssignMessage": "{count, plural, one{Diese Operation wird den Dokumenttyp {docType} dem ausgewählten Dokument zuweisen.} other{Diese Operation wird den Dokumenttyp {docType} den {count} ausgewählten Dokumenten zuweisen.}}",
"bulkEditStoragePathAssignMessage": "{count, plural, one{Diese Operation wird den Speicherpfad {path} dem ausgewählten Dokument zuweisen.} other{Diese Operation wird den Speicherpfad {path} den {count} ausgewählten Dokumenten zuweisen.}}",
"bulkEditCorrespondentRemoveMessage": "{count, plural, one{Diese Operation wird den Korrespondent {correspondent} vom ausgewählten Dokument entfernen.} other{Diese Operation wird den Korrespondenten {correspondent} von {count} ausgewählten Dokumenten entfernen.}}",
"bulkEditDocumentTypeRemoveMessage": "{count, plural, one{Diese Operation wird den Dokumenttyp {docType} vom ausgewählten Dokument entfernen.} other{Diese Operation wird den Dokumenttyp {docType} von {count} ausgewählten Dokumenten entfernen.}}",
"bulkEditStoragePathRemoveMessage": "{count, plural, one{Diese Operation wird den Speicherpfad {path} vom ausgewählten Dokument entfernen.} other{Diese Operation wird den Speicherpfad {path} von {count} ausgewählten Dokumenten entfernen.}}",
"bulkEditCorrespondentRemoveMessage": "{count, plural, one{Diese Operation wird den Korrespondent vom ausgewählten Dokument entfernen.} other{Diese Operation wird den Korrespondent von {count} ausgewählten Dokumenten entfernen.}}",
"bulkEditDocumentTypeRemoveMessage": "{count, plural, one{Diese Operation wird den Dokumenttyp vom ausgewählten Dokument entfernen.} other{Diese Operation wird den Dokumenttyp von {count} ausgewählten Dokumenten entfernen.}}",
"bulkEditStoragePathRemoveMessage": "{count, plural, one{Diese Operation wird den Speicherpfad vom ausgewählten Dokument entfernen.} other{Diese Operation wird den Speicherpfad von {count} ausgewählten Dokumenten entfernen.}}",
"anyTag": "Irgendeines",
"@anyTag": {
"description": "Label shown when any tag should be filtered"

View File

@@ -719,9 +719,9 @@
"bulkEditCorrespondentAssignMessage": "{count, plural, one{This operation will assign the correspondent {correspondent} to the selected document.} other{This operation will assign the correspondent {correspondent} to {count} selected documents.}}",
"bulkEditDocumentTypeAssignMessage": "{count, plural, one{This operation will assign the document type {docType} to the selected document.} other{This operation will assign the documentType {docType} to {count} selected documents.}}",
"bulkEditStoragePathAssignMessage": "{count, plural, one{This operation will assign the storage path {path} to the selected document.} other{This operation will assign the storage path {path} to {count} selected documents.}}",
"bulkEditCorrespondentRemoveMessage": "{count, plural, one{This operation will remove the correspondent {correspondent} from the selected document.} other{This operation will remove the correspondent {correspondent} from {count} selected documents.}}",
"bulkEditDocumentTypeRemoveMessage": "{count, plural, one{This operation will remove the document type {docType} from the selected document.} other{This operation will remove the document type {docType} from {count} selected documents.}}",
"bulkEditStoragePathRemoveMessage": "{count, plural, one{This operation will remove the storage path {path} from the selected document.} other{This operation will remove the storage path {path} from {count} selected documents.}}",
"bulkEditCorrespondentRemoveMessage": "{count, plural, one{This operation will remove the correspondent from the selected document.} other{This operation will remove the correspondent from {count} selected documents.}}",
"bulkEditDocumentTypeRemoveMessage": "{count, plural, one{This operation will remove the document type from the selected document.} other{This operation will remove the document type from {count} selected documents.}}",
"bulkEditStoragePathRemoveMessage": "{count, plural, one{This operation will remove the storage path from the selected document.} other{This operation will remove the storage path from {count} selected documents.}}",
"anyTag": "Any",
"@anyTag": {
"description": "Label shown when any tag should be filtered"

View File

@@ -719,9 +719,9 @@
"bulkEditCorrespondentAssignMessage": "{count, plural, one{This operation will assign the correspondent {correspondent} to the selected document.} other{This operation will assign the correspondent {correspondent} to {count} selected documents.}}",
"bulkEditDocumentTypeAssignMessage": "{count, plural, one{This operation will assign the document type {docType} to the selected document.} other{This operation will assign the documentType {docType} to {count} selected documents.}}",
"bulkEditStoragePathAssignMessage": "{count, plural, one{This operation will assign the storage path {path} to the selected document.} other{This operation will assign the storage path {path} to {count} selected documents.}}",
"bulkEditCorrespondentRemoveMessage": "{count, plural, one{This operation will remove the correspondent {correspondent} from the selected document.} other{This operation will remove the correspondent {correspondent} from {count} selected documents.}}",
"bulkEditDocumentTypeRemoveMessage": "{count, plural, one{This operation will remove the document type {docType} from the selected document.} other{This operation will remove the document type {docType} from {count} selected documents.}}",
"bulkEditStoragePathRemoveMessage": "{count, plural, one{This operation will remove the storage path {path} from the selected document.} other{This operation will remove the storage path {path} from {count} selected documents.}}",
"bulkEditCorrespondentRemoveMessage": "{count, plural, one{This operation will remove the correspondent from the selected document.} other{This operation will remove the correspondent from {count} selected documents.}}",
"bulkEditDocumentTypeRemoveMessage": "{count, plural, one{This operation will remove the document type from the selected document.} other{This operation will remove the document type from {count} selected documents.}}",
"bulkEditStoragePathRemoveMessage": "{count, plural, one{This operation will remove the storage path from the selected document.} other{This operation will remove the storage path from {count} selected documents.}}",
"anyTag": "Any",
"@anyTag": {
"description": "Label shown when any tag should be filtered"

View File

@@ -719,9 +719,9 @@
"bulkEditCorrespondentAssignMessage": "{count, plural, one{This operation will assign the correspondent {correspondent} to the selected document.} other{This operation will assign the correspondent {correspondent} to {count} selected documents.}}",
"bulkEditDocumentTypeAssignMessage": "{count, plural, one{This operation will assign the document type {docType} to the selected document.} other{This operation will assign the documentType {docType} to {count} selected documents.}}",
"bulkEditStoragePathAssignMessage": "{count, plural, one{This operation will assign the storage path {path} to the selected document.} other{This operation will assign the storage path {path} to {count} selected documents.}}",
"bulkEditCorrespondentRemoveMessage": "{count, plural, one{This operation will remove the correspondent {correspondent} from the selected document.} other{This operation will remove the correspondent {correspondent} from {count} selected documents.}}",
"bulkEditDocumentTypeRemoveMessage": "{count, plural, one{This operation will remove the document type {docType} from the selected document.} other{This operation will remove the document type {docType} from {count} selected documents.}}",
"bulkEditStoragePathRemoveMessage": "{count, plural, one{This operation will remove the storage path {path} from the selected document.} other{This operation will remove the storage path {path} from {count} selected documents.}}",
"bulkEditCorrespondentRemoveMessage": "{count, plural, one{This operation will remove the correspondent from the selected document.} other{This operation will remove the correspondent from {count} selected documents.}}",
"bulkEditDocumentTypeRemoveMessage": "{count, plural, one{This operation will remove the document type from the selected document.} other{This operation will remove the document type from {count} selected documents.}}",
"bulkEditStoragePathRemoveMessage": "{count, plural, one{This operation will remove the storage path from the selected document.} other{This operation will remove the storage path from {count} selected documents.}}",
"anyTag": "Any",
"@anyTag": {
"description": "Label shown when any tag should be filtered"

View File

@@ -719,9 +719,9 @@
"bulkEditCorrespondentAssignMessage": "{count, plural, one{This operation will assign the correspondent {correspondent} to the selected document.} other{This operation will assign the correspondent {correspondent} to {count} selected documents.}}",
"bulkEditDocumentTypeAssignMessage": "{count, plural, one{This operation will assign the document type {docType} to the selected document.} other{This operation will assign the documentType {docType} to {count} selected documents.}}",
"bulkEditStoragePathAssignMessage": "{count, plural, one{This operation will assign the storage path {path} to the selected document.} other{This operation will assign the storage path {path} to {count} selected documents.}}",
"bulkEditCorrespondentRemoveMessage": "{count, plural, one{This operation will remove the correspondent {correspondent} from the selected document.} other{This operation will remove the correspondent {correspondent} from {count} selected documents.}}",
"bulkEditDocumentTypeRemoveMessage": "{count, plural, one{This operation will remove the document type {docType} from the selected document.} other{This operation will remove the document type {docType} from {count} selected documents.}}",
"bulkEditStoragePathRemoveMessage": "{count, plural, one{This operation will remove the storage path {path} from the selected document.} other{This operation will remove the storage path {path} from {count} selected documents.}}",
"bulkEditCorrespondentRemoveMessage": "{count, plural, one{This operation will remove the correspondent from the selected document.} other{This operation will remove the correspondent from {count} selected documents.}}",
"bulkEditDocumentTypeRemoveMessage": "{count, plural, one{This operation will remove the document type from the selected document.} other{This operation will remove the document type from {count} selected documents.}}",
"bulkEditStoragePathRemoveMessage": "{count, plural, one{This operation will remove the storage path from the selected document.} other{This operation will remove the storage path from {count} selected documents.}}",
"anyTag": "Any",
"@anyTag": {
"description": "Label shown when any tag should be filtered"

View File

@@ -719,9 +719,9 @@
"bulkEditCorrespondentAssignMessage": "{count, plural, one{This operation will assign the correspondent {correspondent} to the selected document.} other{This operation will assign the correspondent {correspondent} to {count} selected documents.}}",
"bulkEditDocumentTypeAssignMessage": "{count, plural, one{This operation will assign the document type {docType} to the selected document.} other{This operation will assign the documentType {docType} to {count} selected documents.}}",
"bulkEditStoragePathAssignMessage": "{count, plural, one{This operation will assign the storage path {path} to the selected document.} other{This operation will assign the storage path {path} to {count} selected documents.}}",
"bulkEditCorrespondentRemoveMessage": "{count, plural, one{This operation will remove the correspondent {correspondent} from the selected document.} other{This operation will remove the correspondent {correspondent} from {count} selected documents.}}",
"bulkEditDocumentTypeRemoveMessage": "{count, plural, one{This operation will remove the document type {docType} from the selected document.} other{This operation will remove the document type {docType} from {count} selected documents.}}",
"bulkEditStoragePathRemoveMessage": "{count, plural, one{This operation will remove the storage path {path} from the selected document.} other{This operation will remove the storage path {path} from {count} selected documents.}}",
"bulkEditCorrespondentRemoveMessage": "{count, plural, one{This operation will remove the correspondent from the selected document.} other{This operation will remove the correspondent from {count} selected documents.}}",
"bulkEditDocumentTypeRemoveMessage": "{count, plural, one{This operation will remove the document type from the selected document.} other{This operation will remove the document type from {count} selected documents.}}",
"bulkEditStoragePathRemoveMessage": "{count, plural, one{This operation will remove the storage path from the selected document.} other{This operation will remove the storage path from {count} selected documents.}}",
"anyTag": "Any",
"@anyTag": {
"description": "Label shown when any tag should be filtered"