/* * QQQ - Low-code Application Framework for Engineers. * Copyright (C) 2021-2022. Kingsrook, LLC * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States * contact@kingsrook.com * https://github.com/Kingsrook/ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData"; import {QWidgetMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QWidgetMetaData"; import {QRecord} from "@kingsrook/qqq-frontend-core/lib/model/QRecord"; import {Skeleton} from "@mui/material"; import Box from "@mui/material/Box"; import Icon from "@mui/material/Icon"; import Typography from "@mui/material/Typography"; import React from "react"; import Widget from "qqq/components/widgets/Widget"; import ValueUtils from "qqq/utils/qqq/ValueUtils"; interface Props { widgetMetaData: QWidgetMetaData; data: any; reloadWidgetCallback?: (params: string) => void; } FieldValueListWidget.defaultProps = {}; function FieldValueListWidget({widgetMetaData, data, reloadWidgetCallback}: Props): JSX.Element { if(data?.dropdownNeedsSelectedText) { return (
); } if(!data.fields || !data.record) { const skeletons = [75, 50, 90]; return ( {skeletons.map((s) => ( )) } ); } const fields = data.fields.map((f: any) => new QFieldMetaData(f)); const record = new QRecord(data.record); const fieldLabelPrefixIconNames = data.fieldLabelPrefixIconNames ?? {}; const fieldLabelPrefixIconColors = data.fieldLabelPrefixIconColors ?? {}; const fieldIndentLevels = data.fieldIndentLevels ?? {}; return ( { fields.map((field: QFieldMetaData, index: number) => ( { fieldLabelPrefixIconNames[field.name] && {fieldLabelPrefixIconNames[field.name]} } { field.label && {field.label}: } {ValueUtils.getDisplayValue(field, record, "view")} )) } ); } export default FieldValueListWidget;