bfg-common 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -327,8 +327,8 @@ const onChangeNameAndNext = (name: string, node: UI_I_TreeNode): void => {
|
|
|
327
327
|
'id',
|
|
328
328
|
'parent'
|
|
329
329
|
)
|
|
330
|
-
vmForm.value.dataCenter = node
|
|
331
|
-
vmFormCash.value.dataCenterId =
|
|
330
|
+
vmForm.value.dataCenter = $recursion.findParentByValue(node, 'datacenter', 'type', 'parent')
|
|
331
|
+
vmFormCash.value.dataCenterId = vmForm.value.dataCenter?.id || null
|
|
332
332
|
onNext(true)
|
|
333
333
|
}
|
|
334
334
|
// Для сферы
|
package/package.json
CHANGED
package/plugins/recursion.ts
CHANGED
|
@@ -204,6 +204,21 @@ export default defineNuxtPlugin(() => {
|
|
|
204
204
|
return (parentPath ? `${parentPath}/` : '') + node[valueProp]
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
+
self.findParentByValue = (
|
|
208
|
+
node: any,
|
|
209
|
+
value: any,
|
|
210
|
+
valueProp: string,
|
|
211
|
+
parentProp: string
|
|
212
|
+
): any | null => {
|
|
213
|
+
if (!node) return null
|
|
214
|
+
|
|
215
|
+
if (node[valueProp] === value) return node
|
|
216
|
+
const parent = node[parentProp]
|
|
217
|
+
if (parent) return self.findParentByValue(parent, value, valueProp, parentProp)
|
|
218
|
+
|
|
219
|
+
return null
|
|
220
|
+
}
|
|
221
|
+
|
|
207
222
|
return self
|
|
208
223
|
}.call({})
|
|
209
224
|
|