jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.53k stars 4.02k forks source link

Warning on entity list page due to wrong call to track function #27112

Closed edilsonmendes closed 1 month ago

edilsonmendes commented 1 month ago
Overview of the issue

On list page of any entity the below warning is shown.

NG0955: The provided track expression resulted in duplicated keys for a given collection. Adjust the tracking expression such that it uniquely identifies all the items in the collection. Duplicated keys were:

Captura de tela 2024-08-28 210901

In the list component ts the track is defined as function, but the template isn't calling this function correctly.

I guess we change

@for (spaceEvent of spaceEvents; track trackId) {

to

@for (spaceEvent of spaceEvents; track trackId($index, spaceEvent )) {

Motivation for or Use Case

The call to track function is wrong and it doesn't show warning.

Reproduce the error

Generate a project and enter in any entity list page.

Related issues
Suggest a Fix

Change the entity list template component to call track function as following: track trackId($index, spaceEvent )

JHipster Version(s)

8.7.0

JHipster configuration

To provide all information we need, you should run jhipster info in the project root folder (or workspaces root for microservices), and copy/paste the result here. jhipster info removes sentitive information like rememberKey, jwtSecretKey. Double check if there is any other sensitive info.

WARNING! Since JHipster v8, the jhipster command will not use the locally installed generator-jhipster. If you want to execute the locally installed generator-jhipster, run: npx jhipster

    ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
    ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
    ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝

██╗ ██║ ██╔═══██║ ██║ ██╔════╝ ╚═══██╗ ██║ ██╔═══╝ ██╔══██║ ╚██████╔╝ ██║ ██║ ████████╗ ██║ ██████╔╝ ██║ ████████╗ ██║ ╚██╗ ╚═════╝ ╚═╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═╝ https://www.jhipster.tech Welcome to JHipster v8.7.0

Welcome to the JHipster Information Sub-Generator

jhipster-sample-application@0.0.1-SNAPSHOT /home/embj/sample-v8.7.0
└── generator-jhipster@8.7.0
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "jwt",
    "baseName": "jhipsterSampleApplication",
    "blueprints": [],
    "buildTool": "maven",
    "cacheProvider": "ehcache",
    "clientFramework": "angular",
    "clientPackageManager": "npm",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "clusteredHttpSession": false,
    "creationTimestamp": 1577000812973,
    "databaseType": "sql",
    "devDatabaseType": "h2Memory",
    "devServerPort": 9060,
    "dtoSuffix": "DTO",
    "embeddableLaunchScript": false,
    "enableGradleEnterprise": false,
    "enableHibernateCache": true,
    "enableSocialSignIn": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "entities": [
      "SpaceEvent",
      "Mission"
    ],
    "entitySuffix": "",
    "hibernateCache": "ehcache",
    "jhiPrefix": "jhi",
    "jhipsterVersion": "8.7.0",
    "languages": [
      "en"
    ],
    "lastLiquibaseTimestamp": 1724888876000,
    "messageBroker": false,
    "nativeLanguage": "en",
    "otherModules": [],
    "packageFolder": "io/github/jhipster/sample",
    "packageName": "io.github.jhipster.sample",
    "pages": [],
    "prodDatabaseType": "postgresql",
    "reactive": false,
    "searchEngine": false,
    "serverPort": 8080,
    "serviceDiscoveryType": false,
    "skipCheckLengthOfIdentifier": false,
    "skipClient": false,
    "skipFakeData": false,
    "skipServer": false,
    "skipUserManagement": false,
    "testFrameworks": [
      "gatling",
      "cypress"
    ],
    "useCompass": false,
    "useSass": true,
    "websocket": false,
    "withAdminUi": true
  }
}
Environment and Tools

openjdk version "17.0.6" 2023-01-17 OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10) OpenJDK 64-Bit Server VM Temurin-17.0.6+10 (build 17.0.6+10, mixed mode, sharing)

git version 2.34.1

node: v20.17.0 npm: 10.8.2

Docker version 27.0.3, build 7d4bcd8

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
@ChangelogDate("20240828234755")
entity SpaceEvent {
  name String required
  date LocalDate required
  description TextBlob required
  photo ImageBlob required
  type SpaceEventType required
}
@ChangelogDate("20240828234756")
entity Mission {
  name String required
  description String
}

enum SpaceEventType {
  LAUNCH,
  LANDING
}

relationship OneToOne {
  SpaceEvent{mission(name)} to Mission
}

paginate SpaceEvent with infinite-scroll
paginate Mission with pagination
search SpaceEvent, Mission with no

As alternative you can add a JDL wrapped in below structure

JDL definitions
     JDL content here
  

The information is mandatory for bug reports. This will allow us to use automated tests and genarate the broken sample using jhipster from-issue command.

Browsers and Operating System
kaidohallik commented 1 month ago

fixed by #27114