Skip to content

Commit

Permalink
Change service dialog api call to match CUI
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed May 29, 2018
1 parent c09b5ae commit f0cc7c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
23 changes: 7 additions & 16 deletions client/app/states/catalogs/details/details.state.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,16 @@ function Controller ($stateParams, CollectionsApi, EventNotifications, ShoppingC
dialogs = data[DIALOGS_RESPONSE]
vm.serviceTemplate = data[SERVICE_TEMPLATE_RESPONSE]
vm.parsedDialogs = []

if (dialogs.subcount > 0) {
if (serviceRequest) {
const existingDialogValues = serviceRequest.options.dialog
dialogs.resources[0].content.forEach((dialog) => {
vm.parsedDialogs.push(DialogFieldRefresh.setFieldValueDefaults(dialog, existingDialogValues))
})
} else {
vm.parsedDialogs = dialogs.resources[0].content
}
}
setDialogUrl(vm.serviceTemplate.service_template_catalog_id)
vm.parsedDialogs = dialogs.resources[0].content
setDialogUrl()
vm.loading = false
})
})
}

init()
function setDialogUrl (serviceTemplateCatalogId) {
vm.dialogUrl = `service_catalogs/${serviceTemplateCatalogId}/service_templates`
function setDialogUrl () {
vm.dialogUrl = `service_dialogs`

return vm.dialogUrl
}
Expand All @@ -131,12 +121,13 @@ function Controller ($stateParams, CollectionsApi, EventNotifications, ShoppingC
}

let idList = {
dialogId: vm.parsedDialogs.id,
dialogId: vm.parsedDialogs[0].id,
resourceActionId: resourceActionId,
targetId: vm.serviceTemplate.id,
targetType: 'service_template'
}
const url = `${vm.dialogUrl}/${vm.serviceTemplate.id}`
const url = `${vm.dialogUrl}`

return DialogFieldRefresh.refreshDialogField(vm.dialogData, [field.name], url, idList)
}
/**
Expand Down
4 changes: 2 additions & 2 deletions client/app/states/catalogs/details/details.state.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('State: catalogs.details', () => {
it('it allows a field to be refreshed', (done) => {
controller = $controller($state.get('catalogs.details').controller)
controller.serviceTemplate = serviceTemplate
controller.setDialogUrl(serviceTemplate.service_template_catalog_id)
controller.setDialogUrl()
const refreshSpy = sinon.stub(DialogFieldRefresh, 'refreshDialogField').returns(Promise.resolve({'status': 'success'}))
const dialogData = {
'dialogField1': '1',
Expand All @@ -82,7 +82,7 @@ describe('State: catalogs.details', () => {
controller.refreshField(field).then((data) => {
done()
})
const url = `service_catalogs/${serviceTemplate.service_template_catalog_id}/service_templates/${serviceTemplate.id}`
const url = `/api/service_dialogs/${idList.dialogId}`
expect(refreshSpy).to.have.been.calledWith(dialogData, ['dialogField1'], url, idList)
})
it('allows dialog data to be updated', () => {
Expand Down

0 comments on commit f0cc7c0

Please sign in to comment.