From a316762ad373f8681c5199eee5518b6207ec8fb3 Mon Sep 17 00:00:00 2001 From: OkunElya Date: Fri, 3 Apr 2026 11:43:17 +1000 Subject: [PATCH] sorting list creation draft done --- site/src/components/Sorting.jsx | 73 ++++++++++++++++++++++++++++++++ site/src/components/Table.jsx | 7 ++- site/src/components/TableRow.jsx | 2 +- 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 site/src/components/Sorting.jsx diff --git a/site/src/components/Sorting.jsx b/site/src/components/Sorting.jsx new file mode 100644 index 0000000..7f15661 --- /dev/null +++ b/site/src/components/Sorting.jsx @@ -0,0 +1,73 @@ +import { useState } from "react"; + +const SortLevel = (props) => { + return ( + <> + + reversed? +
+ + ) +} + + +const Sorting = (props) => { + const [selections, updateSelections] = useState([-1]); + const updateOption = (x, id) => { + + selections[id] = x; + + let unusedOptions = [...selections]; + let selectionsUpdate = selections.map((x, i, arr) => { + if (i < id) { + unusedOptions.filter((v) => v != x); + return x; + } + + if (x != -1 && arr.indexOf(x) != i) { + return unusedOptions[0]; + } + return x + }) + + selectionsUpdate = selectionsUpdate.filter((x, i) => x != -1); + + if (selectionsUpdate.length == 0 || selectionsUpdate[selectionsUpdate.length - 1] != -1) { + selectionsUpdate.push(-1) + } + console.log(selectionsUpdate) + updateSelections(selectionsUpdate); + + + } + const array = props.array; + const keys = props.keys; + + + + + return ( + <> + { + selections.map((x, i, arr) => { + let curenSelectiontArr = keys.filter((selection) => !arr.slice(0, i).includes(keys.indexOf(selection))) + const upadteOptionWrap = (event) => { + console.log(event) + updateOption(Number(event.target.value) - 1, i) + }; + + return + }) + + } + + ) +} + + +export default Sorting; \ No newline at end of file diff --git a/site/src/components/Table.jsx b/site/src/components/Table.jsx index 456163e..c9d949b 100644 --- a/site/src/components/Table.jsx +++ b/site/src/components/Table.jsx @@ -2,6 +2,7 @@ import { useState } from "react"; import TableHead from './TableHead.jsx'; import TableBody from './TableBody.jsx'; import Filter from './Filter.jsx'; +import Sorting from './Sorting.jsx'; /* компонент, выводящий на страницу таблицу с пагинацией @@ -27,7 +28,7 @@ const Table = (props) => { //формируем совокупность span с номерами страниц const pages = arr.map((item, index) => - {item} + {item} ); return ( @@ -35,6 +36,10 @@ const Table = (props) => {

Filters

+ +

Sort by

+ + diff --git a/site/src/components/TableRow.jsx b/site/src/components/TableRow.jsx index 2446adf..567a60c 100644 --- a/site/src/components/TableRow.jsx +++ b/site/src/components/TableRow.jsx @@ -12,7 +12,7 @@ const TableRow = (props) => { : props.row.map((item, index) => ); return( - <> {cells} + <>{cells} ) }
{item}