mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-10 08:07:59 -06:00
Merge pull request #213 from astubenbord/feature/reset-filter-button
Feature: Reset filter button
This commit is contained in:
49
README.md
49
README.md
@@ -22,7 +22,7 @@
|
|||||||
<img src="assets/logos/paperless_logo_green.png" alt="Logo" width="80" height="80">
|
<img src="assets/logos/paperless_logo_green.png" alt="Logo" width="80" height="80">
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<h3 align="center">Paperless Mobile</h3>
|
<h2 align="center">Paperless Mobile</h2>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
An (almost) fully fledged mobile paperless client.
|
An (almost) fully fledged mobile paperless client.
|
||||||
@@ -42,26 +42,25 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Important Notice
|
## Important Notice
|
||||||
This project is under **very active** development. Breaking changes are expected and therefore a clean install is recommended for each update! The newest version (2.2.0+28, available in Open Beta on Google Play) is **not** yet compatible with Paperless-ngx 1.14.0 and later!
|
This project is under **very active** development. Breaking changes are expected and therefore a clean install is recommended for each update!
|
||||||
|
|
||||||
<!-- ABOUT THE PROJECT -->
|
<!-- ABOUT THE PROJECT -->
|
||||||
## About The Project
|
## About The Project
|
||||||
With this app you can conveniently add, manage or simply find documents stored in your paperless server without any comproimises. This project started as a small fun side project to learn more about the Flutter framework and because existing solutions didn't fulfill my needs, but it has grown much faster with far more features than I originally anticipated.
|
Paperless Mobile brings <a href="https://github.com/paperless-ngx/paperless-ngx">paperless-ngx</a> to your smartphone without any compromises. While you can use paperless-ngx from a mobile browser, managing your documents this way is often a tedious and slow process. The app integrates a custom scanner, biometric authentication and many more conveniences to help you make the transition from a paper-based to a fully digital office experience.
|
||||||
|
|
||||||
|
### :rocket: Highlights
|
||||||
### :rocket: Features
|
:heavy_check_mark: **View** your documents at a glance<br>
|
||||||
:heavy_check_mark: **View** your documents at a glance, in a compact list or a more detailed grid view<br>
|
:heavy_check_mark: **Add**, **delete** or **edit** documents<br>
|
||||||
:heavy_check_mark: **Add**, **delete** or **edit** your documents<br>
|
:heavy_check_mark: **Share**, **download** and **preview** files<br>
|
||||||
:heavy_check_mark: **Share**, **download** and **preview** PDF files<br>
|
:heavy_check_mark: **Manage** and assign labels<br>
|
||||||
:heavy_check_mark: **Manage** and assign correspondents, document types, tags and storage paths<br>
|
:heavy_check_mark: **Scan** and upload documents to paperless<br>
|
||||||
:heavy_check_mark: **Scan** and upload documents to paperless with preset correspondent, document type, tags and creation date<br>
|
|
||||||
:heavy_check_mark: **Upload existing documents** from other apps via Paperless Mobile<br>
|
:heavy_check_mark: **Upload existing documents** from other apps via Paperless Mobile<br>
|
||||||
:heavy_check_mark: See all new documents in a dedicated **inbox**<br>
|
:heavy_check_mark: Easily process and manage new documents in the dedicated **inbox**<br>
|
||||||
:heavy_check_mark: **Search** for documents using a wide range of filter criteria<br>
|
:heavy_check_mark: **Search** for documents using a wide range of filter criteria<br>
|
||||||
:heavy_check_mark: **Secure** your data with **biometric authentication** across sessions<br>
|
:heavy_check_mark: **Secure** your data with a **biometric factor**<br>
|
||||||
:heavy_check_mark: Support for **TLS mutual authentication** (client certificates)<br>
|
:heavy_check_mark: Support for **TLS mutual authentication** (client certificates)<br>
|
||||||
:heavy_check_mark: **Modern, intuitive UI** built according to the Material Design 3 specification<br>
|
:heavy_check_mark: **Modern, intuitive UI** built according to the Material Design 3 specification<br>
|
||||||
:heavy_check_mark: Available in english and german language (more to come!)<br>
|
:heavy_check_mark: Available in English, German, Polish, French, Catalan, Czech and Turkish language with more to come<br>
|
||||||
|
|
||||||
|
|
||||||
### Built With
|
### Built With
|
||||||
@@ -70,13 +69,12 @@ With this app you can conveniently add, manage or simply find documents stored i
|
|||||||
|
|
||||||
<!-- GETTING STARTED -->
|
<!-- GETTING STARTED -->
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
To get a local copy up and running follow these simple steps.
|
To get a local copy up and running follow these simple steps.
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
* Install an IDE of your choice (e.g. VSCode with the Dart/Flutter extensions)
|
* Install an IDE of your choice (e.g. VSCode with the Dart/Flutter extensions)
|
||||||
* Install the flutter SDK (https://docs.flutter.dev/get-started/install) _or_ use the flutter git submodule pinned in this project by running `git submodule update --init` inside the project root directory.
|
* Install the flutter SDK (https://docs.flutter.dev/get-started/install) _or_ use the flutter git submodule pinned in this project by running `git submodule update --init` inside the project root directory.
|
||||||
*
|
|
||||||
### Install dependencies and generate files
|
### Install dependencies and generate files
|
||||||
1. First, clone the repository:
|
1. First, clone the repository:
|
||||||
```sh
|
```sh
|
||||||
@@ -150,16 +148,19 @@ flutter install --use-application-binary=build/pp/outputs/flutter-apk/<apk_file_
|
|||||||
If you want to contribute by translating a language, feel free to join the [Crowdin](https://crowdin.com/project/paperless-mobile) project!
|
If you want to contribute by translating a language, feel free to join the [Crowdin](https://crowdin.com/project/paperless-mobile) project!
|
||||||
|
|
||||||
Thanks to the following contributors for providing translations:
|
Thanks to the following contributors for providing translations:
|
||||||
- German and English by <a href="https://github.com/astubenbord">astubenbord</a>
|
- German and English language translated by <a href="https://github.com/astubenbord">astubenbord</a>
|
||||||
- Czech language by <a href="https://github.com/svetlemodry">svetlemodry</a>
|
- Czech language translated by <a href="https://github.com/svetlemodry">svetlemodry</a>
|
||||||
- Turkish language by <a href="https://github.com/imsakg">imsakg</a>
|
- Turkish language translated by <a href="https://github.com/imsakg">imsakg</a>
|
||||||
|
- Polish language translated by <a href="https://github.com/losiu97">losiu97</a>
|
||||||
|
- French language translated by <a href="https://github.com/JigSawFr">JigSawFr</a>, <a href="https://github.com/SpicyWasab">SpicyWasab</a> and <a href="https://github.com/nathanaelhoun">nathanaelhoun</a>
|
||||||
|
- Catalan language translated by <a href="https://github.com/rubenix">rubenix</a>
|
||||||
|
|
||||||
<!-- ROADMAP -->
|
<!-- ROADMAP -->
|
||||||
## Roadmap
|
## Roadmap
|
||||||
- [ ] Fully custom document scanner optimized for common white A4 documents and optimized for the use with Paperless
|
- [ ] Fully custom document scanner optimized for common white A4 documents and optimized for the use with Paperless
|
||||||
- [ ] Add more languages
|
- [ ] Add more languages
|
||||||
- [ ] Support for IOS and publish to AppStore
|
- [x] Support for IOS and publish to AppStore
|
||||||
- [ ] Automatic releases and CI/CD with fastlane
|
- [x] Automatic releases and CI/CD with fastlane
|
||||||
- [ ] Templates for recurring scans (e.g. monthly payrolls with same title, dates at end of month, fixed correspondent and document type)
|
- [ ] Templates for recurring scans (e.g. monthly payrolls with same title, dates at end of month, fixed correspondent and document type)
|
||||||
|
|
||||||
See the [open issues](https://github.com/astubenbord/paperless-mobile/issues) for a full list of issues and [open feature requests](https://github.com/astubenbord/paperless-mobile/discussions/categories/feature-requests) for requested features.
|
See the [open issues](https://github.com/astubenbord/paperless-mobile/issues) for a full list of issues and [open feature requests](https://github.com/astubenbord/paperless-mobile/discussions/categories/feature-requests) for requested features.
|
||||||
@@ -174,7 +175,7 @@ Don't forget to give the project a star! Thanks again!
|
|||||||
|
|
||||||
1. Fork the Project
|
1. Fork the Project
|
||||||
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
|
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
|
||||||
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
|
3. Commit your Changes (`git commit -m 'feat: Add some AmazingFeature'`)
|
||||||
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
||||||
5. Open a Pull Request
|
5. Open a Pull Request
|
||||||
|
|
||||||
@@ -183,7 +184,7 @@ Don't forget to give the project a star! Thanks again!
|
|||||||
Distributed under the GNU General Public License v3.0. See `LICENSE.txt` for more information.
|
Distributed under the GNU General Public License v3.0. See `LICENSE.txt` for more information.
|
||||||
|
|
||||||
## Donations
|
## Donations
|
||||||
I do this in my free time, so if you like the project, consider buying me a coffee! Any donation is much appreciated :)
|
I do this in my free time, so if you like the project, consider buying me a coffee! Any donation is much appreciated :^)
|
||||||
|
|
||||||
[](https://www.buymeacoffee.com/astubenbord)
|
[](https://www.buymeacoffee.com/astubenbord)
|
||||||
|
|
||||||
@@ -214,4 +215,6 @@ Made with [contrib.rocks](https://contrib.rocks).
|
|||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
#### Suggestions are not selectable in any of the label form fields
|
#### Suggestions are not selectable in any of the label form fields
|
||||||
This is a known issue and it has to do with accessibility features of Android. Password managers such as Bitwarden often caused this issue. Luckily, this can be resolved by turning off the accessibility features in these apps. This could also be observed with apps that are allowed to display over other apps, such as emulations of the dynamic island on android.
|
This is a known issue and it has to do with accessibility features of Android. Password managers such as Bitwarden often caused this issue. Luckily, this can be resolved by turning off the accessibility features in these apps. This could also be observed with apps that are allowed to display over other apps, such as emulations of the dynamic island on android.
|
||||||
|
## I cannot log in since the update to paperless-ngx 1.14.0 (and above).
|
||||||
|
The app has to somehow get information about it's user from the paperless API. Therefore, the `Users -> View` and the `UISettings -> View` permissions are required for each user trying to log into the app. Otherwise, the app has no way of obtaining your user id and other information required for the usage of most features.
|
||||||
@@ -22,7 +22,6 @@ import 'package:paperless_mobile/features/saved_view/view/saved_view_list.dart';
|
|||||||
import 'package:paperless_mobile/features/tasks/cubit/task_status_cubit.dart';
|
import 'package:paperless_mobile/features/tasks/cubit/task_status_cubit.dart';
|
||||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||||
import 'package:paperless_mobile/helpers/message_helpers.dart';
|
import 'package:paperless_mobile/helpers/message_helpers.dart';
|
||||||
import 'package:sliver_tools/sliver_tools.dart';
|
|
||||||
|
|
||||||
class DocumentFilterIntent {
|
class DocumentFilterIntent {
|
||||||
final DocumentFilter? filter;
|
final DocumentFilter? filter;
|
||||||
@@ -34,7 +33,6 @@ class DocumentFilterIntent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Refactor this
|
|
||||||
class DocumentsPage extends StatefulWidget {
|
class DocumentsPage extends StatefulWidget {
|
||||||
const DocumentsPage({Key? key}) : super(key: key);
|
const DocumentsPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@@ -120,30 +118,60 @@ class _DocumentsPageState extends State<DocumentsPage>
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final appliedFiltersCount = state.filter.appliedFiltersCount;
|
final appliedFiltersCount = state.filter.appliedFiltersCount;
|
||||||
final show = state.selection.isEmpty;
|
final show = state.selection.isEmpty;
|
||||||
|
final canReset = state.filter.appliedFiltersCount > 0;
|
||||||
return AnimatedScale(
|
return AnimatedScale(
|
||||||
scale: show ? 1 : 0,
|
scale: show ? 1 : 0,
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
curve: Curves.easeIn,
|
curve: Curves.easeIn,
|
||||||
child: b.Badge(
|
child: Column(
|
||||||
position: b.BadgePosition.topEnd(top: -12, end: -6),
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
showBadge: appliedFiltersCount > 0,
|
children: [
|
||||||
badgeContent: Text(
|
if (canReset)
|
||||||
'$appliedFiltersCount',
|
Padding(
|
||||||
style: const TextStyle(
|
padding: const EdgeInsets.all(8.0),
|
||||||
color: Colors.white,
|
child: FloatingActionButton.small(
|
||||||
),
|
key: UniqueKey(),
|
||||||
),
|
backgroundColor: Theme.of(context)
|
||||||
animationType: b.BadgeAnimationType.fade,
|
.colorScheme
|
||||||
badgeColor: Colors.red,
|
.onPrimaryContainer,
|
||||||
child: _currentTab == 0
|
onPressed: () {
|
||||||
? FloatingActionButton(
|
context.read<DocumentsCubit>().updateFilter();
|
||||||
child: const Icon(Icons.filter_alt_outlined),
|
},
|
||||||
onPressed: _openDocumentFilter,
|
child: Icon(
|
||||||
)
|
Icons.refresh,
|
||||||
: FloatingActionButton(
|
color: Theme.of(context)
|
||||||
child: const Icon(Icons.add),
|
.colorScheme
|
||||||
onPressed: () => _onCreateSavedView(state.filter),
|
.primaryContainer,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
b.Badge(
|
||||||
|
position: b.BadgePosition.topEnd(top: -12, end: -6),
|
||||||
|
showBadge: appliedFiltersCount > 0,
|
||||||
|
badgeContent: Text(
|
||||||
|
'$appliedFiltersCount',
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
animationType: b.BadgeAnimationType.fade,
|
||||||
|
badgeColor: Colors.red,
|
||||||
|
child: AnimatedSwitcher(
|
||||||
|
duration: const Duration(milliseconds: 250),
|
||||||
|
child: (_currentTab == 0)
|
||||||
|
? FloatingActionButton(
|
||||||
|
child:
|
||||||
|
const Icon(Icons.filter_alt_outlined),
|
||||||
|
onPressed: _openDocumentFilter,
|
||||||
|
)
|
||||||
|
: FloatingActionButton(
|
||||||
|
child: const Icon(Icons.add),
|
||||||
|
onPressed: () =>
|
||||||
|
_onCreateSavedView(state.filter),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ class SliverAdaptiveDocumentsView extends AdaptiveDocumentsView {
|
|||||||
crossAxisCount: 2,
|
crossAxisCount: 2,
|
||||||
mainAxisSpacing: 4,
|
mainAxisSpacing: 4,
|
||||||
crossAxisSpacing: 4,
|
crossAxisSpacing: 4,
|
||||||
childAspectRatio: 1 / 2,
|
mainAxisExtent: 356,
|
||||||
),
|
),
|
||||||
itemCount: documents.length,
|
itemCount: documents.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
|
|||||||
@@ -141,10 +141,10 @@ class DocumentDetailedItem extends DocumentItem {
|
|||||||
],
|
],
|
||||||
).paddedLTRB(8, 0, 8, 4),
|
).paddedLTRB(8, 0, 8, 4),
|
||||||
TagsWidget(
|
TagsWidget(
|
||||||
isMultiLine: false,
|
|
||||||
tags: document.tags
|
tags: document.tags
|
||||||
.map((e) => context.watch<LabelRepository>().state.tags[e]!)
|
.map((e) => context.watch<LabelRepository>().state.tags[e]!)
|
||||||
.toList(),
|
.toList(),
|
||||||
|
onTagSelected: onTagSelected,
|
||||||
).padded(),
|
).padded(),
|
||||||
if (highlights != null)
|
if (highlights != null)
|
||||||
Html(
|
Html(
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
import 'package:paperless_mobile/core/repository/label_repository.dart';
|
import 'package:paperless_mobile/core/repository/label_repository.dart';
|
||||||
import 'package:paperless_mobile/features/documents/view/widgets/document_preview.dart';
|
import 'package:paperless_mobile/features/documents/view/widgets/document_preview.dart';
|
||||||
import 'package:paperless_mobile/features/documents/view/widgets/items/document_item.dart';
|
import 'package:paperless_mobile/features/documents/view/widgets/items/document_item.dart';
|
||||||
import 'package:paperless_mobile/features/labels/correspondent/view/widgets/correspondent_widget.dart';
|
import 'package:paperless_mobile/features/labels/correspondent/view/widgets/correspondent_widget.dart';
|
||||||
import 'package:paperless_mobile/features/labels/document_type/view/widgets/document_type_widget.dart';
|
import 'package:paperless_mobile/features/labels/document_type/view/widgets/document_type_widget.dart';
|
||||||
import 'package:paperless_mobile/features/labels/tags/view/widgets/tags_widget.dart';
|
import 'package:paperless_mobile/features/labels/tags/view/widgets/tags_widget.dart';
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class DocumentGridItem extends DocumentItem {
|
class DocumentGridItem extends DocumentItem {
|
||||||
@@ -42,10 +42,46 @@ class DocumentGridItem extends DocumentItem {
|
|||||||
children: [
|
children: [
|
||||||
AspectRatio(
|
AspectRatio(
|
||||||
aspectRatio: 1,
|
aspectRatio: 1,
|
||||||
child: DocumentPreview(
|
child: Stack(
|
||||||
document: document,
|
children: [
|
||||||
borderRadius: 12.0,
|
Positioned.fill(
|
||||||
enableHero: enableHeroAnimation,
|
child: DocumentPreview(
|
||||||
|
document: document,
|
||||||
|
borderRadius: 12.0,
|
||||||
|
enableHero: enableHeroAnimation,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.bottomLeft,
|
||||||
|
child: SizedBox(
|
||||||
|
height: 48,
|
||||||
|
child: NotificationListener<ScrollNotification>(
|
||||||
|
// Prevents ancestor notification listeners to be notified when this widget scrolls
|
||||||
|
onNotification: (notification) => true,
|
||||||
|
child: CustomScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
slivers: [
|
||||||
|
const SliverToBoxAdapter(
|
||||||
|
child: SizedBox(width: 8),
|
||||||
|
),
|
||||||
|
TagsWidget.sliver(
|
||||||
|
tags: document.tags
|
||||||
|
.map((e) => context
|
||||||
|
.watch<LabelRepository>()
|
||||||
|
.state
|
||||||
|
.tags[e]!)
|
||||||
|
.toList(),
|
||||||
|
onTagSelected: onTagSelected,
|
||||||
|
),
|
||||||
|
const SliverToBoxAdapter(
|
||||||
|
child: SizedBox(width: 8),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -59,27 +95,23 @@ class DocumentGridItem extends DocumentItem {
|
|||||||
.watch<LabelRepository>()
|
.watch<LabelRepository>()
|
||||||
.state
|
.state
|
||||||
.correspondents[document.correspondent],
|
.correspondents[document.correspondent],
|
||||||
|
onSelected: onCorrespondentSelected,
|
||||||
),
|
),
|
||||||
DocumentTypeWidget(
|
DocumentTypeWidget(
|
||||||
documentType: context
|
documentType: context
|
||||||
.watch<LabelRepository>()
|
.watch<LabelRepository>()
|
||||||
.state
|
.state
|
||||||
.documentTypes[document.documentType],
|
.documentTypes[document.documentType],
|
||||||
|
onSelected: onDocumentTypeSelected,
|
||||||
),
|
),
|
||||||
Text(
|
Padding(
|
||||||
document.title,
|
padding: const EdgeInsets.only(bottom: 8.0),
|
||||||
maxLines: document.tags.isEmpty ? 3 : 2,
|
child: Text(
|
||||||
overflow: TextOverflow.ellipsis,
|
document.title,
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
maxLines: 3,
|
||||||
),
|
overflow: TextOverflow.ellipsis,
|
||||||
const Spacer(),
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
TagsWidget(
|
),
|
||||||
tags: document.tags
|
|
||||||
.map((e) =>
|
|
||||||
context.watch<LabelRepository>().state.tags[e]!)
|
|
||||||
.toList(),
|
|
||||||
isMultiLine: false,
|
|
||||||
onTagSelected: onTagSelected,
|
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ class DocumentListItem extends DocumentItem {
|
|||||||
.where((e) => labels.tags.containsKey(e))
|
.where((e) => labels.tags.containsKey(e))
|
||||||
.map((e) => labels.tags[e]!)
|
.map((e) => labels.tags[e]!)
|
||||||
.toList(),
|
.toList(),
|
||||||
isMultiLine: false,
|
|
||||||
onTagSelected: (id) => onTagSelected?.call(id),
|
onTagSelected: (id) => onTagSelected?.call(id),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -213,13 +213,11 @@ class _InboxItemState extends State<InboxItem> {
|
|||||||
TagsWidget(
|
TagsWidget(
|
||||||
tags: widget.document.tags
|
tags: widget.document.tags
|
||||||
.map((e) => state.labels.tags[e])
|
.map((e) => state.labels.tags[e])
|
||||||
.whereNot((element) => element == null)
|
.whereNot((e) => e == null)
|
||||||
.toList()
|
.toList()
|
||||||
.cast<Tag>(),
|
.cast<Tag>(),
|
||||||
isMultiLine: false,
|
|
||||||
isClickable: false,
|
isClickable: false,
|
||||||
showShortNames: true,
|
showShortNames: true,
|
||||||
dense: true,
|
|
||||||
).paddedOnly(left: 8, bottom: 8),
|
).paddedOnly(left: 8, bottom: 8),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -4,51 +4,95 @@ import 'package:paperless_mobile/features/labels/tags/view/widgets/tag_widget.da
|
|||||||
|
|
||||||
class TagsWidget extends StatelessWidget {
|
class TagsWidget extends StatelessWidget {
|
||||||
final List<Tag> tags;
|
final List<Tag> tags;
|
||||||
final bool isMultiLine;
|
|
||||||
final void Function(int tagId)? onTagSelected;
|
final void Function(int tagId)? onTagSelected;
|
||||||
final bool isClickable;
|
final bool isClickable;
|
||||||
final bool showShortNames;
|
final bool showShortNames;
|
||||||
final bool dense;
|
final bool dense;
|
||||||
|
|
||||||
const TagsWidget({
|
const TagsWidget({
|
||||||
Key? key,
|
super.key,
|
||||||
required this.tags,
|
required this.tags,
|
||||||
this.isMultiLine = true,
|
|
||||||
this.isClickable = true,
|
|
||||||
this.onTagSelected,
|
this.onTagSelected,
|
||||||
|
this.isClickable = true,
|
||||||
this.showShortNames = false,
|
this.showShortNames = false,
|
||||||
this.dense = true,
|
this.dense = true,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
|
List<Widget> get _children {
|
||||||
|
return [
|
||||||
|
for (var tag in tags)
|
||||||
|
TagWidget(
|
||||||
|
tag: tag,
|
||||||
|
isClickable: isClickable,
|
||||||
|
onSelected: () => onTagSelected?.call(tag.id!),
|
||||||
|
showShortName: showShortNames,
|
||||||
|
dense: dense,
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
const factory TagsWidget.multiLine({
|
||||||
|
Key? key,
|
||||||
|
required List<Tag> tags,
|
||||||
|
required void Function(int tagId)? onTagSelected,
|
||||||
|
required bool isClickable,
|
||||||
|
required bool showShortNames,
|
||||||
|
required bool dense,
|
||||||
|
}) = _MultiLineTagsWidget;
|
||||||
|
|
||||||
|
const factory TagsWidget.sliver({
|
||||||
|
Key? key,
|
||||||
|
required List<Tag> tags,
|
||||||
|
void Function(int tagId)? onTagSelected,
|
||||||
|
bool isClickable,
|
||||||
|
bool showShortNames,
|
||||||
|
bool dense,
|
||||||
|
}) = _SliverTagsWidget;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Builder(
|
return SingleChildScrollView(
|
||||||
builder: (context) {
|
scrollDirection: Axis.horizontal,
|
||||||
final children = tags
|
child: Row(children: _children),
|
||||||
.map(
|
);
|
||||||
(tag) => TagWidget(
|
}
|
||||||
tag: tag,
|
}
|
||||||
isClickable: isClickable,
|
|
||||||
onSelected: () => onTagSelected?.call(tag.id!),
|
class _MultiLineTagsWidget extends TagsWidget {
|
||||||
showShortName: showShortNames,
|
const _MultiLineTagsWidget({
|
||||||
dense: dense,
|
super.key,
|
||||||
),
|
required super.tags,
|
||||||
)
|
super.onTagSelected,
|
||||||
.toList();
|
super.isClickable,
|
||||||
if (isMultiLine) {
|
super.showShortNames,
|
||||||
return Wrap(
|
super.dense,
|
||||||
runAlignment: WrapAlignment.start,
|
});
|
||||||
children: children,
|
|
||||||
runSpacing: 4,
|
@override
|
||||||
spacing: 4,
|
Widget build(BuildContext context) {
|
||||||
);
|
return Wrap(
|
||||||
} else {
|
runAlignment: WrapAlignment.start,
|
||||||
return SingleChildScrollView(
|
children: _children,
|
||||||
scrollDirection: Axis.horizontal,
|
runSpacing: 4,
|
||||||
child: Row(children: children),
|
spacing: 4,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
|
class _SliverTagsWidget extends TagsWidget {
|
||||||
|
const _SliverTagsWidget({
|
||||||
|
super.key,
|
||||||
|
required super.tags,
|
||||||
|
super.isClickable,
|
||||||
|
super.showShortNames,
|
||||||
|
super.dense,
|
||||||
|
super.onTagSelected,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SliverList.list(
|
||||||
|
children: _children,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _login() async {
|
Future<void> _login() async {
|
||||||
|
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
if (_formKey.currentState?.saveAndValidate() ?? false) {
|
if (_formKey.currentState?.saveAndValidate() ?? false) {
|
||||||
final form = _formKey.currentState!.value;
|
final form = _formKey.currentState!.value;
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ class ObscuredInputTextFormField extends StatefulWidget {
|
|||||||
final void Function(String?) onChanged;
|
final void Function(String?) onChanged;
|
||||||
final FormFieldValidator<String>? validator;
|
final FormFieldValidator<String>? validator;
|
||||||
final bool enabled;
|
final bool enabled;
|
||||||
|
final FocusNode? focusNode;
|
||||||
|
|
||||||
|
final ValueChanged<String?>? onFieldSubmitted;
|
||||||
|
|
||||||
const ObscuredInputTextFormField({
|
const ObscuredInputTextFormField({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -14,6 +17,8 @@ class ObscuredInputTextFormField extends StatefulWidget {
|
|||||||
this.validator,
|
this.validator,
|
||||||
this.initialValue,
|
this.initialValue,
|
||||||
this.enabled = true,
|
this.enabled = true,
|
||||||
|
this.focusNode,
|
||||||
|
this.onFieldSubmitted,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -24,7 +29,13 @@ class ObscuredInputTextFormField extends StatefulWidget {
|
|||||||
class _ObscuredInputTextFormFieldState
|
class _ObscuredInputTextFormFieldState
|
||||||
extends State<ObscuredInputTextFormField> {
|
extends State<ObscuredInputTextFormField> {
|
||||||
bool _showPassword = false;
|
bool _showPassword = false;
|
||||||
final FocusNode _passwordFocusNode = FocusNode();
|
late final FocusNode _passwordFocusNode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_passwordFocusNode = widget.focusNode ?? FocusNode();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
@@ -37,6 +48,7 @@ class _ObscuredInputTextFormFieldState
|
|||||||
return TextFormField(
|
return TextFormField(
|
||||||
enabled: widget.enabled,
|
enabled: widget.enabled,
|
||||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
|
onFieldSubmitted: widget.onFieldSubmitted,
|
||||||
validator: widget.validator,
|
validator: widget.validator,
|
||||||
initialValue: widget.initialValue,
|
initialValue: widget.initialValue,
|
||||||
focusNode: _passwordFocusNode,
|
focusNode: _passwordFocusNode,
|
||||||
|
|||||||
@@ -9,8 +9,11 @@ import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
|||||||
class UserCredentialsFormField extends StatefulWidget {
|
class UserCredentialsFormField extends StatefulWidget {
|
||||||
static const fkCredentials = 'credentials';
|
static const fkCredentials = 'credentials';
|
||||||
|
|
||||||
|
final void Function() onFieldsSubmitted;
|
||||||
|
|
||||||
const UserCredentialsFormField({
|
const UserCredentialsFormField({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
required this.onFieldsSubmitted,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -19,6 +22,9 @@ class UserCredentialsFormField extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _UserCredentialsFormFieldState extends State<UserCredentialsFormField> {
|
class _UserCredentialsFormFieldState extends State<UserCredentialsFormField> {
|
||||||
|
final _usernameFocusNode = FocusNode();
|
||||||
|
final _passwordFocusNode = FocusNode();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FormBuilderField<LoginFormCredentials?>(
|
return FormBuilderField<LoginFormCredentials?>(
|
||||||
@@ -28,9 +34,13 @@ class _UserCredentialsFormFieldState extends State<UserCredentialsFormField> {
|
|||||||
children: [
|
children: [
|
||||||
TextFormField(
|
TextFormField(
|
||||||
key: const ValueKey('login-username'),
|
key: const ValueKey('login-username'),
|
||||||
textCapitalization: TextCapitalization.words,
|
focusNode: _usernameFocusNode,
|
||||||
|
textCapitalization: TextCapitalization.none,
|
||||||
|
textInputAction: TextInputAction.next,
|
||||||
|
onFieldSubmitted: (value) {
|
||||||
|
_passwordFocusNode.requestFocus();
|
||||||
|
},
|
||||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
// USERNAME
|
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
onChanged: (username) => field.didChange(
|
onChanged: (username) => field.didChange(
|
||||||
field.value?.copyWith(username: username) ??
|
field.value?.copyWith(username: username) ??
|
||||||
@@ -49,11 +59,15 @@ class _UserCredentialsFormFieldState extends State<UserCredentialsFormField> {
|
|||||||
),
|
),
|
||||||
ObscuredInputTextFormField(
|
ObscuredInputTextFormField(
|
||||||
key: const ValueKey('login-password'),
|
key: const ValueKey('login-password'),
|
||||||
|
focusNode: _passwordFocusNode,
|
||||||
label: S.of(context)!.password,
|
label: S.of(context)!.password,
|
||||||
onChanged: (password) => field.didChange(
|
onChanged: (password) => field.didChange(
|
||||||
field.value?.copyWith(password: password) ??
|
field.value?.copyWith(password: password) ??
|
||||||
LoginFormCredentials(password: password),
|
LoginFormCredentials(password: password),
|
||||||
),
|
),
|
||||||
|
onFieldSubmitted: (_) {
|
||||||
|
widget.onFieldsSubmitted();
|
||||||
|
},
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value?.trim().isEmpty ?? true) {
|
if (value?.trim().isEmpty ?? true) {
|
||||||
return S.of(context)!.passwordMustNotBeEmpty;
|
return S.of(context)!.passwordMustNotBeEmpty;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class ServerLoginPage extends StatefulWidget {
|
|||||||
final String submitText;
|
final String submitText;
|
||||||
final Future<void> Function() onSubmit;
|
final Future<void> Function() onSubmit;
|
||||||
final GlobalKey<FormBuilderState> formBuilderKey;
|
final GlobalKey<FormBuilderState> formBuilderKey;
|
||||||
|
|
||||||
const ServerLoginPage({
|
const ServerLoginPage({
|
||||||
super.key,
|
super.key,
|
||||||
required this.onSubmit,
|
required this.onSubmit,
|
||||||
@@ -41,8 +42,21 @@ class _ServerLoginPageState extends State<ServerLoginPage> {
|
|||||||
),
|
),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
children: [
|
children: [
|
||||||
Text(S.of(context)!.signInToServer(serverAddress)).padded(),
|
Text(
|
||||||
const UserCredentialsFormField(),
|
S.of(context)!.signInToServer(serverAddress) + ":",
|
||||||
|
style: Theme.of(context).textTheme.labelLarge,
|
||||||
|
).padded(16),
|
||||||
|
UserCredentialsFormField(
|
||||||
|
onFieldsSubmitted: widget.onSubmit,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
S.of(context)!.loginRequiredPermissionsHint,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.apply(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onBackground
|
||||||
|
.withOpacity(0.6)),
|
||||||
|
).padded(16),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
bottomNavigationBar: BottomAppBar(
|
bottomNavigationBar: BottomAppBar(
|
||||||
|
|||||||
@@ -825,36 +825,40 @@
|
|||||||
"description": "title of the alert dialog when exporting scans to pdf"
|
"description": "title of the alert dialog when exporting scans to pdf"
|
||||||
},
|
},
|
||||||
"allScansWillBeMerged": "Els escanejos s'uniran en un únic document PDF.",
|
"allScansWillBeMerged": "Els escanejos s'uniran en un únic document PDF.",
|
||||||
"behavior": "Behavior",
|
"behavior": "Comportament",
|
||||||
"@behavior": {
|
"@behavior": {
|
||||||
"description": "Title of the settings concerning app beahvior"
|
"description": "Title of the settings concerning app beahvior"
|
||||||
},
|
},
|
||||||
"theme": "Theme",
|
"theme": "Tema",
|
||||||
"@theme": {
|
"@theme": {
|
||||||
"description": "Title of the theme mode setting"
|
"description": "Title of the theme mode setting"
|
||||||
},
|
},
|
||||||
"clearCache": "Clear cache",
|
"clearCache": "Esborra cache",
|
||||||
"@clearCache": {
|
"@clearCache": {
|
||||||
"description": "Title of the clear cache setting"
|
"description": "Title of the clear cache setting"
|
||||||
},
|
},
|
||||||
"freeBytes": "Free {bytes}",
|
"freeBytes": "Lliure {bytes}",
|
||||||
"@freeBytes": {
|
"@freeBytes": {
|
||||||
"description": "Text shown for clear storage settings"
|
"description": "Text shown for clear storage settings"
|
||||||
},
|
},
|
||||||
"calculatingDots": "Calculating...",
|
"calculatingDots": "Calculant...",
|
||||||
"@calculatingDots": {
|
"@calculatingDots": {
|
||||||
"description": "Text shown when the byte size is still being calculated"
|
"description": "Text shown when the byte size is still being calculated"
|
||||||
},
|
},
|
||||||
"freedDiskSpace": "Successfully freed {bytes} of disk space.",
|
"freedDiskSpace": "Alliberats {bytes} d'espai de disc.",
|
||||||
"@freedDiskSpace": {
|
"@freedDiskSpace": {
|
||||||
"description": "Message shown after clearing storage"
|
"description": "Message shown after clearing storage"
|
||||||
},
|
},
|
||||||
"uploadScansAsPdf": "Upload scans as PDF",
|
"uploadScansAsPdf": "Puja escanejos com a PDF",
|
||||||
"@uploadScansAsPdf": {
|
"@uploadScansAsPdf": {
|
||||||
"description": "Title of the setting which toggles whether scans are always uploaded as pdf"
|
"description": "Title of the setting which toggles whether scans are always uploaded as pdf"
|
||||||
},
|
},
|
||||||
"convertSinglePageScanToPdf": "Always convert single page scans to PDF before uploading",
|
"convertSinglePageScanToPdf": "Coverteix únics escanejos a PDF abans de pujar",
|
||||||
"@convertSinglePageScanToPdf": {
|
"@convertSinglePageScanToPdf": {
|
||||||
"description": "description of the upload scans as pdf setting"
|
"description": "description of the upload scans as pdf setting"
|
||||||
|
},
|
||||||
|
"loginRequiredPermissionsHint": "Using Paperless Mobile requires a minimum set of user permissions since paperless-ngx 1.14.0 and higher. Therefore, please make sure that the user to be logged in has the permission to view other users (User → View) and the settings (UISettings → View). If you do not have these permissions, please contact an administrator of your paperless-ngx server.",
|
||||||
|
"@loginRequiredPermissionsHint": {
|
||||||
|
"description": "Hint shown on the login page informing the user of the required permissions to use the app."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -856,5 +856,9 @@
|
|||||||
"convertSinglePageScanToPdf": "Always convert single page scans to PDF before uploading",
|
"convertSinglePageScanToPdf": "Always convert single page scans to PDF before uploading",
|
||||||
"@convertSinglePageScanToPdf": {
|
"@convertSinglePageScanToPdf": {
|
||||||
"description": "description of the upload scans as pdf setting"
|
"description": "description of the upload scans as pdf setting"
|
||||||
|
},
|
||||||
|
"loginRequiredPermissionsHint": "Using Paperless Mobile requires a minimum set of user permissions since paperless-ngx 1.14.0 and higher. Therefore, please make sure that the user to be logged in has the permission to view other users (User → View) and the settings (UISettings → View). If you do not have these permissions, please contact an administrator of your paperless-ngx server.",
|
||||||
|
"@loginRequiredPermissionsHint": {
|
||||||
|
"description": "Hint shown on the login page informing the user of the required permissions to use the app."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -856,5 +856,9 @@
|
|||||||
"convertSinglePageScanToPdf": "Einseitige Scans vor dem Hochladen immer in PDF umwandeln",
|
"convertSinglePageScanToPdf": "Einseitige Scans vor dem Hochladen immer in PDF umwandeln",
|
||||||
"@convertSinglePageScanToPdf": {
|
"@convertSinglePageScanToPdf": {
|
||||||
"description": "description of the upload scans as pdf setting"
|
"description": "description of the upload scans as pdf setting"
|
||||||
|
},
|
||||||
|
"loginRequiredPermissionsHint": "Die Verwendung von Paperless Mobile erfordert seit paperless-ngx 1.14.0 und höher ein Mindestmaß an Benutzerberechtigungen. Stelle deshalb bitte sicher, dass der anzumeldende Benutzer die Berechtigung hat, andere Benutzer (User → View) und die Einstellungen (UISettings → View) einzusehen. Falls du nicht über diese Berechtigungen verfügst, wende dich bitte an einen Administrator deines paperless-ngx Servers.",
|
||||||
|
"@loginRequiredPermissionsHint": {
|
||||||
|
"description": "Hint shown on the login page informing the user of the required permissions to use the app."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -856,5 +856,9 @@
|
|||||||
"convertSinglePageScanToPdf": "Always convert single page scans to PDF before uploading",
|
"convertSinglePageScanToPdf": "Always convert single page scans to PDF before uploading",
|
||||||
"@convertSinglePageScanToPdf": {
|
"@convertSinglePageScanToPdf": {
|
||||||
"description": "description of the upload scans as pdf setting"
|
"description": "description of the upload scans as pdf setting"
|
||||||
|
},
|
||||||
|
"loginRequiredPermissionsHint": "Using Paperless Mobile requires a minimum set of user permissions since paperless-ngx 1.14.0 and higher. Therefore, please make sure that the user to be logged in has the permission to view other users (User → View) and the settings (UISettings → View). If you do not have these permissions, please contact an administrator of your paperless-ngx server.",
|
||||||
|
"@loginRequiredPermissionsHint": {
|
||||||
|
"description": "Hint shown on the login page informing the user of the required permissions to use the app."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -856,5 +856,9 @@
|
|||||||
"convertSinglePageScanToPdf": "Always convert single page scans to PDF before uploading",
|
"convertSinglePageScanToPdf": "Always convert single page scans to PDF before uploading",
|
||||||
"@convertSinglePageScanToPdf": {
|
"@convertSinglePageScanToPdf": {
|
||||||
"description": "description of the upload scans as pdf setting"
|
"description": "description of the upload scans as pdf setting"
|
||||||
|
},
|
||||||
|
"loginRequiredPermissionsHint": "Using Paperless Mobile requires a minimum set of user permissions since paperless-ngx 1.14.0 and higher. Therefore, please make sure that the user to be logged in has the permission to view other users (User → View) and the settings (UISettings → View). If you do not have these permissions, please contact an administrator of your paperless-ngx server.",
|
||||||
|
"@loginRequiredPermissionsHint": {
|
||||||
|
"description": "Hint shown on the login page informing the user of the required permissions to use the app."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -856,5 +856,9 @@
|
|||||||
"convertSinglePageScanToPdf": "Always convert single page scans to PDF before uploading",
|
"convertSinglePageScanToPdf": "Always convert single page scans to PDF before uploading",
|
||||||
"@convertSinglePageScanToPdf": {
|
"@convertSinglePageScanToPdf": {
|
||||||
"description": "description of the upload scans as pdf setting"
|
"description": "description of the upload scans as pdf setting"
|
||||||
|
},
|
||||||
|
"loginRequiredPermissionsHint": "Using Paperless Mobile requires a minimum set of user permissions since paperless-ngx 1.14.0 and higher. Therefore, please make sure that the user to be logged in has the permission to view other users (User → View) and the settings (UISettings → View). If you do not have these permissions, please contact an administrator of your paperless-ngx server.",
|
||||||
|
"@loginRequiredPermissionsHint": {
|
||||||
|
"description": "Hint shown on the login page informing the user of the required permissions to use the app."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -856,5 +856,9 @@
|
|||||||
"convertSinglePageScanToPdf": "Always convert single page scans to PDF before uploading",
|
"convertSinglePageScanToPdf": "Always convert single page scans to PDF before uploading",
|
||||||
"@convertSinglePageScanToPdf": {
|
"@convertSinglePageScanToPdf": {
|
||||||
"description": "description of the upload scans as pdf setting"
|
"description": "description of the upload scans as pdf setting"
|
||||||
|
},
|
||||||
|
"loginRequiredPermissionsHint": "Using Paperless Mobile requires a minimum set of user permissions since paperless-ngx 1.14.0 and higher. Therefore, please make sure that the user to be logged in has the permission to view other users (User → View) and the settings (UISettings → View). If you do not have these permissions, please contact an administrator of your paperless-ngx server.",
|
||||||
|
"@loginRequiredPermissionsHint": {
|
||||||
|
"description": "Hint shown on the login page informing the user of the required permissions to use the app."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -856,5 +856,9 @@
|
|||||||
"convertSinglePageScanToPdf": "Always convert single page scans to PDF before uploading",
|
"convertSinglePageScanToPdf": "Always convert single page scans to PDF before uploading",
|
||||||
"@convertSinglePageScanToPdf": {
|
"@convertSinglePageScanToPdf": {
|
||||||
"description": "description of the upload scans as pdf setting"
|
"description": "description of the upload scans as pdf setting"
|
||||||
|
},
|
||||||
|
"loginRequiredPermissionsHint": "Using Paperless Mobile requires a minimum set of user permissions since paperless-ngx 1.14.0 and higher. Therefore, please make sure that the user to be logged in has the permission to view other users (User → View) and the settings (UISettings → View). If you do not have these permissions, please contact an administrator of your paperless-ngx server.",
|
||||||
|
"@loginRequiredPermissionsHint": {
|
||||||
|
"description": "Hint shown on the login page informing the user of the required permissions to use the app."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,6 @@ import 'package:paperless_mobile/core/database/tables/local_user_app_state.dart'
|
|||||||
import 'package:paperless_mobile/core/exception/server_message_exception.dart';
|
import 'package:paperless_mobile/core/exception/server_message_exception.dart';
|
||||||
import 'package:paperless_mobile/core/factory/paperless_api_factory.dart';
|
import 'package:paperless_mobile/core/factory/paperless_api_factory.dart';
|
||||||
import 'package:paperless_mobile/core/factory/paperless_api_factory_impl.dart';
|
import 'package:paperless_mobile/core/factory/paperless_api_factory_impl.dart';
|
||||||
import 'package:paperless_mobile/core/interceptor/dio_http_error_interceptor.dart';
|
|
||||||
import 'package:paperless_mobile/core/interceptor/language_header.interceptor.dart';
|
import 'package:paperless_mobile/core/interceptor/language_header.interceptor.dart';
|
||||||
import 'package:paperless_mobile/core/notifier/document_changed_notifier.dart';
|
import 'package:paperless_mobile/core/notifier/document_changed_notifier.dart';
|
||||||
import 'package:paperless_mobile/core/security/session_manager.dart';
|
import 'package:paperless_mobile/core/security/session_manager.dart';
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:paperless_api/paperless_api.dart';
|
import 'package:paperless_api/paperless_api.dart';
|
||||||
|
import 'package:paperless_api/src/models/query_parameters/date_range_queries/date_range_unit.dart';
|
||||||
|
|
||||||
class PaperlessApiHiveTypeIds {
|
class PaperlessApiHiveTypeIds {
|
||||||
PaperlessApiHiveTypeIds._();
|
PaperlessApiHiveTypeIds._();
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import 'package:equatable/equatable.dart';
|
|||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:json_annotation/json_annotation.dart';
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
import 'package:paperless_api/paperless_api.dart';
|
import 'package:paperless_api/paperless_api.dart';
|
||||||
|
import 'package:paperless_api/src/models/query_parameters/date_range_queries/date_range_query.dart';
|
||||||
|
import 'package:paperless_api/src/models/query_parameters/date_range_queries/date_range_query_field.dart';
|
||||||
|
|
||||||
part 'document_filter.g.dart';
|
part 'document_filter.g.dart';
|
||||||
|
|
||||||
@@ -187,16 +189,45 @@ class DocumentFilter extends Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int get appliedFiltersCount => [
|
int get appliedFiltersCount => [
|
||||||
documentType != initial.documentType,
|
documentType.maybeWhen(
|
||||||
correspondent != initial.correspondent,
|
unset: () => 0,
|
||||||
storagePath != initial.storagePath,
|
orElse: () => 1,
|
||||||
tags != initial.tags,
|
),
|
||||||
added != initial.added,
|
correspondent.maybeWhen(
|
||||||
created != initial.created,
|
unset: () => 0,
|
||||||
modified != initial.modified,
|
orElse: () => 1,
|
||||||
asnQuery != initial.asnQuery,
|
),
|
||||||
((query.queryText ?? '') != (initial.query.queryText ?? '')),
|
storagePath.maybeWhen(
|
||||||
].fold(0, (previousValue, element) => previousValue += element ? 1 : 0);
|
unset: () => 0,
|
||||||
|
orElse: () => 1,
|
||||||
|
),
|
||||||
|
tags.maybeWhen(
|
||||||
|
ids: (include, exclude) => include.length + exclude.length,
|
||||||
|
anyAssigned: (tagIds) => tagIds.length,
|
||||||
|
notAssigned: () => 1,
|
||||||
|
orElse: () => 0,
|
||||||
|
),
|
||||||
|
switch (added) {
|
||||||
|
RelativeDateRangeQuery() => 1,
|
||||||
|
AbsoluteDateRangeQuery() => 1,
|
||||||
|
UnsetDateRangeQuery() => 0,
|
||||||
|
},
|
||||||
|
switch (created) {
|
||||||
|
RelativeDateRangeQuery() => 1,
|
||||||
|
AbsoluteDateRangeQuery() => 1,
|
||||||
|
UnsetDateRangeQuery() => 0,
|
||||||
|
},
|
||||||
|
switch (modified) {
|
||||||
|
RelativeDateRangeQuery() => 1,
|
||||||
|
AbsoluteDateRangeQuery() => 1,
|
||||||
|
UnsetDateRangeQuery() => 0,
|
||||||
|
},
|
||||||
|
asnQuery.maybeWhen(
|
||||||
|
unset: () => 0,
|
||||||
|
orElse: () => 1,
|
||||||
|
),
|
||||||
|
(query.queryText?.isNotEmpty ?? false) ? 1 : 0,
|
||||||
|
].fold(0, (previousValue, element) => previousValue + element);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [
|
List<Object?> get props => [
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import 'package:json_annotation/json_annotation.dart';
|
|||||||
import 'package:paperless_api/paperless_api.dart';
|
import 'package:paperless_api/paperless_api.dart';
|
||||||
import 'package:paperless_api/src/constants.dart';
|
import 'package:paperless_api/src/constants.dart';
|
||||||
import 'package:paperless_api/src/converters/local_date_time_json_converter.dart';
|
import 'package:paperless_api/src/converters/local_date_time_json_converter.dart';
|
||||||
|
import 'package:paperless_api/src/models/query_parameters/date_range_queries/date_range_query.dart';
|
||||||
|
import 'package:paperless_api/src/models/query_parameters/date_range_queries/date_range_query_field.dart';
|
||||||
|
import 'package:paperless_api/src/models/query_parameters/date_range_queries/date_range_unit.dart';
|
||||||
|
|
||||||
part 'filter_rule_model.g.dart';
|
part 'filter_rule_model.g.dart';
|
||||||
|
|
||||||
@@ -73,7 +76,9 @@ class FilterRule with EquatableMixin {
|
|||||||
);
|
);
|
||||||
case hasAnyTag:
|
case hasAnyTag:
|
||||||
return filter.copyWith(
|
return filter.copyWith(
|
||||||
tags: value == "true" ? const TagsQuery.anyAssigned() : const TagsQuery.notAssigned(),
|
tags: value == "true"
|
||||||
|
? const TagsQuery.anyAssigned()
|
||||||
|
: const TagsQuery.notAssigned(),
|
||||||
);
|
);
|
||||||
case includeTagsRule:
|
case includeTagsRule:
|
||||||
assert(filter.tags is IdsTagsQuery);
|
assert(filter.tags is IdsTagsQuery);
|
||||||
@@ -105,7 +110,8 @@ class FilterRule with EquatableMixin {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return filter.copyWith(
|
return filter.copyWith(
|
||||||
created: AbsoluteDateRangeQuery(before: _dateTimeConverter.fromJson(value!)),
|
created: AbsoluteDateRangeQuery(
|
||||||
|
before: _dateTimeConverter.fromJson(value!)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case createdAfterRule:
|
case createdAfterRule:
|
||||||
@@ -116,7 +122,8 @@ class FilterRule with EquatableMixin {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return filter.copyWith(
|
return filter.copyWith(
|
||||||
created: AbsoluteDateRangeQuery(after: _dateTimeConverter.fromJson(value!)),
|
created: AbsoluteDateRangeQuery(
|
||||||
|
after: _dateTimeConverter.fromJson(value!)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case addedBeforeRule:
|
case addedBeforeRule:
|
||||||
@@ -127,7 +134,8 @@ class FilterRule with EquatableMixin {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return filter.copyWith(
|
return filter.copyWith(
|
||||||
added: AbsoluteDateRangeQuery(before: _dateTimeConverter.fromJson(value!)),
|
added: AbsoluteDateRangeQuery(
|
||||||
|
before: _dateTimeConverter.fromJson(value!)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case addedAfterRule:
|
case addedAfterRule:
|
||||||
@@ -138,7 +146,8 @@ class FilterRule with EquatableMixin {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return filter.copyWith(
|
return filter.copyWith(
|
||||||
added: AbsoluteDateRangeQuery(after: _dateTimeConverter.fromJson(value!)),
|
added: AbsoluteDateRangeQuery(
|
||||||
|
after: _dateTimeConverter.fromJson(value!)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case modifiedBeforeRule:
|
case modifiedBeforeRule:
|
||||||
@@ -149,7 +158,8 @@ class FilterRule with EquatableMixin {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return filter.copyWith(
|
return filter.copyWith(
|
||||||
modified: AbsoluteDateRangeQuery(before: _dateTimeConverter.fromJson(value!)),
|
modified: AbsoluteDateRangeQuery(
|
||||||
|
before: _dateTimeConverter.fromJson(value!)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case modifiedAfterRule:
|
case modifiedAfterRule:
|
||||||
@@ -160,7 +170,8 @@ class FilterRule with EquatableMixin {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return filter.copyWith(
|
return filter.copyWith(
|
||||||
added: AbsoluteDateRangeQuery(after: _dateTimeConverter.fromJson(value!)),
|
added: AbsoluteDateRangeQuery(
|
||||||
|
after: _dateTimeConverter.fromJson(value!)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case titleAndContentRule:
|
case titleAndContentRule:
|
||||||
@@ -273,7 +284,8 @@ class FilterRule with EquatableMixin {
|
|||||||
filterRules.add(FilterRule(titleRule, filter.query.queryText!));
|
filterRules.add(FilterRule(titleRule, filter.query.queryText!));
|
||||||
break;
|
break;
|
||||||
case QueryType.titleAndContent:
|
case QueryType.titleAndContent:
|
||||||
filterRules.add(FilterRule(titleAndContentRule, filter.query.queryText!));
|
filterRules
|
||||||
|
.add(FilterRule(titleAndContentRule, filter.query.queryText!));
|
||||||
break;
|
break;
|
||||||
case QueryType.extended:
|
case QueryType.extended:
|
||||||
filterRules.add(FilterRule(extendedRule, filter.query.queryText!));
|
filterRules.add(FilterRule(extendedRule, filter.query.queryText!));
|
||||||
@@ -299,8 +311,8 @@ class FilterRule with EquatableMixin {
|
|||||||
}
|
}
|
||||||
} else if (created is RelativeDateRangeQuery) {
|
} else if (created is RelativeDateRangeQuery) {
|
||||||
filterRules.add(
|
filterRules.add(
|
||||||
FilterRule(
|
FilterRule(extendedRule,
|
||||||
extendedRule, created.toQueryParameter(DateRangeQueryField.created).values.first),
|
created.toQueryParameter(DateRangeQueryField.created).values.first),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +331,8 @@ class FilterRule with EquatableMixin {
|
|||||||
}
|
}
|
||||||
} else if (added is RelativeDateRangeQuery) {
|
} else if (added is RelativeDateRangeQuery) {
|
||||||
filterRules.add(
|
filterRules.add(
|
||||||
FilterRule(extendedRule, added.toQueryParameter(DateRangeQueryField.added).values.first),
|
FilterRule(extendedRule,
|
||||||
|
added.toQueryParameter(DateRangeQueryField.added).values.first),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,18 +346,25 @@ class FilterRule with EquatableMixin {
|
|||||||
}
|
}
|
||||||
if (modified.before != null) {
|
if (modified.before != null) {
|
||||||
filterRules.add(
|
filterRules.add(
|
||||||
FilterRule(modifiedBeforeRule, apiDateFormat.format(modified.before!)),
|
FilterRule(
|
||||||
|
modifiedBeforeRule, apiDateFormat.format(modified.before!)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (modified is RelativeDateRangeQuery) {
|
} else if (modified is RelativeDateRangeQuery) {
|
||||||
filterRules.add(
|
filterRules.add(
|
||||||
FilterRule(
|
FilterRule(
|
||||||
extendedRule, modified.toQueryParameter(DateRangeQueryField.modified).values.first),
|
extendedRule,
|
||||||
|
modified
|
||||||
|
.toQueryParameter(DateRangeQueryField.modified)
|
||||||
|
.values
|
||||||
|
.first),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Join values of all extended filter rules if exist
|
//Join values of all extended filter rules if exist
|
||||||
if (filterRules.where((e) => e.ruleType == FilterRule.extendedRule).isNotEmpty) {
|
if (filterRules
|
||||||
|
.where((e) => e.ruleType == FilterRule.extendedRule)
|
||||||
|
.isNotEmpty) {
|
||||||
final mergedExtendedRule = filterRules
|
final mergedExtendedRule = filterRules
|
||||||
.where((r) => r.ruleType == FilterRule.extendedRule)
|
.where((r) => r.ruleType == FilterRule.extendedRule)
|
||||||
.map((e) => e.value)
|
.map((e) => e.value)
|
||||||
@@ -368,5 +388,6 @@ class FilterRule with EquatableMixin {
|
|||||||
|
|
||||||
Map<String, dynamic> toJson() => _$FilterRuleToJson(this);
|
Map<String, dynamic> toJson() => _$FilterRuleToJson(this);
|
||||||
|
|
||||||
factory FilterRule.fromJson(Map<String, dynamic> json) => _$FilterRuleFromJson(json);
|
factory FilterRule.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$FilterRuleFromJson(json);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,33 @@
|
|||||||
|
export 'bulk_edit_model.dart';
|
||||||
|
export 'document_filter.dart';
|
||||||
|
export 'document_meta_data_model.dart';
|
||||||
|
export 'document_model.dart';
|
||||||
|
export 'field_suggestions.dart';
|
||||||
|
export 'filter_rule_model.dart';
|
||||||
|
export 'group_model.dart';
|
||||||
export 'labels/correspondent_model.dart';
|
export 'labels/correspondent_model.dart';
|
||||||
export 'labels/document_type_model.dart';
|
export 'labels/document_type_model.dart';
|
||||||
export 'labels/label_model.dart';
|
export 'labels/label_model.dart';
|
||||||
export 'labels/matching_algorithm.dart';
|
export 'labels/matching_algorithm.dart';
|
||||||
export 'labels/storage_path_model.dart';
|
export 'labels/storage_path_model.dart';
|
||||||
export 'labels/tag_model.dart';
|
export 'labels/tag_model.dart';
|
||||||
export 'query_parameters/id_query_parameter.dart';
|
|
||||||
export 'query_parameters/query_type.dart';
|
|
||||||
export 'query_parameters/sort_field.dart';
|
|
||||||
export 'query_parameters/sort_order.dart';
|
|
||||||
export 'query_parameters/date_range_queries/date_range_queries.dart';
|
|
||||||
export 'query_parameters/tags_query/tags_query.dart';
|
|
||||||
export 'query_parameters/text_query.dart';
|
|
||||||
export 'bulk_edit_model.dart';
|
|
||||||
export 'document_filter.dart';
|
|
||||||
export 'document_meta_data_model.dart';
|
|
||||||
export 'document_model.dart';
|
|
||||||
export 'filter_rule_model.dart';
|
|
||||||
export 'paged_search_result.dart';
|
export 'paged_search_result.dart';
|
||||||
export 'paperless_server_exception.dart';
|
export 'paperless_server_exception.dart';
|
||||||
export 'paperless_server_information_model.dart';
|
export 'paperless_server_information_model.dart';
|
||||||
export 'paperless_server_statistics_model.dart';
|
export 'paperless_server_statistics_model.dart';
|
||||||
|
export 'permissions/inherited_permissions.dart';
|
||||||
|
export 'permissions/permissions.dart';
|
||||||
|
export 'permissions/user_permission_extension.dart';
|
||||||
|
export 'permissions/user_permissions.dart';
|
||||||
|
export 'query_parameters/date_range_queries/date_range_query.dart';
|
||||||
|
export 'query_parameters/date_range_queries/date_range_unit.dart';
|
||||||
|
export 'query_parameters/id_query_parameter.dart';
|
||||||
|
export 'query_parameters/query_type.dart';
|
||||||
|
export 'query_parameters/sort_field.dart';
|
||||||
|
export 'query_parameters/sort_order.dart';
|
||||||
|
export 'query_parameters/tags_query/tags_query.dart';
|
||||||
|
export 'query_parameters/text_query.dart';
|
||||||
export 'saved_view_model.dart';
|
export 'saved_view_model.dart';
|
||||||
export 'task/task.dart';
|
export 'task/task.dart';
|
||||||
export 'task/task_status.dart';
|
export 'task/task_status.dart';
|
||||||
export 'field_suggestions.dart';
|
|
||||||
export 'permissions/permissions.dart';
|
|
||||||
export 'permissions/user_permissions.dart';
|
|
||||||
export 'permissions/inherited_permissions.dart';
|
|
||||||
export 'group_model.dart';
|
|
||||||
export 'user_model.dart';
|
export 'user_model.dart';
|
||||||
export 'permissions/user_permission_extension.dart';
|
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
import 'package:hive/hive.dart';
|
|
||||||
import 'package:json_annotation/json_annotation.dart';
|
|
||||||
import 'package:paperless_api/config/hive/hive_type_ids.dart';
|
|
||||||
import 'package:paperless_api/src/constants.dart';
|
|
||||||
import 'package:paperless_api/src/converters/local_date_time_json_converter.dart';
|
|
||||||
|
|
||||||
import 'date_range_query.dart';
|
|
||||||
import 'date_range_query_field.dart';
|
|
||||||
|
|
||||||
part 'absolute_date_range_query.g.dart';
|
|
||||||
|
|
||||||
@JsonSerializable()
|
|
||||||
@HiveType(typeId: PaperlessApiHiveTypeIds.absoluteDateRangeQuery)
|
|
||||||
class AbsoluteDateRangeQuery extends DateRangeQuery {
|
|
||||||
@LocalDateTimeJsonConverter()
|
|
||||||
@HiveField(0)
|
|
||||||
final DateTime? after;
|
|
||||||
|
|
||||||
@LocalDateTimeJsonConverter()
|
|
||||||
@HiveField(1)
|
|
||||||
final DateTime? before;
|
|
||||||
|
|
||||||
const AbsoluteDateRangeQuery({this.after, this.before});
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [after, before];
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, String> toQueryParameter(DateRangeQueryField field) {
|
|
||||||
final Map<String, String> params = {};
|
|
||||||
|
|
||||||
// Add/subtract one day in the following because paperless uses gt/lt not gte/lte
|
|
||||||
if (after != null) {
|
|
||||||
params.putIfAbsent('${field.name}__date__gt',
|
|
||||||
() => apiDateFormat.format(after!.subtract(const Duration(days: 1))));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (before != null) {
|
|
||||||
params.putIfAbsent('${field.name}__date__lt',
|
|
||||||
() => apiDateFormat.format(before!.add(const Duration(days: 1))));
|
|
||||||
}
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
AbsoluteDateRangeQuery copyWith({
|
|
||||||
DateTime? before,
|
|
||||||
DateTime? after,
|
|
||||||
}) {
|
|
||||||
return AbsoluteDateRangeQuery(
|
|
||||||
before: before ?? this.before,
|
|
||||||
after: after ?? this.after,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
factory AbsoluteDateRangeQuery.fromJson(json) => _$AbsoluteDateRangeQueryFromJson(json);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, dynamic> toJson() => _$AbsoluteDateRangeQueryToJson(this);
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool matches(DateTime dt) {
|
|
||||||
//TODO: Check if after and before are inclusive or exclusive definitions.
|
|
||||||
bool matches = true;
|
|
||||||
if (after != null) {
|
|
||||||
matches &= dt.isAfter(after!) || dt == after;
|
|
||||||
}
|
|
||||||
if (before != null) {
|
|
||||||
matches &= dt.isBefore(before!) || dt == before;
|
|
||||||
}
|
|
||||||
return matches;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
export 'date_range_query.dart';
|
|
||||||
export 'unset_date_range_query.dart';
|
|
||||||
export 'absolute_date_range_query.dart';
|
|
||||||
export 'relative_date_range_query.dart';
|
|
||||||
export 'date_range_unit.dart';
|
|
||||||
export 'date_range_query_field.dart';
|
|
||||||
@@ -1,8 +1,17 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:jiffy/jiffy.dart';
|
||||||
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
|
import 'package:paperless_api/config/hive/hive_type_ids.dart';
|
||||||
|
import 'package:paperless_api/src/constants.dart';
|
||||||
|
import 'package:paperless_api/src/converters/local_date_time_json_converter.dart';
|
||||||
|
|
||||||
import 'date_range_query_field.dart';
|
import 'date_range_query_field.dart';
|
||||||
|
import 'date_range_unit.dart';
|
||||||
|
|
||||||
abstract class DateRangeQuery extends Equatable {
|
part 'date_range_query.g.dart';
|
||||||
|
|
||||||
|
sealed class DateRangeQuery extends Equatable {
|
||||||
const DateRangeQuery();
|
const DateRangeQuery();
|
||||||
|
|
||||||
Map<String, String> toQueryParameter(DateRangeQueryField field);
|
Map<String, String> toQueryParameter(DateRangeQueryField field);
|
||||||
@@ -11,3 +20,166 @@ abstract class DateRangeQuery extends Equatable {
|
|||||||
|
|
||||||
bool matches(DateTime dt);
|
bool matches(DateTime dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class UnsetDateRangeQuery extends DateRangeQuery {
|
||||||
|
const UnsetDateRangeQuery();
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, String> toQueryParameter(DateRangeQueryField field) => const {};
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() => const {};
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool matches(DateTime dt) => true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable()
|
||||||
|
@HiveType(typeId: PaperlessApiHiveTypeIds.relativeDateRangeQuery)
|
||||||
|
class RelativeDateRangeQuery extends DateRangeQuery {
|
||||||
|
@HiveField(0)
|
||||||
|
final int offset;
|
||||||
|
@HiveField(1)
|
||||||
|
final DateRangeUnit unit;
|
||||||
|
|
||||||
|
const RelativeDateRangeQuery([
|
||||||
|
this.offset = 1,
|
||||||
|
this.unit = DateRangeUnit.day,
|
||||||
|
]);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [offset, unit];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, String> toQueryParameter(DateRangeQueryField field) {
|
||||||
|
return {
|
||||||
|
'query': '${field.name}:[-$offset ${unit.name} to now]',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
RelativeDateRangeQuery copyWith({
|
||||||
|
int? offset,
|
||||||
|
DateRangeUnit? unit,
|
||||||
|
}) {
|
||||||
|
return RelativeDateRangeQuery(
|
||||||
|
offset ?? this.offset,
|
||||||
|
unit ?? this.unit,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the datetime when subtracting the offset given the unit from now.
|
||||||
|
DateTime get dateTime {
|
||||||
|
switch (unit) {
|
||||||
|
case DateRangeUnit.day:
|
||||||
|
return Jiffy().subtract(days: offset).dateTime;
|
||||||
|
case DateRangeUnit.week:
|
||||||
|
return Jiffy().subtract(weeks: offset).dateTime;
|
||||||
|
case DateRangeUnit.month:
|
||||||
|
return Jiffy().subtract(months: offset).dateTime;
|
||||||
|
case DateRangeUnit.year:
|
||||||
|
return Jiffy().subtract(years: offset).dateTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() => _$RelativeDateRangeQueryToJson(this);
|
||||||
|
|
||||||
|
factory RelativeDateRangeQuery.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$RelativeDateRangeQueryFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool matches(DateTime dt) {
|
||||||
|
return dt.isAfter(dateTime) || dt == dateTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable()
|
||||||
|
@HiveType(typeId: PaperlessApiHiveTypeIds.absoluteDateRangeQuery)
|
||||||
|
class AbsoluteDateRangeQuery extends DateRangeQuery {
|
||||||
|
@LocalDateTimeJsonConverter()
|
||||||
|
@HiveField(0)
|
||||||
|
final DateTime? after;
|
||||||
|
|
||||||
|
@LocalDateTimeJsonConverter()
|
||||||
|
@HiveField(1)
|
||||||
|
final DateTime? before;
|
||||||
|
|
||||||
|
const AbsoluteDateRangeQuery({this.after, this.before});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [after, before];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, String> toQueryParameter(DateRangeQueryField field) {
|
||||||
|
final Map<String, String> params = {};
|
||||||
|
|
||||||
|
// Add/subtract one day in the following because paperless uses gt/lt not gte/lte
|
||||||
|
if (after != null) {
|
||||||
|
params.putIfAbsent('${field.name}__date__gt',
|
||||||
|
() => apiDateFormat.format(after!.subtract(const Duration(days: 1))));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (before != null) {
|
||||||
|
params.putIfAbsent('${field.name}__date__lt',
|
||||||
|
() => apiDateFormat.format(before!.add(const Duration(days: 1))));
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
AbsoluteDateRangeQuery copyWith({
|
||||||
|
DateTime? before,
|
||||||
|
DateTime? after,
|
||||||
|
}) {
|
||||||
|
return AbsoluteDateRangeQuery(
|
||||||
|
before: before ?? this.before,
|
||||||
|
after: after ?? this.after,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory AbsoluteDateRangeQuery.fromJson(json) =>
|
||||||
|
_$AbsoluteDateRangeQueryFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() => _$AbsoluteDateRangeQueryToJson(this);
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool matches(DateTime dt) {
|
||||||
|
//TODO: Check if after and before are inclusive or exclusive definitions.
|
||||||
|
bool matches = true;
|
||||||
|
if (after != null) {
|
||||||
|
matches &= dt.isAfter(after!) || dt == after;
|
||||||
|
}
|
||||||
|
if (before != null) {
|
||||||
|
matches &= dt.isBefore(before!) || dt == before;
|
||||||
|
}
|
||||||
|
return matches;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class UnsetDateRangeQueryAdapter extends TypeAdapter<UnsetDateRangeQuery> {
|
||||||
|
@override
|
||||||
|
final int typeId = 113;
|
||||||
|
|
||||||
|
@override
|
||||||
|
UnsetDateRangeQuery read(BinaryReader reader) {
|
||||||
|
reader.readByte();
|
||||||
|
return const UnsetDateRangeQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void write(BinaryWriter writer, UnsetDateRangeQuery obj) {
|
||||||
|
writer.writeByte(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => typeId.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
identical(this, other) ||
|
||||||
|
other is UnsetDateRangeQueryAdapter &&
|
||||||
|
runtimeType == other.runtimeType &&
|
||||||
|
typeId == other.typeId;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
import 'package:hive/hive.dart';
|
|
||||||
import 'package:jiffy/jiffy.dart';
|
|
||||||
import 'package:json_annotation/json_annotation.dart';
|
|
||||||
import 'package:paperless_api/config/hive/hive_type_ids.dart';
|
|
||||||
|
|
||||||
import 'date_range_query.dart';
|
|
||||||
import 'date_range_query_field.dart';
|
|
||||||
import 'date_range_unit.dart';
|
|
||||||
part 'relative_date_range_query.g.dart';
|
|
||||||
|
|
||||||
@JsonSerializable()
|
|
||||||
@HiveType(typeId: PaperlessApiHiveTypeIds.relativeDateRangeQuery)
|
|
||||||
class RelativeDateRangeQuery extends DateRangeQuery {
|
|
||||||
@HiveField(0)
|
|
||||||
final int offset;
|
|
||||||
@HiveField(1)
|
|
||||||
final DateRangeUnit unit;
|
|
||||||
|
|
||||||
const RelativeDateRangeQuery([
|
|
||||||
this.offset = 1,
|
|
||||||
this.unit = DateRangeUnit.day,
|
|
||||||
]);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [offset, unit];
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, String> toQueryParameter(DateRangeQueryField field) {
|
|
||||||
return {
|
|
||||||
'query': '${field.name}:[-$offset ${unit.name} to now]',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
RelativeDateRangeQuery copyWith({
|
|
||||||
int? offset,
|
|
||||||
DateRangeUnit? unit,
|
|
||||||
}) {
|
|
||||||
return RelativeDateRangeQuery(
|
|
||||||
offset ?? this.offset,
|
|
||||||
unit ?? this.unit,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the datetime when subtracting the offset given the unit from now.
|
|
||||||
DateTime get dateTime {
|
|
||||||
switch (unit) {
|
|
||||||
case DateRangeUnit.day:
|
|
||||||
return Jiffy().subtract(days: offset).dateTime;
|
|
||||||
case DateRangeUnit.week:
|
|
||||||
return Jiffy().subtract(weeks: offset).dateTime;
|
|
||||||
case DateRangeUnit.month:
|
|
||||||
return Jiffy().subtract(months: offset).dateTime;
|
|
||||||
case DateRangeUnit.year:
|
|
||||||
return Jiffy().subtract(years: offset).dateTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, dynamic> toJson() => _$RelativeDateRangeQueryToJson(this);
|
|
||||||
|
|
||||||
factory RelativeDateRangeQuery.fromJson(Map<String, dynamic> json) =>
|
|
||||||
_$RelativeDateRangeQueryFromJson(json);
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool matches(DateTime dt) {
|
|
||||||
return dt.isAfter(dateTime) || dt == dateTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,44 +2,3 @@ import 'package:hive/hive.dart';
|
|||||||
import 'package:paperless_api/src/models/query_parameters/date_range_queries/date_range_query_field.dart';
|
import 'package:paperless_api/src/models/query_parameters/date_range_queries/date_range_query_field.dart';
|
||||||
|
|
||||||
import 'date_range_query.dart';
|
import 'date_range_query.dart';
|
||||||
|
|
||||||
class UnsetDateRangeQuery extends DateRangeQuery {
|
|
||||||
const UnsetDateRangeQuery();
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [];
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, String> toQueryParameter(DateRangeQueryField field) => const {};
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, dynamic> toJson() => const {};
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool matches(DateTime dt) => true;
|
|
||||||
}
|
|
||||||
|
|
||||||
class UnsetDateRangeQueryAdapter extends TypeAdapter<UnsetDateRangeQuery> {
|
|
||||||
@override
|
|
||||||
final int typeId = 113;
|
|
||||||
|
|
||||||
@override
|
|
||||||
UnsetDateRangeQuery read(BinaryReader reader) {
|
|
||||||
reader.readByte();
|
|
||||||
return const UnsetDateRangeQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void write(BinaryWriter writer, UnsetDateRangeQuery obj) {
|
|
||||||
writer.writeByte(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => typeId.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) =>
|
|
||||||
identical(this, other) ||
|
|
||||||
other is UnsetDateRangeQueryAdapter &&
|
|
||||||
runtimeType == other.runtimeType &&
|
|
||||||
typeId == other.typeId;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,9 +23,6 @@ dependencies:
|
|||||||
freezed_annotation: ^2.2.0
|
freezed_annotation: ^2.2.0
|
||||||
hive: ^2.2.3
|
hive: ^2.2.3
|
||||||
|
|
||||||
dependency_overrides:
|
|
||||||
graphs: 2.2.0
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|||||||
@@ -761,7 +761,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.2"
|
||||||
graphs:
|
graphs:
|
||||||
dependency: "direct overridden"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: graphs
|
name: graphs
|
||||||
sha256: f9e130f3259f52d26f0cfc0e964513796dafed572fa52e45d2f8d6ca14db39b2
|
sha256: f9e130f3259f52d26f0cfc0e964513796dafed572fa52e45d2f8d6ca14db39b2
|
||||||
|
|||||||
@@ -93,7 +93,6 @@ dependencies:
|
|||||||
|
|
||||||
dependency_overrides:
|
dependency_overrides:
|
||||||
intl: ^0.18.0
|
intl: ^0.18.0
|
||||||
graphs: 2.2.0
|
|
||||||
http: ^1.0.0
|
http: ^1.0.0
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user