diff --git a/app/controllers/sso_login_controller.rb b/app/controllers/sso_login_controller.rb index abad7a3d..5203cafd 100644 --- a/app/controllers/sso_login_controller.rb +++ b/app/controllers/sso_login_controller.rb @@ -10,7 +10,6 @@ class SsoLoginController < ApplicationController def login token = params[:token] - template_id = params[:template_id] unless token.present? return redirect_to root_path, alert: 'Missing authentication token' @@ -23,6 +22,7 @@ class SsoLoginController < ApplicationController email = decoded_token['email']&.downcase first_name = decoded_token['first_name'] last_name = decoded_token['last_name'] + template_id = decoded_token['template_id'] # Check for facility_id/facility_name first (new payload format), then fallback to company_id/company_name company_id = decoded_token['facility_id'] || decoded_token['company_id'] || decoded_token['account_id'] || decoded_token['organization_id'] company_name = decoded_token['facility_name'] || decoded_token['company_name'] || decoded_token['account_name'] || decoded_token['organization_name'] @@ -44,7 +44,8 @@ class SsoLoginController < ApplicationController # Redirect to template preview if template_id is present if template_id.present? - return redirect_to controller: 'templates', action: 'preview', id: template_id + Rails.logger.error("It is here actually. TemplateID: #{template_id}") + return redirect_to template_preview_path(template_id) end # Redirect to dashboard diff --git a/app/javascript/application.js b/app/javascript/application.js index 4b5988c9..2c1e2069 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -175,7 +175,8 @@ safeRegisterElement('template-builder', class extends HTMLElement { withDownload: true, currencies: (this.dataset.currencies || '').split(',').filter(Boolean), acceptFileTypes: this.dataset.acceptFileTypes, - showTourStartForm: this.dataset.showTourStartForm === 'true' + showTourStartForm: this.dataset.showTourStartForm === 'true', + predefinedFields: JSON.parse(this.dataset.predefinedFields || '[]') }) this.component = this.app.mount(this.appElem) @@ -219,4 +220,4 @@ safeRegisterElement('import-list', class extends HTMLElement { this.app?.unmount() this.appElem?.remove() } -}) +}) \ No newline at end of file diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index 33bc748b..9afe02a1 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -489,10 +489,12 @@ :only-defined-fields="onlyDefinedFields" :editable="editable" :show-tour-start-form="showTourStartForm" + :predefined-fields="predefinedFields" @add-field="addField" @set-draw="[drawField = $event.field, drawOption = $event.option]" @select-submitter="selectedSubmitter = $event" @set-draw-type="[drawFieldType = $event, showDrawField = true]" + @set-draw-with-name="[drawFieldType = $event.type, drawFieldName = $event.name, showDrawField = true]" @set-drag="dragField = $event" @set-drag-placeholder="$refs.dragPlaceholder.dragPlaceholder = $event" @change-submitter="selectedSubmitter = $event" @@ -885,6 +887,11 @@ export default { type: Boolean, required: false, default: false + }, + predefinedFields: { + type: Array, + required: false, + default: () => [] } }, data () { @@ -902,6 +909,7 @@ export default { pendingFieldAttachmentUuids: [], drawField: null, drawFieldType: null, + drawFieldName: '', drawOption: null, dragField: null, isDragFile: false @@ -1390,7 +1398,7 @@ export default { }, addField (type, area = null) { const field = { - name: '', + name: this.drawFieldName || '', uuid: v4(), required: type !== 'checkbox', areas: area ? [area] : [], @@ -1428,6 +1436,8 @@ export default { field.preferences.with_signature_id = this.withSignatureId } + this.drawFieldName = '' + this.insertField(field) this.save() @@ -1515,6 +1525,7 @@ export default { this.drawField = null this.drawOption = null this.showDrawField = false + this.drawFieldName = '' if (!this.withSelectedFieldType) { this.drawFieldType = '' @@ -2724,4 +2735,4 @@ export default { } } } - + \ No newline at end of file diff --git a/app/javascript/template_builder/fields.vue b/app/javascript/template_builder/fields.vue index 9f015106..95807915 100644 --- a/app/javascript/template_builder/fields.vue +++ b/app/javascript/template_builder/fields.vue @@ -192,6 +192,23 @@ +
+
Predefined Fields
+
+ +
+
[] } }, - emits: ['add-field', 'set-draw', 'set-draw-type', 'set-drag', 'drag-end', 'scroll-to-area', 'change-submitter', 'set-drag-placeholder', 'select-submitter'], + emits: ['add-field', 'set-draw', 'set-draw-type', 'set-drag', 'drag-end', 'scroll-to-area', 'change-submitter', 'set-drag-placeholder', 'select-submitter', 'set-draw-with-name'], data () { return { fieldPagesLoaded: null, @@ -620,4 +642,4 @@ export default { } } } - + \ No newline at end of file diff --git a/app/views/templates/edit.html.erb b/app/views/templates/edit.html.erb index 9fbc8d39..a41a0ad6 100644 --- a/app/views/templates/edit.html.erb +++ b/app/views/templates/edit.html.erb @@ -6,4 +6,29 @@ <%= button_to nil, user_configs_path, method: :post, params: { user_config: { key: UserConfig::SHOW_APP_TOUR, value: true } }, class: 'hidden', id: 'start_tour_button' %> <% end %> <% end %> - +<% predefined_fields = [ + { name: 'units', type: 'number', title: 'Units' }, + { name: 'schedule_date', type: 'date', title: 'Schedule Date' }, + { name: 'from_time', type: 'text', title: 'From Time' }, + { name: 'to_time', type: 'text', title: 'To Time' }, + { name: 'place_of_service', type: 'text', title: 'Place of Service' }, + { name: 'time_duration', type: 'text', title: 'Time Duration' }, + { name: 'supervisor_name', type: 'text', title: 'Supervisor Name' }, + { name: 'provider_npi', type: 'text', title: 'Provider NPI' }, + { name: 'provider_name', type: 'text', title: 'Provider Name' }, + { name: 'provider_credential_type', type: 'text', title: 'Provider Credential Type' }, + { name: 'patient_name', type: 'text', title: 'Patient Name' }, + { name: 'patient_first_name', type: 'text', title: 'Patient First Name' }, + { name: 'patient_last_name', type: 'text', title: 'Patient Last Name' }, + { name: 'patient_gender', type: 'text', title: 'Patient Gender' }, + { name: 'patient_dob', type: 'date', title: 'Patient DOB' }, + { name: 'patient_address', type: 'text', title: 'Patient Address' }, + { name: 'patient_phone', type: 'text', title: 'Patient Phone' }, + { name: 'patient_initials', type: 'initials', title: 'Patient Initials' }, + { name: 'patient_age', type: 'number', title: 'Patient Age' }, + { name: 'patient_language', type: 'text', title: 'Patient Language' }, + { name: 'patient_parent_name', type: 'text', title: 'Patient Parent Name' }, + { name: 'patient_first_seen_date', type: 'date', title: 'Patient First Seen Date' }, + { name: 'payor_name', type: 'text', title: 'Payor Name' } +] %> + \ No newline at end of file