diff --git a/server/modules/core-apps/nps.module.ts b/server/modules/core-apps/nps.module.ts index 5e5b9d3112285..42107c20bfca5 100644 --- a/server/modules/core-apps/nps.module.ts +++ b/server/modules/core-apps/nps.module.ts @@ -8,8 +8,9 @@ export class Nps implements IUiKitCoreApp { async blockAction(payload: any): Promise { const { triggerId, + actionId, container: { - id: bannerId, + id: viewId, }, payload: { value: score, @@ -18,10 +19,13 @@ export class Nps implements IUiKitCoreApp { user, } = payload; + const bannerId = viewId.replace(`${ npsId }-`, ''); + return createModal({ + type: actionId === 'nps-score' ? 'modal.update' : 'modal.open', + id: `${ npsId }-${ bannerId }`, appId: this.appId, npsId, - bannerId, triggerId, score, user, @@ -37,7 +41,7 @@ export class Nps implements IUiKitCoreApp { payload: { view: { state, - id: bannerId, + id: viewId, }, }, user: { @@ -48,9 +52,11 @@ export class Nps implements IUiKitCoreApp { const [npsId] = Object.keys(state); + const bannerId = viewId.replace(`${ npsId }-`, ''); + const { [npsId]: { - score, + 'nps-score': score, comment, }, } = state; diff --git a/server/modules/core-apps/nps/createModal.ts b/server/modules/core-apps/nps/createModal.ts index 8dd95a3b1ce0e..a530d34c522f6 100644 --- a/server/modules/core-apps/nps/createModal.ts +++ b/server/modules/core-apps/nps/createModal.ts @@ -5,25 +5,26 @@ import { settings } from '../../../../app/settings/server'; import { IUser } from '../../../../definition/IUser'; export type ModalParams = { + id: string; + type: string; appId: string; npsId: string; - bannerId: string; triggerId: string; score: string; user: IUser; } -export const createModal = Meteor.bindEnvironment(({ appId, npsId, bannerId, triggerId, score, user }: ModalParams): any => { +export const createModal = Meteor.bindEnvironment(({ type = 'modal.open', id, appId, npsId, triggerId, score, user }: ModalParams): any => { const language = user.language || settings.get('Language') || 'en'; return { - type: 'modal.open', + type, triggerId, appId, view: { appId, type: 'modal', - id: bannerId, + id, title: { type: 'plain_text', text: TAPi18n.__('We_appreciate_your_feedback', { lng: language }), @@ -49,14 +50,14 @@ export const createModal = Meteor.bindEnvironment(({ appId, npsId, bannerId, tri }, blocks: [{ blockId: npsId, - type: 'input', - element: { + type: 'actions', + elements: [{ type: 'linear_scale', initialValue: score, - actionId: 'score', + actionId: 'nps-score', preLabel: { type: 'plain_text', text: TAPi18n.__('Not_likely', { lng: language }) }, postLabel: { type: 'plain_text', text: TAPi18n.__('Extremely_likely', { lng: language }) }, - }, + }], label: { type: 'plain_text', text: TAPi18n.__('Score', { lng: language }), diff --git a/server/services/nps/service.ts b/server/services/nps/service.ts index 56fbc9a9e7dcf..fc17fec311567 100644 --- a/server/services/nps/service.ts +++ b/server/services/nps/service.ts @@ -110,6 +110,7 @@ export class NPSService extends ServiceClass implements INPSService { }, }, { projection: { + _id: 0, identifier: 1, roles: 1, score: 1,