Service worker update {{}} - menu working ! + clean code

This commit is contained in:
Thomas Fransolet 2025-05-23 15:17:01 +02:00
parent 4ea07c2bd5
commit 7263303b7e
24 changed files with 68 additions and 303 deletions

View File

@ -67,7 +67,6 @@ class _AudioPlayerFloatingContainerState extends State<AudioPlayerFloatingContai
setState(() { setState(() {
//refresh the UI //refresh the UI
if(currentpos > player.duration!.inMilliseconds) { if(currentpos > player.duration!.inMilliseconds) {
print("RESET ALL");
player.stop(); player.stop();
player.seek(const Duration(seconds: 0)); player.seek(const Duration(seconds: 0));
isplaying = false; isplaying = false;

View File

@ -23,12 +23,10 @@ class _TranslationInputAndResourceContainerState extends State<TranslationInputA
currentLanguage = ValueNotifier<String>(widget.newValues.first.language!); currentLanguage = ValueNotifier<String>(widget.newValues.first.language!);
controllerQuill.onEditorLoaded(() { controllerQuill.onEditorLoaded(() {
print("onEditorLoaded");
isInit = true; isInit = true;
}); });
Future.delayed(Duration(milliseconds: 500), () { Future.delayed(Duration(milliseconds: 500), () {
print("Future.delayed");
controllerQuill.clear(); controllerQuill.clear();
controllerQuill.insertText(widget.newValues[_tabController!.index].value!); controllerQuill.insertText(widget.newValues[_tabController!.index].value!);
isInit = true; isInit = true;
@ -38,7 +36,6 @@ class _TranslationInputAndResourceContainerState extends State<TranslationInputA
var plainText = await controllerQuill.getPlainText(); var plainText = await controllerQuill.getPlainText();
if(widget.isTitle) { if(widget.isTitle) {
if(plainText.length > kTitleMaxLength) { if(plainText.length > kTitleMaxLength) {
print("to much text au dessus");
controllerQuill.undo(); controllerQuill.undo();
} }
} else { } else {

View File

@ -24,12 +24,10 @@ class _TranslationInputContainerState extends State<TranslationInputContainer> w
currentLanguage = ValueNotifier<String>(widget.newValues.first.language!); currentLanguage = ValueNotifier<String>(widget.newValues.first.language!);
controllerQuill.onEditorLoaded(() { controllerQuill.onEditorLoaded(() {
print("onEditorLoaded");
isInit = true; isInit = true;
}); });
Future.delayed(Duration(milliseconds: 500), () { Future.delayed(Duration(milliseconds: 500), () {
print("Future.delayed");
controllerQuill.clear(); controllerQuill.clear();
controllerQuill.insertText(widget.newValues[_tabController!.index].value!); controllerQuill.insertText(widget.newValues[_tabController!.index].value!);
isInit = true; isInit = true;
@ -39,12 +37,10 @@ class _TranslationInputContainerState extends State<TranslationInputContainer> w
var plainText = await controllerQuill.getPlainText(); var plainText = await controllerQuill.getPlainText();
if(widget.isTitle) { if(widget.isTitle) {
if(plainText.length > kTitleMaxLength) { if(plainText.length > kTitleMaxLength) {
print("to much text au dessus");
controllerQuill.undo(); controllerQuill.undo();
} }
} else { } else {
if(plainText.length > kDescriptionMaxLength) { if(plainText.length > kDescriptionMaxLength) {
print("to much text description au dessus");
controllerQuill.undo(); controllerQuill.undo();
} }
} }

View File

@ -64,8 +64,6 @@ getContent(List<TranslationDTO> translations, int maxLines) {
maxLines: maxLines, maxLines: maxLines,
initialValue: translation.value, initialValue: translation.value,
onChanged: (String value) { onChanged: (String value) {
//print("onChanged value in tranbslationTAB");
//print(value);
translation.value = value; translation.value = value;
}, },
cursorColor: kPrimaryColor, cursorColor: kPrimaryColor,

View File

@ -27,7 +27,6 @@ class _UploadOnlineResourceContainerState extends State<UploadOnlineResourceCont
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
//print(size.width);
return displayElement(size); return displayElement(size);
} }

View File

@ -84,7 +84,6 @@ class FileHelper {
if (e.toString().contains("cannot find the file")) { if (e.toString().contains("cannot find the file")) {
final path = await _localPath; final path = await _localPath;
new File('$path/session.json').createSync(recursive: true); new File('$path/session.json').createSync(recursive: true);
//print("file created");
await writeSession(new Session(rememberMe: false)); await writeSession(new Session(rememberMe: false));
} }
// If encountering an error, return 0 // If encountering an error, return 0

View File

@ -101,7 +101,6 @@ class _ArticleConfigState extends State<ArticleConfig> {
isChecked: articleDTO.isContentTop, isChecked: articleDTO.isContentTop,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
//print(value);
articleDTO.isContentTop = value; articleDTO.isContentTop = value;
widget.onChanged(articleDTO); widget.onChanged(articleDTO);
}); });
@ -135,7 +134,6 @@ class _ArticleConfigState extends State<ArticleConfig> {
isChecked: articleDTO.isReadAudioAuto, isChecked: articleDTO.isReadAudioAuto,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
//print(value);
articleDTO.isReadAudioAuto = value; articleDTO.isReadAudioAuto = value;
widget.onChanged(articleDTO); widget.onChanged(articleDTO);
}); });

View File

@ -28,7 +28,6 @@ class _CategoryInputContainerState extends State<CategoryInputContainer> {
@override @override
void initState() { void initState() {
middleCategories = widget.initialValue; middleCategories = widget.initialValue;
print("initStateinitStateinitState");
super.initState(); super.initState();
} }
@ -50,13 +49,7 @@ class _CategoryInputContainerState extends State<CategoryInputContainer> {
child: InkWell( child: InkWell(
onTap: () { onTap: () {
List<CategorieDTO> newValues = <CategorieDTO>[]; List<CategorieDTO> newValues = <CategorieDTO>[];
print("HERE COMES THE FUCKKKERS");
print(middleCategories);
showCreateOrUpdateCategories("Catégories", middleCategories, newValues, (value) { showCreateOrUpdateCategories("Catégories", middleCategories, newValues, (value) {
print("RESULT HERERERER");
print(value);
setState(() { setState(() {
widget.onChanged(value); widget.onChanged(value);
middleCategories = value; middleCategories = value;
@ -107,7 +100,6 @@ showCreateOrUpdateCategories(String modalLabel, List<CategorieDTO> initials, Lis
height: size.height * 0.7, height: size.height * 0.7,
width: size.width * 0.65, width: size.width * 0.65,
child: CategoryList(categories: initials, onChanged: (result) { child: CategoryList(categories: initials, onChanged: (result) {
print("ON CHANGZED HERE");
newValues = result; newValues = result;
//onGetResult(result); //onGetResult(result);
}), }),
@ -126,8 +118,6 @@ showCreateOrUpdateCategories(String modalLabel, List<CategorieDTO> initials, Lis
color: kSecond, color: kSecond,
press: () { press: () {
onGetResult(initials); onGetResult(initials);
print("INITALASSS");
print(initials);
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
fontSize: 20, fontSize: 20,

View File

@ -26,15 +26,12 @@ class _CategoryListState extends State<CategoryList> {
@override @override
void initState() { void initState() {
print("INISTASTETETTETET CATEGORY LIIST");
super.initState(); super.initState();
categoriesMiddle = new List<CategorieDTO>.from(widget.categories); categoriesMiddle = new List<CategorieDTO>.from(widget.categories);
categoriesMiddle.sort((a, b) => a.order!.compareTo(b.order!)); categoriesMiddle.sort((a, b) => a.order!.compareTo(b.order!));
currentIndex = getNextAvailableIndex(categoriesMiddle); currentIndex = getNextAvailableIndex(categoriesMiddle);
assignIdsToNull(categoriesMiddle); assignIdsToNull(categoriesMiddle);
print(currentIndex);
print(categoriesMiddle);
} }
int getNextAvailableIndex(List<CategorieDTO> categoriesMiddle) { int getNextAvailableIndex(List<CategorieDTO> categoriesMiddle) {
@ -210,7 +207,6 @@ class _CategoryListState extends State<CategoryList> {
if (result != null) if (result != null)
{ {
setState(() { setState(() {
print("RESUUULT MODIFYY ");
category = result; category = result;
categoriesMiddle[category.order!] = category; categoriesMiddle[category.order!] = category;
widget.onChanged(categoriesMiddle); widget.onChanged(categoriesMiddle);

View File

@ -106,13 +106,6 @@ class _MapConfigState extends State<MapConfig> {
break; break;
} }
} }
/*print("MAPDTO");
print(mapDTO);
print(mapDTO.mapType.toString());
if (mapDTO.mapType == null) {
mapDTO.mapType = MapTypeApp.hybrid;
}*/
} }
@override @override
@ -245,8 +238,6 @@ class _MapConfigState extends State<MapConfig> {
color: kPrimaryColor, color: kPrimaryColor,
onChanged: (List<CategorieDTO>? value) { onChanged: (List<CategorieDTO>? value) {
if(value != null) { if(value != null) {
//print("COUCOU CategoryInputContainerCategoryInputContainerCategoryInputContainer");
//print(value);
mapDTO.categories = value; mapDTO.categories = value;
//update point's category //update point's category
@ -255,34 +246,10 @@ class _MapConfigState extends State<MapConfig> {
// Check if category still exist - Delete // Check if category still exist - Delete
if(p.categorieId != null && !mapDTO.categories!.map((c) => c.id).any((e) => e != null && e == p.categorieId)) 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.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); widget.onChanged(mapDTO);
} }
}, },

View File

@ -85,16 +85,8 @@ Future<CategorieDTO?> showNewOrUpdateCategory(CategorieDTO? inputCategorieDTO, A
onChanged: (ResourceDTO resource) { onChanged: (ResourceDTO resource) {
if(resource.id == null) { if(resource.id == null) {
categorieDTO.resourceDTO = null; categorieDTO.resourceDTO = null;
/*categorieDTO.resourceDTO?.id = null;
categorieDTO.resourceDTO?.url = null;
categorieDTO.resourceDTO?.label = null;*/
} else { } else {
categorieDTO.resourceDTO = resource; 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 isSmall: true

View File

@ -78,18 +78,15 @@ void showNewOrUpdateGeoPoint(MapDTO mapDTO, GeoPointDTO? inputGeoPointDTO, Funct
onError: (e) => print(e), onError: (e) => print(e),
selectLocationButtonLeadingIcon: const Icon(Icons.check, color: kPrimaryColor), selectLocationButtonLeadingIcon: const Icon(Icons.check, color: kPrimaryColor),
onPicked: (pickedData) { onPicked: (pickedData) {
print("onPicked");
geoPointDTO.latitude = pickedData.latLong.latitude.toString(); geoPointDTO.latitude = pickedData.latLong.latitude.toString();
geoPointDTO.longitude = pickedData.latLong.longitude.toString(); geoPointDTO.longitude = pickedData.latLong.longitude.toString();
print(geoPointDTO.latitude);
print(geoPointDTO.longitude);
}, },
onChanged: (pickedData) { onChanged: (pickedData) {
print("onChanged"); /*print("onChanged");
print(pickedData.latLong.latitude); print(pickedData.latLong.latitude);
print(pickedData.latLong.longitude); print(pickedData.latLong.longitude);
print(pickedData.address); print(pickedData.address);
print(pickedData.addressData); print(pickedData.addressData);*/
}, },
showContributorBadgeForOSM: false, showContributorBadgeForOSM: false,
), ),

View File

@ -188,213 +188,61 @@ class _ListViewCardSubSection extends State<ListViewCardSubSection> {
); );
} }
updateSectionDetail(SectionDTO sectionDTO, Object sectionDetailDTO) { dynamic updateSectionDetail(SectionDTO sectionDTO, Object sectionDetailDTO) {
switch(sectionDTO.type) dynamic castedDetail;
{
switch (sectionDTO.type) {
case SectionType.Map: case SectionType.Map:
(sectionDetailDTO as MapDTO).id = sectionDTO.id; castedDetail = sectionDetailDTO is MapDTO ? sectionDetailDTO : MapDTO.fromJson(sectionDetailDTO)!;
(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;
break; break;
case SectionType.Slider: case SectionType.Slider:
(sectionDetailDTO as SliderDTO).id = sectionDTO.id; castedDetail = sectionDetailDTO is SliderDTO ? sectionDetailDTO : SliderDTO.fromJson(sectionDetailDTO)!;
(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;
break; break;
case SectionType.Video: case SectionType.Video:
(sectionDetailDTO as VideoDTO).id = sectionDTO.id; castedDetail = sectionDetailDTO is VideoDTO ? sectionDetailDTO : VideoDTO.fromJson(sectionDetailDTO)!;
(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;
break; break;
case SectionType.Web: case SectionType.Web:
(sectionDetailDTO as WebDTO).id = sectionDTO.id; castedDetail = sectionDetailDTO is WebDTO ? sectionDetailDTO : WebDTO.fromJson(sectionDetailDTO)!;
(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;
break; break;
case SectionType.Quiz: case SectionType.Quiz:
(sectionDetailDTO as QuizDTO).id = sectionDTO.id; castedDetail = sectionDetailDTO is QuizDTO ? sectionDetailDTO : QuizDTO.fromJson(sectionDetailDTO)!;
(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;
break; break;
case SectionType.Pdf: case SectionType.Pdf:
(sectionDetailDTO as PdfDTO).id = sectionDTO.id; castedDetail = sectionDetailDTO is PdfDTO ? sectionDetailDTO : PdfDTO.fromJson(sectionDetailDTO)!;
(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;
break; break;
case SectionType.Puzzle: case SectionType.Puzzle:
(sectionDetailDTO as PuzzleDTO).id = sectionDTO.id; castedDetail = sectionDetailDTO is PuzzleDTO ? sectionDetailDTO : PuzzleDTO.fromJson(sectionDetailDTO)!;
(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;
break; break;
case SectionType.Agenda: case SectionType.Agenda:
(sectionDetailDTO as AgendaDTO).id = sectionDTO.id; castedDetail = sectionDetailDTO is AgendaDTO ? sectionDetailDTO : AgendaDTO.fromJson(sectionDetailDTO)!;
(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;
break; break;
case SectionType.Weather: case SectionType.Weather:
(sectionDetailDTO as WeatherDTO).id = sectionDTO.id; castedDetail = sectionDetailDTO is WeatherDTO ? sectionDetailDTO : WeatherDTO.fromJson(sectionDetailDTO)!;
(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;
break; 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) { boxDecoration(SectionDTO sectionDTO, appContext) {

View File

@ -36,6 +36,7 @@ class MenuConfig extends StatefulWidget {
class _MenuConfigState extends State<MenuConfig> { class _MenuConfigState extends State<MenuConfig> {
late MenuDTO menuDTO; late MenuDTO menuDTO;
late List<dynamic> rawSubsections;
@override @override
void initState() { void initState() {
@ -56,11 +57,28 @@ class _MenuConfigState extends State<MenuConfig> {
Widget bodyGrid(Size size, AppContext appContext) { 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) { if (newIndex > oldIndex) {
newIndex -= 1; newIndex -= 1;
@ -76,7 +94,9 @@ class _MenuConfigState extends State<MenuConfig> {
widget.onChanged(jsonEncode(menuDTO).toString()); widget.onChanged(jsonEncode(menuDTO).toString());
}, },
); );*/
} }
return SingleChildScrollView( return SingleChildScrollView(
child: Stack( child: Stack(
@ -94,9 +114,9 @@ class _MenuConfigState extends State<MenuConfig> {
} else { } else {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
var rawList = snapshot.data; var rawList = snapshot.data;
var rawSectionDTOList = jsonDecode(jsonEncode(snapshot.data)); rawSubsections = jsonDecode(jsonEncode(snapshot.data));
rawSectionDTOList = rawSectionDTOList.map((json) => SectionDTO.fromJson(json)).toList(); rawSubsections = rawSubsections.map((json) => SectionDTO.fromJson(json)).toList();
List<SectionDTO> sectionList = rawSectionDTOList.whereType<SectionDTO>().toList(); List<SectionDTO> sectionList = rawSubsections.whereType<SectionDTO>().toList();
menuDTO.sections = sectionList; menuDTO.sections = sectionList;
menuDTO.sections!.sort((a, b) => a.order!.compareTo(b.order!)); menuDTO.sections!.sort((a, b) => a.order!.compareTo(b.order!));

View File

@ -70,8 +70,6 @@ Future<OrderedTranslationAndResourceDTO?> showNewOrUpdatePDFFile(OrderedTranslat
resourceTypes: [ResourceType.Pdf], resourceTypes: [ResourceType.Pdf],
onGetResult: (value) { onGetResult: (value) {
if (pdfFileDTO.translationAndResourceDTOs != value) { if (pdfFileDTO.translationAndResourceDTOs != value) {
print("get resut hereeee");
print(value);
pdfFileDTO.translationAndResourceDTOs = value; pdfFileDTO.translationAndResourceDTOs = value;
} }
}, },

View File

@ -167,7 +167,6 @@ class _PDFListState extends State<PDFList> {
if (result != null) if (result != null)
{ {
setState(() { setState(() {
print("RESUUULT MODIFYY ");
pdfFileDTO = result; pdfFileDTO = result;
pdfsMiddle[pdfFileDTO.order!] = pdfFileDTO; pdfsMiddle[pdfFileDTO.order!] = pdfFileDTO;
widget.onChanged(pdfsMiddle); widget.onChanged(pdfsMiddle);

View File

@ -77,11 +77,8 @@ class _PuzzleConfigState extends State<PuzzleConfig> {
initialValue: puzzleDTO.messageDebut != null ? puzzleDTO.messageDebut! : [], initialValue: puzzleDTO.messageDebut != null ? puzzleDTO.messageDebut! : [],
resourceTypes: [ResourceType.Image, ResourceType.ImageUrl], resourceTypes: [ResourceType.Image, ResourceType.ImageUrl],
onGetResult: (value) { onGetResult: (value) {
print("Mess depart test");
print(value);
if (puzzleDTO.messageDebut != value) { if (puzzleDTO.messageDebut != value) {
setState(() { setState(() {
print(puzzleDTO.messageDebut);
puzzleDTO.messageDebut = value; puzzleDTO.messageDebut = value;
widget.onChanged(puzzleDTO); widget.onChanged(puzzleDTO);
}); });
@ -131,7 +128,6 @@ class _PuzzleConfigState extends State<PuzzleConfig> {
widget.onChanged(puzzleDTO); widget.onChanged(puzzleDTO);
}); });
} catch (e) { } catch (e) {
print('Puzzle rows not a number');
showNotification(Colors.orange, kWhite, 'Cela doit être un chiffre', context, null); showNotification(Colors.orange, kWhite, 'Cela doit être un chiffre', context, null);
} }
}, },
@ -151,7 +147,6 @@ class _PuzzleConfigState extends State<PuzzleConfig> {
widget.onChanged(puzzleDTO); widget.onChanged(puzzleDTO);
}); });
} catch (e) { } catch (e) {
print('Puzzle rows not a number');
showNotification(Colors.orange, kWhite, 'Cela doit être un chiffre', context, null); showNotification(Colors.orange, kWhite, 'Cela doit être un chiffre', context, null);
} }
}, },

View File

@ -42,12 +42,8 @@ Future<List<TranslationAndResourceDTO>?> showNewOrUpdateScoreQuizz(List<Translat
}); });
showMultiStringInputAndResourceHTML("Message pour un mauvais score", "Message pour un mauvais score", true, initials, newValues, (value) { showMultiStringInputAndResourceHTML("Message pour un mauvais score", "Message pour un mauvais score", true, initials, newValues, (value) {
print("RTESULTYTYT ");
print(value);
if(value != null && value.isNotEmpty) { if(value != null && value.isNotEmpty) {
levelDTO = value; levelDTO = value;
print("RETURN VALUE");
print(levelDTO);
return levelDTO; return levelDTO;
} }
}, 1, [], context); }, 1, [], context);

View File

@ -70,20 +70,6 @@ class _QuizzConfigState extends State<QuizzConfig> {
} catch(e) { } catch(e) {
showNotification(kError, kWhite, "Une erreur est survenue lors de la mise à jour de l'ordre des questions", context, null); 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 return

View File

@ -41,6 +41,7 @@ class _VideoConfigState extends State<VideoConfig> {
widget.onChanged(resourceSource); widget.onChanged(resourceSource);
}, },
isUrl: true, isUrl: true,
maxLength: 100,
); );
} }
} }

View File

@ -41,6 +41,7 @@ class _WebConfigState extends State<WebConfig> {
widget.onChanged(resourceSource); widget.onChanged(resourceSource);
}, },
isUrl: true, isUrl: true,
maxLength: 100
); );
} }
} }

View File

@ -145,19 +145,12 @@ Future<List<ResourceDTO>?> getResources(Function? onGetResult, bool isImage, App
Future<List<ResourceDTO?>?> create(ResourceDTO resourceDTO, List<File>? files, List<PlatformFile>? filesWeb, AppContext appContext, context) async { Future<List<ResourceDTO?>?> create(ResourceDTO resourceDTO, List<File>? files, List<PlatformFile>? filesWeb, AppContext appContext, context) async {
List<ResourceDTO?> createdResources = []; List<ResourceDTO?> createdResources = [];
print("Coucou create");
print(resourceDTO);
ManagerAppContext managerAppContext = appContext.getContext(); ManagerAppContext managerAppContext = appContext.getContext();
int index = 0; int index = 0;
if(filesWeb != null) { if(filesWeb != null) {
for (PlatformFile platformFile in filesWeb) { for (PlatformFile platformFile in filesWeb) {
var mimeType = ""; var mimeType = "";
print("Coucou platformFile");
print(platformFile);
print(platformFile.name);
print(platformFile.extension);
ResourceDTO resourceDTO = new ResourceDTO(label: platformFile.name); ResourceDTO resourceDTO = new ResourceDTO(label: platformFile.name);
switch(platformFile.extension) { switch(platformFile.extension) {
case 'jpg': case 'jpg':

View File

@ -19,7 +19,7 @@ Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
initialRoute = '/welcome'; initialRoute = '/login';
var session = await loadJsonSessionFile(); var session = await loadJsonSessionFile();
@ -94,7 +94,7 @@ class _MyAppState extends State<MyApp> {
visualDensity: VisualDensity.adaptivePlatformDensity, visualDensity: VisualDensity.adaptivePlatformDensity,
), ),
routes: { routes: {
'/welcome': (context) => LoginScreen(session: widget.session), '/login': (context) => LoginScreen(session: widget.session),
'/main': (context) => MainScreen(), '/main': (context) => MainScreen(),
'/policy': (context) => PolicyScreen(), '/policy': (context) => PolicyScreen(),
'/policy/mdlf': (context) => PolicyScreen(param: "mdlf"), '/policy/mdlf': (context) => PolicyScreen(param: "mdlf"),

View File

@ -48,7 +48,7 @@
application. For more information, see: application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers --> https://developers.google.com/web/fundamentals/primers/service-workers -->
<script> <script>
var serviceWorkerVersion = null; var serviceWorkerVersion = {{flutter_service_worker_version}};
var scriptLoaded = false; var scriptLoaded = false;
function loadMainDartJs() { function loadMainDartJs() {
if (scriptLoaded) { if (scriptLoaded) {