Browse Source

Feature: Mobile - Improved handling of rendered object attribute fields.

Martin Gruner 2 years ago
parent
commit
b014e41caf

+ 0 - 6
app/frontend/shared/graphql/types.ts

@@ -718,12 +718,6 @@ export type ObjectAttributeValue = {
   value?: Maybe<Scalars['JSON']>;
   value?: Maybe<Scalars['JSON']>;
 };
 };
 
 
-
-/** Data of one object attribute value of another object */
-export type ObjectAttributeValueRenderedValueArgs = {
-  templateRenderContext: TemplateRenderContextInput;
-};
-
 /** Data of one object attribute value of another object */
 /** Data of one object attribute value of another object */
 export type ObjectAttributeValueInput = {
 export type ObjectAttributeValueInput = {
   /** The name of the current object's attribute */
   /** The name of the current object's attribute */

+ 3 - 6
app/graphql/gql/types/object_attribute_value_type.rb

@@ -7,12 +7,9 @@ module Gql::Types
 
 
     field :attribute, Gql::Types::ObjectManager::FrontendAttributeType, null: false, description: 'The object attribute record'
     field :attribute, Gql::Types::ObjectManager::FrontendAttributeType, null: false, description: 'The object attribute record'
     field :value, GraphQL::Types::JSON, description: "The value of the current object's object attribute"
     field :value, GraphQL::Types::JSON, description: "The value of the current object's object attribute"
+    field :rendered_value, GraphQL::Types::JSON, description: 'Rendered version of the value that considers templates which are defined'
 
 
-    field :rendered_value, GraphQL::Types::JSON, description: 'Rendered version of the value that considers templates which are defined' do
-      argument :template_render_context, Gql::Types::Input::TemplateRenderContextInputType, description: 'Context data for the text module rendering, e.g. customer data.'
-    end
-
-    def rendered_value(template_render_context:)
+    def rendered_value
       value = @object[:value]
       value = @object[:value]
       return value if !value.is_a?(String)
       return value if !value.is_a?(String)
 
 
@@ -20,7 +17,7 @@ module Gql::Types
       return value if !template
       return value if !template
 
 
       NotificationFactory::Renderer.new(
       NotificationFactory::Renderer.new(
-        objects:  template_render_context.to_context_hash,
+        objects:  { @object[:parent].class.name.downcase.to_sym => @object[:parent] },
         template: template,
         template: template,
         escape:   false
         escape:   false
       ).render
       ).render

+ 1 - 1
app/graphql/gql/types/object_attribute_values_interface.rb

@@ -14,7 +14,7 @@ module Gql::Types
       return [] if !@object || !context.current_user?
       return [] if !@object || !context.current_user?
 
 
       find_object_attributes.reduce([]) do |result, oa|
       find_object_attributes.reduce([]) do |result, oa|
-        result << { attribute: attribute_hash(oa.attribute), value: @object[oa.attribute[:name].to_sym] }
+        result << { attribute: attribute_hash(oa.attribute), value: @object[oa.attribute[:name].to_sym], parent: @object }
       end
       end
     end
     end
 
 

+ 1 - 1
spec/graphql/gql/queries/current_user_spec.rb

@@ -21,7 +21,7 @@ RSpec.describe Gql::Queries::CurrentUser, type: :graphql do
                 name
                 name
               }
               }
               value
               value
-              renderedValue(templateRenderContext: {})
+              renderedValue
             }
             }
             organization {
             organization {
               name
               name