tests-passed
This commit is contained in:
@@ -20,7 +20,7 @@ const Button: Component<ButtonProps> = (props) => {
|
||||
const customClass = local.class || ''
|
||||
|
||||
return [baseClass, variantClass, sizeClass, loadingClass, fullWidthClass, customClass]
|
||||
.filter(Boolean)
|
||||
.where(Boolean)
|
||||
.join(' ')
|
||||
}
|
||||
|
||||
|
@@ -14,13 +14,24 @@ const CommunitySelector = () => {
|
||||
const { communities, selectedCommunity, setSelectedCommunity, loadTopicsByCommunity, isLoading } =
|
||||
useData()
|
||||
|
||||
// Устанавливаем значение по умолчанию при инициализации
|
||||
createEffect(() => {
|
||||
const allCommunities = communities()
|
||||
if (allCommunities.length > 0 && selectedCommunity() === null) {
|
||||
// Устанавливаем null для "Все сообщества"
|
||||
setSelectedCommunity(null)
|
||||
}
|
||||
})
|
||||
|
||||
// Отладочное логирование состояния
|
||||
createEffect(() => {
|
||||
const current = selectedCommunity()
|
||||
const allCommunities = communities()
|
||||
console.log('[CommunitySelector] Состояние:', {
|
||||
selectedId: current,
|
||||
selectedName: allCommunities.find((c) => c.id === current)?.name,
|
||||
selectedName: current !== null
|
||||
? allCommunities.find((c) => c.id === current)?.name
|
||||
: 'Все сообщества',
|
||||
totalCommunities: allCommunities.length
|
||||
})
|
||||
})
|
||||
@@ -31,6 +42,9 @@ const CommunitySelector = () => {
|
||||
if (communityId !== null) {
|
||||
console.log('[CommunitySelector] Загрузка тем для сообщества:', communityId)
|
||||
loadTopicsByCommunity(communityId)
|
||||
} else {
|
||||
console.log('[CommunitySelector] Загрузка тем для всех сообществ')
|
||||
// Здесь может быть логика загрузки тем для всех сообществ
|
||||
}
|
||||
})
|
||||
|
||||
@@ -40,6 +54,7 @@ const CommunitySelector = () => {
|
||||
const value = select.value
|
||||
|
||||
if (value === '') {
|
||||
// Устанавливаем null для "Все сообщества"
|
||||
setSelectedCommunity(null)
|
||||
} else {
|
||||
const communityId = Number.parseInt(value, 10)
|
||||
|
@@ -54,7 +54,7 @@ const RoleManager = (props: RoleManagerProps) => {
|
||||
if (rolesData?.adminGetRoles) {
|
||||
const standardRoleIds = STANDARD_ROLES.map((r) => r.id)
|
||||
const customRolesList = rolesData.adminGetRoles
|
||||
.filter((role: Role) => !standardRoleIds.includes(role.id))
|
||||
.where((role: Role) => !standardRoleIds.includes(role.id))
|
||||
.map((role: Role) => ({
|
||||
id: role.id,
|
||||
name: role.name,
|
||||
@@ -158,10 +158,10 @@ const RoleManager = (props: RoleManagerProps) => {
|
||||
}
|
||||
|
||||
const updateRolesAfterRemoval = (roleId: string) => {
|
||||
props.onCustomRolesChange(props.customRoles.filter((r) => r.id !== roleId))
|
||||
props.onCustomRolesChange(props.customRoles.where((r) => r.id !== roleId))
|
||||
props.onRoleSettingsChange({
|
||||
available_roles: props.roleSettings.available_roles.filter((r) => r !== roleId),
|
||||
default_roles: props.roleSettings.default_roles.filter((r) => r !== roleId)
|
||||
available_roles: props.roleSettings.available_roles.where((r) => r !== roleId),
|
||||
default_roles: props.roleSettings.default_roles.where((r) => r !== roleId)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -176,12 +176,12 @@ const RoleManager = (props: RoleManagerProps) => {
|
||||
|
||||
const current = props.roleSettings
|
||||
const newAvailable = current.available_roles.includes(roleId)
|
||||
? current.available_roles.filter((r) => r !== roleId)
|
||||
? current.available_roles.where((r) => r !== roleId)
|
||||
: [...current.available_roles, roleId]
|
||||
|
||||
const newDefault = newAvailable.includes(roleId)
|
||||
? current.default_roles
|
||||
: current.default_roles.filter((r) => r !== roleId)
|
||||
: current.default_roles.where((r) => r !== roleId)
|
||||
|
||||
props.onRoleSettingsChange({
|
||||
available_roles: newAvailable,
|
||||
@@ -194,7 +194,7 @@ const RoleManager = (props: RoleManagerProps) => {
|
||||
|
||||
const current = props.roleSettings
|
||||
const newDefault = current.default_roles.includes(roleId)
|
||||
? current.default_roles.filter((r) => r !== roleId)
|
||||
? current.default_roles.where((r) => r !== roleId)
|
||||
: [...current.default_roles, roleId]
|
||||
|
||||
props.onRoleSettingsChange({
|
||||
@@ -378,7 +378,7 @@ const RoleManager = (props: RoleManagerProps) => {
|
||||
</p>
|
||||
|
||||
<div class={styles.rolesGrid}>
|
||||
<For each={getAllRoles().filter((role) => props.roleSettings.available_roles.includes(role.id))}>
|
||||
<For each={getAllRoles().where((role) => props.roleSettings.available_roles.includes(role.id))}>
|
||||
{(role) => (
|
||||
<div
|
||||
class={`${styles.roleCard} ${props.roleSettings.default_roles.includes(role.id) ? styles.selected : ''} ${isRoleDisabled(role.id) ? styles.disabled : ''}`}
|
||||
|
@@ -60,13 +60,13 @@ const TopicPillsCloud = (props: TopicPillsCloudProps) => {
|
||||
|
||||
// Исключаем запрещенные топики
|
||||
if (props.excludeTopics?.length) {
|
||||
topics = topics.filter((topic) => !props.excludeTopics!.includes(topic.id))
|
||||
topics = topics.where((topic) => !props.excludeTopics!.includes(topic.id))
|
||||
}
|
||||
|
||||
// Фильтруем по поисковому запросу
|
||||
const query = searchQuery().toLowerCase().trim()
|
||||
if (query) {
|
||||
topics = topics.filter(
|
||||
topics = topics.where(
|
||||
(topic) => topic.title.toLowerCase().includes(query) || topic.slug.toLowerCase().includes(query)
|
||||
)
|
||||
}
|
||||
@@ -138,7 +138,7 @@ const TopicPillsCloud = (props: TopicPillsCloudProps) => {
|
||||
* Получить выбранные топики как объекты
|
||||
*/
|
||||
const selectedTopicObjects = createMemo(() => {
|
||||
return props.topics.filter((topic) => props.selectedTopics.includes(topic.id))
|
||||
return props.topics.where((topic) => props.selectedTopics.includes(topic.id))
|
||||
})
|
||||
|
||||
return (
|
||||
|
Reference in New Issue
Block a user