service update generation + sections list display in detail
This commit is contained in:
parent
1ed3912b27
commit
6aca22b758
@ -10,12 +10,13 @@ class ManagerAppContext with ChangeNotifier{
|
||||
Client clientAPI;
|
||||
String currentRoute;
|
||||
ConfigurationDTO selectedConfiguration;
|
||||
SectionDTO selectedSection;
|
||||
|
||||
ManagerAppContext({this.email, this.token, this.currentRoute});
|
||||
|
||||
// Implement toString to make it easier to see information about
|
||||
@override
|
||||
String toString() {
|
||||
return 'ManagerAppContext{email: $email, token: $token, currentRoute: $currentRoute}, selectedConfiguration: $selectedConfiguration}';
|
||||
return 'ManagerAppContext{email: $email, token: $token, currentRoute: $currentRoute}, selectedConfiguration: $selectedConfiguration, selectedSection: $selectedSection}';
|
||||
}
|
||||
}
|
||||
@ -29,6 +29,7 @@ class ConfigurationDetailScreen extends StatefulWidget {
|
||||
|
||||
class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
ConfigurationDTO configurationDTO;
|
||||
SectionDTO selectedSection;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -179,6 +180,21 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Text("Sections :", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300))
|
||||
),
|
||||
FutureBuilder(
|
||||
future: getSections(configurationDTO, appContext.getContext().clientAPI),
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
var tempOutput = new List<SectionDTO>.from(snapshot.data);
|
||||
print(tempOutput);
|
||||
tempOutput.add(SectionDTO(id: null));
|
||||
return bodyGrid(tempOutput, size, appContext);
|
||||
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||
return Text("No data");
|
||||
} else {
|
||||
return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE')));
|
||||
}
|
||||
}
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -238,8 +254,8 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
getElement(ConfigurationDTO configuration, Size size) {
|
||||
if (configuration.id != null) {
|
||||
getElement(dynamic element, Size size) {
|
||||
if (element.id != null) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@ -247,7 +263,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: AutoSizeText(
|
||||
configuration.label,
|
||||
element.label,
|
||||
style: new TextStyle(fontSize: 25),
|
||||
maxLines: 1,
|
||||
),
|
||||
@ -255,7 +271,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: AutoSizeText(
|
||||
DateFormat('dd/MM/yyyy').format(configuration.dateCreation),
|
||||
DateFormat('dd/MM/yyyy').format(element.dateCreation),
|
||||
style: new TextStyle(fontSize: 18, fontFamily: ""),
|
||||
maxLines: 1,
|
||||
),
|
||||
@ -266,11 +282,44 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
return Icon(
|
||||
Icons.add,
|
||||
color: kTextLightColor,
|
||||
size: 100.0,
|
||||
size: 50.0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget bodyGrid(data, Size size, AppContext appContext) {
|
||||
return GridView.builder(
|
||||
shrinkWrap: true,
|
||||
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 8),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (data[index].id == null) {
|
||||
print("open modal to create new section !");
|
||||
} else {
|
||||
setState(() {
|
||||
ManagerAppContext managerAppContext = appContext.getContext();
|
||||
managerAppContext.selectedSection = data[index];
|
||||
selectedSection = data[index];
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
decoration: boxDecoration(data[index]),
|
||||
padding: const EdgeInsets.all(15),
|
||||
margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: getElement(data[index], size)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> save(ConfigurationDTO configurationDTO, AppContext appContext) async {
|
||||
ConfigurationDTO configuration = await appContext.getContext().clientAPI.configurationApi.configurationUpdate(configurationDTO);
|
||||
ManagerAppContext managerAppContext = appContext.getContext();
|
||||
@ -315,11 +364,17 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
Future<List<SectionDTO>> getSections(ConfigurationDTO configurationDTO, Client client) async {
|
||||
List<SectionDTO> sections = await client.sectionApi.sectionGetFromConfiguration(configurationDTO.id);
|
||||
print(sections);
|
||||
return sections;
|
||||
}
|
||||
}
|
||||
|
||||
boxDecoration(ConfigurationDTO configurationDTO) {
|
||||
boxDecoration(dynamic element) {
|
||||
return BoxDecoration(
|
||||
color: configurationDTO.id == null ? Colors.lightGreen : kTextLightColor,
|
||||
color: element.id == null ? Colors.lightGreen : kTextLightColor,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
boxShadow: [
|
||||
|
||||
@ -63,8 +63,8 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
print("error auth");
|
||||
}
|
||||
|
||||
/*if (!isError) {
|
||||
UserDetailDTO user = await clientAPI.userApi.userGetDetail("6071f74aaf542f03116f2b9b");
|
||||
if (!isError) {
|
||||
/*UserDetailDTO user = await clientAPI.userApi.userGetDetail("6071f74aaf542f03116f2b9b");
|
||||
print("user values ??");
|
||||
print(user.email);
|
||||
print(user.id);
|
||||
@ -75,7 +75,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
print(element);
|
||||
});
|
||||
|
||||
List<SectionDTO> sections = await clientAPI.sectionApi.sectionGet();
|
||||
List<SectionDTO> sections = await clientAPI.sectionApi.sectionGetFromConfiguration(id);
|
||||
print("number of sections " + sections.length.toString());
|
||||
sections.forEach((element) {
|
||||
print(element);
|
||||
@ -85,8 +85,8 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
print("number of ressources " + ressources.length.toString());
|
||||
ressources.forEach((element) {
|
||||
print(element);
|
||||
});
|
||||
}*/
|
||||
});*/
|
||||
}
|
||||
}
|
||||
|
||||
void setAccessToken(String accessToken) {
|
||||
|
||||
@ -42,5 +42,3 @@ lib/model/token_dto.dart
|
||||
lib/model/user.dart
|
||||
lib/model/user_detail_dto.dart
|
||||
pubspec.yaml
|
||||
test/configuration_api_test.dart
|
||||
test/configuration_dto_test.dart
|
||||
|
||||
@ -82,6 +82,7 @@ Class | Method | HTTP request | Description
|
||||
*SectionApi* | [**sectionGet**](doc\/SectionApi.md#sectionget) | **GET** /api/Section |
|
||||
*SectionApi* | [**sectionGetAllSectionSubSections**](doc\/SectionApi.md#sectiongetallsectionsubsections) | **GET** /api/Section/{id}/subsections |
|
||||
*SectionApi* | [**sectionGetDetail**](doc\/SectionApi.md#sectiongetdetail) | **GET** /api/Section/{id} |
|
||||
*SectionApi* | [**sectionGetFromConfiguration**](doc\/SectionApi.md#sectiongetfromconfiguration) | **GET** /api/Section/configuration/{id} |
|
||||
*SectionApi* | [**sectionUpdate**](doc\/SectionApi.md#sectionupdate) | **PUT** /api/Section |
|
||||
*UserApi* | [**userCreateUser**](doc\/UserApi.md#usercreateuser) | **POST** /api/User |
|
||||
*UserApi* | [**userDeleteUser**](doc\/UserApi.md#userdeleteuser) | **DELETE** /api/User/{id} |
|
||||
|
||||
@ -14,6 +14,7 @@ Method | HTTP request | Description
|
||||
[**sectionGet**](SectionApi.md#sectionget) | **GET** /api/Section |
|
||||
[**sectionGetAllSectionSubSections**](SectionApi.md#sectiongetallsectionsubsections) | **GET** /api/Section/{id}/subsections |
|
||||
[**sectionGetDetail**](SectionApi.md#sectiongetdetail) | **GET** /api/Section/{id} |
|
||||
[**sectionGetFromConfiguration**](SectionApi.md#sectiongetfromconfiguration) | **GET** /api/Section/configuration/{id} |
|
||||
[**sectionUpdate**](SectionApi.md#sectionupdate) | **PUT** /api/Section |
|
||||
|
||||
|
||||
@ -228,6 +229,49 @@ Name | Type | Description | Notes
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **sectionGetFromConfiguration**
|
||||
> List<SectionDTO> sectionGetFromConfiguration(id)
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
```dart
|
||||
import 'package:managerapi/api.dart';
|
||||
// TODO Configure OAuth2 access token for authorization: bearer
|
||||
//defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN';
|
||||
|
||||
final api_instance = SectionApi();
|
||||
final id = id_example; // String |
|
||||
|
||||
try {
|
||||
final result = api_instance.sectionGetFromConfiguration(id);
|
||||
print(result);
|
||||
} catch (e) {
|
||||
print('Exception when calling SectionApi->sectionGetFromConfiguration: $e\n');
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**id** | **String**| |
|
||||
|
||||
### Return type
|
||||
|
||||
[**List<SectionDTO>**](SectionDTO.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[bearer](../README.md#bearer)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **sectionUpdate**
|
||||
> SectionDTO sectionUpdate(sectionDTO)
|
||||
|
||||
|
||||
@ -326,6 +326,72 @@ class SectionApi {
|
||||
return Future<Object>.value(null);
|
||||
}
|
||||
|
||||
/// Performs an HTTP 'GET /api/Section/configuration/{id}' operation and returns the [Response].
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] id (required):
|
||||
Future<Response> sectionGetFromConfigurationWithHttpInfo(String id) async {
|
||||
// Verify required params are set.
|
||||
if (id == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: id');
|
||||
}
|
||||
|
||||
final path = r'/api/Section/configuration/{id}'
|
||||
.replaceAll('{' + 'id' + '}', id.toString());
|
||||
|
||||
Object postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
final contentTypes = <String>[];
|
||||
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
|
||||
final authNames = <String>['bearer'];
|
||||
|
||||
if (
|
||||
nullableContentType != null &&
|
||||
nullableContentType.toLowerCase().startsWith('multipart/form-data')
|
||||
) {
|
||||
bool hasFields = false;
|
||||
final mp = MultipartRequest(null, null);
|
||||
if (hasFields) {
|
||||
postBody = mp;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return await apiClient.invokeAPI(
|
||||
path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
nullableContentType,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Parameters:
|
||||
///
|
||||
/// * [String] id (required):
|
||||
Future<List<SectionDTO>> sectionGetFromConfiguration(String id) async {
|
||||
final response = await sectionGetFromConfigurationWithHttpInfo(id);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
}
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return (apiClient.deserialize(_decodeBodyBytes(response), 'List<SectionDTO>') as List)
|
||||
.cast<SectionDTO>()
|
||||
.toList(growable: false);
|
||||
}
|
||||
return Future<List<SectionDTO>>.value(null);
|
||||
}
|
||||
|
||||
/// Performs an HTTP 'PUT /api/Section' operation and returns the [Response].
|
||||
/// Parameters:
|
||||
///
|
||||
|
||||
@ -482,6 +482,42 @@ paths:
|
||||
type: string
|
||||
security:
|
||||
- bearer: []
|
||||
'/api/Section/configuration/{id}':
|
||||
get:
|
||||
tags:
|
||||
- Section
|
||||
operationId: Section_GetFromConfiguration
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
nullable: true
|
||||
x-position: 1
|
||||
responses:
|
||||
'200':
|
||||
description: ''
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/SectionDTO'
|
||||
'400':
|
||||
description: ''
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
'500':
|
||||
description: ''
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
security:
|
||||
- bearer: []
|
||||
'/api/Section/{id}/subsections':
|
||||
get:
|
||||
tags:
|
||||
@ -503,6 +539,12 @@ paths:
|
||||
schema:
|
||||
type: array
|
||||
items: {}
|
||||
'400':
|
||||
description: ''
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
'500':
|
||||
description: ''
|
||||
content:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user