1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-12-25 00:11:36 +01:00

Remove customOrder prop

As some options of Select component should be ordered by values or keys,
it was decided to handle sorting not in options, but locally in
corresponding lists.
This commit is contained in:
Aleksandr Gumroian 2022-02-17 13:01:40 +01:00
parent f952e25205
commit 175a07a865
No known key found for this signature in database
GPG Key ID: 9E77849C64F0A733
2 changed files with 5 additions and 12 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2021 CZ.NIC z.s.p.o. (http://www.nic.cz/)
* Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
@ -18,20 +18,14 @@ Select.propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
/** Help text message. */
helpText: PropTypes.string,
/** Turns on/off alphabetical ordering of the Select options. */
customOrder: PropTypes.bool,
};
export function Select({ label, choices, helpText, customOrder, ...props }) {
export function Select({ label, choices, helpText, ...props }) {
const uid = useUID();
const keys = Object.keys(choices);
if (!customOrder) {
keys.sort((a, b) => a - b || a.toString().localeCompare(b.toString()));
}
const options = keys.map((key) => (
<option key={key} value={key}>
{choices[key]}
const options = Object.keys(choices).map((choice) => (
<option key={choice} value={choice}>
{choices[choice]}
</option>
));

View File

@ -209,7 +209,6 @@ function DeviceForm({
[deviceIndex]: { encryption: { $set: value } },
},
}))}
customOrder
{...props}
/>