- implemented displaying table based submitted data related to criterion;

This commit is contained in:
Vitalii Kiiko
2024-11-09 11:29:57 +01:00
parent 137e48e60b
commit cff391ae9c
2 changed files with 36 additions and 10 deletions

View File

@@ -16,7 +16,7 @@
flex-direction: column; flex-direction: column;
gap: 7px; gap: 7px;
padding: 10px; padding: 10px;
background-color: #efefef; background-color: #f5f5f5;
font-size: 14px; font-size: 14px;
ul { ul {
@@ -28,4 +28,14 @@
color: var(--global-textColor); color: var(--global-textColor);
} }
} }
table, th, td {
border: 1px solid var(--table-border-color);
border-collapse: collapse;
text-align: left;
}
th, td {
padding: 3px;
}
} }

View File

@@ -196,15 +196,31 @@ const DomandaEditPreInstructor = () => {
} }
const criteriaDataItem = (item) => { const criteriaDataItem = (item) => {
const content = is(String, item.fieldValue) let content = '';
? item.fieldValue
: item.fieldValue && item.fieldValue.length if (is(String, item.fieldValue)) {
? <ul> content = item.fieldValue;
} else if (item.fieldValue && item.fieldValue.length && !isNil(item.fieldValue[0].filePath)) {
content = <ul>
{item.fieldValue.map(o => <li key={o.id}> {item.fieldValue.map(o => <li key={o.id}>
{o.filePath ? <a href={o.filePath}>{o.name}</a> : null} {o.filePath ? <a href={o.filePath}>{o.name}</a> : null}
</li>)} </li>)}
</ul> </ul>;
: null; } else if (item.fieldValue && item.fieldValue.length && isNil(item.fieldValue[0].filePath)) {
const th = Object.keys(item.fieldValue[0]);
content = <table>
<thead>
<tr>
{th.map(v => <th key={v}>{v}</th>)}
</tr>
</thead>
<tbody>
{item.fieldValue.map((o, i) => <tr key={i}>
{Object.values(o).map(v => <td key={v}>{v}</td>)}
</tr>)}
</tbody>
</table>;
}
return <div key={item.id} className="criterionRelatedData__item"> return <div key={item.id} className="criterionRelatedData__item">
<strong>{item.fieldLabel}</strong> <strong>{item.fieldLabel}</strong>