diff --git a/src/public/main.js b/src/public/main.js index e29766efe4..e683cbdcf1 100644 --- a/src/public/main.js +++ b/src/public/main.js @@ -257,7 +257,6 @@ require('./modules/forms/config/forms.client.routes.js') // forms services require('./modules/forms/services/form-fields.client.service.js') -require('./modules/forms/services/form-factory.client.service.js') require('./modules/forms/services/form-api.client.factory.js') require('./modules/forms/services/form-error.client.factory.js') require('./modules/forms/services/spcp-session.client.factory.js') diff --git a/src/public/modules/forms/admin/controllers/create-form-modal.client.controller.js b/src/public/modules/forms/admin/controllers/create-form-modal.client.controller.js index a82b2e615c..f34a61caf7 100644 --- a/src/public/modules/forms/admin/controllers/create-form-modal.client.controller.js +++ b/src/public/modules/forms/admin/controllers/create-form-modal.client.controller.js @@ -37,7 +37,7 @@ angular 'responseModeEnum', 'createFormModalOptions', 'FormToDuplicate', - 'FormFactory', + 'FormApi', 'FormFields', 'GTag', 'FormSgSdk', @@ -56,7 +56,7 @@ function CreateFormModalController( responseModeEnum, createFormModalOptions, FormToDuplicate, - FormFactory, + FormApi, FormFields, GTag, FormSgSdk, @@ -258,11 +258,7 @@ function CreateFormModalController( switch (formMode) { case 'duplicate': { $q.when( - FormFactory.generateForm( - formMode, - formParams, - FormToDuplicate._id, - ), + FormApi.duplicateForm(FormToDuplicate._id, formParams), ).then((data) => { vm.closeCreateModal() externalScope.onDuplicateSuccess(data) @@ -271,9 +267,7 @@ function CreateFormModalController( } case 'useTemplate': { const { form } = externalScope - $q.when( - FormFactory.generateForm(formMode, formParams, form._id), - ).then((data) => { + $q.when(FormApi.useTemplate(form._id, formParams)).then((data) => { vm.closeCreateModal() vm.goToWithId('viewForm', data._id + '') GTag.examplesClickCreateNewForm(form) @@ -283,23 +277,17 @@ function CreateFormModalController( case 'createFromTemplate': { // Create new form from template selected const newForm = Object.assign({}, vm.template, formParams) - $q.when(FormFactory.generateForm('create', newForm)).then( - (data) => { - vm.closeCreateModal() - vm.goToWithId('viewForm', data._id + '') - }, - handleCreateFormError, - ) + $q.when(FormApi.createForm(newForm)).then((data) => { + vm.closeCreateModal() + vm.goToWithId('viewForm', data._id + '') + }, handleCreateFormError) break } case 'create': // Create form - $q.when(FormFactory.generateForm(formMode, formParams)).then( - (data) => { - vm.closeCreateModal() - vm.goToWithId('viewForm', data._id + '') - }, - handleCreateFormError, - ) + $q.when(FormApi.createForm(formParams)).then((data) => { + vm.closeCreateModal() + vm.goToWithId('viewForm', data._id + '') + }, handleCreateFormError) break } } diff --git a/src/public/modules/forms/services/form-factory.client.service.js b/src/public/modules/forms/services/form-factory.client.service.js deleted file mode 100644 index 79ba86aae2..0000000000 --- a/src/public/modules/forms/services/form-factory.client.service.js +++ /dev/null @@ -1,27 +0,0 @@ -angular.module('forms').service('FormFactory', ['FormApi', FormFactory]) - -function FormFactory(FormApi) { - this.generateForm = generateForm - - /** - * Creates a new form from one of three options - * @param {string} mode One of 'create', 'duplicate', 'useTemplate' - * @param {Object} params Parameters for the form object. This can be any valid - * parameter in the backend Form model - * @param {string} [formId] Form ID for duplication an admin's existing form, - * or using the template of another form - * when responseMode is 'encrypt' - */ - function generateForm(mode, params, formId) { - switch (mode) { - case 'create': - return FormApi.createForm(params) - case 'duplicate': - return FormApi.duplicateForm(formId, params) - case 'useTemplate': - return FormApi.useTemplate(formId, params) - default: - throw new Error('Unsupported mode of form generation.') - } - } -}