mirror of
https://github.com/go-vikunja/app
synced 2024-06-02 18:49:47 +00:00
chore: continual of prev. commit, deleting all references to lists and namespaces
This commit is contained in:
parent
4e78b5615e
commit
d30a3cf5f2
|
@ -1,53 +0,0 @@
|
||||||
import 'package:vikunja_app/models/task.dart';
|
|
||||||
import 'package:vikunja_app/models/user.dart';
|
|
||||||
|
|
||||||
class TaskList {
|
|
||||||
final int id;
|
|
||||||
int namespaceId;
|
|
||||||
String title, description;
|
|
||||||
final User owner;
|
|
||||||
final DateTime created, updated;
|
|
||||||
final List<Task> tasks;
|
|
||||||
final bool isFavorite;
|
|
||||||
|
|
||||||
TaskList({
|
|
||||||
this.id = 0,
|
|
||||||
required this.title,
|
|
||||||
required this.namespaceId,
|
|
||||||
this.description = '',
|
|
||||||
required this.owner,
|
|
||||||
DateTime? created,
|
|
||||||
DateTime? updated,
|
|
||||||
List<Task>? tasks,
|
|
||||||
this.isFavorite = false,
|
|
||||||
}) : this.created = created ?? DateTime.now(),
|
|
||||||
this.updated = updated ?? DateTime.now(),
|
|
||||||
this.tasks = tasks ?? [];
|
|
||||||
|
|
||||||
TaskList.fromJson(Map<String, dynamic> json)
|
|
||||||
: id = json['id'],
|
|
||||||
owner = User.fromJson(json['owner']),
|
|
||||||
description = json['description'],
|
|
||||||
title = json['title'],
|
|
||||||
updated = DateTime.parse(json['updated']),
|
|
||||||
created = DateTime.parse(json['created']),
|
|
||||||
isFavorite = json['is_favorite'],
|
|
||||||
namespaceId = json['namespace_id'],
|
|
||||||
tasks = json['tasks'] == null
|
|
||||||
? []
|
|
||||||
: (json['tasks'] as List<dynamic>)
|
|
||||||
.map((taskJson) => Task.fromJson(taskJson))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
toJSON() {
|
|
||||||
return {
|
|
||||||
'id': id,
|
|
||||||
'title': title,
|
|
||||||
'description': description,
|
|
||||||
'owner': owner.toJSON(),
|
|
||||||
'created': created.toUtc().toIso8601String(),
|
|
||||||
'updated': updated.toUtc().toIso8601String(),
|
|
||||||
'namespace_id': namespaceId
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
import 'package:vikunja_app/models/user.dart';
|
|
||||||
|
|
||||||
class Namespace {
|
|
||||||
final int id;
|
|
||||||
final DateTime created, updated;
|
|
||||||
final String title, description;
|
|
||||||
final User? owner;
|
|
||||||
|
|
||||||
Namespace({
|
|
||||||
this.id = 0,
|
|
||||||
DateTime? created,
|
|
||||||
DateTime? updated,
|
|
||||||
required this.title,
|
|
||||||
this.description = '',
|
|
||||||
required this.owner,
|
|
||||||
}) : this.created = created ?? DateTime.now(),
|
|
||||||
this.updated = updated ?? DateTime.now();
|
|
||||||
|
|
||||||
Namespace.fromJson(Map<String, dynamic> json)
|
|
||||||
: title = json['title'],
|
|
||||||
description = json['description'],
|
|
||||||
id = json['id'],
|
|
||||||
created = DateTime.parse(json['created']),
|
|
||||||
updated = DateTime.parse(json['updated']),
|
|
||||||
owner = json['owner'] != null ? User.fromJson(json['owner']) : null;
|
|
||||||
|
|
||||||
Map<String, dynamic> toJSON() => {
|
|
||||||
'id': id,
|
|
||||||
'created': created.toUtc().toIso8601String(),
|
|
||||||
'updated': updated.toUtc().toIso8601String(),
|
|
||||||
'title': title,
|
|
||||||
'owner': owner?.toJSON(),
|
|
||||||
'description': description
|
|
||||||
};
|
|
||||||
|
|
||||||
Namespace copyWith({
|
|
||||||
int? id,
|
|
||||||
DateTime? created,
|
|
||||||
DateTime? updated,
|
|
||||||
String? title,
|
|
||||||
String? description,
|
|
||||||
User? owner,
|
|
||||||
}) {
|
|
||||||
return Namespace(
|
|
||||||
id: id ?? this.id,
|
|
||||||
created: created ?? this.created,
|
|
||||||
updated: updated ?? this.updated,
|
|
||||||
title: title ?? this.title,
|
|
||||||
description: description ?? this.description,
|
|
||||||
owner: owner ?? this.owner,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,7 +2,6 @@ import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:vikunja_app/global.dart';
|
import 'package:vikunja_app/global.dart';
|
||||||
import 'package:vikunja_app/models/list.dart';
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
|
||||||
import '../main.dart';
|
import '../main.dart';
|
||||||
|
|
|
@ -1,202 +1,11 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:vikunja_app/api/response.dart';
|
|
||||||
import 'package:vikunja_app/models/list.dart';
|
|
||||||
import 'package:vikunja_app/models/namespace.dart';
|
|
||||||
import 'package:vikunja_app/models/task.dart';
|
|
||||||
import 'package:vikunja_app/models/user.dart';
|
import 'package:vikunja_app/models/user.dart';
|
||||||
import 'package:vikunja_app/service/services.dart';
|
import 'package:vikunja_app/service/services.dart';
|
||||||
|
|
||||||
// Data for mocked services
|
// Data for mocked services
|
||||||
var _users = {1: User(id: 1, username: 'test1')};
|
var _users = {1: User(id: 1, username: 'test1')};
|
||||||
|
|
||||||
var _namespaces = {
|
|
||||||
1: Namespace(
|
|
||||||
id: 1,
|
|
||||||
title: 'Test 1',
|
|
||||||
created: DateTime.now(),
|
|
||||||
updated: DateTime.now(),
|
|
||||||
description: 'A namespace for testing purposes',
|
|
||||||
owner: _users[1]!,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
var _nsLists = {
|
|
||||||
1: [1]
|
|
||||||
};
|
|
||||||
|
|
||||||
var _lists = {
|
|
||||||
1: TaskList(
|
|
||||||
id: 1,
|
|
||||||
title: 'List 1',
|
|
||||||
tasks: _tasks.values.toList(),
|
|
||||||
owner: _users[1]!,
|
|
||||||
description: 'A nice list',
|
|
||||||
created: DateTime.now(),
|
|
||||||
updated: DateTime.now(),
|
|
||||||
namespaceId: 1)
|
|
||||||
};
|
|
||||||
|
|
||||||
var _tasks = {
|
|
||||||
1: Task(
|
|
||||||
id: 1,
|
|
||||||
title: 'Task 1',
|
|
||||||
createdBy: _users[1]!,
|
|
||||||
updated: DateTime.now(),
|
|
||||||
created: DateTime.now(),
|
|
||||||
description: 'A descriptive task',
|
|
||||||
done: false,
|
|
||||||
projectId: 1,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
// Mocked services
|
|
||||||
|
|
||||||
class MockedNamespaceService implements NamespaceService {
|
|
||||||
@override
|
|
||||||
Future<Namespace> create(Namespace ns) {
|
|
||||||
_namespaces[ns.id] = ns;
|
|
||||||
return Future.value(ns);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future delete(int namespaceId) {
|
|
||||||
_namespaces.remove(namespaceId);
|
|
||||||
return Future.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Namespace> get(int namespaceId) {
|
|
||||||
return Future.value(_namespaces[namespaceId]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<Namespace>> getAll() {
|
|
||||||
return Future.value(_namespaces.values.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Namespace> update(Namespace ns) {
|
|
||||||
if (!_namespaces.containsKey(ns.id))
|
|
||||||
throw Exception('Namespace ${ns.id} does not exsists');
|
|
||||||
return create(ns);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
class MockedListService implements ListService {
|
|
||||||
@override
|
|
||||||
Future<TaskList> create(namespaceId, TaskList tl) {
|
|
||||||
_nsLists[namespaceId]?.add(tl.id);
|
|
||||||
return Future.value(_lists[tl.id] = tl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future delete(int listId) {
|
|
||||||
_lists.remove(listId);
|
|
||||||
return Future.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<TaskList> get(int listId) {
|
|
||||||
return Future.value(_lists[listId]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<TaskList>> getAll() {
|
|
||||||
return Future.value(_lists.values.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<TaskList>> getByNamespace(int namespaceId) {
|
|
||||||
return Future.value(
|
|
||||||
_nsLists[namespaceId]!.map((listId) => _lists[listId]!).toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<TaskList> update(TaskList tl) {
|
|
||||||
if (!_lists.containsKey(tl))
|
|
||||||
throw Exception('TaskList ${tl.id} does not exists');
|
|
||||||
return Future.value(_lists[tl.id] = tl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<String> getDisplayDoneTasks(int listId) {
|
|
||||||
// TODO: implement getDisplayDoneTasks
|
|
||||||
throw UnimplementedError();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void setDisplayDoneTasks(int listId, String value) {
|
|
||||||
// TODO: implement setDisplayDoneTasks
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<String> getDefaultList() {
|
|
||||||
// TODO: implement getDefaultList
|
|
||||||
throw UnimplementedError();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void setDefaultList(int? listId) {
|
|
||||||
// TODO: implement setDefaultList
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
class MockedTaskService implements TaskService {
|
|
||||||
@override
|
|
||||||
Future delete(int taskId) {
|
|
||||||
_lists.forEach(
|
|
||||||
(_, list) => list.tasks.removeWhere((task) => task.id == taskId));
|
|
||||||
_tasks.remove(taskId);
|
|
||||||
return Future.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Task> update(Task task) {
|
|
||||||
_lists.forEach((_, list) {
|
|
||||||
if (list.tasks.where((t) => t.id == task.id).length > 0) {
|
|
||||||
list.tasks.removeWhere((t) => t.id == task.id);
|
|
||||||
list.tasks.add(task);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return Future.value(_tasks[task.id] = task);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Task> add(int listId, Task task) {
|
|
||||||
var id = _tasks.keys.last + 1;
|
|
||||||
_tasks[id] = task;
|
|
||||||
_lists[listId]!.tasks.add(task);
|
|
||||||
return Future.value(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get maxPages => 1;
|
|
||||||
Future<Task> get(int taskId) {
|
|
||||||
// TODO: implement get
|
|
||||||
throw UnimplementedError();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<Task>> getByOptions(TaskServiceOptions options) {
|
|
||||||
// TODO: implement getByOptions
|
|
||||||
throw UnimplementedError();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<Task>> getAll() {
|
|
||||||
// TODO: implement getAll
|
|
||||||
throw UnimplementedError();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Response?> getAllByProject(int projectId,
|
|
||||||
[Map<String, List<String>>? queryParameters]) {
|
|
||||||
// TODO: implement getAllByProject
|
|
||||||
return Future.value(new Response(_tasks.values.toList(), 200, {}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MockedUserService implements UserService {
|
class MockedUserService implements UserService {
|
||||||
@override
|
@override
|
||||||
Future<UserTokenPair> login(String username, password,
|
Future<UserTokenPair> login(String username, password,
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:vikunja_app/api/response.dart';
|
import 'package:vikunja_app/api/response.dart';
|
||||||
import 'package:vikunja_app/models/label.dart';
|
import 'package:vikunja_app/models/label.dart';
|
||||||
import 'package:vikunja_app/models/labelTask.dart';
|
import 'package:vikunja_app/models/labelTask.dart';
|
||||||
import 'package:vikunja_app/models/namespace.dart';
|
|
||||||
import 'package:vikunja_app/models/task.dart';
|
import 'package:vikunja_app/models/task.dart';
|
||||||
import 'package:vikunja_app/models/user.dart';
|
import 'package:vikunja_app/models/user.dart';
|
||||||
import 'package:vikunja_app/models/bucket.dart';
|
import 'package:vikunja_app/models/bucket.dart';
|
||||||
|
@ -151,40 +149,6 @@ abstract class ProjectService {
|
||||||
//void setDefaultList(int? listId);
|
//void setDefaultList(int? listId);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class NamespaceService {
|
|
||||||
Future<List<Namespace>?> getAll();
|
|
||||||
|
|
||||||
Future<Namespace?> get(int namespaceId);
|
|
||||||
|
|
||||||
Future<Namespace?> create(Namespace ns);
|
|
||||||
|
|
||||||
Future<Namespace?> update(Namespace ns);
|
|
||||||
|
|
||||||
Future delete(int namespaceId);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
abstract class ListService {
|
|
||||||
Future<List<TaskList>?> getAll();
|
|
||||||
|
|
||||||
Future<TaskList?> get(int listId);
|
|
||||||
|
|
||||||
Future<List<TaskList>?> getByNamespace(int namespaceId);
|
|
||||||
|
|
||||||
Future<TaskList?> create(int namespaceId, TaskList tl);
|
|
||||||
|
|
||||||
Future<TaskList?> update(TaskList tl);
|
|
||||||
|
|
||||||
Future delete(int listId);
|
|
||||||
|
|
||||||
Future<String?> getDisplayDoneTasks(int listId);
|
|
||||||
|
|
||||||
void setDisplayDoneTasks(int listId, String value);
|
|
||||||
|
|
||||||
Future<String?> getDefaultList();
|
|
||||||
|
|
||||||
//void setDefaultList(int? listId);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
abstract class TaskService {
|
abstract class TaskService {
|
||||||
Future<Task?> get(int taskId);
|
Future<Task?> get(int taskId);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user