From e644cd487f8bc06b7b6dae79e3ac0f7d4ed669f3 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Wed, 14 May 2025 17:13:13 +0200 Subject: [PATCH] misc ! --- .../color_picker_input_container.dart | 24 ++++- lib/Components/fetch_section_icon.dart | 2 +- lib/Helpers/PDFHelper.dart | 2 +- .../SubSection/Article/article_config.dart | 20 ++-- .../Section/SubSection/Map/category_list.dart | 3 + .../SubSection/Map/geopoint_image_list.dart | 9 +- .../Section/SubSection/Map/map_config.dart | 6 +- .../SubSection/Map/new_update_categorie.dart | 10 +- .../Section/section_detail_screen.dart | 98 +++++++++++-------- .../configuration_detail_screen.dart | 4 +- lib/client.dart | 8 ++ manager_api_new/lib/model/categorie_dto.dart | 4 +- manager_api_new/lib/model/section_type.dart | 10 +- 13 files changed, 125 insertions(+), 75 deletions(-) diff --git a/lib/Components/color_picker_input_container.dart b/lib/Components/color_picker_input_container.dart index 3963d23..0ccdaad 100644 --- a/lib/Components/color_picker_input_container.dart +++ b/lib/Components/color_picker_input_container.dart @@ -25,7 +25,11 @@ class _ColorPickerInputContainerState extends State { @override void initState() { setState(() { - colorVar = widget.color == null ? new Color(0x12345678) : new Color(int.parse(widget.color!.split('(0x')[1].split(')')[0], radix: 16)); + try { + colorVar = widget.color == null || widget.color!.isEmpty ? new Color(0x12345678) : new Color(int.parse(widget.color!.split('(0x')[1].split(')')[0], radix: 16)); + } catch(e) { + colorVar = new Color(0x12345678); + } }); super.initState(); } @@ -55,7 +59,7 @@ class _ColorPickerInputContainerState extends State { setState(() { colorVar = color; }); - widget.onChanged(color.toString()); + widget.onChanged(colorToString(color)); }, context ); @@ -74,4 +78,20 @@ class _ColorPickerInputContainerState extends State { ), ); } + + String colorToString(Color color) { + int a = (color.a * 255).round(); + int r = (color.r * 255).round(); + int g = (color.g * 255).round(); + int b = (color.b * 255).round(); + + final aHex = a.toRadixString(16).padLeft(2, '0'); + final rHex = r.toRadixString(16).padLeft(2, '0'); + final gHex = g.toRadixString(16).padLeft(2, '0'); + final bHex = b.toRadixString(16).padLeft(2, '0'); + + return 'Color(0x$aHex$rHex$gHex$bHex)'; + } + + } \ No newline at end of file diff --git a/lib/Components/fetch_section_icon.dart b/lib/Components/fetch_section_icon.dart index 658b2ef..71ac7f7 100644 --- a/lib/Components/fetch_section_icon.dart +++ b/lib/Components/fetch_section_icon.dart @@ -13,7 +13,7 @@ IconData getSectionIcon(elementType) { return Icons.web; case SectionType.Menu: return Icons.apps_sharp; - case SectionType.Quizz: + case SectionType.Quiz: return Icons.question_answer; case SectionType.Article: return Icons.article_outlined; diff --git a/lib/Helpers/PDFHelper.dart b/lib/Helpers/PDFHelper.dart index 97bc95c..c96e06d 100644 --- a/lib/Helpers/PDFHelper.dart +++ b/lib/Helpers/PDFHelper.dart @@ -7,7 +7,7 @@ import 'dart:html' as html; class PDFHelper { static downloadPDF(ManagerAppContext managerAppContext, List sections) async { - var sectionsArticle = sections.where((section) => section.type == SectionType.Article || section.type == SectionType.Quizz); // TODO HERE Support more section types + var sectionsArticle = sections.where((section) => section.type == SectionType.Article || section.type == SectionType.Quiz); // TODO HERE Support more section types if(sectionsArticle.length > 0) { //final font = await rootBundle.load("fonts/OpenSans-Medium.ttf"); //Uint8List byteData = new File("fonts/OpenSans-Medium.ttf").readAsBytesSync(); diff --git a/lib/Screens/Configurations/Section/SubSection/Article/article_config.dart b/lib/Screens/Configurations/Section/SubSection/Article/article_config.dart index f94375b..28b5998 100644 --- a/lib/Screens/Configurations/Section/SubSection/Article/article_config.dart +++ b/lib/Screens/Configurations/Section/SubSection/Article/article_config.dart @@ -15,7 +15,7 @@ class ArticleConfig extends StatefulWidget { final String? color; final String? label; final ArticleDTO initialValue; - final ValueChanged onChanged; + final ValueChanged onChanged; const ArticleConfig({ Key? key, this.color, @@ -61,7 +61,7 @@ class _ArticleConfigState extends State { i++; }); - widget.onChanged(jsonEncode(articleDTO).toString()); + widget.onChanged(articleDTO); }, ); } @@ -83,14 +83,14 @@ class _ArticleConfigState extends State { modalLabel: "Contenu", color: kPrimaryColor, isHTML: true, - initialValue: articleDTO != null ? articleDTO.content! : [], + initialValue: articleDTO.content!, isTitle: false, onGetResult: (value) { setState(() { if (articleDTO.content! != value) { articleDTO.content = value; //save(true, articleDTO, appContext); - widget.onChanged(jsonEncode(articleDTO).toString()); + widget.onChanged(articleDTO); } }); }, @@ -103,7 +103,7 @@ class _ArticleConfigState extends State { setState(() { //print(value); articleDTO.isContentTop = value; - widget.onChanged(jsonEncode(articleDTO).toString()); + widget.onChanged(articleDTO); }); }, ), @@ -117,14 +117,14 @@ class _ArticleConfigState extends State { resourceTypes: [ResourceType.Audio], modalLabel: "Audio", color: kPrimaryColor, - initialValue: articleDTO != null ? articleDTO.audioIds! : [], + initialValue: articleDTO.audioIds!, isTitle: false, onGetResult: (value) { setState(() { if (articleDTO.audioIds != value) { articleDTO.audioIds = value; //save(true, articleDTO, appContext); - widget.onChanged(jsonEncode(articleDTO).toString()); + widget.onChanged(articleDTO); } }); }, @@ -137,7 +137,7 @@ class _ArticleConfigState extends State { setState(() { //print(value); articleDTO.isReadAudioAuto = value; - widget.onChanged(jsonEncode(articleDTO).toString()); + widget.onChanged(articleDTO); }); }, ), @@ -184,7 +184,7 @@ class _ArticleConfigState extends State { articleToSend.isContentTop = articleDTO.isContentTop; articleToSend.content = articleDTO.content; articleToSend.isReadAudioAuto = articleDTO.isReadAudioAuto; - widget.onChanged(jsonEncode(articleToSend).toString()); + widget.onChanged(articleToSend); }); }, true, // don't show titles @@ -213,7 +213,7 @@ class _ArticleConfigState extends State { setState(() { result.order = articleDTO.contents!.length; articleDTO.contents!.add(result); - widget.onChanged(jsonEncode(articleDTO).toString()); + widget.onChanged(articleDTO); }); } }, diff --git a/lib/Screens/Configurations/Section/SubSection/Map/category_list.dart b/lib/Screens/Configurations/Section/SubSection/Map/category_list.dart index 7cf8ce8..4e604eb 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/category_list.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/category_list.dart @@ -133,6 +133,9 @@ class _CategoryListState extends State { if (result != null) { setState(() { + if(result.id == null) { + result.id = categoriesMiddle.isEmpty ? 1 : categoriesMiddle.map((c) => c.id!).reduce((a, b) => a > b ? a : b) + 1; + } result.order = categoriesMiddle.length; categoriesMiddle.add(result); widget.onChanged(categoriesMiddle); diff --git a/lib/Screens/Configurations/Section/SubSection/Map/geopoint_image_list.dart b/lib/Screens/Configurations/Section/SubSection/Map/geopoint_image_list.dart index b88f131..e7bbf1b 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/geopoint_image_list.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/geopoint_image_list.dart @@ -99,12 +99,11 @@ class _GeoPointContentListState extends State { ); if (result != null) { setState(() { - print("TODO CHECK !!"); - ContentDTO newImage = new ContentDTO(resourceId: result.id, resource: ResourceDTO(url: result.url, label: result.label, type: result.type)); - //print("RESULT IMAGES = "); - //print(newImage); + ContentDTO newImage = new ContentDTO(resourceId: result.id, resource: result); + if(newImage.order == null) { + newImage.order = contentsGeo.isEmpty ? 1 : contentsGeo.map((cg) => cg.order!).reduce((a, b) => a > b ? a : b) + 1; + } contentsGeo.add(newImage); - //print(imagesGeo); widget.onChanged(contentsGeo); }); } diff --git a/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart b/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart index 3cb59df..4c2b2ea 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart @@ -4,6 +4,7 @@ import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:location_picker_flutter_map/location_picker_flutter_map.dart'; import 'package:manager_app/Components/geoloc_input_container.dart'; import 'package:manager_app/Components/multi_select_dropdown_language_container.dart'; +import 'package:manager_app/Models/managerContext.dart'; import 'package:manager_app/Screens/Configurations/Section/SubSection/Map/category_input_container.dart'; import 'package:manager_app/Components/dropDown_input_container.dart'; import 'package:manager_app/Components/fetch_section_icon.dart'; @@ -400,7 +401,7 @@ class _MapConfigState extends State { showNewOrUpdateGeoPoint( mapDTO, null, - (GeoPointDTO geoPoint) { + (GeoPointDTO geoPoint) async { setState(() { mapDTO.points!.add(geoPoint); mapDTO.points!.sort((a, b) => a.title!.firstWhere((t) => t.language == 'FR').value!.toLowerCase().compareTo(b.title!.firstWhere((t) => t.language == 'FR').value!.toLowerCase())); @@ -416,6 +417,9 @@ class _MapConfigState extends State { //widget.onChanged(jsonEncode(mapDTO).toString()); widget.onChanged(mapDTO); }); + + await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionMapApi!.sectionMapCreate(mapDTO.id!, geoPoint); + // TODO refresh points list }, appContext, context); diff --git a/lib/Screens/Configurations/Section/SubSection/Map/new_update_categorie.dart b/lib/Screens/Configurations/Section/SubSection/Map/new_update_categorie.dart index e723f89..1919f03 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/new_update_categorie.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/new_update_categorie.dart @@ -84,13 +84,15 @@ Future showNewOrUpdateCategory(CategorieDTO? inputCategorieDTO, A color: kPrimaryColor, onChanged: (ResourceDTO resource) { if(resource.id == null) { - categorieDTO.resourceDTO?.id = null; + categorieDTO.resourceDTO = null; + /*categorieDTO.resourceDTO?.id = null; categorieDTO.resourceDTO?.url = null; - categorieDTO.resourceDTO?.label = null; + categorieDTO.resourceDTO?.label = null;*/ } else { - categorieDTO.resourceDTO?.id = resource.id; + categorieDTO.resourceDTO = resource; + /*categorieDTO.resourceDTO?.id = resource.id; categorieDTO.resourceDTO?.url = resource.url; - categorieDTO.resourceDTO?.label = resource.label; + categorieDTO.resourceDTO?.label = resource.label;*/ print("Icône catégorie Icône catégorie"); print(categorieDTO); } diff --git a/lib/Screens/Configurations/Section/section_detail_screen.dart b/lib/Screens/Configurations/Section/section_detail_screen.dart index d512e13..a492c2c 100644 --- a/lib/Screens/Configurations/Section/section_detail_screen.dart +++ b/lib/Screens/Configurations/Section/section_detail_screen.dart @@ -49,6 +49,7 @@ class SectionDetailScreen extends StatefulWidget { class _SectionDetailScreenState extends State { late SectionDTO sectionDTO; + late Object sectionDetailDTO; @override Widget build(BuildContext context) { @@ -63,9 +64,11 @@ class _SectionDetailScreenState extends State { builder: (context, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.done) { rawSectionData = snapshot.data; - sectionDTO = SectionDTO.fromJson(rawSectionData)!; // TODO handle null value ! - if(sectionDTO != null) { + var nullableSection = SectionDTO.fromJson(rawSectionData); + + if(nullableSection != null) { + sectionDTO = nullableSection; return Stack( children: [ bodySection(rawSectionData, size, appContext, context, globalKey), @@ -73,7 +76,7 @@ class _SectionDetailScreenState extends State { alignment: AlignmentDirectional.bottomCenter, child: Container( height: 80, - child: getButtons(sectionDTO!, appContext), + child: getButtons(sectionDTO, appContext), ), ) ], @@ -122,19 +125,19 @@ class _SectionDetailScreenState extends State { Padding( padding: const EdgeInsets.all(8.0), child: Icon( - sectionDTO != null ? getSectionIcon(sectionDTO.type) : Icons.add, + getSectionIcon(sectionDTO.type), color: kPrimaryColor, size: 25, ), ), - Text(sectionDTO != null ? sectionDTO.label! : "", style: TextStyle(fontSize: 30, fontWeight: FontWeight.w400)), + Text(sectionDTO.label!, style: TextStyle(fontSize: 30, fontWeight: FontWeight.w400)), if((appContext.getContext() as ManagerAppContext).selectedConfiguration!.isMobile!) - DownloadPDF(sections: [sectionDTO!]), + DownloadPDF(sections: [sectionDTO]), ], ), Padding( padding: const EdgeInsets.all(5.0), - child: Text(sectionDTO != null ? DateFormat('dd/MM/yyyy').format(sectionDTO.dateCreation!) : "", style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200)), + child: Text(DateFormat('dd/MM/yyyy').format(sectionDTO.dateCreation!), style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200)), ), ], ), @@ -197,7 +200,7 @@ class _SectionDetailScreenState extends State { key: globalKey, child: QrImageView( padding: EdgeInsets.only(left: 5.0, top: 5.0, bottom: 5.0, right: 5.0), - data: "${managerAppContext.host!.replaceFirst("api", "web")}/${managerAppContext.instanceId}/${managerAppContext.selectedConfiguration!.id}/${sectionDTO!.id!}", + data: "${managerAppContext.host!.replaceFirst("api", "web")}/${managerAppContext.instanceId}/${managerAppContext.selectedConfiguration!.id}/${sectionDTO.id!}", version: QrVersions.auto, size: 50.0, ), @@ -214,7 +217,7 @@ class _SectionDetailScreenState extends State { onChanged: (value) { setState(() { sectionDTO.isBeacon = value; - save(false, sectionDTO, appContext); + save(false, appContext); }); }, ), @@ -242,9 +245,9 @@ class _SectionDetailScreenState extends State { height: 100, child: StringInputContainer( label: "Identifiant :", - initialValue: sectionDTO != null ? sectionDTO.label : "", + initialValue: sectionDTO.label, onChanged: (String value) { - sectionDTO!.label = value; + sectionDTO.label = value; }, ), ), @@ -252,11 +255,11 @@ class _SectionDetailScreenState extends State { label: "Titre affiché:", modalLabel: "Titre", color: kPrimaryColor, - initialValue: sectionDTO != null ? sectionDTO.title! : [], + initialValue: sectionDTO.title!, onGetResult: (value) { - if (sectionDTO!.title! != value) { + if (sectionDTO.title! != value) { sectionDTO.title = value; - save(true, sectionDTO, appContext); + save(true, appContext); } }, maxLines: 1, @@ -269,12 +272,12 @@ class _SectionDetailScreenState extends State { modalLabel: "Description", color: kPrimaryColor, isHTML: true, - initialValue: sectionDTO != null ? sectionDTO.description! : [], + initialValue: sectionDTO.description!, isMandatory: false, onGetResult: (value) { - if (sectionDTO!.description != value) { + if (sectionDTO.description != value) { sectionDTO.description = value!; - save(true, sectionDTO, appContext); + save(true, appContext); } }, maxLines: 2, @@ -288,14 +291,14 @@ class _SectionDetailScreenState extends State { children: [ ResourceInputContainer( label: "Image :", - initialValue: sectionDTO != null ? sectionDTO.imageId : null, + initialValue: sectionDTO.imageId, color: kPrimaryColor, onChanged: (ResourceDTO resource) { if(resource.id == null) { - sectionDTO!.imageId = null; + sectionDTO.imageId = null; sectionDTO.imageSource = null; } else { - sectionDTO!.imageId = resource.id; + sectionDTO.imageId = resource.id; sectionDTO.imageSource = resource.url; } }, @@ -315,7 +318,7 @@ class _SectionDetailScreenState extends State { height: size.height * 0.5, child: Padding( padding: const EdgeInsets.all(10.0), - child: sectionDTO != null ? getSpecificData(sectionDTO, rawSectionDTO, appContext) : null, + child: getSpecificData(rawSectionDTO, appContext), ), decoration: BoxDecoration( //color: Colors.lightGreen, @@ -343,7 +346,7 @@ class _SectionDetailScreenState extends State { textColor: Colors.white, fontSize: 15, press: () { - cancel(sectionDTO, appContext); + cancel(appContext); }, ), ), @@ -356,7 +359,7 @@ class _SectionDetailScreenState extends State { textColor: Colors.white, fontSize: 15, press: () { - delete(sectionDTO, appContext); + delete(appContext); }, ), ), @@ -369,7 +372,7 @@ class _SectionDetailScreenState extends State { textColor: Colors.white, fontSize: 15, press: () { - save(false, sectionDTO, appContext); + save(false, appContext); }, ), ), @@ -378,15 +381,18 @@ class _SectionDetailScreenState extends State { ); } - Future cancel(SectionDTO sectionDTO, AppContext appContext) async { + Future cancel(AppContext appContext) async { ManagerAppContext managerAppContext = appContext.getContext(); - Object? section = await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionGetDetail(sectionDTO.id!); - // TODO parse as SectionDTO - managerAppContext.selectedSection = section as SectionDTO; - appContext.setContext(managerAppContext); + Object? rawData = await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionGetDetail(sectionDTO.id!); + var nullableSection = SectionDTO.fromJson(rawData); + if(nullableSection != null) + { + managerAppContext.selectedSection = nullableSection!; + appContext.setContext(managerAppContext); + } } - Future delete(SectionDTO sectionDTO, AppContext appContext) async { + Future delete(AppContext appContext) async { showConfirmationDialog( "Êtes-vous sûr de vouloir supprimer cette section ?", () {}, @@ -400,8 +406,8 @@ class _SectionDetailScreenState extends State { ); } - Future save(bool isTraduction, SectionDTO sectionDTO, AppContext appContext) async { - SectionDTO? section = await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionUpdate(sectionDTO); + Future save(bool isTraduction, AppContext appContext) async { + SectionDTO? section = await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionUpdate(sectionDetailDTO); ManagerAppContext managerAppContext = appContext.getContext(); managerAppContext.selectedSection = section; appContext.setContext(managerAppContext); @@ -413,22 +419,20 @@ class _SectionDetailScreenState extends State { } } - getSpecificData(SectionDTO sectionDTO, Object? rawSectionData, AppContext appContext) { - // TODO handle null value ! - + getSpecificData(Object? rawSectionData, AppContext appContext) { switch(sectionDTO.type) { case SectionType.Map: MapDTO mapDTO = MapDTO.fromJson(rawSectionData)!; + sectionDetailDTO = mapDTO; return MapConfig( initialValue: mapDTO, - onChanged: (MapDTO mapDTO) { - // TODO DO something - //sectionDTO.data = data; - //save(false, sectionDTO, appContext); + onChanged: (MapDTO changedMap) { + sectionDetailDTO = changedMap; }, ); case SectionType.Slider: SliderDTO sliderDTO = SliderDTO.fromJson(rawSectionData)!; + sectionDetailDTO = sliderDTO; return SliderConfig( initialValue: sliderDTO, onChanged: (String data) { @@ -440,6 +444,7 @@ class _SectionDetailScreenState extends State { case SectionType.Video: case SectionType.Web: WebDTO webDTO = WebDTO.fromJson(rawSectionData)!; + sectionDetailDTO = webDTO; return WebOrVideoConfig( label: sectionDTO.type == SectionType.Video ? "Url de la vidéo:": "Url du site web:", initialValue: webDTO, @@ -450,14 +455,16 @@ class _SectionDetailScreenState extends State { ); case SectionType.Menu: MenuDTO menuDTO = MenuDTO.fromJson(rawSectionData)!; + sectionDetailDTO = menuDTO; return MenuConfig( initialValue: menuDTO, onChanged: (String data) { //sectionDTO.data = data; }, ); - case SectionType.Quizz: + case SectionType.Quiz: QuizDTO quizDTO = QuizDTO.fromJson(rawSectionData)!; + sectionDetailDTO = quizDTO; return QuizzConfig( initialValue: quizDTO, onChanged: (String data) { @@ -466,15 +473,17 @@ class _SectionDetailScreenState extends State { ); case SectionType.Article: ArticleDTO articleDTO = ArticleDTO.fromJson(rawSectionData)!; + sectionDetailDTO = articleDTO; return ArticleConfig( initialValue: articleDTO, - onChanged: (String data) { - /*sectionDTO.data = data; - save(false, sectionDTO, appContext);*/ + onChanged: (ArticleDTO changedArticle) + { + sectionDetailDTO = changedArticle; }, ); case SectionType.Pdf: PdfDTO pdfDTO = PdfDTO.fromJson(rawSectionData)!; + sectionDetailDTO = pdfDTO; return PDFConfig( initialValue: pdfDTO, onChanged: (String data) { @@ -484,6 +493,7 @@ class _SectionDetailScreenState extends State { ); case SectionType.Puzzle: PuzzleDTO puzzleDTO = PuzzleDTO.fromJson(rawSectionData)!; + sectionDetailDTO = puzzleDTO; return PuzzleConfig( initialValue: puzzleDTO, onChanged: (String data) { @@ -492,6 +502,7 @@ class _SectionDetailScreenState extends State { ); case SectionType.Agenda: AgendaDTO agendaDTO = AgendaDTO.fromJson(rawSectionData)!; + sectionDetailDTO = agendaDTO; return AgendaConfig( initialValue: agendaDTO, onChanged: (String data) { @@ -501,6 +512,7 @@ class _SectionDetailScreenState extends State { ); case SectionType.Weather: WeatherDTO weatherDTO = WeatherDTO.fromJson(rawSectionData)!; + sectionDetailDTO = weatherDTO; return WeatherConfig( initialValue: weatherDTO, onChanged: (String data) { diff --git a/lib/Screens/Configurations/configuration_detail_screen.dart b/lib/Screens/Configurations/configuration_detail_screen.dart index 710f229..4ec42dc 100644 --- a/lib/Screens/Configurations/configuration_detail_screen.dart +++ b/lib/Screens/Configurations/configuration_detail_screen.dart @@ -237,6 +237,7 @@ class _ConfigurationDetailScreenState extends State { isChecked: configurationDTO.isTablet, onChanged: (value) { configurationDTO.isTablet = value; + save(configurationDTO, appContext); }, ), CheckInputContainer( @@ -246,6 +247,7 @@ class _ConfigurationDetailScreenState extends State { isChecked: configurationDTO.isMobile, onChanged: (value) { configurationDTO.isMobile = value; + save(configurationDTO, appContext); }, ), if(configurationDTO.isMobile != null && configurationDTO.isMobile!) @@ -404,7 +406,7 @@ class _ConfigurationDetailScreenState extends State { { if(configurationDTO.isMobile!) { // Only see Article and Quizz type - sections = new List.from(snapshot.data).where((section) => !section.isSubSection! && (section.type == SectionType.Article || section.type == SectionType.Quizz)).toList(); + sections = new List.from(snapshot.data).where((section) => !section.isSubSection! && (section.type == SectionType.Article || section.type == SectionType.Quiz)).toList(); } else { sections = new List.from(snapshot.data).where((section) => !section.isSubSection!).toList(); } diff --git a/lib/client.dart b/lib/client.dart index 9d16ba4..9459cf8 100644 --- a/lib/client.dart +++ b/lib/client.dart @@ -23,6 +23,12 @@ class Client { DeviceApi? _deviceApi; DeviceApi? get deviceApi => _deviceApi; + SectionMapApi? _sectionMapApi; + SectionMapApi? get sectionMapApi => _sectionMapApi; + + SectionQuizApi? _sectionQuizApi; + SectionQuizApi? get sectionQuizApi => _sectionQuizApi; + Client(String path) { _apiClient = ApiClient( basePath: path); @@ -35,5 +41,7 @@ class Client { _sectionApi = SectionApi(_apiClient); _resourceApi = ResourceApi(_apiClient); _deviceApi = DeviceApi(_apiClient); + _sectionMapApi = SectionMapApi(_apiClient); + _sectionQuizApi = SectionQuizApi(_apiClient); } } \ No newline at end of file diff --git a/manager_api_new/lib/model/categorie_dto.dart b/manager_api_new/lib/model/categorie_dto.dart index cfd2f88..eda272d 100644 --- a/manager_api_new/lib/model/categorie_dto.dart +++ b/manager_api_new/lib/model/categorie_dto.dart @@ -32,7 +32,7 @@ class CategorieDTO { String? icon; - ContentDTOResource? resourceDTO; + ResourceDTO? resourceDTO; int? order; @@ -113,7 +113,7 @@ class CategorieDTO { id: mapValueOfType(json, r'id'), label: TranslationDTO.listFromJson(json[r'label']), icon: mapValueOfType(json, r'icon'), - resourceDTO: ContentDTOResource.fromJson(json[r'resourceDTO']), + resourceDTO: ResourceDTO.fromJson(json[r'resourceDTO']), order: mapValueOfType(json, r'order'), ); } diff --git a/manager_api_new/lib/model/section_type.dart b/manager_api_new/lib/model/section_type.dart index 2493c31..ad229bc 100644 --- a/manager_api_new/lib/model/section_type.dart +++ b/manager_api_new/lib/model/section_type.dart @@ -10,7 +10,7 @@ part of openapi.api; -/// 0 = Map 1 = Slider 2 = Video 3 = Web 4 = Menu 5 = Quizz 6 = Article 7 = PDF 8 = Puzzle 9 = Agenda +/// 0 = Map 1 = Slider 2 = Video 3 = Web 4 = Menu 5 = Quiz 6 = Article 7 = PDF 8 = Puzzle 9 = Agenda class SectionType { /// Instantiate a new enum with the provided [value]. const SectionType._(this.value); @@ -28,7 +28,7 @@ class SectionType { static const Video = SectionType._(2); static const Web = SectionType._(3); static const Menu = SectionType._(4); - static const Quizz = SectionType._(5); + static const Quiz = SectionType._(5); static const Article = SectionType._(6); static const Pdf = SectionType._(7); static const Puzzle = SectionType._(8); @@ -42,7 +42,7 @@ class SectionType { Video, Web, Menu, - Quizz, + Quiz, Article, Pdf, Puzzle, @@ -92,7 +92,7 @@ class SectionTypeTypeTransformer { case r'Video': return SectionType.Video; case r'Web': return SectionType.Web; case r'Menu': return SectionType.Menu; - case r'Quizz': return SectionType.Quizz; + case r'Quiz': return SectionType.Quiz; case r'Article': return SectionType.Article; case r'PDF': return SectionType.Pdf; case r'Puzzle': return SectionType.Puzzle; @@ -111,7 +111,7 @@ class SectionTypeTypeTransformer { case 2: return SectionType.Video; case 3: return SectionType.Web; case 4: return SectionType.Menu; - case 5: return SectionType.Quizz; + case 5: return SectionType.Quiz; case 6: return SectionType.Article; case 7: return SectionType.Pdf; case 8: return SectionType.Puzzle;