remove spaces from vacancy name (#7417)

Signed-off-by: Nikolay Chunosov <Chunosov.N@gmail.com>
This commit is contained in:
Chunosov 2024-12-10 17:47:53 +07:00 committed by GitHub
parent 9421887f01
commit 417a6ac084
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View File

@ -103,7 +103,7 @@
type: typeId as Ref<ProjectType> type: typeId as Ref<ProjectType>
} }
export function canClose (): boolean { export function canClose (): boolean {
return name === '' && typeId !== undefined return name.trim() === '' && typeId !== undefined
} }
const client = getClient() const client = getClient()
@ -185,7 +185,7 @@
const resId: Ref<Issue> = generateId() const resId: Ref<Issue> = generateId()
const identifier = `${project?.identifier}-${number}` const identifier = `${project?.identifier}-${number}`
const data: AttachedData<Issue> = { const data: AttachedData<Issue> = {
title: template.title + ` (${name})`, title: template.title + ` (${name.trim()})`,
description: null, description: null,
assignee: template.assignee, assignee: template.assignee,
component: template.component, component: template.component,
@ -240,7 +240,7 @@
const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true) const incResult = await client.update(sequence, { $inc: { sequence: 1 } }, true)
const data: Data<Vacancy> = { const data: Data<Vacancy> = {
...vacancyData, ...vacancyData,
name, name: name.trim(),
description: template?.shortDescription ?? '', description: template?.shortDescription ?? '',
fullDescription: null, fullDescription: null,
private: false, private: false,
@ -336,7 +336,7 @@
<Card <Card
label={recruit.string.CreateVacancy} label={recruit.string.CreateVacancy}
okAction={createVacancy} okAction={createVacancy}
canSave={!!name} canSave={name.trim() !== ''}
gap={'gapV-4'} gap={'gapV-4'}
on:close={() => { on:close={() => {
dispatch('close') dispatch('close')

View File

@ -101,9 +101,13 @@
const updates: Partial<Data<Vacancy>> = {} const updates: Partial<Data<Vacancy>> = {}
const trimmedName = rawName.trim() const trimmedName = rawName.trim()
const trimmedNameOld = object.name?.trim()
if (trimmedName.length > 0 && trimmedName !== object.name?.trim()) { if (trimmedName.length > 0 && (trimmedName !== trimmedNameOld || trimmedNameOld !== object.name)) {
updates.name = trimmedName updates.name = trimmedName
rawName = trimmedName
} else {
rawName = object.name
} }
if (rawDesc !== object.description) { if (rawDesc !== object.description) {