From e11818dd946efb15e74d60e1718f509560f265c6 Mon Sep 17 00:00:00 2001 From: Aliaksei Date: Thu, 28 Sep 2023 17:13:52 +0200 Subject: [PATCH] #3372 - Update customQuery for bonds using topology (#3374) --- .../modal/components/toolbox/Bond/Bond.tsx | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Bond/Bond.tsx b/packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Bond/Bond.tsx index 9309f73ff6..21725236d9 100644 --- a/packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Bond/Bond.tsx +++ b/packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Bond/Bond.tsx @@ -149,23 +149,31 @@ function customQueryValid(customQuery: string, isCustomQuery: boolean) { function getBondCustomQuery(bond: BondSettings) { let queryAttrsText = ''; const { type, topology } = bond; - const bondType = { - single: '-', - double: '=', - triple: '#', - aromatic: ':', - any: '~', - up: '/', - down: '\\', + const patterns = { + bondType: { + single: '-', + double: '=', + triple: '#', + aromatic: ':', + any: '~', + up: '/', + down: '\\', + }, + topology: { + [CoreBond.PATTERN.TOPOLOGY.RING]: '@', + [CoreBond.PATTERN.TOPOLOGY.CHAIN]: '!@', + }, }; - if (type in bondType) { - queryAttrsText += bondType[type]; - } - if (queryAttrsText) { - queryAttrsText += ';'; + + if (type in patterns.bondType) { + queryAttrsText += patterns.bondType[type]; } - if (topology === CoreBond.PATTERN.TOPOLOGY.RING) { - queryAttrsText += '@'; + + if (topology && topology in patterns.topology) { + if (queryAttrsText) { + queryAttrsText += ';'; + } + queryAttrsText += patterns.topology[topology]; } return queryAttrsText; }