This commit is contained in:
kolaente 2019-03-21 19:29:36 +01:00
parent dfdd6bbd36
commit dc83fc74c4
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
5 changed files with 22 additions and 15 deletions

View File

@ -6,13 +6,16 @@ import 'package:vikunja_app/models/task.dart';
import 'package:vikunja_app/service/services.dart';
class LabelTaskBulkAPIService extends APIService
implements LabelTaskBulkService {
implements LabelTaskBulkService {
LabelTaskBulkAPIService(Client client) : super(client);
@override
Future<Label> update(Task task, List<Label> labels) {
return client
.post('/tasks/${task.id}/labels/bulk', body: LabelTaskBulk(labels: labels).toJSON())
.then((labels) { print(labels.toString());});
.post('/tasks/${task.id}/labels/bulk',
body: LabelTaskBulk(labels: labels).toJSON())
.then((labels) {
print(labels.toString());
});
}
}
}

View File

@ -23,7 +23,9 @@ class Label {
: id = json['id'],
title = json['title'],
description = json['description'],
color = json['hex_color'] == '' ? null : new Color(int.parse(json['hex_color'], radix: 16) + 0xFF000000),
color = json['hex_color'] == ''
? null
: new Color(int.parse(json['hex_color'], radix: 16) + 0xFF000000),
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
createdBy = User.fromJson(json['created_by']);
@ -32,7 +34,9 @@ class Label {
'id': id,
'title': title,
'description': description,
'hex_color': color?.value == null ? null : color.value.toRadixString(16).padLeft(8, '0').substring(2),
'hex_color': color?.value == null
? null
: color.value.toRadixString(16).padLeft(8, '0').substring(2),
'created_by': createdBy?.toJSON(),
'updated': updated?.millisecondsSinceEpoch,
'created': created?.millisecondsSinceEpoch,

View File

@ -9,10 +9,10 @@ class LabelTask {
LabelTask({@required this.label, @required this.task});
LabelTask.fromJson(Map<String, dynamic> json)
: label = new Label(id: json['label_id']),
task = null;
: label = new Label(id: json['label_id']),
task = null;
toJSON() => {
'label_id': label.id,
};
'label_id': label.id,
};
}

View File

@ -1,4 +1,4 @@
import'package:meta/meta.dart';
import 'package:meta/meta.dart';
import 'package:vikunja_app/models/label.dart';
class LabelTaskBulk {
@ -7,9 +7,9 @@ class LabelTaskBulk {
LabelTaskBulk({@required this.labels});
LabelTaskBulk.fromJson(Map<String, dynamic> json)
: labels = json['labels']?.map((label) => Label.fromJson(label));
: labels = json['labels']?.map((label) => Label.fromJson(label));
toJSON() => {
'labels': labels.map((label) => label.toJSON()).toList(),
};
'labels': labels.map((label) => label.toJSON()).toList(),
};
}

View File

@ -52,4 +52,4 @@ abstract class LabelTaskService {
abstract class LabelTaskBulkService {
Future<Label> update(Task task, List<Label> labels);
}
}