Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions server/modules/core-apps/nps.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ export class Nps implements IUiKitCoreApp {
async blockAction(payload: any): Promise<any> {
const {
triggerId,
actionId,
container: {
id: bannerId,
id: viewId,
},
payload: {
value: score,
Expand All @@ -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,
Expand All @@ -37,7 +41,7 @@ export class Nps implements IUiKitCoreApp {
payload: {
view: {
state,
id: bannerId,
id: viewId,
},
},
user: {
Expand All @@ -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;
Expand Down
17 changes: 9 additions & 8 deletions server/modules/core-apps/nps/createModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand All @@ -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 }),
Expand Down
1 change: 1 addition & 0 deletions server/services/nps/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export class NPSService extends ServiceClass implements INPSService {
},
}, {
projection: {
_id: 0,
identifier: 1,
roles: 1,
score: 1,
Expand Down