CP-10278 - Hardcode Employee/Manager parties

pull/544/head
Bernardo Anderson 3 months ago
parent d6c2b74b58
commit ded7adbf49

@ -699,6 +699,15 @@ export default {
} }
} }
// Update old party names to new translations
this.template.submitters.forEach((submitter) => {
if (submitter.name === 'First Party') {
submitter.name = this.t('first_party')
} else if (submitter.name === 'Second Party') {
submitter.name = this.t('second_party')
}
})
const existingSubmittersUuids = this.defaultSubmitters.map((name) => { const existingSubmittersUuids = this.defaultSubmitters.map((name) => {
return this.template.submitters.find(e => e.name === name)?.uuid return this.template.submitters.find(e => e.name === name)?.uuid
}) })

@ -77,8 +77,8 @@ const en = {
add_option: 'Add option', add_option: 'Add option',
option: 'Option', option: 'Option',
condition: 'Condition', condition: 'Condition',
first_party: 'First Party', first_party: 'Employee',
second_party: 'Second Party', second_party: 'Manager',
third_party: 'Third Party', third_party: 'Third Party',
fourth_party: 'Fourth Party', fourth_party: 'Fourth Party',
fifth_party: 'Fifth Party', fifth_party: 'Fifth Party',

@ -39,7 +39,7 @@
# fk_rails_... (folder_id => template_folders.id) # fk_rails_... (folder_id => template_folders.id)
# #
class Template < ApplicationRecord class Template < ApplicationRecord
DEFAULT_SUBMITTER_NAME = 'First Party' DEFAULT_SUBMITTER_NAME = 'Employee'
belongs_to :author, class_name: 'User' belongs_to :author, class_name: 'User'
belongs_to :account belongs_to :account

@ -41,7 +41,7 @@
"submitters": [ "submitters": [
{ {
"name": "John Doe", "name": "John Doe",
"role": "<%= current_account.templates.last ? current_account.templates.last.submitters.first['name'] : 'First Party' %>", "role": "<%= current_account.templates.last ? current_account.templates.last.submitters.first['name'] : 'Employee' %>",
"email": "<%= current_user.email.sub('@', '+test@') %>", "email": "<%= current_user.email.sub('@', '+test@') %>",
"values": { "values": {
"Form Text Field Name": "Default Value" "Form Text Field Name": "Default Value"

@ -43,7 +43,7 @@ en: &en
invalid_code: Invalid code invalid_code: Invalid code
unarchive: Unarchive unarchive: Unarchive
signed: Signed signed: Signed
first_party: 'First Party' first_party: 'Employee'
remove_filter: Remove filter remove_filter: Remove filter
add: Add add: Add
adding: Adding adding: Adding

@ -45,7 +45,7 @@ RSpec.describe 'ATS Prefill Integration', type: :request do
author: user, author: user,
folder: template_folder, folder: template_folder,
fields: template_fields, fields: template_fields,
submitters: [{ 'name' => 'First Party', 'uuid' => 'submitter-uuid-1' }]) submitters: [{ 'name' => 'Employee', 'uuid' => 'submitter-uuid-1' }])
end end
let(:submission) do let(:submission) do
@ -54,7 +54,7 @@ RSpec.describe 'ATS Prefill Integration', type: :request do
account: account, account: account,
created_by_user: user, created_by_user: user,
template_fields: template_fields, template_fields: template_fields,
template_submitters: [{ 'name' => 'First Party', 'uuid' => 'submitter-uuid-1' }]) template_submitters: [{ 'name' => 'Employee', 'uuid' => 'submitter-uuid-1' }])
end end
let(:submitter) do let(:submitter) do

@ -77,7 +77,7 @@ describe 'Submission API' do
post '/api/submissions', headers: { 'x-auth-token': author.access_token.token }, params: { post '/api/submissions', headers: { 'x-auth-token': author.access_token.token }, params: {
template_id: templates[0].id, template_id: templates[0].id,
send_email: true, send_email: true,
submitters: [{ role: 'First Party', email: 'john.doe@example.com' }] submitters: [{ role: 'Employee', email: 'john.doe@example.com' }]
}.to_json }.to_json
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
@ -91,7 +91,7 @@ describe 'Submission API' do
post '/api/submissions', headers: { 'x-auth-token': author.access_token.token }, params: { post '/api/submissions', headers: { 'x-auth-token': author.access_token.token }, params: {
template_id: templates[0].id, template_id: templates[0].id,
send_email: true, send_email: true,
submitters: [{ role: 'First Party', email: 'john.doe@example.com' }], submitters: [{ role: 'Employee', email: 'john.doe@example.com' }],
message: {} message: {}
}.to_json }.to_json
@ -105,7 +105,7 @@ describe 'Submission API' do
it 'creates a submission when the submitter is marked as completed' do it 'creates a submission when the submitter is marked as completed' do
post '/api/submissions', headers: { 'x-auth-token': author.access_token.token }, params: { post '/api/submissions', headers: { 'x-auth-token': author.access_token.token }, params: {
template_id: templates[0].id, template_id: templates[0].id,
submitters: [{ role: 'First Party', email: 'john.doe@example.com', completed: true }] submitters: [{ role: 'Employee', email: 'john.doe@example.com', completed: true }]
}.to_json }.to_json
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
@ -122,7 +122,7 @@ describe 'Submission API' do
template_id: multiple_submitters_template.id, template_id: multiple_submitters_template.id,
send_email: true, send_email: true,
submitters: [ submitters: [
{ role: 'First Party', email: 'john.doe@example.com' }, { role: 'Employee', email: 'john.doe@example.com' },
{ email: 'jane.doe@example.com' }, { email: 'jane.doe@example.com' },
{ email: 'mike.doe@example.com' } { email: 'mike.doe@example.com' }
] ]
@ -134,9 +134,9 @@ describe 'Submission API' do
expect(response.parsed_body).to eq(JSON.parse(create_submission_body(submission).to_json)) expect(response.parsed_body).to eq(JSON.parse(create_submission_body(submission).to_json))
expect(response.parsed_body).to eq(JSON.parse(create_submission_body(submission).to_json)) expect(response.parsed_body).to eq(JSON.parse(create_submission_body(submission).to_json))
expect(response.parsed_body[0]['role']).to eq('First Party') expect(response.parsed_body[0]['role']).to eq('Employee')
expect(response.parsed_body[0]['email']).to eq('john.doe@example.com') expect(response.parsed_body[0]['email']).to eq('john.doe@example.com')
expect(response.parsed_body[1]['role']).to eq('Second Party') expect(response.parsed_body[1]['role']).to eq('Manager')
expect(response.parsed_body[1]['email']).to eq('jane.doe@example.com') expect(response.parsed_body[1]['email']).to eq('jane.doe@example.com')
expect(response.parsed_body[2]['role']).to eq('Third Party') expect(response.parsed_body[2]['role']).to eq('Third Party')
expect(response.parsed_body[2]['email']).to eq('mike.doe@example.com') expect(response.parsed_body[2]['email']).to eq('mike.doe@example.com')
@ -147,7 +147,7 @@ describe 'Submission API' do
template_id: templates[0].id, template_id: templates[0].id,
send_email: true, send_email: true,
submitters: [ submitters: [
{ role: 'First Party', email: 'john@example' } { role: 'Employee', email: 'john@example' }
] ]
}.to_json }.to_json
@ -162,7 +162,7 @@ describe 'Submission API' do
post '/api/submissions', headers: { 'x-auth-token': author.access_token.token }, params: { post '/api/submissions', headers: { 'x-auth-token': author.access_token.token }, params: {
template_id: templates[0].id, template_id: templates[0].id,
send_email: true, send_email: true,
submitters: [{ role: 'First Party', email: 'john.doe@example.com' }] submitters: [{ role: 'Employee', email: 'john.doe@example.com' }]
}.to_json }.to_json
expect(response).to have_http_status(:unprocessable_entity) expect(response).to have_http_status(:unprocessable_entity)
@ -174,8 +174,8 @@ describe 'Submission API' do
template_id: multiple_submitters_template.id, template_id: multiple_submitters_template.id,
send_email: true, send_email: true,
submitters: [ submitters: [
{ role: 'First Party', email: 'john.doe@example.com' }, { role: 'Employee', email: 'john.doe@example.com' },
{ role: 'First Party', email: 'jane.doe@example.com' } { role: 'Employee', email: 'jane.doe@example.com' }
] ]
}.to_json }.to_json
@ -189,7 +189,7 @@ describe 'Submission API' do
send_email: true, send_email: true,
submitters: [ submitters: [
{ email: 'jane.doe@example.com' }, { email: 'jane.doe@example.com' },
{ role: 'First Party', email: 'john.doe@example.com' } { role: 'Employee', email: 'john.doe@example.com' }
] ]
}.to_json }.to_json
@ -202,7 +202,7 @@ describe 'Submission API' do
template_id: templates[0].id, template_id: templates[0].id,
send_email: true, send_email: true,
submitters: [ submitters: [
{ role: 'First Party', email: 'john.doe@example.com' } { role: 'Employee', email: 'john.doe@example.com' }
], ],
message: { message: {
subject: 'Custom Email Subject' subject: 'Custom Email Subject'

@ -197,7 +197,7 @@ describe 'Templates API' do
fields: template.fields, fields: template.fields,
submitters: [ submitters: [
{ {
name: 'First Party', name: 'Employee',
uuid: template.submitters.first['uuid'] uuid: template.submitters.first['uuid']
} }
], ],

Loading…
Cancel
Save