Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JCN-373-campos-opcionales #9

Merged
merged 8 commits into from
Apr 26, 2022
Merged

JCN-373-campos-opcionales #9

merged 8 commits into from
Apr 26, 2022

Conversation

Nataniel4
Copy link

LINK AL TICKET
https://fizzmod.atlassian.net/browse/JCN-373

LINK A LA HISTORIA
https://fizzmod.atlassian.net/browse/JCN-372

DESCRIPCIÓN DEL REQUERIMIENTO

  • Se necesita que se puedan guardar (es decir crear o actualizar) datos extras propios del Cliente en JID.

    • Cada Servicio debe poder definir que datos requiere guardar.
    • Si no definien datos extras no debe realizarse ninguna request a JID.
    • Si un dato es borrado en JID, debe borrarse en el servicio.
  • Esto se debe hacer para que funcione en:

    • POST/ CLIENTE CREATE
    • LISTENER/ CLIENTE UPDATE
    • LISTENER/ CLIENTE CREATE
  • Logicamente actualizar el README con la nueva caracteristicas 😌

DESCRIPCIÓN DE LA SOLUCIÓN

  • Se realizaron los cambios solicitados
  • Se hicieron algunas mejoras pequeñas de prolijidad al codigo
  • En la clase de la API Client Created y Event Listener Client Created se le sumó el objeto del cliente creado al segundo parametro del postSaveHook ya que puede ser util en futuros desarrollos.

README.md Outdated Show resolved Hide resolved
lib/api-create.js Outdated Show resolved Hide resolved
lib/api-create.js Outdated Show resolved Hide resolved
@gastonpereyra gastonpereyra added the enhancement New feature or request label Apr 25, 2022
@gastonpereyra gastonpereyra self-requested a review April 25, 2022 14:04
Comment on lines 31 to 40
if(!additionalFields)
return formattedClient;

additionalFields.forEach(field => {

if(client[field])
formattedClient[field] = client[field];
});

return formattedClient;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(!additionalFields)
return formattedClient;
additionalFields.forEach(field => {
if(client[field])
formattedClient[field] = client[field];
});
return formattedClient;
if(additionalFields) {
additionalFields.forEach(field => {
if(client[field])
formattedClient[field] = client[field];
});
}
return formattedClient;

Copy link
Contributor

@gastonpereyra gastonpereyra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comentarios chicos

Copy link
Member

@jormaechea jormaechea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dejé unos ajustes chiquitos para hacer..

additionalFields.forEach(field => {

if(client[field])
formattedClient[field] = client[field];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ojo, si el campo en el cliente tiene un valor falsy (más que nada 0 o false) no los está guardando. Debería chequear algo como typeof client[field] !== 'undefined' o algo parecido..

Agreguemos estos casos en los tests para asegurarnos que no se rompa en una próxima versión!


ClientModel.additionalFields.forEach(fieldName => {

if(updatedClient[fieldName])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acá está el mismo problema con los valores falsy..

static async formatForCreate(clientCodes) {
/**
* Get additional fields
* @returns {undefined} returns undefined by default
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @returns {undefined} returns undefined by default
* @returns {string[]|undefined} returns undefined by default

@jormaechea jormaechea merged commit 1c5d61f into master Apr 26, 2022
@jormaechea jormaechea deleted the JCN-373-campos-opcionales branch April 26, 2022 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants