Task edit #37

Open
konrad wants to merge 76 commits from feature/edit-task into master
3 changed files with 15 additions and 7 deletions
Showing only changes of commit e97cd9a2f9 - Show all commits

View File

@ -9,7 +9,7 @@ class LabelAPIService extends APIService implements LabelService {
@override
Future<Label> create(Label label) {
return client
.put('/labels', body: label)
.put('/labels', body: label.toJSON())
.then((result) => Label.fromJson(result));
}

View File

@ -11,7 +11,7 @@ class Label {
final Color color;
Label(
{@required this.id,
{this.id,
this.title,
this.description,
this.color,

View File

@ -32,7 +32,6 @@ class _TaskEditPageState extends State<TaskEditPage> {
_suggestedLabels; // we use this to find the label object after a user taps on the suggestion, because the typeahead only uses strings, not full objects.
var _reminderInputs = new List<Widget>();
final _labelTypeAheadController = TextEditingController();
String _labelSearchText;
@override
Widget build(BuildContext ctx) {
@ -247,7 +246,6 @@ class _TaskEditPageState extends State<TaskEditPage> {
child: TypeAheadFormField(
textFieldConfiguration: TextFieldConfiguration(
controller: _labelTypeAheadController,
onChanged: (value) => _labelSearchText = value,
decoration: InputDecoration(
labelText: 'Add a new label')),
suggestionsCallback: (pattern) {
@ -268,9 +266,7 @@ class _TaskEditPageState extends State<TaskEditPage> {
),
),
IconButton(
onPressed: () {
print(_labelSearchText);
},
onPressed: () => _createAndAddLabel(_labelTypeAheadController.text),
icon: Icon(Icons.add),
)
],
@ -377,6 +373,18 @@ class _TaskEditPageState extends State<TaskEditPage> {
}
}
_createAndAddLabel(String labelTitle) {
Label newLabel = Label(title: labelTitle);
VikunjaGlobal.of(context)
.labelService.create(newLabel)
.then((createdLabel) {
setState(() {
_labels.add(createdLabel);
_labelTypeAheadController.clear();
});
});
}
// FIXME: Move the following two functions to an extra class or type.
_priorityFromString(String priority) {
switch (priority) {