mirror of
https://github.com/go-vikunja/app
synced 2024-06-14 00:14:25 +00:00
ee99869cf6
* Ran make format Signed-off-by: Timo Reichl <timo.reichl@mailbox.org> * Add VS Code launch config Signed-off-by: Timo Reichl <timo.reichl@mailbox.org> * pages/list/list.dart: Stop spinning wheel after adding a task Signed-off-by: Timo Reichl <timo.reichl@mailbox.org> * stores/list_store.dart: Fix updateTask() not being a future Signed-off-by: Timo Reichl <timo.reichl@mailbox.org> * Replace FlatButton with TextButton widgets Signed-off-by: Timo Reichl <timo.reichl@mailbox.org> * components/TaskTile.dart: Remove dead code Signed-off-by: Timo Reichl <timo.reichl@mailbox.org> * theme/theme.dart: Fix accentColor deprecation Signed-off-by: Timo Reichl <timo.reichl@mailbox.org> * pages/list/list_edit.dart: Fix SnackBar.hideCurrentSnackBar() deprecation Signed-off-by: Timo Reichl <timo.reichl@mailbox.org> * Remove unused folder lib/managers Signed-off-by: Timo Reichl <timo.reichl@mailbox.org>
60 lines
1.7 KiB
Dart
60 lines
1.7 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:vikunja_app/api/client.dart';
|
|
import 'package:vikunja_app/api/service.dart';
|
|
import 'package:vikunja_app/models/list.dart';
|
|
import 'package:vikunja_app/service/services.dart';
|
|
|
|
class ListAPIService extends APIService implements ListService {
|
|
ListAPIService(Client client) : super(client);
|
|
|
|
@override
|
|
Future<TaskList> create(namespaceId, TaskList tl) {
|
|
return client
|
|
.put('/namespaces/$namespaceId/lists', body: tl.toJSON())
|
|
.then((response) => TaskList.fromJson(response.body));
|
|
}
|
|
|
|
@override
|
|
Future delete(int listId) {
|
|
return client.delete('/lists/$listId').then((_) {});
|
|
}
|
|
|
|
@override
|
|
Future<TaskList> get(int listId) {
|
|
/*
|
|
return client
|
|
.get('/lists/$listId')
|
|
.then((response) => TaskList.fromJson(response.body));
|
|
*/
|
|
return client.get('/lists/$listId').then((response) {
|
|
final map = response.body;
|
|
if (map.containsKey('id')) {
|
|
return client
|
|
.get("/lists/$listId/tasks")
|
|
.then((tasks) => TaskList.fromJson(map, tasksJson: tasks.body));
|
|
}
|
|
return TaskList.fromJson(map);
|
|
});
|
|
}
|
|
|
|
@override
|
|
Future<List<TaskList>> getAll() {
|
|
return client.get('/lists').then((response) =>
|
|
convertList(response.body, (result) => TaskList.fromJson(result)));
|
|
}
|
|
|
|
@override
|
|
Future<List<TaskList>> getByNamespace(int namespaceId) {
|
|
return client.get('/namespaces/$namespaceId/lists').then((response) =>
|
|
convertList(response.body, (result) => TaskList.fromJson(result)));
|
|
}
|
|
|
|
@override
|
|
Future<TaskList> update(TaskList tl) {
|
|
return client
|
|
.post('/lists/${tl.id}', body: tl.toJSON())
|
|
.then((response) => TaskList.fromJson(response.body));
|
|
}
|
|
}
|