Tasks
This commit is contained in:
parent
c512c9f423
commit
0346c9ea8d
|
|
@ -21,6 +21,7 @@ import 'package:invoiceninja_flutter/redux/product/product_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/client/client_state.dart';
|
import 'package:invoiceninja_flutter/redux/client/client_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/ui/ui_state.dart';
|
import 'package:invoiceninja_flutter/redux/ui/ui_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/invoice/invoice_state.dart';
|
import 'package:invoiceninja_flutter/redux/invoice/invoice_state.dart';
|
||||||
|
|
||||||
// STARTER: import - do not remove comment
|
// STARTER: import - do not remove comment
|
||||||
import 'package:invoiceninja_flutter/redux/task/task_state.dart';
|
import 'package:invoiceninja_flutter/redux/task/task_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/project/project_state.dart';
|
import 'package:invoiceninja_flutter/redux/project/project_state.dart';
|
||||||
|
|
@ -76,10 +77,9 @@ part 'serializers.g.dart';
|
||||||
TimezoneListResponse,
|
TimezoneListResponse,
|
||||||
// STARTER: serializers - do not remove comment
|
// STARTER: serializers - do not remove comment
|
||||||
TaskEntity,
|
TaskEntity,
|
||||||
|
|
||||||
ProjectEntity,
|
ProjectEntity,
|
||||||
|
|
||||||
PaymentEntity,
|
PaymentEntity,
|
||||||
|
TaskStatusEntity,
|
||||||
])
|
])
|
||||||
final Serializers serializers =
|
final Serializers serializers =
|
||||||
(_$serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();
|
(_$serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@ Serializers _$serializers = (new Serializers().toBuilder()
|
||||||
..add(TaskItemResponse.serializer)
|
..add(TaskItemResponse.serializer)
|
||||||
..add(TaskListResponse.serializer)
|
..add(TaskListResponse.serializer)
|
||||||
..add(TaskState.serializer)
|
..add(TaskState.serializer)
|
||||||
|
..add(TaskStatusEntity.serializer)
|
||||||
..add(TaskTime.serializer)
|
..add(TaskTime.serializer)
|
||||||
..add(TaskUIState.serializer)
|
..add(TaskUIState.serializer)
|
||||||
..add(TaxRateEntity.serializer)
|
..add(TaxRateEntity.serializer)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,9 @@ class InvoiceStatusFields {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class InvoiceStatusEntity extends Object with EntityStatus implements Built<InvoiceStatusEntity, InvoiceStatusEntityBuilder> {
|
abstract class InvoiceStatusEntity extends Object
|
||||||
|
with EntityStatus
|
||||||
|
implements Built<InvoiceStatusEntity, InvoiceStatusEntityBuilder> {
|
||||||
|
|
||||||
factory InvoiceStatusEntity() {
|
factory InvoiceStatusEntity() {
|
||||||
return _$InvoiceStatusEntity._(
|
return _$InvoiceStatusEntity._(
|
||||||
|
|
@ -38,8 +40,10 @@ abstract class InvoiceStatusEntity extends Object with EntityStatus implements B
|
||||||
name: '',
|
name: '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceStatusEntity._();
|
InvoiceStatusEntity._();
|
||||||
|
|
||||||
static Serializer<InvoiceStatusEntity> get serializer => _$invoiceStatusEntitySerializer;
|
static Serializer<InvoiceStatusEntity> get serializer =>
|
||||||
|
_$invoiceStatusEntitySerializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,8 +120,7 @@ abstract class TaskEntity extends Object
|
||||||
..isRunning = false
|
..isRunning = false
|
||||||
..duration = 0
|
..duration = 0
|
||||||
..timeLog = '[]'
|
..timeLog = '[]'
|
||||||
..description = ''
|
..description = '');
|
||||||
);
|
|
||||||
|
|
||||||
TaskEntity toggle() => isRunning ? stop() : start();
|
TaskEntity toggle() => isRunning ? stop() : start();
|
||||||
|
|
||||||
|
|
@ -304,7 +303,6 @@ abstract class TaskEntity extends Object
|
||||||
actions.add(EntityAction.clone);
|
actions.add(EntityAction.clone);
|
||||||
actions.add(null);
|
actions.add(null);
|
||||||
|
|
||||||
|
|
||||||
return actions..addAll(getBaseActions(user: user));
|
return actions..addAll(getBaseActions(user: user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -358,3 +356,19 @@ abstract class TaskEntity extends Object
|
||||||
|
|
||||||
static Serializer<TaskEntity> get serializer => _$taskEntitySerializer;
|
static Serializer<TaskEntity> get serializer => _$taskEntitySerializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract class TaskStatusEntity extends Object
|
||||||
|
with EntityStatus
|
||||||
|
implements Built<TaskStatusEntity, TaskStatusEntityBuilder> {
|
||||||
|
factory TaskStatusEntity() {
|
||||||
|
return _$TaskStatusEntity._(
|
||||||
|
id: 0,
|
||||||
|
name: '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskStatusEntity._();
|
||||||
|
|
||||||
|
static Serializer<TaskStatusEntity> get serializer =>
|
||||||
|
_$taskStatusEntitySerializer;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ Serializer<TaskItemResponse> _$taskItemResponseSerializer =
|
||||||
new _$TaskItemResponseSerializer();
|
new _$TaskItemResponseSerializer();
|
||||||
Serializer<TaskTime> _$taskTimeSerializer = new _$TaskTimeSerializer();
|
Serializer<TaskTime> _$taskTimeSerializer = new _$TaskTimeSerializer();
|
||||||
Serializer<TaskEntity> _$taskEntitySerializer = new _$TaskEntitySerializer();
|
Serializer<TaskEntity> _$taskEntitySerializer = new _$TaskEntitySerializer();
|
||||||
|
Serializer<TaskStatusEntity> _$taskStatusEntitySerializer =
|
||||||
|
new _$TaskStatusEntitySerializer();
|
||||||
|
|
||||||
class _$TaskListResponseSerializer
|
class _$TaskListResponseSerializer
|
||||||
implements StructuredSerializer<TaskListResponse> {
|
implements StructuredSerializer<TaskListResponse> {
|
||||||
|
|
@ -325,6 +327,52 @@ class _$TaskEntitySerializer implements StructuredSerializer<TaskEntity> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _$TaskStatusEntitySerializer
|
||||||
|
implements StructuredSerializer<TaskStatusEntity> {
|
||||||
|
@override
|
||||||
|
final Iterable<Type> types = const [TaskStatusEntity, _$TaskStatusEntity];
|
||||||
|
@override
|
||||||
|
final String wireName = 'TaskStatusEntity';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable serialize(Serializers serializers, TaskStatusEntity object,
|
||||||
|
{FullType specifiedType = FullType.unspecified}) {
|
||||||
|
final result = <Object>[
|
||||||
|
'id',
|
||||||
|
serializers.serialize(object.id, specifiedType: const FullType(int)),
|
||||||
|
'name',
|
||||||
|
serializers.serialize(object.name, specifiedType: const FullType(String)),
|
||||||
|
];
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
TaskStatusEntity deserialize(Serializers serializers, Iterable serialized,
|
||||||
|
{FullType specifiedType = FullType.unspecified}) {
|
||||||
|
final result = new TaskStatusEntityBuilder();
|
||||||
|
|
||||||
|
final iterator = serialized.iterator;
|
||||||
|
while (iterator.moveNext()) {
|
||||||
|
final key = iterator.current as String;
|
||||||
|
iterator.moveNext();
|
||||||
|
final dynamic value = iterator.current;
|
||||||
|
switch (key) {
|
||||||
|
case 'id':
|
||||||
|
result.id = serializers.deserialize(value,
|
||||||
|
specifiedType: const FullType(int)) as int;
|
||||||
|
break;
|
||||||
|
case 'name':
|
||||||
|
result.name = serializers.deserialize(value,
|
||||||
|
specifiedType: const FullType(String)) as String;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _$TaskListResponse extends TaskListResponse {
|
class _$TaskListResponse extends TaskListResponse {
|
||||||
@override
|
@override
|
||||||
final BuiltList<TaskEntity> data;
|
final BuiltList<TaskEntity> data;
|
||||||
|
|
@ -877,3 +925,93 @@ class TaskEntityBuilder implements Builder<TaskEntity, TaskEntityBuilder> {
|
||||||
return _$result;
|
return _$result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _$TaskStatusEntity extends TaskStatusEntity {
|
||||||
|
@override
|
||||||
|
final int id;
|
||||||
|
@override
|
||||||
|
final String name;
|
||||||
|
|
||||||
|
factory _$TaskStatusEntity([void updates(TaskStatusEntityBuilder b)]) =>
|
||||||
|
(new TaskStatusEntityBuilder()..update(updates)).build();
|
||||||
|
|
||||||
|
_$TaskStatusEntity._({this.id, this.name}) : super._() {
|
||||||
|
if (id == null) {
|
||||||
|
throw new BuiltValueNullFieldError('TaskStatusEntity', 'id');
|
||||||
|
}
|
||||||
|
if (name == null) {
|
||||||
|
throw new BuiltValueNullFieldError('TaskStatusEntity', 'name');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
TaskStatusEntity rebuild(void updates(TaskStatusEntityBuilder b)) =>
|
||||||
|
(toBuilder()..update(updates)).build();
|
||||||
|
|
||||||
|
@override
|
||||||
|
TaskStatusEntityBuilder toBuilder() =>
|
||||||
|
new TaskStatusEntityBuilder()..replace(this);
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
if (identical(other, this)) return true;
|
||||||
|
return other is TaskStatusEntity && id == other.id && name == other.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
return $jf($jc($jc(0, id.hashCode), name.hashCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return (newBuiltValueToStringHelper('TaskStatusEntity')
|
||||||
|
..add('id', id)
|
||||||
|
..add('name', name))
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TaskStatusEntityBuilder
|
||||||
|
implements Builder<TaskStatusEntity, TaskStatusEntityBuilder> {
|
||||||
|
_$TaskStatusEntity _$v;
|
||||||
|
|
||||||
|
int _id;
|
||||||
|
int get id => _$this._id;
|
||||||
|
set id(int id) => _$this._id = id;
|
||||||
|
|
||||||
|
String _name;
|
||||||
|
String get name => _$this._name;
|
||||||
|
set name(String name) => _$this._name = name;
|
||||||
|
|
||||||
|
TaskStatusEntityBuilder();
|
||||||
|
|
||||||
|
TaskStatusEntityBuilder get _$this {
|
||||||
|
if (_$v != null) {
|
||||||
|
_id = _$v.id;
|
||||||
|
_name = _$v.name;
|
||||||
|
_$v = null;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void replace(TaskStatusEntity other) {
|
||||||
|
if (other == null) {
|
||||||
|
throw new ArgumentError.notNull('other');
|
||||||
|
}
|
||||||
|
_$v = other as _$TaskStatusEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void update(void updates(TaskStatusEntityBuilder b)) {
|
||||||
|
if (updates != null) updates(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
_$TaskStatusEntity build() {
|
||||||
|
final _$result = _$v ?? new _$TaskStatusEntity._(id: id, name: name);
|
||||||
|
replace(_$result);
|
||||||
|
return _$result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -235,6 +235,12 @@ class FilterTasksByState implements PersistUI {
|
||||||
final EntityState state;
|
final EntityState state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FilterTasksByStatus implements PersistUI {
|
||||||
|
FilterTasksByStatus(this.status);
|
||||||
|
|
||||||
|
final EntityStatus status;
|
||||||
|
}
|
||||||
|
|
||||||
class FilterTasksByCustom1 implements PersistUI {
|
class FilterTasksByCustom1 implements PersistUI {
|
||||||
FilterTasksByCustom1(this.value);
|
FilterTasksByCustom1(this.value);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ TaskEntity _updateEditing(TaskEntity task, dynamic action) {
|
||||||
final taskListReducer = combineReducers<ListUIState>([
|
final taskListReducer = combineReducers<ListUIState>([
|
||||||
TypedReducer<ListUIState, SortTasks>(_sortTasks),
|
TypedReducer<ListUIState, SortTasks>(_sortTasks),
|
||||||
TypedReducer<ListUIState, FilterTasksByState>(_filterTasksByState),
|
TypedReducer<ListUIState, FilterTasksByState>(_filterTasksByState),
|
||||||
|
TypedReducer<ListUIState, FilterTasksByStatus>(_filterTasksByStatus),
|
||||||
TypedReducer<ListUIState, FilterTasks>(_filterTasks),
|
TypedReducer<ListUIState, FilterTasks>(_filterTasks),
|
||||||
TypedReducer<ListUIState, FilterTasksByCustom1>(_filterTasksByCustom1),
|
TypedReducer<ListUIState, FilterTasksByCustom1>(_filterTasksByCustom1),
|
||||||
TypedReducer<ListUIState, FilterTasksByCustom2>(_filterTasksByCustom2),
|
TypedReducer<ListUIState, FilterTasksByCustom2>(_filterTasksByCustom2),
|
||||||
|
|
@ -95,6 +96,16 @@ ListUIState _filterTasksByState(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ListUIState _filterTasksByStatus(ListUIState taskListState,
|
||||||
|
FilterTasksByStatus action) {
|
||||||
|
if (taskListState.statusFilters.contains(action.status)) {
|
||||||
|
return taskListState
|
||||||
|
.rebuild((b) => b..statusFilters.remove(action.status));
|
||||||
|
} else {
|
||||||
|
return taskListState.rebuild((b) => b..statusFilters.add(action.status));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ListUIState _filterTasks(ListUIState taskListState, FilterTasks action) {
|
ListUIState _filterTasks(ListUIState taskListState, FilterTasks action) {
|
||||||
return taskListState.rebuild((b) => b..filter = action.filter);
|
return taskListState.rebuild((b) => b..filter = action.filter);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,9 @@ class TaskScreen extends StatelessWidget {
|
||||||
bottomNavigationBar: AppBottomBar(
|
bottomNavigationBar: AppBottomBar(
|
||||||
entityType: EntityType.task,
|
entityType: EntityType.task,
|
||||||
onSelectedSortField: (value) => store.dispatch(SortTasks(value)),
|
onSelectedSortField: (value) => store.dispatch(SortTasks(value)),
|
||||||
|
onSelectedStatus: (EntityStatus status, value) {
|
||||||
|
store.dispatch(FilterTasksByStatus(status));
|
||||||
|
},
|
||||||
customValues1: company.getCustomFieldValues(CustomFieldType.task1,
|
customValues1: company.getCustomFieldValues(CustomFieldType.task1,
|
||||||
excludeBlank: true),
|
excludeBlank: true),
|
||||||
customValues2: company.getCustomFieldValues(CustomFieldType.task2,
|
customValues2: company.getCustomFieldValues(CustomFieldType.task2,
|
||||||
|
|
@ -61,6 +64,18 @@ class TaskScreen extends StatelessWidget {
|
||||||
TaskFields.duration,
|
TaskFields.duration,
|
||||||
TaskFields.updatedAt,
|
TaskFields.updatedAt,
|
||||||
],
|
],
|
||||||
|
statuses: [
|
||||||
|
TaskStatusEntity().rebuild(
|
||||||
|
(b) => b
|
||||||
|
..id = -1
|
||||||
|
..name = localization.running,
|
||||||
|
),
|
||||||
|
TaskStatusEntity().rebuild(
|
||||||
|
(b) => b
|
||||||
|
..id = -2
|
||||||
|
..name = localization.invoiced,
|
||||||
|
),
|
||||||
|
],
|
||||||
onSelectedState: (EntityState state, value) {
|
onSelectedState: (EntityState state, value) {
|
||||||
store.dispatch(FilterTasksByState(state));
|
store.dispatch(FilterTasksByState(state));
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue