mirror of
https://github.com/go-vikunja/app
synced 2024-10-05 05:38:30 +00:00
feat: added projectViewService, fixed marking button as done
This commit is contained in:
parent
25bac27c63
commit
0ccbe616b1
37
lib/api/view.dart
Normal file
37
lib/api/view.dart
Normal file
@ -0,0 +1,37 @@
|
||||
import 'package:vikunja_app/api/service.dart';
|
||||
import 'package:vikunja_app/models/view.dart';
|
||||
import 'package:vikunja_app/service/services.dart';
|
||||
|
||||
class ProjectViewAPIService extends APIService implements ProjectViewService {
|
||||
ProjectViewAPIService(client) : super(client);
|
||||
|
||||
@override
|
||||
Future<ProjectView?> create(ProjectView view) {
|
||||
// TODO: implement create
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future delete(int projectId, int viewId) {
|
||||
// TODO: implement delete
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ProjectView?> get(int projectId, int viewId) {
|
||||
// TODO: implement get
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ProjectView?> update(ProjectView view) {
|
||||
print(view.toJSON());
|
||||
return client
|
||||
.post('/projects/${view.projectId}/views/${view.id}',
|
||||
body: view.toJSON())
|
||||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return ProjectView.fromJson(response.body);
|
||||
});
|
||||
}
|
||||
}
|
@ -46,8 +46,6 @@ class KanbanClass {
|
||||
_pageController!.viewportFraction != bucketFraction)
|
||||
_pageController = PageController(viewportFraction: bucketFraction);
|
||||
|
||||
print(_project.doneBucketId);
|
||||
|
||||
return ReorderableListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
scrollController: _pageController,
|
||||
@ -175,9 +173,9 @@ class KanbanClass {
|
||||
|
||||
Future<void> _setDoneBucket(BuildContext context, int bucketId) async {
|
||||
//setState(() {});
|
||||
_project = (await VikunjaGlobal.of(context)
|
||||
.projectService
|
||||
.update(_project.copyWith(doneBucketId: bucketId)))!;
|
||||
_view = (await VikunjaGlobal.of(context)
|
||||
.projectViewService
|
||||
.update(_view.copyWith(doneBucketId: bucketId)))!;
|
||||
notify();
|
||||
}
|
||||
|
||||
@ -287,7 +285,7 @@ class KanbanClass {
|
||||
minLeadingWidth: 15,
|
||||
horizontalTitleGap: 4,
|
||||
contentPadding: const EdgeInsets.only(left: 16, right: 10),
|
||||
leading: bucket.id == _project.doneBucketId
|
||||
leading: bucket.id == _view.doneBucketId
|
||||
? Icon(
|
||||
Icons.done_all,
|
||||
color: Colors.green,
|
||||
@ -357,7 +355,6 @@ class KanbanClass {
|
||||
});
|
||||
break;
|
||||
case BucketMenu.done:
|
||||
//bucket.isDoneBucket = !(bucket.id == _list.doneBucketId);
|
||||
_project =
|
||||
_project.copyWith(doneBucketId: bucket.id);
|
||||
_setDoneBucket(context, bucket.id);
|
||||
@ -384,7 +381,7 @@ class KanbanClass {
|
||||
padding: const EdgeInsets.only(right: 4),
|
||||
child: Icon(
|
||||
Icons.done_all,
|
||||
color: bucket.id == _project.doneBucketId
|
||||
color: bucket.id == _view.doneBucketId
|
||||
? Colors.green
|
||||
: null,
|
||||
),
|
||||
|
@ -21,6 +21,7 @@ import 'package:timezone/data/latest_all.dart' as tz;
|
||||
import 'package:workmanager/workmanager.dart';
|
||||
|
||||
import 'api/project.dart';
|
||||
import 'api/view.dart';
|
||||
import 'main.dart';
|
||||
|
||||
class VikunjaGlobal extends StatefulWidget {
|
||||
@ -69,6 +70,9 @@ class VikunjaGlobalState extends State<VikunjaGlobal> {
|
||||
|
||||
ProjectService get projectService => new ProjectAPIService(client, _storage);
|
||||
|
||||
ProjectViewService get projectViewService =>
|
||||
new ProjectViewAPIService(client);
|
||||
|
||||
TaskService get taskService => new TaskAPIService(client);
|
||||
|
||||
BucketService get bucketService => new BucketAPIService(client);
|
||||
|
@ -10,7 +10,6 @@ class Bucket {
|
||||
double? position;
|
||||
final DateTime created, updated;
|
||||
User createdBy;
|
||||
bool? isDoneBucket;
|
||||
final List<Task> tasks;
|
||||
|
||||
Bucket({
|
||||
@ -19,7 +18,6 @@ class Bucket {
|
||||
required this.title,
|
||||
this.position,
|
||||
required this.limit,
|
||||
this.isDoneBucket = false,
|
||||
DateTime? created,
|
||||
DateTime? updated,
|
||||
required this.createdBy,
|
||||
@ -36,7 +34,6 @@ class Bucket {
|
||||
? json['position'].toDouble()
|
||||
: json['position'],
|
||||
limit = json['limit'],
|
||||
isDoneBucket = json['is_done_bucket'],
|
||||
created = DateTime.parse(json['created']),
|
||||
updated = DateTime.parse(json['updated']),
|
||||
createdBy = User.fromJson(json['created_by']),
|
||||
@ -52,7 +49,6 @@ class Bucket {
|
||||
'title': title,
|
||||
'position': position,
|
||||
'limit': limit,
|
||||
'is_done_bucket': isDoneBucket,
|
||||
'created': created.toUtc().toIso8601String(),
|
||||
'updated': updated.toUtc().toIso8601String(),
|
||||
'created_by': createdBy.toJSON(),
|
||||
|
@ -13,7 +13,6 @@ class Project {
|
||||
final DateTime created, updated;
|
||||
final Color? color;
|
||||
final bool isArchived, isFavourite;
|
||||
final int? doneBucketId;
|
||||
|
||||
Iterable<Project>? subprojects;
|
||||
final List<ProjectView> views;
|
||||
@ -24,7 +23,6 @@ class Project {
|
||||
this.parentProjectId = 0,
|
||||
this.description = '',
|
||||
this.position = 0,
|
||||
this.doneBucketId,
|
||||
this.color,
|
||||
this.isArchived = false,
|
||||
this.isFavourite = false,
|
||||
@ -42,7 +40,6 @@ class Project {
|
||||
position = json['position'].toDouble(),
|
||||
isArchived = json['is_archived'],
|
||||
isFavourite = json['is_archived'],
|
||||
doneBucketId = json['done_bucket_id'],
|
||||
parentProjectId = json['parent_project_id'],
|
||||
views = json['views']
|
||||
.map<ProjectView>((view) => ProjectView.fromJson(view))
|
||||
@ -66,7 +63,6 @@ class Project {
|
||||
color?.value.toRadixString(16).padLeft(8, '0').substring(2),
|
||||
'is_archived': isArchived,
|
||||
'is_favourite': isFavourite,
|
||||
'done_bucket_id': doneBucketId,
|
||||
'position': position
|
||||
};
|
||||
|
||||
@ -92,7 +88,6 @@ class Project {
|
||||
owner: owner ?? this.owner,
|
||||
description: description ?? this.description,
|
||||
parentProjectId: parentProjectId ?? this.parentProjectId,
|
||||
doneBucketId: doneBucketId ?? this.doneBucketId,
|
||||
color: color ?? this.color,
|
||||
isArchived: isArchived ?? this.isArchived,
|
||||
isFavourite: isFavourite ?? this.isFavourite,
|
||||
|
@ -53,4 +53,27 @@ class ProjectView {
|
||||
"updated": updated.toUtc().toIso8601String(),
|
||||
"view_kind": viewKind
|
||||
};
|
||||
|
||||
ProjectView copyWith({
|
||||
DateTime? created, // "created": "string",
|
||||
int? defaultBucketId, //": 0,
|
||||
int? doneBucketId,
|
||||
int? id, //": 0,
|
||||
int? position,
|
||||
int? projectId,
|
||||
String? title,
|
||||
DateTime? updated,
|
||||
String? viewKind,
|
||||
}) {
|
||||
return ProjectView(
|
||||
created ?? this.created,
|
||||
defaultBucketId ?? this.defaultBucketId,
|
||||
doneBucketId ?? this.doneBucketId,
|
||||
id ?? this.id,
|
||||
position ?? this.position,
|
||||
projectId ?? this.projectId,
|
||||
title ?? this.title,
|
||||
updated ?? this.updated,
|
||||
viewKind ?? this.viewKind);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import 'package:vikunja_app/models/bucket.dart';
|
||||
|
||||
import '../models/project.dart';
|
||||
import '../models/server.dart';
|
||||
import '../models/view.dart';
|
||||
|
||||
enum TaskServiceOptionSortBy {
|
||||
id,
|
||||
@ -152,6 +153,13 @@ abstract class ProjectService {
|
||||
//void setDefaultList(int? listId);
|
||||
}
|
||||
|
||||
abstract class ProjectViewService {
|
||||
Future<ProjectView?> get(int projectId, int viewId);
|
||||
Future<ProjectView?> create(ProjectView view);
|
||||
Future<ProjectView?> update(ProjectView view);
|
||||
Future delete(int projectId, int viewId);
|
||||
}
|
||||
|
||||
abstract class NamespaceService {
|
||||
Future<List<Namespace>?> getAll();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user