From 7263303b7e7e169a822ff991b10b415fe6c972c8 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Fri, 23 May 2025 15:17:01 +0200 Subject: [PATCH] Service worker update {{}} - menu working ! + clean code --- lib/Components/audio_player.dart | 1 - ...nslation_input_and_resource_container.dart | 3 - .../translation_input_container.dart | 4 - lib/Components/translation_tab.dart | 2 - .../upload_online_resources_container.dart | 1 - lib/Helpers/FileHelper.dart | 1 - .../SubSection/Article/article_config.dart | 2 - .../Map/category_input_container.dart | 10 - .../Section/SubSection/Map/category_list.dart | 4 - .../Section/SubSection/Map/map_config.dart | 33 --- .../SubSection/Map/new_update_categorie.dart | 8 - .../Map/showNewOrUpdateGeoPoint.dart | 7 +- .../Menu/listView_card_subSection.dart | 220 +++--------------- .../Section/SubSection/Menu/menu_config.dart | 34 ++- .../SubSection/PDF/new_update_pdfFile.dart | 2 - .../Section/SubSection/PDF/pdf_list.dart | 1 - .../SubSection/Puzzle/puzzle_config.dart | 5 - .../new_update_score_quizz - deprecated.dart | 4 - .../SubSection/Quizz/quizz_config.dart | 14 -- .../SubSection/Video/video_config.dart | 1 + .../SubSection/WebOrVideo/web_config.dart | 1 + lib/Screens/Resources/resources_screen.dart | 7 - lib/main.dart | 4 +- web/index.html | 2 +- 24 files changed, 68 insertions(+), 303 deletions(-) diff --git a/lib/Components/audio_player.dart b/lib/Components/audio_player.dart index 3eeb644..9cd129a 100644 --- a/lib/Components/audio_player.dart +++ b/lib/Components/audio_player.dart @@ -67,7 +67,6 @@ class _AudioPlayerFloatingContainerState extends State player.duration!.inMilliseconds) { - print("RESET ALL"); player.stop(); player.seek(const Duration(seconds: 0)); isplaying = false; diff --git a/lib/Components/translation_input_and_resource_container.dart b/lib/Components/translation_input_and_resource_container.dart index 14f4476..aa2ab16 100644 --- a/lib/Components/translation_input_and_resource_container.dart +++ b/lib/Components/translation_input_and_resource_container.dart @@ -23,12 +23,10 @@ class _TranslationInputAndResourceContainerState extends State(widget.newValues.first.language!); controllerQuill.onEditorLoaded(() { - print("onEditorLoaded"); isInit = true; }); Future.delayed(Duration(milliseconds: 500), () { - print("Future.delayed"); controllerQuill.clear(); controllerQuill.insertText(widget.newValues[_tabController!.index].value!); isInit = true; @@ -38,7 +36,6 @@ class _TranslationInputAndResourceContainerState extends State kTitleMaxLength) { - print("to much text au dessus"); controllerQuill.undo(); } } else { diff --git a/lib/Components/translation_input_container.dart b/lib/Components/translation_input_container.dart index 7066113..2ab65bc 100644 --- a/lib/Components/translation_input_container.dart +++ b/lib/Components/translation_input_container.dart @@ -24,12 +24,10 @@ class _TranslationInputContainerState extends State w currentLanguage = ValueNotifier(widget.newValues.first.language!); controllerQuill.onEditorLoaded(() { - print("onEditorLoaded"); isInit = true; }); Future.delayed(Duration(milliseconds: 500), () { - print("Future.delayed"); controllerQuill.clear(); controllerQuill.insertText(widget.newValues[_tabController!.index].value!); isInit = true; @@ -39,12 +37,10 @@ class _TranslationInputContainerState extends State w var plainText = await controllerQuill.getPlainText(); if(widget.isTitle) { if(plainText.length > kTitleMaxLength) { - print("to much text au dessus"); controllerQuill.undo(); } } else { if(plainText.length > kDescriptionMaxLength) { - print("to much text description au dessus"); controllerQuill.undo(); } } diff --git a/lib/Components/translation_tab.dart b/lib/Components/translation_tab.dart index 21ccc31..b8a37d5 100644 --- a/lib/Components/translation_tab.dart +++ b/lib/Components/translation_tab.dart @@ -64,8 +64,6 @@ getContent(List translations, int maxLines) { maxLines: maxLines, initialValue: translation.value, onChanged: (String value) { - //print("onChanged value in tranbslationTAB"); - //print(value); translation.value = value; }, cursorColor: kPrimaryColor, diff --git a/lib/Components/upload_online_resources_container.dart b/lib/Components/upload_online_resources_container.dart index bc0d67a..8b9ed42 100644 --- a/lib/Components/upload_online_resources_container.dart +++ b/lib/Components/upload_online_resources_container.dart @@ -27,7 +27,6 @@ class _UploadOnlineResourceContainerState extends State { isChecked: articleDTO.isContentTop, onChanged: (value) { setState(() { - //print(value); articleDTO.isContentTop = value; widget.onChanged(articleDTO); }); @@ -135,7 +134,6 @@ class _ArticleConfigState extends State { isChecked: articleDTO.isReadAudioAuto, onChanged: (value) { setState(() { - //print(value); articleDTO.isReadAudioAuto = value; widget.onChanged(articleDTO); }); diff --git a/lib/Screens/Configurations/Section/SubSection/Map/category_input_container.dart b/lib/Screens/Configurations/Section/SubSection/Map/category_input_container.dart index e92ce83..e5fb2c6 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/category_input_container.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/category_input_container.dart @@ -28,7 +28,6 @@ class _CategoryInputContainerState extends State { @override void initState() { middleCategories = widget.initialValue; - print("initStateinitStateinitState"); super.initState(); } @@ -50,13 +49,7 @@ class _CategoryInputContainerState extends State { child: InkWell( onTap: () { List newValues = []; - - print("HERE COMES THE FUCKKKERS"); - print(middleCategories); - showCreateOrUpdateCategories("Catégories", middleCategories, newValues, (value) { - print("RESULT HERERERER"); - print(value); setState(() { widget.onChanged(value); middleCategories = value; @@ -107,7 +100,6 @@ showCreateOrUpdateCategories(String modalLabel, List initials, Lis height: size.height * 0.7, width: size.width * 0.65, child: CategoryList(categories: initials, onChanged: (result) { - print("ON CHANGZED HERE"); newValues = result; //onGetResult(result); }), @@ -126,8 +118,6 @@ showCreateOrUpdateCategories(String modalLabel, List initials, Lis color: kSecond, press: () { onGetResult(initials); - print("INITALASSS"); - print(initials); Navigator.of(context).pop(); }, fontSize: 20, diff --git a/lib/Screens/Configurations/Section/SubSection/Map/category_list.dart b/lib/Screens/Configurations/Section/SubSection/Map/category_list.dart index 4e604eb..3079986 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/category_list.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/category_list.dart @@ -26,15 +26,12 @@ class _CategoryListState extends State { @override void initState() { - print("INISTASTETETTETET CATEGORY LIIST"); super.initState(); categoriesMiddle = new List.from(widget.categories); categoriesMiddle.sort((a, b) => a.order!.compareTo(b.order!)); currentIndex = getNextAvailableIndex(categoriesMiddle); assignIdsToNull(categoriesMiddle); - print(currentIndex); - print(categoriesMiddle); } int getNextAvailableIndex(List categoriesMiddle) { @@ -210,7 +207,6 @@ class _CategoryListState extends State { if (result != null) { setState(() { - print("RESUUULT MODIFYY "); category = result; categoriesMiddle[category.order!] = category; widget.onChanged(categoriesMiddle); diff --git a/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart b/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart index a37134c..ab3e8fb 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart @@ -106,13 +106,6 @@ class _MapConfigState extends State { break; } } - - /*print("MAPDTO"); - print(mapDTO); - print(mapDTO.mapType.toString()); - if (mapDTO.mapType == null) { - mapDTO.mapType = MapTypeApp.hybrid; - }*/ } @override @@ -245,8 +238,6 @@ class _MapConfigState extends State { color: kPrimaryColor, onChanged: (List? value) { if(value != null) { - //print("COUCOU CategoryInputContainerCategoryInputContainerCategoryInputContainer"); - //print(value); mapDTO.categories = value; //update point's category @@ -255,34 +246,10 @@ class _MapConfigState extends State { // Check if category still exist - Delete if(p.categorieId != null && !mapDTO.categories!.map((c) => c.id).any((e) => e != null && e == p.categorieId)) { - print("DELETE CAT REF"); - print(p.categorieId); - //print(p.categorie); - // delete cat ref from point p.categorieId = null; - //p.categorie = null; } - // update point category - Update - if(p.categorieId != null && mapDTO.categories!.map((c) => c.id).any((e) => e != null && e == p.categorieId)) - { - var categorie = mapDTO.categories!.firstWhere((c) => c.id == p.categorieId); - //p.categorie = categorie; - print("UPDATE CAT REF"); - } - - print(p); - /*if(p.categorieId == null && p.categorie != null && p.categorie!.label != null) - { - // need to update with label - var categorie = mapDTO.categories!.firstWhere((c) => c.label![0].value == p.categorie!.label![0].value); - //p.categorie = categorie; - p.categorieId = categorie.id; - }*/ }); } - /*print("mapDTO.points"); - print(mapDTO.points);*/ - //widget.onChanged(jsonEncode(mapDTO).toString()); widget.onChanged(mapDTO); } }, 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 1919f03..64b6972 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/new_update_categorie.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/new_update_categorie.dart @@ -85,16 +85,8 @@ Future showNewOrUpdateCategory(CategorieDTO? inputCategorieDTO, A onChanged: (ResourceDTO resource) { if(resource.id == null) { categorieDTO.resourceDTO = null; - /*categorieDTO.resourceDTO?.id = null; - categorieDTO.resourceDTO?.url = null; - categorieDTO.resourceDTO?.label = null;*/ } else { categorieDTO.resourceDTO = resource; - /*categorieDTO.resourceDTO?.id = resource.id; - categorieDTO.resourceDTO?.url = resource.url; - categorieDTO.resourceDTO?.label = resource.label;*/ - print("Icône catégorie Icône catégorie"); - print(categorieDTO); } }, isSmall: true diff --git a/lib/Screens/Configurations/Section/SubSection/Map/showNewOrUpdateGeoPoint.dart b/lib/Screens/Configurations/Section/SubSection/Map/showNewOrUpdateGeoPoint.dart index 841cf30..b05673f 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/showNewOrUpdateGeoPoint.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/showNewOrUpdateGeoPoint.dart @@ -78,18 +78,15 @@ void showNewOrUpdateGeoPoint(MapDTO mapDTO, GeoPointDTO? inputGeoPointDTO, Funct onError: (e) => print(e), selectLocationButtonLeadingIcon: const Icon(Icons.check, color: kPrimaryColor), onPicked: (pickedData) { - print("onPicked"); geoPointDTO.latitude = pickedData.latLong.latitude.toString(); geoPointDTO.longitude = pickedData.latLong.longitude.toString(); - print(geoPointDTO.latitude); - print(geoPointDTO.longitude); }, onChanged: (pickedData) { - print("onChanged"); + /*print("onChanged"); print(pickedData.latLong.latitude); print(pickedData.latLong.longitude); print(pickedData.address); - print(pickedData.addressData); + print(pickedData.addressData);*/ }, showContributorBadgeForOSM: false, ), diff --git a/lib/Screens/Configurations/Section/SubSection/Menu/listView_card_subSection.dart b/lib/Screens/Configurations/Section/SubSection/Menu/listView_card_subSection.dart index 6aa2d92..0d5f1a2 100644 --- a/lib/Screens/Configurations/Section/SubSection/Menu/listView_card_subSection.dart +++ b/lib/Screens/Configurations/Section/SubSection/Menu/listView_card_subSection.dart @@ -188,213 +188,61 @@ class _ListViewCardSubSection extends State { ); } - updateSectionDetail(SectionDTO sectionDTO, Object sectionDetailDTO) { - switch(sectionDTO.type) - { + dynamic updateSectionDetail(SectionDTO sectionDTO, Object sectionDetailDTO) { + dynamic castedDetail; + + switch (sectionDTO.type) { case SectionType.Map: - (sectionDetailDTO as MapDTO).id = sectionDTO.id; - (sectionDetailDTO as MapDTO).order = sectionDTO.order; - (sectionDetailDTO as MapDTO).dateCreation = sectionDTO.dateCreation; - (sectionDetailDTO as MapDTO).type = sectionDTO.type; - (sectionDetailDTO as MapDTO).instanceId = sectionDTO.instanceId; - (sectionDetailDTO as MapDTO).configurationId = sectionDTO.configurationId; - (sectionDetailDTO as MapDTO).isSubSection = sectionDTO.isSubSection; - (sectionDetailDTO as MapDTO).parentId = sectionDTO.parentId; - (sectionDetailDTO as MapDTO).label = sectionDTO.label; - (sectionDetailDTO as MapDTO).title = sectionDTO.title; - (sectionDetailDTO as MapDTO).description = sectionDTO.description; - (sectionDetailDTO as MapDTO).imageId = sectionDTO.imageId; - (sectionDetailDTO as MapDTO).imageSource = sectionDTO.imageSource; - (sectionDetailDTO as MapDTO).isBeacon = sectionDTO.isBeacon; - (sectionDetailDTO as MapDTO).beaconId = sectionDTO.beaconId; - (sectionDetailDTO as MapDTO).latitude = sectionDTO.latitude; - (sectionDetailDTO as MapDTO).longitude = sectionDTO.longitude; - (sectionDetailDTO as MapDTO).meterZoneGPS = sectionDTO.meterZoneGPS; + castedDetail = sectionDetailDTO is MapDTO ? sectionDetailDTO : MapDTO.fromJson(sectionDetailDTO)!; break; case SectionType.Slider: - (sectionDetailDTO as SliderDTO).id = sectionDTO.id; - (sectionDetailDTO as SliderDTO).order = sectionDTO.order; - (sectionDetailDTO as SliderDTO).dateCreation = sectionDTO.dateCreation; - (sectionDetailDTO as SliderDTO).type = sectionDTO.type; - (sectionDetailDTO as SliderDTO).instanceId = sectionDTO.instanceId; - (sectionDetailDTO as SliderDTO).configurationId = sectionDTO.configurationId; - (sectionDetailDTO as SliderDTO).isSubSection = sectionDTO.isSubSection; - (sectionDetailDTO as SliderDTO).parentId = sectionDTO.parentId; - (sectionDetailDTO as SliderDTO).label = sectionDTO.label; - (sectionDetailDTO as SliderDTO).title = sectionDTO.title; - (sectionDetailDTO as SliderDTO).description = sectionDTO.description; - (sectionDetailDTO as SliderDTO).imageId = sectionDTO.imageId; - (sectionDetailDTO as SliderDTO).imageSource = sectionDTO.imageSource; - (sectionDetailDTO as SliderDTO).isBeacon = sectionDTO.isBeacon; - (sectionDetailDTO as SliderDTO).beaconId = sectionDTO.beaconId; - (sectionDetailDTO as SliderDTO).latitude = sectionDTO.latitude; - (sectionDetailDTO as SliderDTO).longitude = sectionDTO.longitude; - (sectionDetailDTO as SliderDTO).meterZoneGPS = sectionDTO.meterZoneGPS; + castedDetail = sectionDetailDTO is SliderDTO ? sectionDetailDTO : SliderDTO.fromJson(sectionDetailDTO)!; break; case SectionType.Video: - (sectionDetailDTO as VideoDTO).id = sectionDTO.id; - (sectionDetailDTO as VideoDTO).order = sectionDTO.order; - (sectionDetailDTO as VideoDTO).dateCreation = sectionDTO.dateCreation; - (sectionDetailDTO as VideoDTO).type = sectionDTO.type; - (sectionDetailDTO as VideoDTO).instanceId = sectionDTO.instanceId; - (sectionDetailDTO as VideoDTO).configurationId = sectionDTO.configurationId; - (sectionDetailDTO as VideoDTO).isSubSection = sectionDTO.isSubSection; - (sectionDetailDTO as VideoDTO).parentId = sectionDTO.parentId; - (sectionDetailDTO as VideoDTO).label = sectionDTO.label; - (sectionDetailDTO as VideoDTO).title = sectionDTO.title; - (sectionDetailDTO as VideoDTO).description = sectionDTO.description; - (sectionDetailDTO as VideoDTO).imageId = sectionDTO.imageId; - (sectionDetailDTO as VideoDTO).imageSource = sectionDTO.imageSource; - (sectionDetailDTO as VideoDTO).isBeacon = sectionDTO.isBeacon; - (sectionDetailDTO as VideoDTO).beaconId = sectionDTO.beaconId; - (sectionDetailDTO as VideoDTO).latitude = sectionDTO.latitude; - (sectionDetailDTO as VideoDTO).longitude = sectionDTO.longitude; - (sectionDetailDTO as VideoDTO).meterZoneGPS = sectionDTO.meterZoneGPS; + castedDetail = sectionDetailDTO is VideoDTO ? sectionDetailDTO : VideoDTO.fromJson(sectionDetailDTO)!; break; case SectionType.Web: - (sectionDetailDTO as WebDTO).id = sectionDTO.id; - (sectionDetailDTO as WebDTO).order = sectionDTO.order; - (sectionDetailDTO as WebDTO).dateCreation = sectionDTO.dateCreation; - (sectionDetailDTO as WebDTO).type = sectionDTO.type; - (sectionDetailDTO as WebDTO).instanceId = sectionDTO.instanceId; - (sectionDetailDTO as WebDTO).configurationId = sectionDTO.configurationId; - (sectionDetailDTO as WebDTO).isSubSection = sectionDTO.isSubSection; - (sectionDetailDTO as WebDTO).parentId = sectionDTO.parentId; - (sectionDetailDTO as WebDTO).label = sectionDTO.label; - (sectionDetailDTO as WebDTO).title = sectionDTO.title; - (sectionDetailDTO as WebDTO).description = sectionDTO.description; - (sectionDetailDTO as WebDTO).imageId = sectionDTO.imageId; - (sectionDetailDTO as WebDTO).imageSource = sectionDTO.imageSource; - (sectionDetailDTO as WebDTO).isBeacon = sectionDTO.isBeacon; - (sectionDetailDTO as WebDTO).beaconId = sectionDTO.beaconId; - (sectionDetailDTO as WebDTO).latitude = sectionDTO.latitude; - (sectionDetailDTO as WebDTO).longitude = sectionDTO.longitude; - (sectionDetailDTO as WebDTO).meterZoneGPS = sectionDTO.meterZoneGPS; - break; - case SectionType.Menu: - (sectionDetailDTO as MenuDTO).id = sectionDTO.id; - (sectionDetailDTO as MenuDTO).order = sectionDTO.order; - (sectionDetailDTO as MenuDTO).dateCreation = sectionDTO.dateCreation; - (sectionDetailDTO as MenuDTO).type = sectionDTO.type; - (sectionDetailDTO as MenuDTO).instanceId = sectionDTO.instanceId; - (sectionDetailDTO as MenuDTO).configurationId = sectionDTO.configurationId; - (sectionDetailDTO as MenuDTO).isSubSection = sectionDTO.isSubSection; - (sectionDetailDTO as MenuDTO).parentId = sectionDTO.parentId; - (sectionDetailDTO as MenuDTO).label = sectionDTO.label; - (sectionDetailDTO as MenuDTO).title = sectionDTO.title; - (sectionDetailDTO as MenuDTO).description = sectionDTO.description; - (sectionDetailDTO as MenuDTO).imageId = sectionDTO.imageId; - (sectionDetailDTO as MenuDTO).imageSource = sectionDTO.imageSource; - (sectionDetailDTO as MenuDTO).isBeacon = sectionDTO.isBeacon; - (sectionDetailDTO as MenuDTO).beaconId = sectionDTO.beaconId; - (sectionDetailDTO as MenuDTO).latitude = sectionDTO.latitude; - (sectionDetailDTO as MenuDTO).longitude = sectionDTO.longitude; - (sectionDetailDTO as MenuDTO).meterZoneGPS = sectionDTO.meterZoneGPS; + castedDetail = sectionDetailDTO is WebDTO ? sectionDetailDTO : WebDTO.fromJson(sectionDetailDTO)!; break; case SectionType.Quiz: - (sectionDetailDTO as QuizDTO).id = sectionDTO.id; - (sectionDetailDTO as QuizDTO).order = sectionDTO.order; - (sectionDetailDTO as QuizDTO).dateCreation = sectionDTO.dateCreation; - (sectionDetailDTO as QuizDTO).type = sectionDTO.type; - (sectionDetailDTO as QuizDTO).instanceId = sectionDTO.instanceId; - (sectionDetailDTO as QuizDTO).configurationId = sectionDTO.configurationId; - (sectionDetailDTO as QuizDTO).isSubSection = sectionDTO.isSubSection; - (sectionDetailDTO as QuizDTO).parentId = sectionDTO.parentId; - (sectionDetailDTO as QuizDTO).label = sectionDTO.label; - (sectionDetailDTO as QuizDTO).title = sectionDTO.title; - (sectionDetailDTO as QuizDTO).description = sectionDTO.description; - (sectionDetailDTO as QuizDTO).imageId = sectionDTO.imageId; - (sectionDetailDTO as QuizDTO).imageSource = sectionDTO.imageSource; - (sectionDetailDTO as QuizDTO).isBeacon = sectionDTO.isBeacon; - (sectionDetailDTO as QuizDTO).beaconId = sectionDTO.beaconId; - (sectionDetailDTO as QuizDTO).latitude = sectionDTO.latitude; - (sectionDetailDTO as QuizDTO).longitude = sectionDTO.longitude; - (sectionDetailDTO as QuizDTO).meterZoneGPS = sectionDTO.meterZoneGPS; + castedDetail = sectionDetailDTO is QuizDTO ? sectionDetailDTO : QuizDTO.fromJson(sectionDetailDTO)!; break; case SectionType.Pdf: - (sectionDetailDTO as PdfDTO).id = sectionDTO.id; - (sectionDetailDTO as PdfDTO).order = sectionDTO.order; - (sectionDetailDTO as PdfDTO).dateCreation = sectionDTO.dateCreation; - (sectionDetailDTO as PdfDTO).type = sectionDTO.type; - (sectionDetailDTO as PdfDTO).instanceId = sectionDTO.instanceId; - (sectionDetailDTO as PdfDTO).configurationId = sectionDTO.configurationId; - (sectionDetailDTO as PdfDTO).isSubSection = sectionDTO.isSubSection; - (sectionDetailDTO as PdfDTO).parentId = sectionDTO.parentId; - (sectionDetailDTO as PdfDTO).label = sectionDTO.label; - (sectionDetailDTO as PdfDTO).title = sectionDTO.title; - (sectionDetailDTO as PdfDTO).description = sectionDTO.description; - (sectionDetailDTO as PdfDTO).imageId = sectionDTO.imageId; - (sectionDetailDTO as PdfDTO).imageSource = sectionDTO.imageSource; - (sectionDetailDTO as PdfDTO).isBeacon = sectionDTO.isBeacon; - (sectionDetailDTO as PdfDTO).beaconId = sectionDTO.beaconId; - (sectionDetailDTO as PdfDTO).latitude = sectionDTO.latitude; - (sectionDetailDTO as PdfDTO).longitude = sectionDTO.longitude; - (sectionDetailDTO as PdfDTO).meterZoneGPS = sectionDTO.meterZoneGPS; + castedDetail = sectionDetailDTO is PdfDTO ? sectionDetailDTO : PdfDTO.fromJson(sectionDetailDTO)!; break; case SectionType.Puzzle: - (sectionDetailDTO as PuzzleDTO).id = sectionDTO.id; - (sectionDetailDTO as PuzzleDTO).order = sectionDTO.order; - (sectionDetailDTO as PuzzleDTO).dateCreation = sectionDTO.dateCreation; - (sectionDetailDTO as PuzzleDTO).type = sectionDTO.type; - (sectionDetailDTO as PuzzleDTO).instanceId = sectionDTO.instanceId; - (sectionDetailDTO as PuzzleDTO).configurationId = sectionDTO.configurationId; - (sectionDetailDTO as PuzzleDTO).isSubSection = sectionDTO.isSubSection; - (sectionDetailDTO as PuzzleDTO).parentId = sectionDTO.parentId; - (sectionDetailDTO as PuzzleDTO).label = sectionDTO.label; - (sectionDetailDTO as PuzzleDTO).title = sectionDTO.title; - (sectionDetailDTO as PuzzleDTO).description = sectionDTO.description; - (sectionDetailDTO as PuzzleDTO).imageId = sectionDTO.imageId; - (sectionDetailDTO as PuzzleDTO).imageSource = sectionDTO.imageSource; - (sectionDetailDTO as PuzzleDTO).isBeacon = sectionDTO.isBeacon; - (sectionDetailDTO as PuzzleDTO).beaconId = sectionDTO.beaconId; - (sectionDetailDTO as PuzzleDTO).latitude = sectionDTO.latitude; - (sectionDetailDTO as PuzzleDTO).longitude = sectionDTO.longitude; - (sectionDetailDTO as PuzzleDTO).meterZoneGPS = sectionDTO.meterZoneGPS; + castedDetail = sectionDetailDTO is PuzzleDTO ? sectionDetailDTO : PuzzleDTO.fromJson(sectionDetailDTO)!; break; case SectionType.Agenda: - (sectionDetailDTO as AgendaDTO).id = sectionDTO.id; - (sectionDetailDTO as AgendaDTO).order = sectionDTO.order; - (sectionDetailDTO as AgendaDTO).dateCreation = sectionDTO.dateCreation; - (sectionDetailDTO as AgendaDTO).type = sectionDTO.type; - (sectionDetailDTO as AgendaDTO).instanceId = sectionDTO.instanceId; - (sectionDetailDTO as AgendaDTO).configurationId = sectionDTO.configurationId; - (sectionDetailDTO as AgendaDTO).isSubSection = sectionDTO.isSubSection; - (sectionDetailDTO as AgendaDTO).parentId = sectionDTO.parentId; - (sectionDetailDTO as AgendaDTO).label = sectionDTO.label; - (sectionDetailDTO as AgendaDTO).title = sectionDTO.title; - (sectionDetailDTO as AgendaDTO).description = sectionDTO.description; - (sectionDetailDTO as AgendaDTO).imageId = sectionDTO.imageId; - (sectionDetailDTO as AgendaDTO).imageSource = sectionDTO.imageSource; - (sectionDetailDTO as AgendaDTO).isBeacon = sectionDTO.isBeacon; - (sectionDetailDTO as AgendaDTO).beaconId = sectionDTO.beaconId; - (sectionDetailDTO as AgendaDTO).latitude = sectionDTO.latitude; - (sectionDetailDTO as AgendaDTO).longitude = sectionDTO.longitude; - (sectionDetailDTO as AgendaDTO).meterZoneGPS = sectionDTO.meterZoneGPS; + castedDetail = sectionDetailDTO is AgendaDTO ? sectionDetailDTO : AgendaDTO.fromJson(sectionDetailDTO)!; break; case SectionType.Weather: - (sectionDetailDTO as WeatherDTO).id = sectionDTO.id; - (sectionDetailDTO as WeatherDTO).order = sectionDTO.order; - (sectionDetailDTO as WeatherDTO).dateCreation = sectionDTO.dateCreation; - (sectionDetailDTO as WeatherDTO).type = sectionDTO.type; - (sectionDetailDTO as WeatherDTO).instanceId = sectionDTO.instanceId; - (sectionDetailDTO as WeatherDTO).configurationId = sectionDTO.configurationId; - (sectionDetailDTO as WeatherDTO).isSubSection = sectionDTO.isSubSection; - (sectionDetailDTO as WeatherDTO).parentId = sectionDTO.parentId; - (sectionDetailDTO as WeatherDTO).label = sectionDTO.label; - (sectionDetailDTO as WeatherDTO).title = sectionDTO.title; - (sectionDetailDTO as WeatherDTO).description = sectionDTO.description; - (sectionDetailDTO as WeatherDTO).imageId = sectionDTO.imageId; - (sectionDetailDTO as WeatherDTO).imageSource = sectionDTO.imageSource; - (sectionDetailDTO as WeatherDTO).isBeacon = sectionDTO.isBeacon; - (sectionDetailDTO as WeatherDTO).beaconId = sectionDTO.beaconId; - (sectionDetailDTO as WeatherDTO).latitude = sectionDTO.latitude; - (sectionDetailDTO as WeatherDTO).longitude = sectionDTO.longitude; - (sectionDetailDTO as WeatherDTO).meterZoneGPS = sectionDTO.meterZoneGPS; + castedDetail = sectionDetailDTO is WeatherDTO ? sectionDetailDTO : WeatherDTO.fromJson(sectionDetailDTO)!; break; } - return sectionDetailDTO; + // Mise à jour générique des champs communs + castedDetail.id = sectionDTO.id; + castedDetail.order = sectionDTO.order; + castedDetail.dateCreation = sectionDTO.dateCreation; + castedDetail.type = sectionDTO.type; + castedDetail.instanceId = sectionDTO.instanceId; + castedDetail.configurationId = sectionDTO.configurationId; + castedDetail.isSubSection = sectionDTO.isSubSection; + castedDetail.parentId = sectionDTO.parentId; + castedDetail.label = sectionDTO.label; + castedDetail.title = sectionDTO.title; + castedDetail.description = sectionDTO.description; + castedDetail.imageId = sectionDTO.imageId; + castedDetail.imageSource = sectionDTO.imageSource; + castedDetail.isBeacon = sectionDTO.isBeacon; + castedDetail.beaconId = sectionDTO.beaconId; + castedDetail.latitude = sectionDTO.latitude; + castedDetail.longitude = sectionDTO.longitude; + castedDetail.meterZoneGPS = sectionDTO.meterZoneGPS; + return castedDetail; } + } boxDecoration(SectionDTO sectionDTO, appContext) { diff --git a/lib/Screens/Configurations/Section/SubSection/Menu/menu_config.dart b/lib/Screens/Configurations/Section/SubSection/Menu/menu_config.dart index 34575a9..af85a0e 100644 --- a/lib/Screens/Configurations/Section/SubSection/Menu/menu_config.dart +++ b/lib/Screens/Configurations/Section/SubSection/Menu/menu_config.dart @@ -36,6 +36,7 @@ class MenuConfig extends StatefulWidget { class _MenuConfigState extends State { late MenuDTO menuDTO; + late List rawSubsections; @override void initState() { @@ -56,11 +57,28 @@ class _MenuConfigState extends State { Widget bodyGrid(Size size, AppContext appContext) { - void _onReorder(int oldIndex, int newIndex) { + void _onReorder(int oldIndex, int newIndex) async { - // TODO Edit order (copy quiz question order lofic) + // TODO Edit order (copy quiz question order logic) + if (newIndex > oldIndex) { + newIndex -= 1; + } + try { + final SectionDTO item = menuDTO.sections![oldIndex]; + //quizzDTO.questions!.insert(newIndex, item); - setState( + item.order = newIndex; + await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionUpdate(item); + showNotification(kSuccess, kWhite, "L'ordre des sous sections a été mis à jour avec succès", context, null); + setState(() { + // refresh ui + print("Refresh UI"); + }); + } catch(e) { + showNotification(kError, kWhite, "Une erreur est survenue lors de la mise à jour de l'ordre des sous sections", context, null); + } + + /*setState( () { if (newIndex > oldIndex) { newIndex -= 1; @@ -76,7 +94,9 @@ class _MenuConfigState extends State { widget.onChanged(jsonEncode(menuDTO).toString()); }, - ); + );*/ + + } return SingleChildScrollView( child: Stack( @@ -94,9 +114,9 @@ class _MenuConfigState extends State { } else { if (snapshot.connectionState == ConnectionState.done) { var rawList = snapshot.data; - var rawSectionDTOList = jsonDecode(jsonEncode(snapshot.data)); - rawSectionDTOList = rawSectionDTOList.map((json) => SectionDTO.fromJson(json)).toList(); - List sectionList = rawSectionDTOList.whereType().toList(); + rawSubsections = jsonDecode(jsonEncode(snapshot.data)); + rawSubsections = rawSubsections.map((json) => SectionDTO.fromJson(json)).toList(); + List sectionList = rawSubsections.whereType().toList(); menuDTO.sections = sectionList; menuDTO.sections!.sort((a, b) => a.order!.compareTo(b.order!)); diff --git a/lib/Screens/Configurations/Section/SubSection/PDF/new_update_pdfFile.dart b/lib/Screens/Configurations/Section/SubSection/PDF/new_update_pdfFile.dart index 7b795a0..3da71b0 100644 --- a/lib/Screens/Configurations/Section/SubSection/PDF/new_update_pdfFile.dart +++ b/lib/Screens/Configurations/Section/SubSection/PDF/new_update_pdfFile.dart @@ -70,8 +70,6 @@ Future showNewOrUpdatePDFFile(OrderedTranslat resourceTypes: [ResourceType.Pdf], onGetResult: (value) { if (pdfFileDTO.translationAndResourceDTOs != value) { - print("get resut hereeee"); - print(value); pdfFileDTO.translationAndResourceDTOs = value; } }, diff --git a/lib/Screens/Configurations/Section/SubSection/PDF/pdf_list.dart b/lib/Screens/Configurations/Section/SubSection/PDF/pdf_list.dart index 4b578d4..1b44ca5 100644 --- a/lib/Screens/Configurations/Section/SubSection/PDF/pdf_list.dart +++ b/lib/Screens/Configurations/Section/SubSection/PDF/pdf_list.dart @@ -167,7 +167,6 @@ class _PDFListState extends State { if (result != null) { setState(() { - print("RESUUULT MODIFYY "); pdfFileDTO = result; pdfsMiddle[pdfFileDTO.order!] = pdfFileDTO; widget.onChanged(pdfsMiddle); diff --git a/lib/Screens/Configurations/Section/SubSection/Puzzle/puzzle_config.dart b/lib/Screens/Configurations/Section/SubSection/Puzzle/puzzle_config.dart index a69bed3..504dc2d 100644 --- a/lib/Screens/Configurations/Section/SubSection/Puzzle/puzzle_config.dart +++ b/lib/Screens/Configurations/Section/SubSection/Puzzle/puzzle_config.dart @@ -77,11 +77,8 @@ class _PuzzleConfigState extends State { initialValue: puzzleDTO.messageDebut != null ? puzzleDTO.messageDebut! : [], resourceTypes: [ResourceType.Image, ResourceType.ImageUrl], onGetResult: (value) { - print("Mess depart test"); - print(value); if (puzzleDTO.messageDebut != value) { setState(() { - print(puzzleDTO.messageDebut); puzzleDTO.messageDebut = value; widget.onChanged(puzzleDTO); }); @@ -131,7 +128,6 @@ class _PuzzleConfigState extends State { widget.onChanged(puzzleDTO); }); } catch (e) { - print('Puzzle rows not a number'); showNotification(Colors.orange, kWhite, 'Cela doit être un chiffre', context, null); } }, @@ -151,7 +147,6 @@ class _PuzzleConfigState extends State { widget.onChanged(puzzleDTO); }); } catch (e) { - print('Puzzle rows not a number'); showNotification(Colors.orange, kWhite, 'Cela doit être un chiffre', context, null); } }, diff --git a/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_score_quizz - deprecated.dart b/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_score_quizz - deprecated.dart index 34b407b..e2e542a 100644 --- a/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_score_quizz - deprecated.dart +++ b/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_score_quizz - deprecated.dart @@ -42,12 +42,8 @@ Future?> showNewOrUpdateScoreQuizz(List { } catch(e) { showNotification(kError, kWhite, "Une erreur est survenue lors de la mise à jour de l'ordre des questions", context, null); } - - /*var i = 0; - quizzDTO.questions!.forEach((question) { - question.order = i; - i++; - });*/ - - /*setState( - () async { - - - widget.onChanged(quizzDTO); - }, - );*/ } return diff --git a/lib/Screens/Configurations/Section/SubSection/Video/video_config.dart b/lib/Screens/Configurations/Section/SubSection/Video/video_config.dart index 8c2186f..e7362fd 100644 --- a/lib/Screens/Configurations/Section/SubSection/Video/video_config.dart +++ b/lib/Screens/Configurations/Section/SubSection/Video/video_config.dart @@ -41,6 +41,7 @@ class _VideoConfigState extends State { widget.onChanged(resourceSource); }, isUrl: true, + maxLength: 100, ); } } diff --git a/lib/Screens/Configurations/Section/SubSection/WebOrVideo/web_config.dart b/lib/Screens/Configurations/Section/SubSection/WebOrVideo/web_config.dart index ab94e88..a718cdb 100644 --- a/lib/Screens/Configurations/Section/SubSection/WebOrVideo/web_config.dart +++ b/lib/Screens/Configurations/Section/SubSection/WebOrVideo/web_config.dart @@ -41,6 +41,7 @@ class _WebConfigState extends State { widget.onChanged(resourceSource); }, isUrl: true, + maxLength: 100 ); } } diff --git a/lib/Screens/Resources/resources_screen.dart b/lib/Screens/Resources/resources_screen.dart index 9dc95c1..a3d26be 100644 --- a/lib/Screens/Resources/resources_screen.dart +++ b/lib/Screens/Resources/resources_screen.dart @@ -145,19 +145,12 @@ Future?> getResources(Function? onGetResult, bool isImage, App Future?> create(ResourceDTO resourceDTO, List? files, List? filesWeb, AppContext appContext, context) async { List createdResources = []; - print("Coucou create"); - print(resourceDTO); - ManagerAppContext managerAppContext = appContext.getContext(); int index = 0; if(filesWeb != null) { for (PlatformFile platformFile in filesWeb) { var mimeType = ""; - print("Coucou platformFile"); - print(platformFile); - print(platformFile.name); - print(platformFile.extension); ResourceDTO resourceDTO = new ResourceDTO(label: platformFile.name); switch(platformFile.extension) { case 'jpg': diff --git a/lib/main.dart b/lib/main.dart index 4fe852c..c010ee5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -19,7 +19,7 @@ Future main() async { WidgetsFlutterBinding.ensureInitialized(); - initialRoute = '/welcome'; + initialRoute = '/login'; var session = await loadJsonSessionFile(); @@ -94,7 +94,7 @@ class _MyAppState extends State { visualDensity: VisualDensity.adaptivePlatformDensity, ), routes: { - '/welcome': (context) => LoginScreen(session: widget.session), + '/login': (context) => LoginScreen(session: widget.session), '/main': (context) => MainScreen(), '/policy': (context) => PolicyScreen(), '/policy/mdlf': (context) => PolicyScreen(param: "mdlf"), diff --git a/web/index.html b/web/index.html index 83a22bb..ab849df 100644 --- a/web/index.html +++ b/web/index.html @@ -48,7 +48,7 @@ application. For more information, see: https://developers.google.com/web/fundamentals/primers/service-workers -->