info on resource item
This commit is contained in:
parent
bed48b4cb4
commit
57c6d74ff5
@ -160,7 +160,7 @@ abstract class AbstractItem<X extends AbstractPricing, Y extends AbstractPartner
|
|||||||
String? description;
|
String? description;
|
||||||
String? restrictions;
|
String? restrictions;
|
||||||
String? shortDescription;
|
String? shortDescription;
|
||||||
int selectedInstance = -1;
|
int selectedInstance = 0;
|
||||||
|
|
||||||
List<AbstractInstance<X,Y>> instances = [];
|
List<AbstractInstance<X,Y>> instances = [];
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ abstract class AbstractItem<X extends AbstractPricing, Y extends AbstractPartner
|
|||||||
this.description,
|
this.description,
|
||||||
this.shortDescription,
|
this.shortDescription,
|
||||||
this.owners = const [],
|
this.owners = const [],
|
||||||
this.selectedInstance = -1,
|
this.selectedInstance = 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
void addEnv(List<dynamic> infos) {
|
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.owners = json.containsKey("owners") ? fromListJson(json["owners"], Owner()) : [];
|
||||||
this.instances = json.containsKey("instances") ? fromListJson(json["instances"], ex) : [];
|
this.instances = json.containsKey("instances") ? fromListJson(json["instances"], ex) : [];
|
||||||
this.updatedAt = json.containsKey("update_date") ? DateTime.parse(json["update_date"]) : null;
|
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.shortDescription = json.containsKey("short_description") ? json["short_description"] : null;
|
||||||
this.createdAt = json.containsKey("creation_date") ? DateTime.parse(json["creation_date"]) : null;
|
this.createdAt = json.containsKey("creation_date") ? DateTime.parse(json["creation_date"]) : null;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import 'package:oc_front/widgets/inputs/sub_dropdown_input%20.dart';
|
|||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class ResourceFormsWidget extends StatefulWidget {
|
class ResourceFormsWidget extends StatefulWidget {
|
||||||
int instanceID = 0;
|
|
||||||
AbstractItem item;
|
AbstractItem item;
|
||||||
Dashboard dash;
|
Dashboard dash;
|
||||||
String elementID;
|
String elementID;
|
||||||
@ -68,13 +67,13 @@ class ResourceFormsWidgetState extends State<ResourceFormsWidget> {
|
|||||||
)));
|
)));
|
||||||
childrenReadOnly.add(Padding(padding: EdgeInsets.only(bottom: 15), child:
|
childrenReadOnly.add(Padding(padding: EdgeInsets.only(bottom: 15), child:
|
||||||
SubDropdownInputWidget( dropdownMenuEntries: dpItems, subkey: "", width: 180, empty: false,
|
SubDropdownInputWidget( dropdownMenuEntries: dpItems, subkey: "", width: 180, empty: false,
|
||||||
initialValue: "${widget.instanceID}", change: (value) {
|
initialValue: "${widget.item.selectedInstance}", change: (value) {
|
||||||
if (value != null) { setState(() { widget.instanceID = int.parse(value); }); }
|
if (value != null) { setState(() { widget.item.selectedInstance = int.parse(value); }); }
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
if (widget.item.instances.length > widget.instanceID) {
|
if (widget.item.instances.length > (widget.item.selectedInstance)) {
|
||||||
childrenReadOnly.addAll(getWidgets(widget.item.instances[widget.instanceID].infos()));
|
childrenReadOnly.addAll(getWidgets(widget.item.instances[(widget.item.selectedInstance)].infos()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
instancesCat.add(ContainerFormsWidget(dash: widget.dash, item: widget.item, elementID: widget.elementID));
|
instancesCat.add(ContainerFormsWidget(dash: widget.dash, item: widget.item, elementID: widget.elementID));
|
||||||
|
@ -5,6 +5,7 @@ import 'package:oc_front/pages/shared.dart';
|
|||||||
|
|
||||||
class ShallowDropdownInputWidget extends StatefulWidget {
|
class ShallowDropdownInputWidget extends StatefulWidget {
|
||||||
double? width;
|
double? width;
|
||||||
|
double? height;
|
||||||
CollaborativeAreaType type = CollaborativeAreaType.workspace;
|
CollaborativeAreaType type = CollaborativeAreaType.workspace;
|
||||||
Future<List<Shallow>> Function()? all;
|
Future<List<Shallow>> Function()? all;
|
||||||
Future<void> Function(String)? load;
|
Future<void> Function(String)? load;
|
||||||
@ -17,7 +18,7 @@ class ShallowDropdownInputWidget extends StatefulWidget {
|
|||||||
Widget? prefixIcon;
|
Widget? prefixIcon;
|
||||||
IconData? iconLoad;
|
IconData? iconLoad;
|
||||||
IconData? iconRemove;
|
IconData? iconRemove;
|
||||||
|
String? label;
|
||||||
String? hint;
|
String? hint;
|
||||||
|
|
||||||
String? tooltipLoad;
|
String? tooltipLoad;
|
||||||
@ -30,8 +31,8 @@ class ShallowDropdownInputWidget extends StatefulWidget {
|
|||||||
bool deletion = false;
|
bool deletion = false;
|
||||||
|
|
||||||
ShallowDropdownInputWidget ({ Key? key, this.width, this.current, required this.all, this.prefixIcon,
|
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.iconLoad, this.iconRemove, this.hint, this.filled, this.hintColor, this.color, this.height,
|
||||||
this.tooltipLoad, this.tooltipRemove, this.deletion = false, this.maptoDropdown,
|
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);
|
required this.type, this.canLoad, this.canRemove, this.load, this.remove, this.change }): super(key: key);
|
||||||
@override ShallowDropdownInputWidgetState createState() => ShallowDropdownInputWidgetState();
|
@override ShallowDropdownInputWidgetState createState() => ShallowDropdownInputWidgetState();
|
||||||
}
|
}
|
||||||
@ -54,11 +55,12 @@ class ShallowDropdownInputWidgetState extends State<ShallowDropdownInputWidget>
|
|||||||
data: Theme.of(context).copyWith(
|
data: Theme.of(context).copyWith(
|
||||||
canvasColor: widget.filled ??Colors.white,
|
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(
|
decoration: const BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
child: DropdownButtonFormField(
|
child: Center(child: DropdownButtonFormField(
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
widget.current = value;
|
widget.current = value;
|
||||||
@ -78,6 +80,8 @@ class ShallowDropdownInputWidgetState extends State<ShallowDropdownInputWidget>
|
|||||||
),
|
),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
filled: true,
|
filled: true,
|
||||||
|
label: widget.label == null ? null : Text(widget.label!),
|
||||||
|
alignLabelWithHint: false,
|
||||||
prefixIconColor: Colors.grey,
|
prefixIconColor: Colors.grey,
|
||||||
prefixIcon: widget.prefixIcon,
|
prefixIcon: widget.prefixIcon,
|
||||||
suffixIconColor: widget.hintColor ?? Colors.grey ,
|
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),
|
contentPadding: EdgeInsets.only(left: (widget.width ?? 400) < 200 ? 0 : 30, right: (widget.width ?? 400) < 200 ? 0 : 30, top: 18, bottom: 18),
|
||||||
),
|
),
|
||||||
items: items,
|
items: items,
|
||||||
)))),
|
))))),
|
||||||
widget.load == null ? Container() : Tooltip(
|
widget.load == null ? Container() : Tooltip(
|
||||||
message: widget.tooltipLoad ?? "load $t",
|
message: widget.tooltipLoad ?? "load $t",
|
||||||
child:InkWell(
|
child:InkWell(
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
import 'package:oc_front/main.dart';
|
import 'package:oc_front/main.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:oc_front/models/resources/resources.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
|
// ignore: must_be_immutable
|
||||||
class ItemWidget extends StatefulWidget {
|
class ItemWidget extends StatefulWidget {
|
||||||
@ -10,21 +14,86 @@ class ItemWidget extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
class ItemWidgetState extends State<ItemWidget> {
|
class ItemWidgetState extends State<ItemWidget> {
|
||||||
@override Widget build(BuildContext context) {
|
@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(
|
return SizedBox(
|
||||||
height: getHeight(context) - 300,
|
height: getHeight(context) - 200,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [
|
child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
widget.item.description == null ? Container() : Container(
|
widget.item.description == null ? Container() : Container(
|
||||||
width: getMainWidth(context),
|
width: getMainWidth(context),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
|
height: 100,
|
||||||
decoration: BoxDecoration(border: Border(bottom: BorderSide(color: midColor))),
|
decoration: BoxDecoration(border: Border(bottom: BorderSide(color: midColor))),
|
||||||
padding: const EdgeInsets.all(30),
|
padding: const EdgeInsets.symmetric(vertical: 30, horizontal: 50),
|
||||||
child: Text(widget.item.description!,
|
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))),
|
style: TextStyle(fontSize: 15, color: Colors.grey, fontWeight: FontWeight.w500))),
|
||||||
Container(padding: const EdgeInsets.all(30),
|
Row( children: [
|
||||||
alignment: Alignment.topLeft,
|
Container(padding: const EdgeInsets.symmetric(vertical: 20),
|
||||||
color: midColor, width: getMainWidth(context) / 2, child: w)
|
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)
|
||||||
|
])
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user