updates for asset registration
This commit is contained in:
@@ -221,12 +221,51 @@
|
||||
}
|
||||
},
|
||||
"assetRegistration": {
|
||||
"default": {
|
||||
"profileId": 1,
|
||||
"locationId": 1,
|
||||
"processId": 1,
|
||||
"status": "actief",
|
||||
"childAssets": []
|
||||
},
|
||||
"rules": {
|
||||
"type": "object",
|
||||
"schema": {
|
||||
"profileId": {
|
||||
"default": 1,
|
||||
"rules": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"locationId": {
|
||||
"default": 1,
|
||||
"rules": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"processId": {
|
||||
"default": 1,
|
||||
"rules": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"status": {
|
||||
"default": "actief",
|
||||
"rules": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"childAssets": {
|
||||
"default": [],
|
||||
"rules": {
|
||||
"type": "array",
|
||||
"itemType": "string",
|
||||
"minLength": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"scaling": {
|
||||
"enabled": {
|
||||
"default": false,
|
||||
|
||||
@@ -459,6 +459,10 @@ class AssetMenu {
|
||||
const normalized = tag ? tag.toString() : '';
|
||||
const input = document.getElementById('node-input-assetTagNumber');
|
||||
const hint = document.getElementById('node-input-assetTagNumber-hint');
|
||||
console.info('[AssetMenu] tag number update', {
|
||||
nodeId: node && node.id ? node.id : null,
|
||||
tag: normalized
|
||||
});
|
||||
if (input) {
|
||||
input.value = normalized;
|
||||
}
|
||||
@@ -475,8 +479,14 @@ class AssetMenu {
|
||||
const candidateTag = tagInput && tagInput.value ? tagInput.value.trim() : '';
|
||||
const fallbackTag = node && node.assetTagNumber ? node.assetTagNumber : '';
|
||||
const registrationDefaults =
|
||||
(window.EVOLV.nodes.${nodeName}.config && window.EVOLV.nodes.${nodeName}.config.assetRegistration) || {};
|
||||
(window.EVOLV.nodes.${nodeName}.config && window.EVOLV.nodes.${nodeName}.config.assetRegistration && window.EVOLV.nodes.${nodeName}.config.assetRegistration.default) || {};
|
||||
const displayName = node && node.name ? node.name : node && node.id ? node.id : '${nodeName}';
|
||||
console.info('[AssetMenu] build sync payload', {
|
||||
nodeId: node && node.id ? node.id : null,
|
||||
candidateTag,
|
||||
fallbackTag,
|
||||
status: registrationDefaults.status || 'actief'
|
||||
});
|
||||
return {
|
||||
asset: {
|
||||
tagNumber: candidateTag || fallbackTag,
|
||||
@@ -501,6 +511,11 @@ class AssetMenu {
|
||||
const trimmedRoot = adminRoot && adminRoot.endsWith('/') ? adminRoot.slice(0, -1) : adminRoot || '';
|
||||
const prefix = trimmedRoot || '';
|
||||
const endpoint = (prefix || '') + '/${nodeName}/asset-reg';
|
||||
console.info('[AssetMenu] sync request', {
|
||||
endpoint,
|
||||
nodeId: node && node.id ? node.id : null,
|
||||
tagNumber: payload && payload.asset ? payload.asset.tagNumber : null
|
||||
});
|
||||
fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -513,6 +528,7 @@ class AssetMenu {
|
||||
})
|
||||
)
|
||||
.then((result) => {
|
||||
console.info('[AssetMenu] sync response', result);
|
||||
if (result && result.success) {
|
||||
const newTag = (result.data && result.data.asset_tag_number) || payload.asset.tagNumber || '';
|
||||
this.setAssetTagNumber(node, newTag);
|
||||
|
||||
Reference in New Issue
Block a user