fix: projects editor to selected project editor, moved attributes editor

This commit is contained in:
2025-03-02 16:49:28 +04:00
parent 17e6c5f23a
commit e151e4bc5e
44 changed files with 476 additions and 512 deletions

View File

@@ -0,0 +1,23 @@
import { formatDate, formatDateTime } from "../../../../../types/utils.ts";
const defaultValueToStr = (defaultValue: string | null | number | boolean, type: string): string => {
if (defaultValue === null) {
return "Значения по умолчанию нет";
}
let strValue;
const prefix = "Значение по умолчанию: ";
if (type === "bool") {
strValue = defaultValue ? "true" : "false";
} else if (type === "datetime") {
strValue = formatDateTime(defaultValue as string);
} else if (type === "date") {
strValue = formatDate(defaultValue as string);
} else {
strValue = String(defaultValue);
}
return prefix + strValue;
};
export default defaultValueToStr;

View File

@@ -0,0 +1,6 @@
const eqSet = (firstSet: Set<number>, secondSet: Set<number>) =>
firstSet.size === secondSet.size &&
[...firstSet].every((x) => secondSet.has(x));
export default eqSet;

View File

@@ -0,0 +1,25 @@
const translitMap: Record<string, string> = {
'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'yo',
'ж': 'zh', 'з': 'z', 'и': 'i', 'й': 'y', 'к': 'k', 'л': 'l', 'м': 'm',
'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u',
'ф': 'f', 'х': 'kh', 'ц': 'ts', 'ч': 'ch', 'ш': 'sh', 'щ': 'shch', 'ъ': '',
'ы': 'y', 'ь': '', 'э': 'e', 'ю': 'yu', 'я': 'ya',
};
const transliterate = (text: string): string => {
return text.toLowerCase().split('').map(char => translitMap[char] || char).join('');
};
const toSnakeCase = (text: string): string => {
return text
.toLowerCase()
.replace(/\s+/g, '_') // Replace spaces with underscores
.replace(/[^a-z_0-9]/g, '') // Remove non-English letters and special chars
.replace(/__+/g, '_') // Replace multiple underscores with single one
.replace(/^_+|_+$/g, ''); // Trim leading/trailing underscores
};
export const convertRussianToSnakeCase = (input: string): string => {
const transliterated = transliterate(input);
return toSnakeCase(transliterated);
};