Quiz ok (must be more tested) + menu (wip)
This commit is contained in:
parent
807d599910
commit
4ea07c2bd5
@ -1,6 +1,8 @@
|
|||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:manager_app/Components/confirmation_dialog.dart';
|
||||||
import 'package:manager_app/Components/fetch_section_icon.dart';
|
import 'package:manager_app/Components/fetch_section_icon.dart';
|
||||||
|
import 'package:manager_app/Components/message_notification.dart';
|
||||||
import 'package:manager_app/Models/managerContext.dart';
|
import 'package:manager_app/Models/managerContext.dart';
|
||||||
import 'package:manager_app/Screens/Configurations/Section/SubSection/Menu/showEditSubSection.dart';
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/Menu/showEditSubSection.dart';
|
||||||
import 'package:manager_app/app_context.dart';
|
import 'package:manager_app/app_context.dart';
|
||||||
@ -14,13 +16,15 @@ class ListViewCardSubSection extends StatefulWidget {
|
|||||||
final List<SectionDTO> listItems;
|
final List<SectionDTO> listItems;
|
||||||
final AppContext appContext;
|
final AppContext appContext;
|
||||||
final ValueChanged<List<SectionDTO>> onChanged;
|
final ValueChanged<List<SectionDTO>> onChanged;
|
||||||
|
final Object rawData;
|
||||||
|
|
||||||
ListViewCardSubSection(
|
ListViewCardSubSection(
|
||||||
this.listItems,
|
this.listItems,
|
||||||
this.index,
|
this.index,
|
||||||
this.key,
|
this.key,
|
||||||
this.appContext,
|
this.appContext,
|
||||||
this.onChanged
|
this.onChanged,
|
||||||
|
this.rawData
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -58,15 +62,23 @@ class _ListViewCardSubSection extends State<ListViewCardSubSection> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
showEditSubSection(
|
showEditSubSection(
|
||||||
widget.listItems[widget.index],
|
widget.listItems[widget.index],
|
||||||
(SectionDTO value) async {
|
(Object value) async {
|
||||||
var result = await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionUpdate(value);
|
try {
|
||||||
|
var test = updateSectionDetail(widget.listItems[widget.index], value);
|
||||||
|
// update sub section
|
||||||
|
await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionUpdate(test);
|
||||||
|
showNotification(kSuccess, kWhite, "La sous section a été mis à jour avec succès", context, null);
|
||||||
setState(() {
|
setState(() {
|
||||||
widget.listItems[widget.index] = value;
|
//widget.listItems[widget.index] = value;
|
||||||
widget.onChanged(widget.listItems);
|
widget.onChanged(widget.listItems); // For resfreh ui
|
||||||
});
|
});
|
||||||
|
} catch(e) {
|
||||||
|
showNotification(kError, kWhite, "Une erreur est survenue lors de la mise à jour de la sous section", context, null);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
widget.appContext,
|
widget.appContext,
|
||||||
context
|
context,
|
||||||
|
widget.rawData
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@ -79,9 +91,24 @@ class _ListViewCardSubSection extends State<ListViewCardSubSection> {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
widget.listItems.removeAt(widget.index);
|
showConfirmationDialog(
|
||||||
|
"Êtes-vous sûr de vouloir supprimer cette sous section ?",
|
||||||
|
() {},
|
||||||
|
() async {
|
||||||
|
try {
|
||||||
|
var sectionToDelete = widget.listItems[widget.index];
|
||||||
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
|
await managerAppContext.clientAPI!.sectionApi!.sectionDelete(sectionToDelete.id!);
|
||||||
|
showNotification(kSuccess, kWhite, 'La sous section a été supprimée avec succès', context, null);
|
||||||
|
// refresh UI
|
||||||
widget.onChanged(widget.listItems);
|
widget.onChanged(widget.listItems);
|
||||||
|
} catch(e) {
|
||||||
|
showNotification(kError, kWhite, 'Une erreur est survenue lors de la suppression de la sous section', context, null);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
context
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(6.0),
|
padding: const EdgeInsets.all(6.0),
|
||||||
@ -160,6 +187,214 @@ class _ListViewCardSubSection extends State<ListViewCardSubSection> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateSectionDetail(SectionDTO sectionDTO, Object sectionDetailDTO) {
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sectionDetailDTO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boxDecoration(SectionDTO sectionDTO, appContext) {
|
boxDecoration(SectionDTO sectionDTO, appContext) {
|
||||||
|
|||||||
@ -1,10 +1,16 @@
|
|||||||
|
import 'dart:js_interop';
|
||||||
|
|
||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:manager_app/Components/common_loader.dart';
|
||||||
|
import 'package:manager_app/Components/confirmation_dialog.dart';
|
||||||
import 'package:manager_app/Components/fetch_section_icon.dart';
|
import 'package:manager_app/Components/fetch_section_icon.dart';
|
||||||
|
import 'package:manager_app/Components/message_notification.dart';
|
||||||
import 'package:manager_app/Models/managerContext.dart';
|
import 'package:manager_app/Models/managerContext.dart';
|
||||||
import 'package:manager_app/Screens/Configurations/Section/SubSection/Menu/listView_card_subSection.dart';
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/Menu/listView_card_subSection.dart';
|
||||||
import 'package:manager_app/Screens/Configurations/new_section_popup.dart';
|
import 'package:manager_app/Screens/Configurations/new_section_popup.dart';
|
||||||
import 'package:manager_app/app_context.dart';
|
import 'package:manager_app/app_context.dart';
|
||||||
|
import 'package:manager_app/client.dart';
|
||||||
import 'package:manager_app/constants.dart';
|
import 'package:manager_app/constants.dart';
|
||||||
import 'package:manager_api_new/api.dart';
|
import 'package:manager_api_new/api.dart';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
@ -51,6 +57,9 @@ 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) {
|
||||||
|
|
||||||
|
// TODO Edit order (copy quiz question order lofic)
|
||||||
|
|
||||||
setState(
|
setState(
|
||||||
() {
|
() {
|
||||||
if (newIndex > oldIndex) {
|
if (newIndex > oldIndex) {
|
||||||
@ -69,7 +78,6 @@ class _MenuConfigState extends State<MenuConfig> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
@ -78,7 +86,22 @@ class _MenuConfigState extends State<MenuConfig> {
|
|||||||
constraints: BoxConstraints(maxHeight: 300, minHeight: 250),
|
constraints: BoxConstraints(maxHeight: 300, minHeight: 250),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child : ReorderableListView(
|
child : FutureBuilder(
|
||||||
|
future: getSubsections((appContext.getContext() as ManagerAppContext).clientAPI!),
|
||||||
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return Center(child: CommonLoader());
|
||||||
|
} 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<SectionDTO> sectionList = rawSectionDTOList.whereType<SectionDTO>().toList();
|
||||||
|
|
||||||
|
menuDTO.sections = sectionList;
|
||||||
|
menuDTO.sections!.sort((a, b) => a.order!.compareTo(b.order!));
|
||||||
|
|
||||||
|
return ReorderableListView(
|
||||||
onReorder: _onReorder,
|
onReorder: _onReorder,
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 15.0),
|
padding: const EdgeInsets.symmetric(vertical: 15.0),
|
||||||
@ -92,14 +115,24 @@ class _MenuConfigState extends State<MenuConfig> {
|
|||||||
appContext,
|
appContext,
|
||||||
(sections) {
|
(sections) {
|
||||||
setState(() {
|
setState(() {
|
||||||
List<SectionDTO> test = new List<SectionDTO>.from(sections);
|
List<SectionDTO> test = new List<
|
||||||
|
SectionDTO>.from(sections);
|
||||||
menuDTO.sections = test;
|
menuDTO.sections = test;
|
||||||
widget.onChanged(jsonEncode(menuDTO).toString());
|
widget.onChanged(
|
||||||
|
jsonEncode(menuDTO).toString());
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
rawList[index]
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Center(child: Text(
|
||||||
|
"Une erreur est survenue lors de la récupération des sous sections"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -107,22 +140,30 @@ class _MenuConfigState extends State<MenuConfig> {
|
|||||||
top: 0,
|
top: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
showNewSection(
|
var newSubsection = await showNewSection(
|
||||||
(appContext.getContext() as ManagerAppContext).selectedConfiguration!.id!,
|
(appContext.getContext() as ManagerAppContext).selectedConfiguration!.id!,
|
||||||
appContext,
|
appContext,
|
||||||
context,
|
context,
|
||||||
true,
|
true,
|
||||||
(SectionDTO newSubsection) {
|
|
||||||
setState(() {
|
|
||||||
//print("RECEIVED new swubssection");
|
|
||||||
//print(newSubsection);
|
|
||||||
menuDTO.sections!.add(newSubsection);
|
|
||||||
widget.onChanged(jsonEncode(menuDTO).toString());
|
|
||||||
});
|
|
||||||
},
|
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
try {
|
||||||
|
if(newSubsection != null)
|
||||||
|
{
|
||||||
|
newSubsection.instanceId = (appContext.getContext() as ManagerAppContext).instanceId;
|
||||||
|
newSubsection.isBeacon = false;
|
||||||
|
await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionCreate(newSubsection);
|
||||||
|
showNotification(kSuccess, kWhite, 'La sous section a été créée avec succès', context, null);
|
||||||
|
setState(() {
|
||||||
|
// refresh ui
|
||||||
|
print("Refresh UI");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
showNotification(kError, kWhite, 'Une erreur est survenue lors de la création de la sous section', context, null);
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
height: MediaQuery.of(context).size.width * 0.04,
|
height: MediaQuery.of(context).size.width * 0.04,
|
||||||
@ -153,65 +194,10 @@ class _MenuConfigState extends State<MenuConfig> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getElement(int index, SectionDTO sectionDTO, Size size, AppContext appContext) {
|
Future<List<dynamic>?> getSubsections(Client client) async {
|
||||||
return Container(
|
final rawList = await client.sectionApi!.sectionGetAllSectionSubSections(menuDTO.id!);
|
||||||
width: double.infinity,
|
var sections = rawList.map((json) => SectionDTO.fromJson(json)).toList();
|
||||||
height: double.infinity,
|
return rawList ?? [];
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: AutoSizeText(
|
|
||||||
sectionDTO.label!,
|
|
||||||
style: new TextStyle(fontSize: 15),
|
|
||||||
maxLines: 2,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
child: Icon(
|
|
||||||
getSectionIcon(sectionDTO.type),
|
|
||||||
color: kSecond,
|
|
||||||
size: 18.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
bottom: 0,
|
|
||||||
left: 0,
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () {
|
|
||||||
/*showNewSection(appContext.getContext().selectedConfiguration.id, appContext, context, true);*/
|
|
||||||
// TODO ?
|
|
||||||
},
|
|
||||||
child: Icon(
|
|
||||||
Icons.edit,
|
|
||||||
color: kPrimaryColor,
|
|
||||||
size: 20.0,
|
|
||||||
)
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
bottom: 0,
|
|
||||||
right: 0,
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
menuDTO.sections!.removeAt(index);
|
|
||||||
widget.onChanged(jsonEncode(menuDTO).toString());
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Icon(
|
|
||||||
Icons.delete,
|
|
||||||
color: kError,
|
|
||||||
size: 20.0,
|
|
||||||
)
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,10 +4,12 @@ import 'package:manager_app/Components/multi_string_input_container.dart';
|
|||||||
import 'package:manager_app/Components/rounded_button.dart';
|
import 'package:manager_app/Components/rounded_button.dart';
|
||||||
import 'package:manager_app/Components/string_input_container.dart';
|
import 'package:manager_app/Components/string_input_container.dart';
|
||||||
import 'package:manager_app/Screens/Configurations/Section/SubSection/Agenda/agenda_config.dart';
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/Agenda/agenda_config.dart';
|
||||||
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/Article/article_config.dart';
|
||||||
import 'package:manager_app/Screens/Configurations/Section/SubSection/PDF/PDF_config.dart';
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/PDF/PDF_config.dart';
|
||||||
import 'package:manager_app/Screens/Configurations/Section/SubSection/Puzzle/puzzle_config.dart';
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/Puzzle/puzzle_config.dart';
|
||||||
import 'package:manager_app/Screens/Configurations/Section/SubSection/Quizz/quizz_config.dart';
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/Quizz/quizz_config.dart';
|
||||||
import 'package:manager_app/Screens/Configurations/Section/SubSection/Slider/slider_config.dart';
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/Slider/slider_config.dart';
|
||||||
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/Video/video_config.dart';
|
||||||
import 'package:manager_app/Screens/Configurations/Section/SubSection/Weather/weather_config.dart';
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/Weather/weather_config.dart';
|
||||||
import 'package:manager_app/Screens/Configurations/Section/SubSection/WebOrVideo/web_config.dart';
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/WebOrVideo/web_config.dart';
|
||||||
import 'package:manager_app/app_context.dart';
|
import 'package:manager_app/app_context.dart';
|
||||||
@ -17,7 +19,8 @@ import 'package:manager_api_new/api.dart';
|
|||||||
import '../Map/map_config.dart';
|
import '../Map/map_config.dart';
|
||||||
import 'menu_config.dart';
|
import 'menu_config.dart';
|
||||||
|
|
||||||
void showEditSubSection(SectionDTO subSectionDTO, Function getResult, AppContext appContext, BuildContext context) {
|
void showEditSubSection(SectionDTO subSectionDTO, Function getResult, AppContext appContext, BuildContext context, Object rawSubSectionData) {
|
||||||
|
Object updatedRawSubSectionData = rawSubSectionData;
|
||||||
|
|
||||||
Size size = MediaQuery.of(context).size;
|
Size size = MediaQuery.of(context).size;
|
||||||
showDialog(
|
showDialog(
|
||||||
@ -119,7 +122,14 @@ void showEditSubSection(SectionDTO subSectionDTO, Function getResult, AppContext
|
|||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: getSpecificData(subSectionDTO, context, appContext),
|
child: getSpecificData(
|
||||||
|
subSectionDTO,
|
||||||
|
rawSubSectionData,
|
||||||
|
rawSubSectionData,
|
||||||
|
appContext,
|
||||||
|
(updatedData) {
|
||||||
|
updatedRawSubSectionData = updatedData;
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -159,7 +169,7 @@ void showEditSubSection(SectionDTO subSectionDTO, Function getResult, AppContext
|
|||||||
color: kPrimaryColor,
|
color: kPrimaryColor,
|
||||||
textColor: kWhite,
|
textColor: kWhite,
|
||||||
press: () {
|
press: () {
|
||||||
getResult(subSectionDTO);
|
getResult(updatedRawSubSectionData);
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
@ -173,85 +183,100 @@ void showEditSubSection(SectionDTO subSectionDTO, Function getResult, AppContext
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSpecificData(SectionDTO sectionDTO, BuildContext context, AppContext appContext) {
|
getSpecificData(SectionDTO subSectionDTO, Object? rawSectionData, Object sectionDetailDTO, AppContext appContext, Function(Object) onChanged) {
|
||||||
switch(sectionDTO.type) {
|
switch(subSectionDTO.type) {
|
||||||
case SectionType.Map:
|
case SectionType.Map:
|
||||||
return Text("TODO");
|
MapDTO mapDTO = MapDTO.fromJson(rawSectionData)!;
|
||||||
/*return MapConfig(
|
sectionDetailDTO = mapDTO;
|
||||||
initialValue: sectionDTO.data!,
|
return MapConfig(
|
||||||
onChanged: (String data) {
|
initialValue: mapDTO,
|
||||||
//print("Received info in parent");
|
onChanged: (MapDTO changedMap) {
|
||||||
//print(data);
|
onChanged(changedMap);
|
||||||
sectionDTO.data = data;
|
|
||||||
},
|
},
|
||||||
);*/
|
);
|
||||||
/*case SectionType.Slider:
|
case SectionType.Slider:
|
||||||
return Container(
|
SliderDTO sliderDTO = SliderDTO.fromJson(rawSectionData)!;
|
||||||
width: MediaQuery.of(context).size.width * 0.5,
|
sectionDetailDTO = sliderDTO;
|
||||||
height: MediaQuery.of(context).size.height * 0.5,
|
return SliderConfig(
|
||||||
child: SliderConfig(
|
initialValue: sliderDTO,
|
||||||
initialValue: sectionDTO.data!,
|
onChanged: (SliderDTO changedSlider) {
|
||||||
onChanged: (String data) {
|
onChanged(changedSlider);
|
||||||
//print("Received info in parent");
|
|
||||||
//print(data);
|
|
||||||
sectionDTO.data = data;
|
|
||||||
},
|
},
|
||||||
),
|
|
||||||
);
|
);
|
||||||
case SectionType.Video:
|
case SectionType.Video:
|
||||||
|
VideoDTO videoDTO = VideoDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = videoDTO;
|
||||||
|
return VideoConfig(
|
||||||
|
label: "Url de la vidéo:",
|
||||||
|
initialValue: videoDTO,
|
||||||
|
onChanged: (VideoDTO updatedWebDTO) {
|
||||||
|
onChanged(updatedWebDTO);
|
||||||
|
},
|
||||||
|
);
|
||||||
case SectionType.Web:
|
case SectionType.Web:
|
||||||
return WebOrVideoConfig(
|
WebDTO webDTO = WebDTO.fromJson(rawSectionData)!;
|
||||||
label: sectionDTO.type == SectionType.Video ? "Url de la vidéo:": "Url du site web:",
|
sectionDetailDTO = webDTO;
|
||||||
initialValue: sectionDTO.data!,
|
return WebConfig(
|
||||||
onChanged: (String data) {
|
label: "Url du site web:",
|
||||||
sectionDTO.data = data;
|
initialValue: webDTO,
|
||||||
|
onChanged: (WebDTO updatedWebDTO) {
|
||||||
|
onChanged(updatedWebDTO);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
case SectionType.Menu:
|
case SectionType.Quiz:
|
||||||
return MenuConfig(
|
QuizDTO quizDTO = QuizDTO.fromJson(rawSectionData)!;
|
||||||
initialValue: sectionDTO.data!,
|
sectionDetailDTO = quizDTO;
|
||||||
onChanged: (String data) {
|
|
||||||
//print("Received info in parent");
|
|
||||||
//print(data);
|
|
||||||
sectionDTO.data = data;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
case SectionType.Quizz:
|
|
||||||
return QuizzConfig(
|
return QuizzConfig(
|
||||||
initialValue: sectionDTO.data!,
|
initialValue: quizDTO,
|
||||||
onChanged: (String data) {
|
onChanged: (QuizDTO updatedQuiz) {
|
||||||
//print("Received info in parent");
|
onChanged(updatedQuiz);
|
||||||
//print(data);
|
},
|
||||||
sectionDTO.data = data;
|
);
|
||||||
|
case SectionType.Article:
|
||||||
|
ArticleDTO articleDTO = ArticleDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = articleDTO;
|
||||||
|
return ArticleConfig(
|
||||||
|
initialValue: articleDTO,
|
||||||
|
onChanged: (ArticleDTO changedArticle)
|
||||||
|
{
|
||||||
|
onChanged(changedArticle);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
case SectionType.Pdf:
|
case SectionType.Pdf:
|
||||||
|
PdfDTO pdfDTO = PdfDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = pdfDTO;
|
||||||
return PDFConfig(
|
return PDFConfig(
|
||||||
initialValue: sectionDTO.data!,
|
initialValue: pdfDTO,
|
||||||
onChanged: (String data) {
|
onChanged: (PdfDTO changedPDF) {
|
||||||
sectionDTO.data = data;
|
onChanged(changedPDF);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
case SectionType.Puzzle:
|
case SectionType.Puzzle:
|
||||||
|
PuzzleDTO puzzleDTO = PuzzleDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = puzzleDTO;
|
||||||
return PuzzleConfig(
|
return PuzzleConfig(
|
||||||
initialValue: sectionDTO.data!,
|
initialValue: puzzleDTO,
|
||||||
onChanged: (String data) {
|
onChanged: (PuzzleDTO updatedPuzzle) {
|
||||||
sectionDTO.data = data;
|
onChanged(updatedPuzzle);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
case SectionType.Agenda:
|
case SectionType.Agenda:
|
||||||
|
AgendaDTO agendaDTO = AgendaDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = agendaDTO;
|
||||||
return AgendaConfig(
|
return AgendaConfig(
|
||||||
initialValue: sectionDTO.data!,
|
initialValue: agendaDTO,
|
||||||
onChanged: (String data) {
|
onChanged: (AgendaDTO updatedAgenda) {
|
||||||
sectionDTO.data = data;
|
onChanged(updatedAgenda);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
case SectionType.Weather:
|
case SectionType.Weather:
|
||||||
|
WeatherDTO weatherDTO = WeatherDTO.fromJson(rawSectionData)!;
|
||||||
|
sectionDetailDTO = weatherDTO;
|
||||||
return WeatherConfig(
|
return WeatherConfig(
|
||||||
initialValue: sectionDTO.data!,
|
initialValue: weatherDTO,
|
||||||
onChanged: (String data) {
|
onChanged: (WeatherDTO updatedWeather) {
|
||||||
sectionDTO.data = data;
|
onChanged(updatedWeather);
|
||||||
},
|
},
|
||||||
);*/
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import 'package:manager_app/app_context.dart';
|
|||||||
import 'package:manager_app/constants.dart';
|
import 'package:manager_app/constants.dart';
|
||||||
import 'package:manager_api_new/api.dart';
|
import 'package:manager_api_new/api.dart';
|
||||||
|
|
||||||
Future<QuestionDTO> showNewOrUpdateQuestionQuizz(QuestionDTO? inputQuestionDTO, AppContext appContext, BuildContext context, String text) async {
|
Future<QuestionDTO?> showNewOrUpdateQuestionQuizz(QuestionDTO? inputQuestionDTO, AppContext appContext, BuildContext context, String text) async {
|
||||||
QuestionDTO questionDTO = new QuestionDTO();
|
QuestionDTO questionDTO = new QuestionDTO();
|
||||||
|
|
||||||
if (inputQuestionDTO != null) {
|
if (inputQuestionDTO != null) {
|
||||||
|
|||||||
@ -127,7 +127,7 @@ class _QuizzResponseListState extends State<QuizzResponseList> {
|
|||||||
widget.onChanged(responsesMiddle);
|
widget.onChanged(responsesMiddle);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, 1, [], context);
|
}, 1, [ResourceType.Image, ResourceType.ImageUrl, ResourceType.Video, ResourceType.VideoUrl, ResourceType.Audio], context);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
height: MediaQuery.of(context).size.width * 0.04,
|
height: MediaQuery.of(context).size.width * 0.04,
|
||||||
|
|||||||
@ -1,11 +1,15 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
|
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
|
||||||
|
import 'package:manager_app/Components/confirmation_dialog.dart';
|
||||||
|
import 'package:manager_app/Components/message_notification.dart';
|
||||||
import 'package:manager_app/Components/multi_string_input_html_modal.dart';
|
import 'package:manager_app/Components/multi_string_input_html_modal.dart';
|
||||||
import 'package:manager_app/Components/rounded_button.dart';
|
import 'package:manager_app/Components/rounded_button.dart';
|
||||||
import 'package:manager_app/Models/managerContext.dart';
|
import 'package:manager_app/Models/managerContext.dart';
|
||||||
import 'package:manager_app/app_context.dart';
|
import 'package:manager_app/app_context.dart';
|
||||||
|
import 'package:manager_app/client.dart';
|
||||||
import 'package:manager_app/constants.dart';
|
import 'package:manager_app/constants.dart';
|
||||||
import 'package:manager_api_new/api.dart';
|
import 'package:manager_api_new/api.dart';
|
||||||
|
import 'package:manager_app/Components/common_loader.dart';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
@ -31,6 +35,7 @@ class QuizzConfig extends StatefulWidget {
|
|||||||
|
|
||||||
class _QuizzConfigState extends State<QuizzConfig> {
|
class _QuizzConfigState extends State<QuizzConfig> {
|
||||||
late QuizDTO quizzDTO;
|
late QuizDTO quizzDTO;
|
||||||
|
late List<QuestionDTO> questions = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -46,24 +51,39 @@ class _QuizzConfigState extends State<QuizzConfig> {
|
|||||||
final appContext = Provider.of<AppContext>(context);
|
final appContext = Provider.of<AppContext>(context);
|
||||||
Size size = MediaQuery.of(context).size;
|
Size size = MediaQuery.of(context).size;
|
||||||
|
|
||||||
void _onReorder(int oldIndex, int newIndex) {
|
void _onReorder(int oldIndex, int newIndex) async {
|
||||||
setState(
|
|
||||||
() {
|
|
||||||
if (newIndex > oldIndex) {
|
if (newIndex > oldIndex) {
|
||||||
newIndex -= 1;
|
newIndex -= 1;
|
||||||
}
|
}
|
||||||
final QuestionDTO item = quizzDTO.questions!.removeAt(oldIndex);
|
final QuestionDTO item = quizzDTO.questions![oldIndex];
|
||||||
quizzDTO.questions!.insert(newIndex, item);
|
//quizzDTO.questions!.insert(newIndex, item);
|
||||||
|
|
||||||
var i = 0;
|
item.order = newIndex;
|
||||||
|
try {
|
||||||
|
await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionQuizApi!.sectionQuizUpdate(item);
|
||||||
|
showNotification(kSuccess, kWhite, "L'ordre des questions 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 questions", context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*var i = 0;
|
||||||
quizzDTO.questions!.forEach((question) {
|
quizzDTO.questions!.forEach((question) {
|
||||||
question.order = i;
|
question.order = i;
|
||||||
i++;
|
i++;
|
||||||
});
|
});*/
|
||||||
|
|
||||||
|
/*setState(
|
||||||
|
() async {
|
||||||
|
|
||||||
|
|
||||||
widget.onChanged(quizzDTO);
|
widget.onChanged(quizzDTO);
|
||||||
},
|
},
|
||||||
);
|
);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -143,7 +163,20 @@ class _QuizzConfigState extends State<QuizzConfig> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
FutureBuilder(
|
||||||
|
future: getQuestions((appContext.getContext() as ManagerAppContext).clientAPI!),
|
||||||
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return Center(child: CommonLoader());
|
||||||
|
} else {
|
||||||
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
|
|
||||||
|
quizzDTO.questions = snapshot.data;
|
||||||
|
quizzDTO.questions!.sort((a, b) => a.order!.compareTo(b.order!));
|
||||||
|
|
||||||
|
questions = quizzDTO.questions!;
|
||||||
|
|
||||||
|
return Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -153,19 +186,27 @@ class _QuizzConfigState extends State<QuizzConfig> {
|
|||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 40, left: 10, right: 10, bottom: 10),
|
padding: const EdgeInsets.only(
|
||||||
|
top: 40, left: 10, right: 10, bottom: 10),
|
||||||
child: Container(
|
child: Container(
|
||||||
height: quizzDTO.questions!.length == 0 ? 75 : null,
|
height: quizzDTO.questions!.length == 0
|
||||||
|
? 75
|
||||||
|
: null,
|
||||||
child: ReorderableListView.builder(
|
child: ReorderableListView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
padding: const EdgeInsets.only(right: 125),
|
padding: const EdgeInsets.only(
|
||||||
itemBuilder: (BuildContext context, int index) {
|
right: 125),
|
||||||
|
itemBuilder: (BuildContext context,
|
||||||
|
int index) {
|
||||||
return Container(
|
return Container(
|
||||||
key: ValueKey(index),
|
key: ValueKey(index),
|
||||||
decoration: boxDecoration(),
|
decoration: boxDecoration(),
|
||||||
padding: const EdgeInsets.all(2),
|
padding: const EdgeInsets.all(2),
|
||||||
margin: EdgeInsets.symmetric(vertical: 3, horizontal: 3),
|
margin: EdgeInsets.symmetric(
|
||||||
child: getElement(index, quizzDTO.questions![index], size, appContext),
|
vertical: 3, horizontal: 3),
|
||||||
|
child: getElement(index,
|
||||||
|
quizzDTO.questions![index],
|
||||||
|
size, appContext),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
itemCount: quizzDTO.questions!.length,
|
itemCount: quizzDTO.questions!.length,
|
||||||
@ -178,7 +219,8 @@ class _QuizzConfigState extends State<QuizzConfig> {
|
|||||||
left: 10,
|
left: 10,
|
||||||
child: Text(
|
child: Text(
|
||||||
"Questions",
|
"Questions",
|
||||||
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500),
|
style: TextStyle(fontSize: 15,
|
||||||
|
fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
@ -186,12 +228,28 @@ class _QuizzConfigState extends State<QuizzConfig> {
|
|||||||
right: 10,
|
right: 10,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
QuestionDTO? result = await showNewOrUpdateQuestionQuizz(null, appContext, context, "Question");
|
QuestionDTO? result = await showNewOrUpdateQuestionQuizz(
|
||||||
|
null, appContext, context, "Question");
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(result != null)
|
||||||
|
{
|
||||||
|
await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionQuizApi!.sectionQuizCreate(quizzDTO.id!, result);
|
||||||
|
showNotification(kSuccess, kWhite, 'La question a été créée avec succès', context, null);
|
||||||
setState(() {
|
setState(() {
|
||||||
|
// refresh ui
|
||||||
|
print("Refresh UI");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
showNotification(kError, kWhite, 'Une erreur est survenue lors de la création de la question', context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*setState(() {
|
||||||
result.order = quizzDTO.questions!.length;
|
result.order = quizzDTO.questions!.length;
|
||||||
quizzDTO.questions!.add(result);
|
quizzDTO.questions!.add(result);
|
||||||
widget.onChanged(quizzDTO);
|
widget.onChanged(quizzDTO);
|
||||||
});
|
});*/
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
height: MediaQuery.of(context).size.width * 0.04,
|
height: MediaQuery.of(context).size.width * 0.04,
|
||||||
@ -210,7 +268,8 @@ class _QuizzConfigState extends State<QuizzConfig> {
|
|||||||
color: kSecond,
|
color: kSecond,
|
||||||
spreadRadius: 0.5,
|
spreadRadius: 0.5,
|
||||||
blurRadius: 5,
|
blurRadius: 5,
|
||||||
offset: Offset(0, 1.5), // changes position of shadow
|
offset: Offset(0,
|
||||||
|
1.5), // changes position of shadow
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -219,12 +278,24 @@ class _QuizzConfigState extends State<QuizzConfig> {
|
|||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Center(child: Text(
|
||||||
|
"Une erreur est survenue lors de la récupération des questions"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<QuestionDTO>?> getQuestions(Client client) async {
|
||||||
|
List<QuestionDTO>? questions = await client.sectionQuizApi!.sectionQuizGetAllQuizQuestionFromSection(widget.initialValue.id!);
|
||||||
|
return questions ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
getElement(int index, QuestionDTO question, Size size, AppContext appContext) {
|
getElement(int index, QuestionDTO question, Size size, AppContext appContext) {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
@ -260,17 +331,31 @@ class _QuizzConfigState extends State<QuizzConfig> {
|
|||||||
message: "Modifier",
|
message: "Modifier",
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
var result = await showNewOrUpdateQuestionQuizz(
|
QuestionDTO? result = await showNewOrUpdateQuestionQuizz(
|
||||||
question,
|
question,
|
||||||
appContext,
|
appContext,
|
||||||
context,
|
context,
|
||||||
"Modifier la question"
|
"Modifier la question"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(result != null)
|
||||||
|
{
|
||||||
|
await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionQuizApi!.sectionQuizUpdate(result);
|
||||||
|
showNotification(kSuccess, kWhite, 'La question a été mis à jour avec succès', context, null);
|
||||||
setState(() {
|
setState(() {
|
||||||
|
// refresh ui
|
||||||
|
print("Refresh UI");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
showNotification(kError, kWhite, 'Une erreur est survenue lors de la mise à jour de la question', context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*setState(() {
|
||||||
quizzDTO.questions![question.order!] = result;
|
quizzDTO.questions![question.order!] = result;
|
||||||
widget.onChanged(quizzDTO);
|
widget.onChanged(quizzDTO);
|
||||||
});
|
});*/
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
@ -286,10 +371,25 @@ class _QuizzConfigState extends State<QuizzConfig> {
|
|||||||
message: "Supprimer",
|
message: "Supprimer",
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
showConfirmationDialog(
|
||||||
|
"Êtes-vous sûr de vouloir supprimer cette question ?",
|
||||||
|
() {},
|
||||||
|
() async {
|
||||||
|
|
||||||
|
try {
|
||||||
|
var questionToRemove = questions[index];
|
||||||
|
(appContext.getContext() as ManagerAppContext).clientAPI!.sectionQuizApi!.sectionQuizDeleteWithHttpInfo(questionToRemove.id!);
|
||||||
|
showNotification(kSuccess, kWhite, 'La question a été supprimée avec succès', context, null);
|
||||||
|
// refresh UI
|
||||||
setState(() {
|
setState(() {
|
||||||
quizzDTO.questions!.removeAt(question.order!);
|
print("Refresh UI");
|
||||||
widget.onChanged(quizzDTO);
|
|
||||||
});
|
});
|
||||||
|
} catch(e) {
|
||||||
|
showNotification(kError, kWhite, 'Une erreur est survenue lors de la suppression de la question', context, null);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
context
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
|||||||
@ -409,7 +409,10 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
|
|
||||||
Future<void> save(bool isTraduction, AppContext appContext) async {
|
Future<void> save(bool isTraduction, AppContext appContext) async {
|
||||||
updateSectionDetail();
|
updateSectionDetail();
|
||||||
SectionDTO? section = await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionUpdate(sectionDetailDTO);
|
|
||||||
|
var sectionResult = await (appContext.getContext() as ManagerAppContext).clientAPI!.sectionApi!.sectionUpdate(sectionDetailDTO);
|
||||||
|
SectionDTO? section = SectionDTO.fromJson(sectionResult);
|
||||||
|
|
||||||
ManagerAppContext managerAppContext = appContext.getContext();
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
managerAppContext.selectedSection = section;
|
managerAppContext.selectedSection = section;
|
||||||
appContext.setContext(managerAppContext);
|
appContext.setContext(managerAppContext);
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import 'package:manager_app/app_context.dart';
|
|||||||
import 'package:manager_app/constants.dart';
|
import 'package:manager_app/constants.dart';
|
||||||
import 'package:manager_api_new/api.dart';
|
import 'package:manager_api_new/api.dart';
|
||||||
|
|
||||||
Future<SectionDTO?> showNewSection(String configurationId, AppContext appContext, BuildContext contextBuild, bool isSubSection, Function? sendSubSection, bool isMobile) {
|
Future<SectionDTO?> showNewSection(String configurationId, AppContext appContext, BuildContext contextBuild, bool isSubSection, bool isMobile) {
|
||||||
SectionDTO sectionDTO = new SectionDTO();
|
SectionDTO sectionDTO = new SectionDTO();
|
||||||
sectionDTO.label = "";
|
sectionDTO.label = "";
|
||||||
sectionDTO.configurationId = configurationId;
|
sectionDTO.configurationId = configurationId;
|
||||||
|
|||||||
@ -147,7 +147,7 @@ class _SectionReorderListState extends State<SectionReorderList> {
|
|||||||
right: 10,
|
right: 10,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
var sectionToCreate = await showNewSection(widget.configurationId, appContext, context, false, null, currentConfiguration.isMobile!);
|
var sectionToCreate = await showNewSection(widget.configurationId, appContext, context, false, currentConfiguration.isMobile!);
|
||||||
if(sectionToCreate != null)
|
if(sectionToCreate != null)
|
||||||
{
|
{
|
||||||
ManagerAppContext managerAppContext = appContext.getContext();
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
|
|||||||
@ -374,7 +374,7 @@ class SectionApi {
|
|||||||
/// Parameters:
|
/// Parameters:
|
||||||
///
|
///
|
||||||
/// * [String] id (required):
|
/// * [String] id (required):
|
||||||
Future<List<Object>?> sectionGetAllSectionSubSections(
|
Future<dynamic> sectionGetAllSectionSubSections(
|
||||||
String id,
|
String id,
|
||||||
) async {
|
) async {
|
||||||
final response = await sectionGetAllSectionSubSectionsWithHttpInfo(
|
final response = await sectionGetAllSectionSubSectionsWithHttpInfo(
|
||||||
@ -388,11 +388,13 @@ class SectionApi {
|
|||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body.isNotEmpty &&
|
if (response.body.isNotEmpty &&
|
||||||
response.statusCode != HttpStatus.noContent) {
|
response.statusCode != HttpStatus.noContent) {
|
||||||
final responseBody = await _decodeBodyBytes(response);
|
/*final responseBody = await _decodeBodyBytes(response);
|
||||||
return (await apiClient.deserializeAsync(responseBody, 'List<Object>')
|
return (await apiClient.deserializeAsync(responseBody, 'List<Object>')
|
||||||
as List)
|
as List)
|
||||||
.cast<Object>()
|
.cast<Object>()
|
||||||
.toList(growable: false);
|
.toList(growable: false);*/
|
||||||
|
final decoded = json.decode(await _decodeBodyBytes(response));
|
||||||
|
return decoded;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -1017,7 +1019,7 @@ class SectionApi {
|
|||||||
/// Parameters:
|
/// Parameters:
|
||||||
///
|
///
|
||||||
/// * [Object] body (required):
|
/// * [Object] body (required):
|
||||||
Future<SectionDTO?> sectionUpdate(
|
Future<Object?> sectionUpdate(
|
||||||
Object body,
|
Object body,
|
||||||
) async {
|
) async {
|
||||||
final response = await sectionUpdateWithHttpInfo(
|
final response = await sectionUpdateWithHttpInfo(
|
||||||
@ -1031,10 +1033,12 @@ class SectionApi {
|
|||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body.isNotEmpty &&
|
if (response.body.isNotEmpty &&
|
||||||
response.statusCode != HttpStatus.noContent) {
|
response.statusCode != HttpStatus.noContent) {
|
||||||
return await apiClient.deserializeAsync(
|
final decoded = json.decode(await _decodeBodyBytes(response));
|
||||||
|
return decoded;
|
||||||
|
/*return await apiClient.deserializeAsync(
|
||||||
await _decodeBodyBytes(response),
|
await _decodeBodyBytes(response),
|
||||||
'SectionDTO',
|
'SectionDTO',
|
||||||
) as SectionDTO;
|
) as SectionDTO*/;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user