adminjs icon indicating copy to clipboard operation
adminjs copied to clipboard

rename fields

Open jhoriascos opened this issue 5 years ago • 14 comments

Is it possible to rename the fields of the displayed tables?

Note: I would like to set special characters such as accents.

Installed libraries and their versions. "admin-bro": "^2.9.0", "admin-bro-expressjs": "^2.1.1", "admin-bro-typeorm": "^0.1.6-alpha.9",

Captura de Pantalla 2021-03-30 a la(s) 10 56 10 a  m Captura de Pantalla 2021-03-30 a la(s) 10 58 38 a  m

jhoriascos avatar Mar 30 '21 15:03 jhoriascos

Yes, you can do this via locale property in AdminBro options: https://adminbro.com/AdminBroOptions.html#locale

dziraf avatar Apr 08 '21 15:04 dziraf

I have tried to change the field from the displayed table, referred: https://adminbro.com/AdminBroOptions.html#locale

Here, Items is the Resource name as well as a model name, and ownerid is the property. image ColumnChange It still remains same. Is there any alternate way to do that?

RudrikaJnext avatar Apr 13 '21 04:04 RudrikaJnext

Any update on this issue?

mokshmodi96 avatar Aug 06 '21 06:08 mokshmodi96

I can't think of a reason why it wouldn't work for you, are you sure your the property name matches exactly what's in your model?

dziraf avatar Aug 06 '21 08:08 dziraf

i want to name it differently than in the model

mokshmodi96 avatar Aug 06 '21 10:08 mokshmodi96

Yes, but if your model field is defined as such:

@Column(...)
public ownerId: number;

you should use ownerId in adminjs locale settings:

...,
resources: {
  YourModel: {
    properties: {
      ownerId: 'Owner',
    },
  },
},

dziraf avatar Aug 06 '21 10:08 dziraf

@dziraf Thank you, Yes it worked for me: But still I am not able to Rename my pages name. image

locale: {
    // language: 'en',
    translations: {
      resources: {
        Reports: {
          properties: {
            userId: 'User'
          }
        },

RudrikaJnext avatar Aug 23 '21 09:08 RudrikaJnext

I have done mine like this and no luck:

locale: {
    translations: {
      resources: {
        Tolerable_Intake: {
          properties: {
            DOCUMENT_URL: 'Document URL',
            TI_MODIFIEDBY: 'Modified by',
          }
       }
    }
 }
}

lumayara avatar Nov 03 '21 18:11 lumayara

Do your properties have uppercased names? Could you share your model schema?

dziraf avatar Nov 03 '21 22:11 dziraf

@dziraf Yes it's all uppercase.. I am using an old db.

const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('Tolerable_Intake', {
     INTAKE_ID: {
      autoIncrement: true,
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true
    },
TI_MODIFIEDBY: {
      type: DataTypes.INTEGER,
      allowNull: true
    },
    DOCUMENT_URL: {
      type: DataTypes.TEXT,
      allowNull: true
    }
  }, {
    sequelize,
    tableName: 'Tolerable_Intake',
    schema: 'dbo',
    timestamps: false,
    indexes: [
      {
        name: "PK__TBL_TOLE__BB5D29EA7A3FD38E",
        unique: true,
        fields: [
          { name: "INTAKE_ID" },
        ]
      },
    ]
  });
};

lumayara avatar Nov 03 '21 23:11 lumayara

Still no luck for me...

lumayara avatar Jun 29 '22 14:06 lumayara

No luck for me either. I can hide the field, but I am not able to rename it. eg: .... properties: { id: { isVisible: false, }, fPublisherID: {isVisible : false}, // works ....

however if I do: properties: { id: { isVisible: false, }, fPublisherID: "Published Status" // does not change the name.

@lumayara were you able to resolve this?

dhammikab avatar Jul 12 '22 03:07 dhammikab

@dhammikab No luck for me. Can anyone else?

lumayara avatar Jul 12 '22 21:07 lumayara

@lumayara did you check here: https://github.com/SoftwareBrothers/adminjs/issues/1169#issuecomment-1181831026 ? 😉

krzysztofstudniarek avatar Jul 13 '22 07:07 krzysztofstudniarek