info on resource item

This commit is contained in:
mr 2025-02-05 12:22:19 +01:00
parent bed48b4cb4
commit 57c6d74ff5
4 changed files with 93 additions and 21 deletions

View File

@ -160,7 +160,7 @@ abstract class AbstractItem<X extends AbstractPricing, Y extends AbstractPartner
String? description;
String? restrictions;
String? shortDescription;
int selectedInstance = -1;
int selectedInstance = 0;
List<AbstractInstance<X,Y>> instances = [];
@ -178,7 +178,7 @@ abstract class AbstractItem<X extends AbstractPricing, Y extends AbstractPartner
this.description,
this.shortDescription,
this.owners = const [],
this.selectedInstance = -1,
this.selectedInstance = 0,
});
void addEnv(List<dynamic> infos) {
@ -263,7 +263,7 @@ abstract class AbstractItem<X extends AbstractPricing, Y extends AbstractPartner
this.owners = json.containsKey("owners") ? fromListJson(json["owners"], Owner()) : [];
this.instances = json.containsKey("instances") ? fromListJson(json["instances"], ex) : [];
this.updatedAt = json.containsKey("update_date") ? DateTime.parse(json["update_date"]) : null;
this.selectedInstance = json.containsKey("selected_instance") ? json["selected_instance"] : -1;
this.selectedInstance = json.containsKey("selected_instance") ? json["selected_instance"] : 0;
this.shortDescription = json.containsKey("short_description") ? json["short_description"] : null;
this.createdAt = json.containsKey("creation_date") ? DateTime.parse(json["creation_date"]) : null;
}

View File

