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;
|
Client clientAPI;
|
||||||
String currentRoute;
|
String currentRoute;
|
||||||
ConfigurationDTO selectedConfiguration;
|
ConfigurationDTO selectedConfiguration;
|
||||||
|
SectionDTO selectedSection;
|
||||||
|
|
||||||
ManagerAppContext({this.email, this.token, this.currentRoute});
|
ManagerAppContext({this.email, this.token, this.currentRoute});
|
||||||
|
|
||||||
// Implement toString to make it easier to see information about
|
// Implement toString to make it easier to see information about
|
||||||
@override
|
@override
|
||||||
String toString() {
|
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> {
|
class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||||
ConfigurationDTO configurationDTO;
|
ConfigurationDTO configurationDTO;
|
||||||
|
SectionDTO selectedSection;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -176,8 +177,23 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
Align(
|
Align(
|
||||||
alignment: AlignmentDirectional.centerStart,
|
alignment: AlignmentDirectional.centerStart,
|
||||||
child: Text("Sections :", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300))
|
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) {
|
getElement(dynamic element, Size size) {
|
||||||
if (configuration.id != null) {
|
if (element.id != null) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
@ -247,7 +263,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
Align(
|
Align(
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: AutoSizeText(
|
child: AutoSizeText(
|
||||||
configuration.label,
|
element.label,
|
||||||
style: new TextStyle(fontSize: 25),
|
style: new TextStyle(fontSize: 25),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
),
|
),
|
||||||
@ -255,7 +271,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
Align(
|
Align(
|
||||||
alignment: Alignment.bottomRight,
|
alignment: Alignment.bottomRight,
|
||||||
child: AutoSizeText(
|
child: AutoSizeText(
|
||||||
DateFormat('dd/MM/yyyy').format(configuration.dateCreation),
|
DateFormat('dd/MM/yyyy').format(element.dateCreation),
|
||||||
style: new TextStyle(fontSize: 18, fontFamily: ""),
|
style: new TextStyle(fontSize: 18, fontFamily: ""),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
),
|
),
|
||||||
@ -266,11 +282,44 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
return Icon(
|
return Icon(
|
||||||
Icons.add,
|
Icons.add,
|
||||||
color: kTextLightColor,
|
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 {
|
Future<void> save(ConfigurationDTO configurationDTO, AppContext appContext) async {
|
||||||
ConfigurationDTO configuration = await appContext.getContext().clientAPI.configurationApi.configurationUpdate(configurationDTO);
|
ConfigurationDTO configuration = await appContext.getContext().clientAPI.configurationApi.configurationUpdate(configurationDTO);
|
||||||
ManagerAppContext managerAppContext = appContext.getContext();
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
@ -315,11 +364,17 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
|
|
||||||
return configuration;
|
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(
|
return BoxDecoration(
|
||||||
color: configurationDTO.id == null ? Colors.lightGreen : kTextLightColor,
|
color: element.id == null ? Colors.lightGreen : kTextLightColor,
|
||||||
shape: BoxShape.rectangle,
|
shape: BoxShape.rectangle,
|
||||||
borderRadius: BorderRadius.circular(25.0),
|
borderRadius: BorderRadius.circular(25.0),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
|
|||||||
@ -63,8 +63,8 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
print("error auth");
|
print("error auth");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (!isError) {
|
if (!isError) {
|
||||||
UserDetailDTO user = await clientAPI.userApi.userGetDetail("6071f74aaf542f03116f2b9b");
|
/*UserDetailDTO user = await clientAPI.userApi.userGetDetail("6071f74aaf542f03116f2b9b");
|
||||||
print("user values ??");
|
print("user values ??");
|
||||||
print(user.email);
|
print(user.email);
|
||||||
print(user.id);
|
print(user.id);
|
||||||
@ -75,7 +75,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
print(element);
|
print(element);
|
||||||
});
|
});
|
||||||
|
|
||||||
List<SectionDTO> sections = await clientAPI.sectionApi.sectionGet();
|
List<SectionDTO> sections = await clientAPI.sectionApi.sectionGetFromConfiguration(id);
|
||||||
print("number of sections " + sections.length.toString());
|
print("number of sections " + sections.length.toString());
|
||||||
sections.forEach((element) {
|
sections.forEach((element) {
|
||||||
print(element);
|
print(element);
|
||||||
@ -85,8 +85,8 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
print("number of ressources " + ressources.length.toString());
|
print("number of ressources " + ressources.length.toString());
|
||||||
ressources.forEach((element) {
|
ressources.forEach((element) {
|
||||||
print(element);
|
print(element);
|
||||||
});
|
});*/
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAccessToken(String accessToken) {
|
void setAccessToken(String accessToken) {
|
||||||
|
|||||||
@ -42,5 +42,3 @@ lib/model/token_dto.dart
|
|||||||
lib/model/user.dart
|
lib/model/user.dart
|
||||||
lib/model/user_detail_dto.dart
|
lib/model/user_detail_dto.dart
|
||||||
pubspec.yaml
|
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* | [**sectionGet**](doc\/SectionApi.md#sectionget) | **GET** /api/Section |
|
||||||
*SectionApi* | [**sectionGetAllSectionSubSections**](doc\/SectionApi.md#sectiongetallsectionsubsections) | **GET** /api/Section/{id}/subsections |
|
*SectionApi* | [**sectionGetAllSectionSubSections**](doc\/SectionApi.md#sectiongetallsectionsubsections) | **GET** /api/Section/{id}/subsections |
|
||||||
*SectionApi* | [**sectionGetDetail**](doc\/SectionApi.md#sectiongetdetail) | **GET** /api/Section/{id} |
|
*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 |
|
*SectionApi* | [**sectionUpdate**](doc\/SectionApi.md#sectionupdate) | **PUT** /api/Section |
|
||||||
*UserApi* | [**userCreateUser**](doc\/UserApi.md#usercreateuser) | **POST** /api/User |
|
*UserApi* | [**userCreateUser**](doc\/UserApi.md#usercreateuser) | **POST** /api/User |
|
||||||
*UserApi* | [**userDeleteUser**](doc\/UserApi.md#userdeleteuser) | **DELETE** /api/User/{id} |
|
*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 |
|
[**sectionGet**](SectionApi.md#sectionget) | **GET** /api/Section |
|
||||||
[**sectionGetAllSectionSubSections**](SectionApi.md#sectiongetallsectionsubsections) | **GET** /api/Section/{id}/subsections |
|
[**sectionGetAllSectionSubSections**](SectionApi.md#sectiongetallsectionsubsections) | **GET** /api/Section/{id}/subsections |
|
||||||
[**sectionGetDetail**](SectionApi.md#sectiongetdetail) | **GET** /api/Section/{id} |
|
[**sectionGetDetail**](SectionApi.md#sectiongetdetail) | **GET** /api/Section/{id} |
|
||||||
|
[**sectionGetFromConfiguration**](SectionApi.md#sectiongetfromconfiguration) | **GET** /api/Section/configuration/{id} |
|
||||||
[**sectionUpdate**](SectionApi.md#sectionupdate) | **PUT** /api/Section |
|
[**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)
|
[[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**
|
# **sectionUpdate**
|
||||||
> SectionDTO sectionUpdate(sectionDTO)
|
> SectionDTO sectionUpdate(sectionDTO)
|
||||||
|
|
||||||
|
|||||||
@ -326,6 +326,72 @@ class SectionApi {
|
|||||||
return Future<Object>.value(null);
|
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].
|
/// Performs an HTTP 'PUT /api/Section' operation and returns the [Response].
|
||||||
/// Parameters:
|
/// Parameters:
|
||||||
///
|
///
|
||||||
|
|||||||
@ -482,6 +482,42 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
security:
|
security:
|
||||||
- bearer: []
|
- 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':
|
'/api/Section/{id}/subsections':
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@ -503,6 +539,12 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items: {}
|
items: {}
|
||||||
|
'400':
|
||||||
|
description: ''
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
'500':
|
'500':
|
||||||
description: ''
|
description: ''
|
||||||
content:
|
content:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user