forest_admin_datasource_active_record 1.0.0.pre.beta.95 → 1.0.0.pre.beta.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 14b38a52aa95adb40477a63cc126e1c0ca9b64deac752faab651dc41b48e7589
         | 
| 4 | 
            +
              data.tar.gz: 99517b7674002b976f641b980c8f132a0f11dd98f5cb05ce4e350ba409201c25
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: bba918fc280643db5e5ae2f85ba4c07524e14aeac607fe3af60509ef01637190859f63c7a7edb2cfbafe124d859a937c08a8c0b1bac64397be11179967b54a4d
         | 
| 7 | 
            +
              data.tar.gz: be1c7702d6830c94e7370e437270b495130989a147fb874a95562f598a309adcb609e3f687bfc29ffc07f4fc15f1cb48b458c471442b8089989a99a54b4f3d41
         | 
| @@ -175,6 +175,18 @@ module ForestAdminDatasourceActiveRecord | |
| 175 175 | 
             
                          )
         | 
| 176 176 | 
             
                        end
         | 
| 177 177 | 
             
                      end
         | 
| 178 | 
            +
                    when :has_and_belongs_to_many
         | 
| 179 | 
            +
                      add_field(
         | 
| 180 | 
            +
                        association.name.to_s,
         | 
| 181 | 
            +
                        ForestAdminDatasourceToolkit::Schema::Relations::ManyToManySchema.new(
         | 
| 182 | 
            +
                          foreign_collection: format_model_name(association.klass.name),
         | 
| 183 | 
            +
                          origin_key: association.join_primary_key,
         | 
| 184 | 
            +
                          origin_key_target: association.join_foreign_key,
         | 
| 185 | 
            +
                          foreign_key: association.association_foreign_key,
         | 
| 186 | 
            +
                          foreign_key_target: association.association_primary_key,
         | 
| 187 | 
            +
                          through_collection: association.join_table.classify
         | 
| 188 | 
            +
                        )
         | 
| 189 | 
            +
                      )
         | 
| 178 190 | 
             
                    end
         | 
| 179 191 | 
             
                  end
         | 
| 180 192 | 
             
                end
         | 
| @@ -78,7 +78,8 @@ module ForestAdminDatasourceActiveRecord | |
| 78 78 | 
             
                    @models << model unless model.abstract_class? ||
         | 
| 79 79 | 
             
                                            @models.include?(model) ||
         | 
| 80 80 | 
             
                                            !model.table_exists? ||
         | 
| 81 | 
            -
                                            !primary_key?(model)
         | 
| 81 | 
            +
                                            !primary_key?(model) ||
         | 
| 82 | 
            +
                                            model.const_defined?(:VIRTUAL_THROUGH_COLLECTION)
         | 
| 82 83 | 
             
                  end
         | 
| 83 84 | 
             
                end
         | 
| 84 85 |  | 
| @@ -101,19 +102,24 @@ module ForestAdminDatasourceActiveRecord | |
| 101 102 | 
             
                  if @habtm_models.key?(model.table_name)
         | 
| 102 103 | 
             
                    @habtm_models[model.table_name].left_reflection = model.right_reflection
         | 
| 103 104 | 
             
                    # when the second model is added, we can push the HABTM model to the models list
         | 
| 104 | 
            -
                     | 
| 105 | 
            +
                    through_model = make_through_model(
         | 
| 105 106 | 
             
                      model.table_name,
         | 
| 106 107 | 
             
                      [
         | 
| 107 108 | 
             
                        @habtm_models[model.table_name].left_reflection,
         | 
| 108 109 | 
             
                        @habtm_models[model.table_name].right_reflection
         | 
| 109 110 | 
             
                      ]
         | 
| 110 111 | 
             
                    )
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                    add_collection(
         | 
| 114 | 
            +
                      Collection.new(self, through_model, support_polymorphic_relations: @support_polymorphic_relations)
         | 
| 115 | 
            +
                    )
         | 
| 111 116 | 
             
                  else
         | 
| 112 117 | 
             
                    @habtm_models[model.table_name] = model
         | 
| 113 118 | 
             
                  end
         | 
| 114 119 | 
             
                end
         | 
| 115 120 |  | 
| 116 121 | 
             
                def make_through_model(table_name, associations)
         | 
| 122 | 
            +
                  through_model_name = table_name.classify
         | 
| 117 123 | 
             
                  through_model = Class.new(ActiveRecord::Base) do
         | 
| 118 124 | 
             
                    class << self
         | 
| 119 125 | 
             
                      attr_accessor :name, :table_name
         | 
| @@ -124,13 +130,15 @@ module ForestAdminDatasourceActiveRecord | |
| 124 130 | 
             
                    end
         | 
| 125 131 | 
             
                  end
         | 
| 126 132 |  | 
| 127 | 
            -
                  through_model.name =  | 
| 133 | 
            +
                  through_model.name = through_model_name
         | 
| 128 134 | 
             
                  through_model.table_name = table_name
         | 
| 129 135 | 
             
                  through_model.primary_key = [associations[0].foreign_key, associations[1].foreign_key]
         | 
| 130 136 | 
             
                  associations.each do |association|
         | 
| 131 137 | 
             
                    through_model.add_association(association.name, association.options)
         | 
| 132 138 | 
             
                  end
         | 
| 133 139 |  | 
| 140 | 
            +
                  through_model.const_set(:VIRTUAL_THROUGH_COLLECTION, true)
         | 
| 141 | 
            +
             | 
| 134 142 | 
             
                  through_model
         | 
| 135 143 | 
             
                end
         | 
| 136 144 | 
             
              end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: forest_admin_datasource_active_record
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0.0.pre.beta. | 
| 4 | 
            +
              version: 1.0.0.pre.beta.97
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Matthieu
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire:
         | 
| 10 10 | 
             
            bindir: exe
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2025- | 
| 12 | 
            +
            date: 2025-02-24 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: activerecord
         |