Skip to content

Commit

Permalink
Trim and ignore case
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <[email protected]>
  • Loading branch information
haiodo committed Apr 4, 2023
1 parent edc8cbf commit ca517b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions packages/presentation/src/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ export class StatusMiddleware extends BasePresentationMiddleware implements Pres
const s = mgr.byId.get(sid)
if (s !== undefined) {
const statuses = mgr.statuses.filter(
(it) => it.ofAttribute === attr._id && it.name === s.name && it._id !== s._id
(it) =>
it.ofAttribute === attr._id &&
it.name.toLowerCase().trim() === s.name.toLowerCase().trim() &&
it._id !== s._id
)
if (statuses !== undefined) {
target.push(...statuses.map((it) => it._id))
Expand Down Expand Up @@ -270,7 +273,7 @@ export class StatusMiddleware extends BasePresentationMiddleware implements Pres
ret = (a.$lookup?.category?.order ?? 0) - (b.$lookup?.category?.order ?? 0)
}
if (ret === 0) {
if (a.name === b.name) {
if (a.name.toLowerCase().trim() === b.name.toLowerCase().trim()) {
return 0
}
ret = a.rank.localeCompare(b.rank)
Expand Down
6 changes: 3 additions & 3 deletions plugins/view-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,18 +614,18 @@ export async function groupByStatusCategories (
for (const v of categories) {
const status = mgr.byId.get(v)
if (status !== undefined) {
let fst = statusMap.get(status.name)
let fst = statusMap.get(status.name.toLowerCase().trim())
if (fst === undefined) {
const statuses = mgr.statuses
.filter(
(it) =>
it.ofAttribute === status.ofAttribute &&
it.name === status.name &&
it.name.toLowerCase().trim() === status.name.toLowerCase().trim() &&
(categories.includes(it._id) || it.space === status.space)
)
.sort((a, b) => a.rank.localeCompare(b.rank))
fst = new StatusValue(status.name, status.color, statuses)
statusMap.set(status.name, fst)
statusMap.set(status.name.toLowerCase().trim(), fst)
existingCategories.push(fst)
}
}
Expand Down

0 comments on commit ca517b7

Please sign in to comment.