Color setting RED.nodes.registerType doesn't work

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.

RED.nodes.registerType('entrée-procédure', {
      color: "#00a700",
      icon: "entry.svg",
      category: 'Opérateur Augmenté',
      defaults: tabDefaultParam,
})

The color is "#ddd" instead of "#00a700". If I load the settings directly I have no problem.

Thanks for your help

Can you show us a bit more what you mean by that?

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.

function initEntreeProcedure() {
    RED.nodes.registerType('entrée-procédure', {
      icon: "entry.svg",
      category: 'Opérateur Augmenté',
      defaults: {
                    code: { value: "", required: true },
                    name: { value: "" },
                    keywords: { value: [{ v: "" }], required: true },
                    service: { value: "" }
                  },
      inputs: 0,
      outputs: 1,
      color: "#9acd32"
})

Is that clearer? Thank you

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.