From ded7adbf4944e21159537bbff7a9fe5ff3a46139 Mon Sep 17 00:00:00 2001 From: Bernardo Anderson Date: Wed, 10 Sep 2025 13:41:36 -0500 Subject: [PATCH 1/4] CP-10278 - Hardcode Employee/Manager parties --- app/javascript/template_builder/builder.vue | 9 ++++++++ app/javascript/template_builder/i18n.js | 4 ++-- app/models/template.rb | 2 +- app/views/api_settings/index.html.erb | 2 +- config/locales/i18n.yml | 2 +- spec/integration/prefill_integration_spec.rb | 4 ++-- spec/requests/submissions_spec.rb | 24 ++++++++++---------- spec/requests/templates_spec.rb | 2 +- 8 files changed, 29 insertions(+), 20 deletions(-) diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index b05f1d67..088b1fe2 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -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) => { return this.template.submitters.find(e => e.name === name)?.uuid }) diff --git a/app/javascript/template_builder/i18n.js b/app/javascript/template_builder/i18n.js index 216657e0..16674fab 100644 --- a/app/javascript/template_builder/i18n.js +++ b/app/javascript/template_builder/i18n.js @@ -77,8 +77,8 @@ const en = { add_option: 'Add option', option: 'Option', condition: 'Condition', - first_party: 'First Party', - second_party: 'Second Party', + first_party: 'Employee', + second_party: 'Manager', third_party: 'Third Party', fourth_party: 'Fourth Party', fifth_party: 'Fifth Party', diff --git a/app/models/template.rb b/app/models/template.rb index a2d7fd19..315c580c 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -39,7 +39,7 @@ # fk_rails_... (folder_id => template_folders.id) # class Template < ApplicationRecord - DEFAULT_SUBMITTER_NAME = 'First Party' + DEFAULT_SUBMITTER_NAME = 'Employee' belongs_to :author, class_name: 'User' belongs_to :account diff --git a/app/views/api_settings/index.html.erb b/app/views/api_settings/index.html.erb index 7defd3c2..326b7a07 100644 --- a/app/views/api_settings/index.html.erb +++ b/app/views/api_settings/index.html.erb @@ -41,7 +41,7 @@ "submitters": [ { "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@') %>", "values": { "Form Text Field Name": "Default Value" diff --git a/config/locales/i18n.yml b/config/locales/i18n.yml index 7b5853b4..bbdfdd3e 100644 --- a/config/locales/i18n.yml +++ b/config/locales/i18n.yml @@ -43,7 +43,7 @@ en: &en invalid_code: Invalid code unarchive: Unarchive signed: Signed - first_party: 'First Party' + first_party: 'Employee' remove_filter: Remove filter add: Add adding: Adding diff --git a/spec/integration/prefill_integration_spec.rb b/spec/integration/prefill_integration_spec.rb index 6ab95172..801396f8 100644 --- a/spec/integration/prefill_integration_spec.rb +++ b/spec/integration/prefill_integration_spec.rb @@ -45,7 +45,7 @@ RSpec.describe 'ATS Prefill Integration', type: :request do author: user, folder: template_folder, fields: template_fields, - submitters: [{ 'name' => 'First Party', 'uuid' => 'submitter-uuid-1' }]) + submitters: [{ 'name' => 'Employee', 'uuid' => 'submitter-uuid-1' }]) end let(:submission) do @@ -54,7 +54,7 @@ RSpec.describe 'ATS Prefill Integration', type: :request do account: account, created_by_user: user, template_fields: template_fields, - template_submitters: [{ 'name' => 'First Party', 'uuid' => 'submitter-uuid-1' }]) + template_submitters: [{ 'name' => 'Employee', 'uuid' => 'submitter-uuid-1' }]) end let(:submitter) do diff --git a/spec/requests/submissions_spec.rb b/spec/requests/submissions_spec.rb index 7a362ef5..d4e7ba6b 100644 --- a/spec/requests/submissions_spec.rb +++ b/spec/requests/submissions_spec.rb @@ -77,7 +77,7 @@ describe 'Submission API' do post '/api/submissions', headers: { 'x-auth-token': author.access_token.token }, params: { template_id: templates[0].id, send_email: true, - submitters: [{ role: 'First Party', email: 'john.doe@example.com' }] + submitters: [{ role: 'Employee', email: 'john.doe@example.com' }] }.to_json 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: { template_id: templates[0].id, send_email: true, - submitters: [{ role: 'First Party', email: 'john.doe@example.com' }], + submitters: [{ role: 'Employee', email: 'john.doe@example.com' }], message: {} }.to_json @@ -105,7 +105,7 @@ describe 'Submission API' 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: { 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 expect(response).to have_http_status(:ok) @@ -122,7 +122,7 @@ describe 'Submission API' do template_id: multiple_submitters_template.id, send_email: true, submitters: [ - { role: 'First Party', email: 'john.doe@example.com' }, + { role: 'Employee', email: 'john.doe@example.com' }, { email: 'jane.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[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[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[2]['role']).to eq('Third Party') 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, send_email: true, submitters: [ - { role: 'First Party', email: 'john@example' } + { role: 'Employee', email: 'john@example' } ] }.to_json @@ -162,7 +162,7 @@ describe 'Submission API' do post '/api/submissions', headers: { 'x-auth-token': author.access_token.token }, params: { template_id: templates[0].id, send_email: true, - submitters: [{ role: 'First Party', email: 'john.doe@example.com' }] + submitters: [{ role: 'Employee', email: 'john.doe@example.com' }] }.to_json expect(response).to have_http_status(:unprocessable_entity) @@ -174,8 +174,8 @@ describe 'Submission API' do template_id: multiple_submitters_template.id, send_email: true, submitters: [ - { role: 'First Party', email: 'john.doe@example.com' }, - { role: 'First Party', email: 'jane.doe@example.com' } + { role: 'Employee', email: 'john.doe@example.com' }, + { role: 'Employee', email: 'jane.doe@example.com' } ] }.to_json @@ -189,7 +189,7 @@ describe 'Submission API' do send_email: true, submitters: [ { email: 'jane.doe@example.com' }, - { role: 'First Party', email: 'john.doe@example.com' } + { role: 'Employee', email: 'john.doe@example.com' } ] }.to_json @@ -202,7 +202,7 @@ describe 'Submission API' do template_id: templates[0].id, send_email: true, submitters: [ - { role: 'First Party', email: 'john.doe@example.com' } + { role: 'Employee', email: 'john.doe@example.com' } ], message: { subject: 'Custom Email Subject' diff --git a/spec/requests/templates_spec.rb b/spec/requests/templates_spec.rb index 7763d8cd..a6df983e 100644 --- a/spec/requests/templates_spec.rb +++ b/spec/requests/templates_spec.rb @@ -197,7 +197,7 @@ describe 'Templates API' do fields: template.fields, submitters: [ { - name: 'First Party', + name: 'Employee', uuid: template.submitters.first['uuid'] } ], From a044b6c5e57a338957d69eab4bc74c107a58258a Mon Sep 17 00:00:00 2001 From: Bernardo Anderson Date: Wed, 10 Sep 2025 13:59:17 -0500 Subject: [PATCH 2/4] CP-10278 - Fix tests --- spec/factories/templates.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/factories/templates.rb b/spec/factories/templates.rb index eb0ea8ba..784fbf09 100644 --- a/spec/factories/templates.rb +++ b/spec/factories/templates.rb @@ -18,11 +18,11 @@ FactoryBot.define do end after(:create) do |template, ev| - number_words = %w[first second third fourth fifth sixth seventh eighth ninth tenth] + party_names = ['Employee', 'Manager', 'Third Party', 'Fourth Party', 'Fifth Party', 'Sixth Party', 'Seventh Party', 'Eighth Party', 'Ninth Party', 'Tenth Party'] template.submitters = Array.new(ev.submitter_count) do |i| { - 'name' => "#{number_words[i]&.capitalize} Party", + 'name' => party_names[i], 'uuid' => SecureRandom.uuid } end From e60cb4aecc6ecb80772b6a580fb74bdca4414703 Mon Sep 17 00:00:00 2001 From: Bernardo Anderson Date: Wed, 10 Sep 2025 14:08:07 -0500 Subject: [PATCH 3/4] CP-10278 - Update Employee and Manager colors --- app/javascript/application.scss | 27 +++++++++++++++++++ app/javascript/template_builder/area.vue | 8 +++--- .../template_builder/field_submitter.vue | 4 +-- spec/factories/templates.rb | 3 ++- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/app/javascript/application.scss b/app/javascript/application.scss index 91aca432..4c705821 100644 --- a/app/javascript/application.scss +++ b/app/javascript/application.scss @@ -131,6 +131,8 @@ label.primary-button { :root { --tooltip-color: black; + --employee-color: #FFD687; + --manager-color: #D6E4FD; } .tooltip-bottom-end:before { @@ -205,3 +207,28 @@ label.primary-button { outline-offset: 3px; outline-color: hsl(var(--bc) / 0.2); } + +/* Custom party colors */ +.bg-employee-color { + background-color: var(--employee-color); +} + +.bg-manager-color { + background-color: var(--manager-color); +} + +.bg-employee-bg-color { + background-color: var(--employee-color); +} + +.bg-manager-bg-color { + background-color: var(--manager-color); +} + +.border-employee-color { + border-color: var(--employee-color); +} + +.border-manager-color { + border-color: var(--manager-color); +} diff --git a/app/javascript/template_builder/area.vue b/app/javascript/template_builder/area.vue index e0a5937e..df631ef0 100644 --- a/app/javascript/template_builder/area.vue +++ b/app/javascript/template_builder/area.vue @@ -447,8 +447,8 @@ export default { }, borderColors () { return [ - 'border-red-500/80', - 'border-sky-500/80', + 'border-employee-color', + 'border-manager-color', 'border-emerald-500/80', 'border-yellow-300/80', 'border-purple-600/80', @@ -461,8 +461,8 @@ export default { }, bgColors () { return [ - 'bg-red-100', - 'bg-sky-100', + 'bg-employee-bg-color', + 'bg-manager-bg-color', 'bg-emerald-100', 'bg-yellow-100', 'bg-purple-100', diff --git a/app/javascript/template_builder/field_submitter.vue b/app/javascript/template_builder/field_submitter.vue index a3151288..f344e597 100644 --- a/app/javascript/template_builder/field_submitter.vue +++ b/app/javascript/template_builder/field_submitter.vue @@ -287,8 +287,8 @@ export default { computed: { colors () { return [ - 'bg-red-500', - 'bg-sky-500', + 'bg-employee-color', + 'bg-manager-color', 'bg-emerald-500', 'bg-yellow-300', 'bg-purple-600', diff --git a/spec/factories/templates.rb b/spec/factories/templates.rb index 784fbf09..428500c7 100644 --- a/spec/factories/templates.rb +++ b/spec/factories/templates.rb @@ -18,7 +18,8 @@ FactoryBot.define do end after(:create) do |template, ev| - party_names = ['Employee', 'Manager', 'Third Party', 'Fourth Party', 'Fifth Party', 'Sixth Party', 'Seventh Party', 'Eighth Party', 'Ninth Party', 'Tenth Party'] + party_names = ['Employee', 'Manager', 'Third Party', 'Fourth Party', 'Fifth Party', 'Sixth Party', + 'Seventh Party', 'Eighth Party', 'Ninth Party', 'Tenth Party'] template.submitters = Array.new(ev.submitter_count) do |i| { From dc81aa3b87f4c625ce9d61d1a0eaa82d380707f0 Mon Sep 17 00:00:00 2001 From: Bernardo Anderson Date: Wed, 10 Sep 2025 15:44:33 -0500 Subject: [PATCH 4/4] CP-10278 - Remove JS update for already made forms --- app/javascript/template_builder/builder.vue | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index 088b1fe2..b05f1d67 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -699,15 +699,6 @@ 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) => { return this.template.submitters.find(e => e.name === name)?.uuid })