Task edit #37
|
@ -9,7 +9,7 @@ class LabelAPIService extends APIService implements LabelService {
|
||||||
@override
|
@override
|
||||||
Future<Label> create(Label label) {
|
Future<Label> create(Label label) {
|
||||||
return client
|
return client
|
||||||
.put('/labels', body: label)
|
.put('/labels', body: label.toJSON())
|
||||||
.then((result) => Label.fromJson(result));
|
.then((result) => Label.fromJson(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Label {
|
||||||
final Color color;
|
final Color color;
|
||||||
|
|
||||||
Label(
|
Label(
|
||||||
{@required this.id,
|
{this.id,
|
||||||
this.title,
|
this.title,
|
||||||
this.description,
|
this.description,
|
||||||
this.color,
|
this.color,
|
||||||
|
|
|
@ -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.
|
_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>();
|
var _reminderInputs = new List<Widget>();
|
||||||
final _labelTypeAheadController = TextEditingController();
|
final _labelTypeAheadController = TextEditingController();
|
||||||
String _labelSearchText;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext ctx) {
|
Widget build(BuildContext ctx) {
|
||||||
|
@ -247,7 +246,6 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
||||||
child: TypeAheadFormField(
|
child: TypeAheadFormField(
|
||||||
textFieldConfiguration: TextFieldConfiguration(
|
textFieldConfiguration: TextFieldConfiguration(
|
||||||
controller: _labelTypeAheadController,
|
controller: _labelTypeAheadController,
|
||||||
onChanged: (value) => _labelSearchText = value,
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'Add a new label')),
|
labelText: 'Add a new label')),
|
||||||
suggestionsCallback: (pattern) {
|
suggestionsCallback: (pattern) {
|
||||||
|
@ -268,9 +266,7 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () => _createAndAddLabel(_labelTypeAheadController.text),
|
||||||
print(_labelSearchText);
|
|
||||||
},
|
|
||||||
icon: Icon(Icons.add),
|
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.
|
// FIXME: Move the following two functions to an extra class or type.
|
||||||
_priorityFromString(String priority) {
|
_priorityFromString(String priority) {
|
||||||
switch (priority) {
|
switch (priority) {
|
||||||
|
|
Reference in New Issue
Block a user