Improve documents
This commit is contained in:
parent
aa7496714f
commit
3eac70a4e6
|
|
@ -23,6 +23,7 @@ final forceSelectedReducer = combineReducers<bool>([
|
||||||
TypedReducer<bool, ViewDocument>((completer, action) => true),
|
TypedReducer<bool, ViewDocument>((completer, action) => true),
|
||||||
TypedReducer<bool, ViewDocumentList>((completer, action) => false),
|
TypedReducer<bool, ViewDocumentList>((completer, action) => false),
|
||||||
TypedReducer<bool, FilterDocumentsByState>((completer, action) => false),
|
TypedReducer<bool, FilterDocumentsByState>((completer, action) => false),
|
||||||
|
TypedReducer<bool, FilterDocumentsByStatus>((completer, action) => false),
|
||||||
TypedReducer<bool, FilterDocuments>((completer, action) => false),
|
TypedReducer<bool, FilterDocuments>((completer, action) => false),
|
||||||
TypedReducer<bool, FilterDocumentsByCustom1>((completer, action) => false),
|
TypedReducer<bool, FilterDocumentsByCustom1>((completer, action) => false),
|
||||||
TypedReducer<bool, FilterDocumentsByCustom2>((completer, action) => false),
|
TypedReducer<bool, FilterDocumentsByCustom2>((completer, action) => false),
|
||||||
|
|
@ -43,6 +44,7 @@ Reducer<String> selectedIdReducer = combineReducers([
|
||||||
TypedReducer<String, SortDocuments>((selectedId, action) => ''),
|
TypedReducer<String, SortDocuments>((selectedId, action) => ''),
|
||||||
TypedReducer<String, FilterDocuments>((selectedId, action) => ''),
|
TypedReducer<String, FilterDocuments>((selectedId, action) => ''),
|
||||||
TypedReducer<String, FilterDocumentsByState>((selectedId, action) => ''),
|
TypedReducer<String, FilterDocumentsByState>((selectedId, action) => ''),
|
||||||
|
TypedReducer<String, FilterDocumentsByStatus>((selectedId, action) => ''),
|
||||||
TypedReducer<String, FilterDocumentsByCustom1>((selectedId, action) => ''),
|
TypedReducer<String, FilterDocumentsByCustom1>((selectedId, action) => ''),
|
||||||
TypedReducer<String, FilterDocumentsByCustom2>((selectedId, action) => ''),
|
TypedReducer<String, FilterDocumentsByCustom2>((selectedId, action) => ''),
|
||||||
TypedReducer<String, FilterDocumentsByCustom3>((selectedId, action) => ''),
|
TypedReducer<String, FilterDocumentsByCustom3>((selectedId, action) => ''),
|
||||||
|
|
@ -68,6 +70,7 @@ DocumentEntity _updateEditing(DocumentEntity document, dynamic action) {
|
||||||
final documentListReducer = combineReducers<ListUIState>([
|
final documentListReducer = combineReducers<ListUIState>([
|
||||||
TypedReducer<ListUIState, SortDocuments>(_sortDocuments),
|
TypedReducer<ListUIState, SortDocuments>(_sortDocuments),
|
||||||
TypedReducer<ListUIState, FilterDocumentsByState>(_filterDocumentsByState),
|
TypedReducer<ListUIState, FilterDocumentsByState>(_filterDocumentsByState),
|
||||||
|
TypedReducer<ListUIState, FilterDocumentsByStatus>(_filterDocumentsByStatus),
|
||||||
TypedReducer<ListUIState, FilterDocuments>(_filterDocuments),
|
TypedReducer<ListUIState, FilterDocuments>(_filterDocuments),
|
||||||
TypedReducer<ListUIState, FilterDocumentsByCustom1>(
|
TypedReducer<ListUIState, FilterDocumentsByCustom1>(
|
||||||
_filterDocumentsByCustom1),
|
_filterDocumentsByCustom1),
|
||||||
|
|
@ -125,6 +128,17 @@ ListUIState _filterDocumentsByState(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ListUIState _filterDocumentsByStatus(
|
||||||
|
ListUIState documentListState, FilterDocumentsByStatus action) {
|
||||||
|
if (documentListState.statusFilters.contains(action.status)) {
|
||||||
|
return documentListState
|
||||||
|
.rebuild((b) => b..statusFilters.remove(action.status));
|
||||||
|
} else {
|
||||||
|
return documentListState
|
||||||
|
.rebuild((b) => b..statusFilters.add(action.status));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ListUIState _filterDocuments(
|
ListUIState _filterDocuments(
|
||||||
ListUIState documentListState, FilterDocuments action) {
|
ListUIState documentListState, FilterDocuments action) {
|
||||||
return documentListState.rebuild((b) => b
|
return documentListState.rebuild((b) => b
|
||||||
|
|
|
||||||
|
|
@ -142,69 +142,71 @@ class _ListFilterState extends State<ListFilter> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (isDesktop(context) &&
|
if (isDesktop(context) && !isDashboardOrSettings) ...[
|
||||||
!isDashboardOrSettings &&
|
if (widget.onSelectedState != null) ...[
|
||||||
widget.onSelectedState != null) ...[
|
SizedBox(width: 8),
|
||||||
SizedBox(width: 8),
|
Flexible(
|
||||||
Flexible(
|
child: DropDownMultiSelect(
|
||||||
child: DropDownMultiSelect(
|
onChanged: (List<dynamic> selected) {
|
||||||
onChanged: (List<dynamic> selected) {
|
final stateFilters = state
|
||||||
final stateFilters = state
|
.getListState(widget.entityType)
|
||||||
|
.stateFilters
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
final added = selected
|
||||||
|
.where((dynamic e) => !stateFilters.contains(e));
|
||||||
|
final removed = stateFilters
|
||||||
|
.where((dynamic e) => !selected.contains(e));
|
||||||
|
|
||||||
|
for (var state in added) {
|
||||||
|
widget.onSelectedState(state, true);
|
||||||
|
}
|
||||||
|
for (var state in removed) {
|
||||||
|
widget.onSelectedState(state, false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
options: EntityState.values.toList(),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: OutlineInputBorder(borderSide: BorderSide()),
|
||||||
|
enabledBorder: state.prefState.enableDarkMode
|
||||||
|
? null
|
||||||
|
: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.white)),
|
||||||
|
isDense: true,
|
||||||
|
contentPadding:
|
||||||
|
EdgeInsets.symmetric(vertical: 13, horizontal: 10),
|
||||||
|
),
|
||||||
|
selectedValues: state
|
||||||
.getListState(widget.entityType)
|
.getListState(widget.entityType)
|
||||||
.stateFilters
|
.stateFilters
|
||||||
.toList();
|
.toList(),
|
||||||
|
whenEmpty: localization.all,
|
||||||
final added =
|
menuItembuilder: (dynamic value) {
|
||||||
selected.where((dynamic e) => !stateFilters.contains(e));
|
final state = value as EntityState;
|
||||||
final removed =
|
return Text(
|
||||||
stateFilters.where((dynamic e) => !selected.contains(e));
|
localization.lookup(state.name),
|
||||||
|
overflow: TextOverflow.clip,
|
||||||
for (var state in added) {
|
maxLines: 1,
|
||||||
widget.onSelectedState(state, true);
|
);
|
||||||
}
|
},
|
||||||
for (var state in removed) {
|
childBuilder: (selected) {
|
||||||
widget.onSelectedState(state, false);
|
return Align(
|
||||||
}
|
child: Padding(
|
||||||
},
|
padding: EdgeInsets.symmetric(horizontal: 10),
|
||||||
options: EntityState.values.toList(),
|
child: Text(
|
||||||
decoration: InputDecoration(
|
selected.isNotEmpty
|
||||||
border: OutlineInputBorder(borderSide: BorderSide()),
|
? selected
|
||||||
enabledBorder: state.prefState.enableDarkMode
|
.map<String>((dynamic value) => localization
|
||||||
? null
|
.lookup((value as EntityState).name))
|
||||||
: OutlineInputBorder(
|
.join(', ')
|
||||||
borderSide: BorderSide(color: Colors.white)),
|
: localization.all,
|
||||||
isDense: true,
|
style: TextStyle(fontSize: 15),
|
||||||
contentPadding:
|
),
|
||||||
EdgeInsets.symmetric(vertical: 13, horizontal: 10),
|
|
||||||
),
|
|
||||||
selectedValues:
|
|
||||||
state.getListState(widget.entityType).stateFilters.toList(),
|
|
||||||
whenEmpty: localization.all,
|
|
||||||
menuItembuilder: (dynamic value) {
|
|
||||||
final state = value as EntityState;
|
|
||||||
return Text(
|
|
||||||
localization.lookup(state.name),
|
|
||||||
overflow: TextOverflow.clip,
|
|
||||||
maxLines: 1,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
childBuilder: (selected) {
|
|
||||||
return Align(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 10),
|
|
||||||
child: Text(
|
|
||||||
selected.isNotEmpty
|
|
||||||
? selected
|
|
||||||
.map<String>((dynamic value) => localization
|
|
||||||
.lookup((value as EntityState).name))
|
|
||||||
.join(', ')
|
|
||||||
: localization.all,
|
|
||||||
style: TextStyle(fontSize: 15),
|
|
||||||
),
|
),
|
||||||
),
|
alignment: Alignment.centerLeft);
|
||||||
alignment: Alignment.centerLeft);
|
}),
|
||||||
}),
|
),
|
||||||
),
|
],
|
||||||
if (widget.statuses != null) ...[
|
if (widget.statuses != null) ...[
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Flexible(
|
Flexible(
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import 'package:invoiceninja_flutter/constants.dart';
|
||||||
|
|
||||||
// Project imports:
|
// Project imports:
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
|
import 'package:invoiceninja_flutter/data/models/static/document_status_model.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/document/document_actions.dart';
|
import 'package:invoiceninja_flutter/redux/document/document_actions.dart';
|
||||||
|
|
@ -36,27 +37,27 @@ class DocumentScreen extends StatelessWidget {
|
||||||
final localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
|
|
||||||
final statuses = [
|
final statuses = [
|
||||||
InvoiceStatusEntity().rebuild(
|
DocumentStatusEntity().rebuild(
|
||||||
(b) => b
|
(b) => b
|
||||||
..id = kDocumentStatusPublic
|
..id = kDocumentStatusPublic
|
||||||
..name = localization.public,
|
..name = localization.public,
|
||||||
),
|
),
|
||||||
InvoiceStatusEntity().rebuild(
|
DocumentStatusEntity().rebuild(
|
||||||
(b) => b
|
(b) => b
|
||||||
..id = kDocumentStatusPrivate
|
..id = kDocumentStatusPrivate
|
||||||
..name = localization.private,
|
..name = localization.private,
|
||||||
),
|
),
|
||||||
InvoiceStatusEntity().rebuild(
|
DocumentStatusEntity().rebuild(
|
||||||
(b) => b
|
(b) => b
|
||||||
..id = kDocumentStatusImage
|
..id = kDocumentStatusImage
|
||||||
..name = localization.image,
|
..name = localization.image,
|
||||||
),
|
),
|
||||||
InvoiceStatusEntity().rebuild(
|
DocumentStatusEntity().rebuild(
|
||||||
(b) => b
|
(b) => b
|
||||||
..id = kDocumentStatusPDF
|
..id = kDocumentStatusPDF
|
||||||
..name = localization.pdf,
|
..name = localization.pdf,
|
||||||
),
|
),
|
||||||
InvoiceStatusEntity().rebuild(
|
DocumentStatusEntity().rebuild(
|
||||||
(b) => b
|
(b) => b
|
||||||
..id = kDocumentStatusOther
|
..id = kDocumentStatusOther
|
||||||
..name = localization.other,
|
..name = localization.other,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue