Sha256: 06b3cb550dbd5df1c76be35a36a3cc4b39cffd70d688074ad616781599054c96

Contents?: true

Size: 1.66 KB

Versions: 16

Compression:

Stored size: 1.66 KB

Contents

class RelationshipGridGenerator < Rails::Generators::NamedBase
  source_root File.expand_path('../templates', __FILE__)
  argument :relationship_type, :type => :string, :required => true
  argument :title, :type => :string, :required => true
  argument :description, :type => :string, :required => true

  def generate_relationship_grid
    path = "public/javascripts/erp_app/organizer/applications/crm/relationship_grid_widgets.js"

    if File.exist?(path)
      insert_into_file path, :after => "});" do
        <<-eos
\nExt.define('Compass.ErpApp.Organizer.Applications.Crm.RelationshipGrid.#{class_name}',{
    extend:'Compass.ErpApp.Organizer.Applications.Crm.RelationshipGrid',
    alias:'widget.#{file_name}',
    initComponent: function () {
        this.callParent(arguments);
    },
    constructor: function(config) {
        config.relationshiptype = '#{relationship_type}';
        config.title = '#{title}';
        this.callParent([config]);
    }
});
        eos
      end
    else 
      create_file path do
        <<-eos
\nExt.define('Compass.ErpApp.Organizer.Applications.Crm.RelationshipGrid.#{class_name}',{
    extend:'Compass.ErpApp.Organizer.Applications.Crm.RelationshipGrid',
    alias:'widget.#{file_name}',
    initComponent: function () {
        this.callParent(arguments);
    },
    constructor: function(config) {
        config.relationshiptype = '#{relationship_type}';
        config.title = '#{title}';
        this.callParent([config]);
    }
});
        eos
      end
    end

    #migration
    template "migrate/migration_template.rb", "db/data_migrations/#{RussellEdge::DataMigrator.next_migration_number}_create_#{file_name}_relationship_grid.rb"
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
erp_app-3.0.16 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.15 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.14 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.13 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.12 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.10 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.9 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.8 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.7 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.6 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.5 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.4 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.3 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.2 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.1 lib/generators/relationship_grid/relationship_grid_generator.rb
erp_app-3.0.0 lib/generators/relationship_grid/relationship_grid_generator.rb