@ -11,7 +11,6 @@ import 'package:oc_front/widgets/inputs/sub_dropdown_input%20.dart';
// ignore: must_be_immutable
class ResourceFormsWidget extends StatefulWidget {
int instanceID = 0;
AbstractItem item;
Dashboard dash;
String elementID;
@ -68,13 +67,13 @@ class ResourceFormsWidgetState extends State<ResourceFormsWidget> {
)));
childrenReadOnly.add(Padding(padding: EdgeInsets.only(bottom: 15), child:
SubDropdownInputWidget( dropdownMenuEntries: dpItems, subkey: "", width: 180, empty: false,
initialValue: "${widget.instanceID}", change: (value) {
if (value != null) { setState(() { widget.instanceID = int.parse(value); }); }
initialValue: "${widget.item.selectedInstance}", change: (value) {
if (value != null) { setState(() { widget.item.selectedInstance = int.parse(value); }); }
},
))
);
if (widget.item.instances.length > widget.instanceID) {
childrenReadOnly.addAll(getWidgets(widget.item.instances[widget.instanceID].infos()));
if (widget.item.instances.length > (widget.item.selectedInstance)) {
childrenReadOnly.addAll(getWidgets(widget.item.instances[(widget.item.selectedInstance)].infos()));
}
}
instancesCat.add(ContainerFormsWidget(dash: widget.dash, item: widget.item, elementID: widget.elementID));

View File

@ -5,6 +5,7 @@ import 'package:oc_front/pages/shared.dart';
class ShallowDropdownInputWidget extends StatefulWidget {
double? width;
double? height;
CollaborativeAreaType type = CollaborativeAreaType.workspace;
Future<List<Shallow>> Function()? all;
Future<void> Function(String)? load;
@ -17,7 +18,7 @@ class ShallowDropdownInputWidget extends StatefulWidget {
Widget? prefixIcon;
IconData? iconLoad;
IconData? iconRemove;
String? label;
String? hint;
String? tooltipLoad;
@ -30,8 +31,8 @@ class ShallowDropdownInputWidget extends StatefulWidget {
bool deletion = false;
ShallowDropdownInputWidget ({ Key? key, this.width, this.current, required this.all, this.prefixIcon,
this.iconLoad, this.iconRemove, this.hint, this.filled, this.hintColor, this.color,
this.tooltipLoad, this.tooltipRemove, this.deletion = false, this.maptoDropdown,
this.iconLoad, this.iconRemove, this.hint, this.filled, this.hintColor, this.color, this.height,
this.tooltipLoad, this.tooltipRemove, this.deletion = false, this.maptoDropdown, this.label,
required this.type, this.canLoad, this.canRemove, this.load, this.remove, this.change }): super(key: key);
@override ShallowDropdownInputWidgetState createState() => ShallowDropdownInputWidgetState();
}
@ -54,11 +55,12 @@ class ShallowDropdownInputWidgetState extends State<ShallowDropdownInputWidget>
data: Theme.of(context).copyWith(
canvasColor: widget.filled ??Colors.white,
),
child: Container( height: 50, width: (widget.width ?? getMainWidth(context)) - (widget.load == null ? 0 : 50) - (widget.remove == null ? 0 : 50),
child: Container( height: widget.height ?? 50,
width: (widget.width ?? getMainWidth(context)) - (widget.load == null ? 0 : 50) - (widget.remove == null ? 0 : 50),
decoration: const BoxDecoration(
color: Colors.white,
),
child: DropdownButtonFormField(
child: Center(child: DropdownButtonFormField(
onChanged: (value) {
setState(() {
widget.current = value;
@ -78,6 +80,8 @@ class ShallowDropdownInputWidgetState extends State<ShallowDropdownInputWidget>
),
decoration: InputDecoration(
filled: true,
label: widget.label == null ? null : Text(widget.label!),
alignLabelWithHint: false,
prefixIconColor: Colors.grey,
prefixIcon: widget.prefixIcon,
suffixIconColor: widget.hintColor ?? Colors.grey ,
@ -88,7 +92,7 @@ class ShallowDropdownInputWidgetState extends State<ShallowDropdownInputWidget>
contentPadding: EdgeInsets.only(left: (widget.width ?? 400) < 200 ? 0 : 30, right: (widget.width ?? 400) < 200 ? 0 : 30, top: 18, bottom: 18),
),
items: items,
)))),
))))),
widget.load == null ? Container() : Tooltip(
message: widget.tooltipLoad ?? "load $t",
child:InkWell(

View File

@ -1,6 +1,10 @@
import 'package:oc_front/main.dart';
import 'package:flutter/material.dart';
import 'package:oc_front/models/resources/resources.dart';
import 'package:oc_front/models/response.dart';
import 'package:oc_front/pages/shared.dart';
import 'package:oc_front/widgets/inputs/shallow_dropdown_input.dart';
import 'package:oc_front/widgets/inputs/sub_dropdown_input%20.dart';
// ignore: must_be_immutable
class ItemWidget extends StatefulWidget {
@ -10,21 +14,86 @@ class ItemWidget extends StatefulWidget {
}
class ItemWidgetState extends State<ItemWidget> {
@override Widget build(BuildContext context) {
Widget w = Container();
List<Widget> widgets = [
Container( margin: EdgeInsets.only(bottom: 20),
decoration: BoxDecoration(border: Border(bottom: BorderSide(color: midColor))),
width: getMainWidth(context) / 2,
child: Center(child: Padding( padding: EdgeInsets.only(bottom: 20),
child: Text("RESOURCE INFORMATIONS", style: TextStyle(fontSize: 18, color: Colors.grey, fontWeight: FontWeight.w500)))))
];
var infos = widget.item.infos();
var count = 0;
for (var info in infos.keys) {
count++;
widgets.add(Padding( padding: EdgeInsets.symmetric(vertical: 5), child : Row(children: [
Padding( padding: EdgeInsets.only(left: 50, right: 10), child : Text("${info.toUpperCase().replaceAll("_", " ")} :", style: TextStyle(fontSize: 15, color: Colors.grey))),
Text("${infos[info] is bool ? (infos[info] == true ? "yes" : "no") : infos[info] ?? "unknown"}",
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 15, color: Colors.black, fontWeight: FontWeight.w500))
])));
}
if (count == 0 ) {
widgets.add(Center(child: Padding( padding: EdgeInsets.symmetric(vertical: 5), child : Row(children: [
Padding( padding: EdgeInsets.only(left: 50, right: 10), child : Text("NO INFORMATION", style: TextStyle(fontSize: 15, color: Colors.grey))),
]))));
}
List<Widget> widgetsInstance = [];
List<Shallow> dpItems = [];
for (var (i, instance) in widget.item.instances.indexed) {
dpItems.add(Shallow(id: "$i", name: instance.name ?? ""));
}
if (dpItems.isNotEmpty) {
widgetsInstance.add(Center( child: Padding(padding: EdgeInsets.only(bottom: 15), child:
ShallowDropdownInputWidget( all: () async => dpItems, width: (getWidth(context) / 2) - 25,
label: "instances", type: CollaborativeAreaType.resource, height: 65,
current: "${widget.item.selectedInstance}", change: (value) {
if (value != null) { setState(() { widget.item.selectedInstance = int.parse(value); }); }
},
))
));
}
if (widget.item.instances.length > widget.item.selectedInstance) {
var instance = widget.item.instances[widget.item.selectedInstance];
widgetsInstance.add(Container(height: 20, width: getWidth(context) / 2,));
var count = 0;
for (var info in instance.infos().keys) {
if (instance.infos()[info] == null || instance.infos()[info] is List) { continue; }
count++;
widgetsInstance.add(Center(child: Padding( padding: EdgeInsets.symmetric(vertical: 5), child : Row(children: [
Padding( padding: EdgeInsets.only(left: 50, right: 10), child : Text("${info.toUpperCase().replaceAll("_", " ")} :", style: TextStyle(fontSize: 15, color: Colors.grey))),
Text("${instance.infos()[info] is bool ? (instance.infos()[info] == true ? "yes" : "no") : instance.infos()[info] ?? "unknown"}",
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 15, color: Colors.black, fontWeight: FontWeight.w500))
]))));
}
if (count == 0 ) {
widgetsInstance.add(Padding( padding: EdgeInsets.symmetric(vertical: 5), child : Row(children: [
Padding( padding: EdgeInsets.only(left: 50, right: 10), child : Text("NO INSTANCE INFORMATION", style: TextStyle(fontSize: 15, color: Colors.grey))),
])));
}
}
Widget w = Column( mainAxisSize: MainAxisSize.max, children: widgets );
Widget w2 = Column( mainAxisSize: MainAxisSize.max, children: widgetsInstance );
return SizedBox(
height: getHeight(context) - 300,
height: getHeight(context) - 200,
child: SingleChildScrollView(
child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [
widget.item.description == null ? Container() : Container(
width: getMainWidth(context),
alignment: Alignment.center,
height: 100,
decoration: BoxDecoration(border: Border(bottom: BorderSide(color: midColor))),
padding: const EdgeInsets.all(30),
child: Text(widget.item.description!,
padding: const EdgeInsets.symmetric(vertical: 30, horizontal: 50),
child: Text(widget.item.description!.length > 350 ? "${widget.item.description!.substring(0, 347)}..." : widget.item.description!,
style: TextStyle(fontSize: 15, color: Colors.grey, fontWeight: FontWeight.w500))),
Container(padding: const EdgeInsets.all(30),
alignment: Alignment.topLeft,
color: midColor, width: getMainWidth(context) / 2, child: w)
Row( children: [
Container(padding: const EdgeInsets.symmetric(vertical: 20),
height: getHeight(context) - 300,
decoration: BoxDecoration(border: Border(right: BorderSide(color: midColor))),
alignment: Alignment.topLeft, width: getMainWidth(context) / 2, child: w),
Container(height: getHeight(context) - 300,
alignment: Alignment.topRight, width: getMainWidth(context) / 2, child: w2)
])
]
)
)