mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 16:19:03 +03:30
Set search cycle by api
This commit is contained in:
@@ -271,14 +271,37 @@ class CyclesProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void search(String value) {
|
||||
Future<void> search(String value) async {
|
||||
print(value);
|
||||
items = [];
|
||||
searchBoxValue = value;
|
||||
originalItems!.forEach((result) {
|
||||
if (result.id.toString().contains(searchBoxValue)) {
|
||||
items!.add(result);
|
||||
var response = await http.get(
|
||||
Uri.parse(Url.searchCycles(value)),
|
||||
headers: {
|
||||
'Authorization': User.token,
|
||||
},
|
||||
);
|
||||
|
||||
var testResultData = json.decode(response.body);
|
||||
List<String> labels = [];
|
||||
if (pageNumber == 1) {
|
||||
originalItems = [];
|
||||
items = [];
|
||||
}
|
||||
for (var item in testResultData['data']) {
|
||||
labels = [];
|
||||
for (var label in item['labels']) {
|
||||
labels.add(label['id'].toString());
|
||||
}
|
||||
});
|
||||
items!.add(
|
||||
CycleResultObject(
|
||||
createdAt: item['date'],
|
||||
id: item['id'].toString(),
|
||||
label: labels,
|
||||
),
|
||||
);
|
||||
}
|
||||
resetLoading();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -332,8 +355,9 @@ class CyclesProvider extends ChangeNotifier {
|
||||
),
|
||||
);
|
||||
}
|
||||
items = originalItems;
|
||||
pageNumber += 1;
|
||||
search('');
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<CycleDetailObject> showCycleResult(String id) async {
|
||||
|
||||
Reference in New Issue
Block a user