From de2faf893fa4711b8c3b821077ecc478f57f0af5 Mon Sep 17 00:00:00 2001 From: angusmcleod Date: Tue, 7 Sep 2021 11:11:29 +0800 Subject: [PATCH] FIX: Minor bugfixes in manager and create_group action (cherry picked from commit 208cb1229a72acc4e8c02d6e9c0e23980b25c5d9) --- controllers/custom_wizard/admin/manager.rb | 11 ++++++----- lib/custom_wizard/mapper.rb | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/controllers/custom_wizard/admin/manager.rb b/controllers/custom_wizard/admin/manager.rb index 2277de48..7dcc662c 100644 --- a/controllers/custom_wizard/admin/manager.rb +++ b/controllers/custom_wizard/admin/manager.rb @@ -48,20 +48,21 @@ class CustomWizard::AdminManagerController < CustomWizard::AdminController imported = [] failures = [] + templates = template_json.is_a?(Array) ? template_json : [template_json] - template_json.each do |json| - template = CustomWizard::Template.new(json) + templates.each do |raw_template| + template = CustomWizard::Template.new(raw_template) template.save(skip_jobs: true, create: true) if template.errors.any? failures.push( - id: json['id'], + id: template.data['id'], messages: template.errors.full_messages.join(', ') ) else imported.push( - id: json['id'], - name: json['name'] + id: template.data['id'], + name: template.data['name'] ) end end diff --git a/lib/custom_wizard/mapper.rb b/lib/custom_wizard/mapper.rb index 0c3543cf..3ba52cb0 100644 --- a/lib/custom_wizard/mapper.rb +++ b/lib/custom_wizard/mapper.rb @@ -225,7 +225,7 @@ class CustomWizard::Mapper end def interpolate(string, opts = { user: true, wizard: true, value: true, template: false }) - return string if string.blank? + return string if string.blank? || string.frozen? if opts[:user] string.gsub!(/u\{(.*?)\}/) { |match| map_user_field($1) || '' }