mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-08 00:07:48 -06:00
fix: Document upload created at field clear button only shows when value is set, consistent ordering of labels
This commit is contained in:
@@ -8,9 +8,6 @@ import 'package:form_builder_validators/form_builder_validators.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:paperless_api/paperless_api.dart';
|
import 'package:paperless_api/paperless_api.dart';
|
||||||
import 'package:paperless_mobile/core/repository/label_repository.dart';
|
import 'package:paperless_mobile/core/repository/label_repository.dart';
|
||||||
import 'package:paperless_mobile/core/repository/state/impl/correspondent_repository_state.dart';
|
|
||||||
import 'package:paperless_mobile/core/repository/state/impl/document_type_repository_state.dart';
|
|
||||||
import 'package:paperless_mobile/core/repository/state/impl/storage_path_repository_state.dart';
|
|
||||||
import 'package:paperless_mobile/core/workarounds/colored_chip.dart';
|
import 'package:paperless_mobile/core/workarounds/colored_chip.dart';
|
||||||
import 'package:paperless_mobile/extensions/flutter_extensions.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/document_edit/cubit/document_edit_cubit.dart';
|
||||||
@@ -21,7 +18,6 @@ import 'package:paperless_mobile/features/labels/tags/view/widgets/tags_form_fie
|
|||||||
import 'package:paperless_mobile/features/labels/view/widgets/label_form_field.dart';
|
import 'package:paperless_mobile/features/labels/view/widgets/label_form_field.dart';
|
||||||
import 'package:paperless_mobile/generated/l10n.dart';
|
import 'package:paperless_mobile/generated/l10n.dart';
|
||||||
import 'package:paperless_mobile/helpers/message_helpers.dart';
|
import 'package:paperless_mobile/helpers/message_helpers.dart';
|
||||||
import 'package:paperless_mobile/constants.dart';
|
|
||||||
|
|
||||||
class DocumentEditPage extends StatefulWidget {
|
class DocumentEditPage extends StatefulWidget {
|
||||||
final FieldSuggestions suggestions;
|
final FieldSuggestions suggestions;
|
||||||
@@ -88,14 +84,14 @@ class _DocumentEditPageState extends State<DocumentEditPage> {
|
|||||||
children: [
|
children: [
|
||||||
_buildTitleFormField(state.document.title).padded(),
|
_buildTitleFormField(state.document.title).padded(),
|
||||||
_buildCreatedAtFormField(state.document.created).padded(),
|
_buildCreatedAtFormField(state.document.created).padded(),
|
||||||
_buildDocumentTypeFormField(
|
|
||||||
state.document.documentType,
|
|
||||||
state.documentTypes,
|
|
||||||
).padded(),
|
|
||||||
_buildCorrespondentFormField(
|
_buildCorrespondentFormField(
|
||||||
state.document.correspondent,
|
state.document.correspondent,
|
||||||
state.correspondents,
|
state.correspondents,
|
||||||
).padded(),
|
).padded(),
|
||||||
|
_buildDocumentTypeFormField(
|
||||||
|
state.document.documentType,
|
||||||
|
state.documentTypes,
|
||||||
|
).padded(),
|
||||||
_buildStoragePathFormField(
|
_buildStoragePathFormField(
|
||||||
state.document.storagePath,
|
state.document.storagePath,
|
||||||
state.storagePaths,
|
state.storagePaths,
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class _DocumentUploadPreparationPageState
|
|||||||
PaperlessValidationErrors _errors = {};
|
PaperlessValidationErrors _errors = {};
|
||||||
bool _isUploadLoading = false;
|
bool _isUploadLoading = false;
|
||||||
late bool _syncTitleAndFilename;
|
late bool _syncTitleAndFilename;
|
||||||
|
bool _showDatePickerDeleteIcon = false;
|
||||||
final _now = DateTime.now();
|
final _now = DateTime.now();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -82,6 +83,7 @@ class _DocumentUploadPreparationPageState
|
|||||||
key: _formKey,
|
key: _formKey,
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: [
|
children: [
|
||||||
|
// Title
|
||||||
FormBuilderTextField(
|
FormBuilderTextField(
|
||||||
autovalidateMode: AutovalidateMode.always,
|
autovalidateMode: AutovalidateMode.always,
|
||||||
name: DocumentModel.titleKey,
|
name: DocumentModel.titleKey,
|
||||||
@@ -112,6 +114,7 @@ class _DocumentUploadPreparationPageState
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
// Filename
|
||||||
FormBuilderTextField(
|
FormBuilderTextField(
|
||||||
autovalidateMode: AutovalidateMode.always,
|
autovalidateMode: AutovalidateMode.always,
|
||||||
readOnly: _syncTitleAndFilename,
|
readOnly: _syncTitleAndFilename,
|
||||||
@@ -129,6 +132,7 @@ class _DocumentUploadPreparationPageState
|
|||||||
initialValue: widget.filename ??
|
initialValue: widget.filename ??
|
||||||
"scan_${fileNameDateFormat.format(_now)}",
|
"scan_${fileNameDateFormat.format(_now)}",
|
||||||
),
|
),
|
||||||
|
// Synchronize title and filename
|
||||||
SwitchListTile(
|
SwitchListTile(
|
||||||
value: _syncTitleAndFilename,
|
value: _syncTitleAndFilename,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
@@ -152,40 +156,33 @@ class _DocumentUploadPreparationPageState
|
|||||||
.documentUploadPageSynchronizeTitleAndFilenameLabel,
|
.documentUploadPageSynchronizeTitleAndFilenameLabel,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// Created at
|
||||||
FormBuilderDateTimePicker(
|
FormBuilderDateTimePicker(
|
||||||
autovalidateMode: AutovalidateMode.always,
|
autovalidateMode: AutovalidateMode.always,
|
||||||
format: DateFormat.yMMMMd(),
|
format: DateFormat.yMMMMd(),
|
||||||
inputType: InputType.date,
|
inputType: InputType.date,
|
||||||
name: DocumentModel.createdKey,
|
name: DocumentModel.createdKey,
|
||||||
initialValue: null,
|
initialValue: null,
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() => _showDatePickerDeleteIcon = value != null);
|
||||||
|
},
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
prefixIcon: const Icon(Icons.calendar_month_outlined),
|
prefixIcon: const Icon(Icons.calendar_month_outlined),
|
||||||
labelText:
|
labelText:
|
||||||
S.of(context).documentCreatedPropertyLabel + " *",
|
S.of(context).documentCreatedPropertyLabel + " *",
|
||||||
suffixIcon: IconButton(
|
suffixIcon: _showDatePickerDeleteIcon
|
||||||
|
? IconButton(
|
||||||
icon: const Icon(Icons.close),
|
icon: const Icon(Icons.close),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_formKey
|
_formKey.currentState!
|
||||||
.currentState!.fields[DocumentModel.createdKey]
|
.fields[DocumentModel.createdKey]
|
||||||
?.didChange(null);
|
?.didChange(null);
|
||||||
},
|
},
|
||||||
)),
|
)
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
LabelFormField<DocumentType>(
|
|
||||||
notAssignedSelectable: false,
|
|
||||||
formBuilderState: _formKey.currentState,
|
|
||||||
labelCreationWidgetBuilder: (initialName) =>
|
|
||||||
RepositoryProvider(
|
|
||||||
create: (context) =>
|
|
||||||
context.read<LabelRepository<DocumentType>>(),
|
|
||||||
child: AddDocumentTypePage(initialName: initialName),
|
|
||||||
),
|
|
||||||
textFieldLabel:
|
|
||||||
S.of(context).documentDocumentTypePropertyLabel + " *",
|
|
||||||
name: DocumentModel.documentTypeKey,
|
|
||||||
labelOptions: state.documentTypes,
|
|
||||||
prefixIcon: const Icon(Icons.description_outlined),
|
|
||||||
),
|
),
|
||||||
|
// Correspondent
|
||||||
LabelFormField<Correspondent>(
|
LabelFormField<Correspondent>(
|
||||||
notAssignedSelectable: false,
|
notAssignedSelectable: false,
|
||||||
formBuilderState: _formKey.currentState,
|
formBuilderState: _formKey.currentState,
|
||||||
@@ -201,6 +198,22 @@ class _DocumentUploadPreparationPageState
|
|||||||
labelOptions: state.correspondents,
|
labelOptions: state.correspondents,
|
||||||
prefixIcon: const Icon(Icons.person_outline),
|
prefixIcon: const Icon(Icons.person_outline),
|
||||||
),
|
),
|
||||||
|
// Document type
|
||||||
|
LabelFormField<DocumentType>(
|
||||||
|
notAssignedSelectable: false,
|
||||||
|
formBuilderState: _formKey.currentState,
|
||||||
|
labelCreationWidgetBuilder: (initialName) =>
|
||||||
|
RepositoryProvider(
|
||||||
|
create: (context) =>
|
||||||
|
context.read<LabelRepository<DocumentType>>(),
|
||||||
|
child: AddDocumentTypePage(initialName: initialName),
|
||||||
|
),
|
||||||
|
textFieldLabel:
|
||||||
|
S.of(context).documentDocumentTypePropertyLabel + " *",
|
||||||
|
name: DocumentModel.documentTypeKey,
|
||||||
|
labelOptions: state.documentTypes,
|
||||||
|
prefixIcon: const Icon(Icons.description_outlined),
|
||||||
|
),
|
||||||
TagFormField(
|
TagFormField(
|
||||||
name: DocumentModel.tagsKey,
|
name: DocumentModel.tagsKey,
|
||||||
notAssignedSelectable: false,
|
notAssignedSelectable: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user