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 @@ +