Hello, I have a problem with the color setting of "RED.nodes.registerType". Node-RED 1.3.5
I am using an asynchronous function to load the default settings, if I harden the settings I don't have the problem.
Also, please try to format code samples properly as it makes them easier to read and ensures the forum software doesn't modify the output. Either use the </> button in the toolbar, or wrap your code blocks with ```. Thanks!
Thank you for your message. I will put two sample code. One for which the "color" attribute is taken into account and the other is not.
Code for which the color attribute is not taken into account, the "defaults" attribute takes for value a collection generated dynamically from an asychronous function :
async function recupEmplacements(){
var promiseListe = $.getJSON("emplacements", (emplacements) => {})
var liste = promiseListe.then()
return liste
}
async function initialisationChamps(){
tabEmplacements = await recupEmplacements()
const initChamps = {
code: { value: "", required: true },
name: { value: "" },
keywords: { value: [{ v: "" }], required: true },
service: { value: "" }
}
for(element in tabEmplacements){
initChamps['emplacement-'+(tabEmplacements[element].qualifiedName).toLowerCase().replace(" ", "_")] = {value:false}
}
return initChamps
}
async function chargeTabDefaultParam() {
let tabDefaultParam = await initialisationChamps()
initEntreeProcedure(tabDefaultParam)
}
function initEntreeProcedure(tabDefaultParam) {
RED.nodes.registerType('entrée-procédure', {
icon: "entry.svg",
category: 'Opérateur Augmenté',
defaults: tabDefaultParam,
inputs: 0,
outputs: 1,
color: "#9acd32"
})
Code with the "defaults" attribute having for value a hard code. Here, the "color" attribute is taken into account.