localtower 0.5.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -17
  3. data/app/controllers/localtower/pages_controller.rb +27 -12
  4. data/app/views/layouts/localtower/application.html.erb +16 -33
  5. data/app/views/localtower/pages/_alert_no_models.html.erb +3 -0
  6. data/app/views/localtower/pages/migrations.html.erb +52 -83
  7. data/app/views/localtower/pages/models.html.erb +53 -70
  8. data/app/views/localtower/pages/new_migration.html.erb +103 -0
  9. data/app/views/localtower/pages/new_model.html.erb +87 -0
  10. data/config/routes.rb +4 -4
  11. data/lib/localtower/generators/migration.rb +51 -120
  12. data/lib/localtower/generators/model.rb +52 -28
  13. data/lib/localtower/generators/service_objects/insert_array.rb +23 -0
  14. data/lib/localtower/generators/service_objects/insert_defaults.rb +15 -43
  15. data/lib/localtower/generators/service_objects/insert_indexes.rb +80 -0
  16. data/lib/localtower/generators/service_objects/insert_nullable.rb +23 -0
  17. data/lib/localtower/status.rb +1 -1
  18. data/lib/localtower/tools.rb +13 -16
  19. data/lib/localtower/version.rb +1 -1
  20. data/public/css/app.css +0 -49
  21. data/public/js/app.js +215 -70
  22. data/public/screenshots/v1.0.0/migrations.png +0 -0
  23. data/public/screenshots/v1.0.0/models.png +0 -0
  24. data/public/screenshots/v1.0.0/new_migration.png +0 -0
  25. data/public/screenshots/v1.0.0/new_model.png +0 -0
  26. data/spec/dummy/Gemfile +0 -2
  27. data/spec/dummy/Gemfile.lock +1 -10
  28. data/spec/dummy/app/models/post.rb +3 -0
  29. data/spec/dummy/app/models/user.rb +1 -0
  30. data/spec/dummy/config/environments/development.rb +1 -0
  31. data/spec/dummy/config/puma.rb +1 -1
  32. data/spec/dummy/db/migrate/20230119221452_create_users.rb +14 -0
  33. data/spec/dummy/db/migrate/20230119221751_change_users_at1674166670.rb +7 -0
  34. data/spec/dummy/db/migrate/20230119222054_create_posts.rb +11 -0
  35. data/spec/dummy/db/migrate/20230119222106_change_posts_at1674166865.rb +5 -0
  36. data/spec/dummy/db/schema.rb +20 -8
  37. data/spec/dummy/log/development.log +15281 -3345
  38. data/spec/dummy/log/localtower.log +1897 -132
  39. data/spec/dummy/log/test.log +0 -0
  40. data/spec/dummy/test/index.html +38 -0
  41. data/spec/dummy/tmp/pids/server.pid +1 -0
  42. data/spec/factories/migration.rb +25 -41
  43. data/spec/factories/model.rb +39 -25
  44. data/spec/lib/localtower/generators/migration_spec.rb +36 -63
  45. data/spec/lib/localtower/generators/model_spec.rb +43 -34
  46. data/spec/lib/localtower/generators/service_objects/insert_array_spec.rb +47 -0
  47. data/spec/lib/localtower/generators/service_objects/insert_defaults_spec.rb +30 -35
  48. data/spec/lib/localtower/generators/service_objects/insert_indexes_spec.rb +90 -0
  49. data/spec/lib/localtower/generators/service_objects/insert_nullable_spec.rb +61 -0
  50. data/spec/lib/localtower/tools_spec.rb +1 -11
  51. data/spec/spec_helper.rb +8 -3
  52. metadata +34 -18
  53. data/app/views/localtower/pages/_migrations.html.erb +0 -57
  54. data/app/views/localtower/pages/schema.html.erb +0 -67
  55. data/spec/dummy/db/migrate/20221115190039_create_users.rb +0 -13
  56. data/spec/dummy/db/migrate/20221115193020_change_users.rb +0 -8
  57. data/spec/dummy/db/migrate/20221115193532_change_users_at1668540931.rb +0 -5
  58. data/spec/dummy/db/migrate/20221115193605_change_users_at1668540964.rb +0 -5
  59. data/spec/dummy/db/migrate/20221115193637_change_users_at1668540996.rb +0 -5
  60. data/spec/dummy/db/migrate/20221115193642_change_users_at1668541001.rb +0 -5
  61. data/spec/lib/localtower/generators/relation_spec.rb +0 -65
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f287a30405aef9188949f37fa3142997d91e188fa0d71db42ba550d47a73bc7
4
- data.tar.gz: 9ba53f02eefe31b6f6f1901c2dc3b8a17461a72db8086fb2bd845ec7979fde7b
3
+ metadata.gz: 9db89fe02b54c1eb46633f4df610405c050aaf5a44bcdc22a90ffe7cbb54637b
4
+ data.tar.gz: 6738a7be7646e0c4cf0844def2b6785f659922c064cf5e7e0ac39242c6f5f7b4
5
5
  SHA512:
6
- metadata.gz: 122fd3997f2540a5fe239cadf8790975c5d881ad85ed4f632f99d53f94719832404b8ce265844f9da00f21661425106c74a6423b608bbdcb649002af6d963789
7
- data.tar.gz: 8f6c8eda883c0e0dc54f1b9b218cfbd41c5dc15c36ab8ec481ffe1e2c241cefa04714c3f468d0b47556dee5576a18e69b4e42e2c46ad52850ffbb54fb332f641
6
+ metadata.gz: 2388bae27139b79e346b70fab53701f87112aca41d104fa3dcd8b2b9d3537dc9d54742c990384135cc347b50207d5023d96b699847b568731e78ed1204a3afe5
7
+ data.tar.gz: 18959e622626a9452fdc67dae321ef93f1be65e81657e66ad692f330bfe2fc47c29fb731c66adddd3d61f718c286caf70b9b0fa9e219ec616aea5acfd8aaee71
data/README.md CHANGED
@@ -4,27 +4,28 @@
4
4
 
5
5
  ## Intro
6
6
 
7
- Update in 2022, please use localtower version `>= 0.4.1`
7
+ Please use localtower version `>= 1.0.0`
8
8
  See installation process below.
9
+
9
10
  Compatibility:
10
11
  - Rails >= 5.2
11
12
  - Ruby >= 2.3
12
13
 
13
- ### See the schema
14
- ![Schema](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v0.1.6/1_schema.png)
15
-
16
14
  ### Create a model
17
- ![Models](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v0.1.6/2_models_1.png)
18
-
19
- ### Create a many to many relation
20
- ![Relations](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v0.1.6/3_relations.png)
15
+ ![New Model](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v1.0.0/new_model.png)
21
16
 
22
17
  ### Create a migration
23
- ![Migrations](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v0.1.6/4_migrations.png)
18
+ ![New Migration](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v1.0.0/new_migration.png)
19
+
20
+ ### See the Models
21
+ ![Models](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v1.0.0/models.png)
22
+
23
+ ### See the Migrations (and migrate)
24
+ ![Migrations](https://raw.githubusercontent.com/damln/localtower/master/public/screenshots/v1.0.0/migrations.png)
24
25
 
25
26
  ## INSTALL
26
27
 
27
- Should work with any Rails 4.2+ application.
28
+ Should work with any Rails 5.2+ application.
28
29
  Only tested with PostgreSQL.
29
30
 
30
31
  Add to your `Gemfile` file:
@@ -42,8 +43,8 @@ bundle install
42
43
  Add to your `config/routes.rb`:
43
44
  ```ruby
44
45
  MyApp::Application.routes.draw do
45
- if Rails.env.development? and defined?(Localtower)
46
- mount Localtower::Engine, at: "localtower"
46
+ if Rails.env.development?
47
+ mount Localtower::Engine, at: 'localtower'
47
48
  end
48
49
 
49
50
  # Your other routes here:
@@ -56,8 +57,6 @@ Change your config/environments/development.rb:
56
57
 
57
58
  ```ruby
58
59
  Rails.application.configure do
59
- # ...
60
-
61
60
  # This is the default:
62
61
  # config.active_record.migration_error = :page_load
63
62
 
@@ -68,10 +67,17 @@ Rails.application.configure do
68
67
  end
69
68
  ```
70
69
 
70
+ If you know how to override this configuration in the gem instead of doing it in your app code, please open an issue and tell me your solution.
71
+
71
72
  ## Usage
72
73
 
73
74
  Open your browser at [http://localhost:3000/localtower](http://localhost:3000/localtower).
74
75
 
76
+ ## Roadmap
77
+
78
+ - Be able to use `uuid` instead of `id` as primary when creating models.
79
+ - Realtime preview of the migration files
80
+ - Better frontend validation
75
81
 
76
82
  ## Run test
77
83
 
@@ -92,12 +98,12 @@ bundle exec rspec spec/
92
98
 
93
99
  ## Contribute
94
100
 
95
- Thanks for reporting issues, I'll do my best 💪
101
+ Thanks for reporting issues, I'll do my best to fix the bugs 💪
96
102
 
97
103
  ![ga](https://www.google-analytics.com/collect?v=1&tid=G-1XG3EBE2DZ&cid=555&aip=1&t=event&ec=github&ea=visit&dp=readme&dt=gem)
98
104
 
99
-
100
105
  ## Deploy
106
+
101
107
  Only for official contributors.
102
108
 
103
109
  rm *.gem | gem build localtower.gemspec && gem push localtower-*.gem
@@ -107,4 +113,6 @@ Only for official contributors.
107
113
  Do not hesitate to open issues if you have troubles using the gem.
108
114
 
109
115
  - By Damian Le Nouaille Diez: https://damln.com
110
- - Link on RubyGems: https://rubygems.org/gems/localtower
116
+ - Supported by Explicit Ruby: https://explicit-ruby.run
117
+ - Link on RubyGems.org: https://rubygems.org/gems/localtower
118
+ - Stats on BestGems.org: https://bestgems.org/gems/localtower
@@ -2,17 +2,17 @@ require_dependency 'localtower/application_controller'
2
2
 
3
3
  module Localtower
4
4
  class PagesController < ApplicationController
5
- before_action :set_migrations, only: [:migrations, :models]
6
-
7
- def schema
5
+ def new_migration
6
+ @models = ::Localtower::Tools.models_presented
8
7
  end
9
8
 
10
9
  def migrations
10
+ @migrations = ::Localtower::Status.new.run
11
11
  end
12
12
 
13
13
  def post_migrations
14
14
  # Because we have a list or a field, take the item from the list in priority
15
- migrations = clean_params["migrations"]["migrations"].map do |action_line|
15
+ migrations = clean_params["migrations"].map do |action_line|
16
16
  # This is used for "rename_column" action:
17
17
  action_line["new_column_type"] = action_line["column_type"]
18
18
 
@@ -26,29 +26,44 @@ module Localtower
26
26
  action_line
27
27
  end
28
28
 
29
- use_generator(::Localtower::Generators::Migration, { 'migrations' => migrations })
29
+ use_generator(::Localtower::Generators::Migration, migrations)
30
+
30
31
  redirect_to migrations_path
31
32
  end
32
33
 
34
+ def new_model
35
+ end
36
+
33
37
  def models
38
+ @models = ::Localtower::Tools.models_presented
34
39
  end
35
40
 
36
41
  def post_models
37
- use_generator(::Localtower::Generators::Model, clean_params["models"])
38
- redirect_to models_path
42
+ model = clean_params["model"]
43
+ model['attributes'] = model['attributes'].map do |attribute_line|
44
+ # Convert checkbox to ruby value:
45
+ attribute_line['nullable'] = false if attribute_line['nullable'].blank?
46
+
47
+ # Convert index hash:
48
+ if attribute_line['index']
49
+ attribute_line['index']['unique'] = true if attribute_line['index']['unique'] == 'true'
50
+ end
51
+
52
+ attribute_line
53
+ end
54
+
55
+ use_generator(::Localtower::Generators::Model, model)
56
+ redirect_to migrations_path
39
57
  end
40
58
 
41
59
  def post_actions
42
- ::Localtower::Tools.perform_cmd(clean_params['cmd'], false)
60
+ cmd = ::Localtower::Tools.perform_cmd(clean_params['cmd'])
61
+ flash[:notice] = cmd if cmd['ERROR']
43
62
  redirect_back fallback_location: root_path
44
63
  end
45
64
 
46
65
  private
47
66
 
48
- def set_migrations
49
- @migrations = ::Localtower::Status.new.run.select { |entry| entry['status'] == :todo }
50
- end
51
-
52
67
  def use_generator(generator_klass, options)
53
68
  generator_klass.new(options).run
54
69
  end
@@ -2,48 +2,44 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <title>Localtower - <%= yield :title %></title>
5
-
6
5
  <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
7
6
  <meta name="viewport" content="width=device-width" />
8
7
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
9
-
10
8
  <link rel="stylesheet" type="text/css" href="/light-bootstrap-dashboard-master/assets/css/bootstrap.min.css">
11
- <link rel="stylesheet" type="text/css" href="/light-bootstrap-dashboard-master/assets/css/animate.min.css">
9
+ <!-- <link rel="stylesheet" type="text/css" href="/light-bootstrap-dashboard-master/assets/css/animate.min.css"> -->
12
10
  <link rel="stylesheet" type="text/css" href="/light-bootstrap-dashboard-master/assets/css/light-bootstrap-dashboard.css">
13
-
14
11
  <!-- Fonts and icons -->
15
12
  <link href="/vendor/font-awesome.min.css" rel="stylesheet">
16
13
  <link rel="stylesheet" type="text/css" href="/light-bootstrap-dashboard-master/assets/css/pe-icon-7-stroke.css">
17
-
18
14
  <link rel="stylesheet" type="text/css" href="/vendor/highlight-js-default.min.css">
19
15
  <link rel="stylesheet" type="text/css" href="/css/app.css">
20
-
21
16
  <%= csrf_meta_tags %>
22
17
  </head>
23
-
24
18
  <body>
25
-
26
19
  <div class="wrapper">
27
20
  <div class="sidebar">
28
-
29
21
  <div class="sidebar-wrapper">
30
22
  <ul class="nav">
31
- <li class="<%= is_active_link?(schema_path, :inclusive) ? "active" : nil %>">
32
- <a href="<%= schema_path %>">
33
- <i class="pe-7s-home"></i>
34
- <p>Schema</p>
23
+ <li class="<%= is_active_link?(models_path, :exclusive) ? "active" : nil %>">
24
+ <a href="<%= models_path %>">
25
+ <i class="pe-7s-network"></i>
26
+ <p>Models</p>
35
27
  </a>
36
28
  </li>
37
-
38
- <li class="<%= is_active_link?(models_path, :inclusive) ? "active" : nil %>">
39
- <a href="<%= models_path %>">
29
+ <li class="<%= is_active_link?(migrations_path, :exclusive) ? "active" : nil %>">
30
+ <a href="<%= migrations_path %>">
31
+ <i class="pe-7s-back"></i>
32
+ <p>Migrations</p>
33
+ </a>
34
+ </li>
35
+ <li class="<%= is_active_link?(new_model_path, :inclusive) ? "active" : nil %>">
36
+ <a href="<%= new_model_path %>">
40
37
  <i class="pe-7s-server"></i>
41
38
  <p>New Model</p>
42
39
  </a>
43
40
  </li>
44
-
45
- <li class="<%= is_active_link?(migrations_path, :inclusive) ? "active" : nil %>">
46
- <a href="<%= migrations_path %>">
41
+ <li class="<%= is_active_link?(new_migration_path, :exclusive) ? "active" : nil %>">
42
+ <a href="<%= new_migration_path %>">
47
43
  <i class="pe-7s-edit"></i>
48
44
  <p>New Migration</p>
49
45
  </a>
@@ -51,8 +47,6 @@
51
47
  </ul>
52
48
  </div>
53
49
  </div>
54
-
55
-
56
50
  <div class="main-panel">
57
51
  <div class="content">
58
52
  <div class="container-fluid">
@@ -61,12 +55,10 @@
61
55
  </div>
62
56
  </div>
63
57
  </div>
64
-
65
58
  <div class="full-message" style="display: none;">
66
-
67
59
  <div class="text-center">
68
60
  <br>
69
- <h3>Magic stuff happening.</h3>
61
+ <h3>Generating files</h3>
70
62
  <br>
71
63
  <i class="pe-7s-refresh-2 rotate"></i>
72
64
  <br>
@@ -79,18 +71,9 @@
79
71
  <code>bundle exec rails db:migrate</code>
80
72
  </p>
81
73
  </div>
82
-
83
74
  </div>
84
-
85
75
  <!-- Core JS Files -->
86
76
  <script src="/light-bootstrap-dashboard-master/assets/js/jquery-1.10.2.js" type="text/javascript"></script>
87
- <script src="/light-bootstrap-dashboard-master/assets/js/bootstrap.min.js" type="text/javascript"></script>
88
-
89
- <!-- Checkbox, Radio & Switch Plugins -->
90
- <script src="/light-bootstrap-dashboard-master/assets/js/bootstrap-checkbox-radio-switch.js"></script>
91
-
92
- <!-- Light Bootstrap Table Core javascript and methods for Demo purpose -->
93
- <script src="/light-bootstrap-dashboard-master/assets/js/light-bootstrap-dashboard.js"></script>
94
77
  <script src="/vendor/highlight.min.js"></script>
95
78
  <script src="/vendor/masonry.pkgd.min.js"></script>
96
79
  <script src="/js/app.js"></script>
@@ -0,0 +1,3 @@
1
+ <div class="alert alert-danger">
2
+ You don't have any models in this app. You can create one <%= link_to 'here.', models_path, class: 'btn btn-primary btn-fill btn-xs' %>
3
+ </div>
@@ -1,92 +1,61 @@
1
1
  <% content_for :title do %>Migrations<% end %>
2
-
3
2
  <div class="row">
4
3
  <div class="col-md-12">
5
- <div class="card">
6
- <div class="header">
7
- <h4 class="title"></h4>
8
- </div>
9
-
10
- <div class="content">
11
- <%= form_tag migrations_path, class: "form" do %>
12
-
13
- <table class="table table-hover table-striped">
14
- <thead>
15
- <th> <span data-selector=''>On Model</span></th>
16
- <th> <span data-selector=''>Action</span></th>
17
- <th> <span data-selector='belongs_to_label'>Belongs To</span></th>
18
- <th> <span data-selector='column_label'>Column</span></th>
19
- <th> <span data-selector='new_column_name_label'>New Column Name</span></th>
20
- <th> <span data-selector='column_type_label'>Type</span></th>
21
- <th> <span data-selector='index_label'>Index?</span></th>
22
- <th> <span data-selector='nullable_label'>Can be null?</span></th>
23
- <th> <span data-selector=''></span></th>
24
- </thead>
25
-
26
- <tbody data-selector="tbody">
27
- <tr data-selector="tr">
28
- <td>
29
- <%= select_tag "migrations[migrations][][table_name]", options_for_select(Localtower::Tools.models.collect {|p| [ p, p.table_name ] }), class: "form-control" %>
30
- </td>
31
-
32
- <td>
33
- <%= select_tag "migrations[migrations][][action]", options_for_select(::Localtower::Generators::Migration::ACTIONS), class: "form-control", "data-selector" => "action" %>
34
- </td>
35
-
36
- <td>
37
- <%= select_tag "migrations[migrations][][belongs_to]", options_for_select(Localtower::Tools.models.collect {|p| [ p, p.table_name ] }), class: "form-control", "data-selector" => "belongs_to" %>
38
- </td>
39
-
40
- <td class="text-center">
41
- <input type="text" name="migrations[migrations][][column]" class="form-control" data-selector="column_text">
42
-
43
- <%= select_tag "migrations[migrations][][column_list]", options_for_select(::Localtower::Tools.all_columns), class: "form-control", include_blank: true, "data-selector" => "column_list", style: "display:none;" %>
44
- </td>
45
-
46
- <td>
47
- <input type="text" name="migrations[migrations][][new_column_name]" class="form-control" data-selector="new_column_name">
48
- </td>
49
-
50
- <td>
51
- <%= select_tag "migrations[migrations][][column_type]", options_for_select(::Localtower::Generators::Migration::TYPES), class: "form-control", "data-selector" => "column_type" %>
52
- </td>
53
-
54
- <td>
55
- <input type="checkbox" name="migrations[migrations][][index]" class="form-control" data-selector="index">
56
- </td>
57
-
58
- <td>
59
- <input type="checkbox" name="migrations[migrations][][nullable]" class="form-control" checked="" data-selector="nullable">
60
- </td>
61
-
62
- <td>
63
- <div class="pull-right">
64
- <button class="btn btn-danger btn-xs pointer" data-selector="remove">Remove</button>
65
- </div>
66
- </td>
67
- </tr>
68
- </tbody>
69
- </table>
70
-
71
- <div class="row">
72
- <div class="col-md-12 text-center">
73
- <i class="pe-7s-plus pointer" data-selector="duplicate" style="font-size: 3em;"></i>
74
- </div>
4
+ <div class="content">
5
+ <% if flash[:notice] %>
6
+ <div class="alert alert-info">
7
+ <span><%= flash[:notice] %></span>
8
+ </div>
9
+ <% end %>
10
+ <div class="card">
11
+ <div class="header">
12
+ <% if @migrations.select {|i| i['status'] == :todo}.any? %>
13
+ <%= form_tag actions_path, class: "form" do %>
14
+ <button name="cmd" type="submit" value="rails db:migrate" class="btn btn-warning btn-fill" data-selector="submit">
15
+ Migrate Pending Migrations <code>bundle exec rails db:migrate</code>
16
+ </button>
17
+ <% end %>
18
+ <% end %>
75
19
  </div>
76
-
77
- <hr>
78
-
79
- <div class="row">
80
- <div class="col-md-12 text-center">
81
- <button type="submit" value="true" class="btn btn-success" data-selector="submit">
82
- Create the migration
83
- </button>
84
- </div>
20
+ <div class="content">
21
+ <% if @migrations.any? %>
22
+ <% @migrations.each do |entry| %>
23
+ <div class="container-fluid">
24
+ <div class="row">
25
+ <div class="col-md-12">
26
+ <h5 style="color: <%= entry['status'] == :todo ? 'red' : 'green' %>;">
27
+ <% if entry['status'] == :todo %>
28
+ <button type="button" class="btn btn-danger btn-xs">PENDING</button>
29
+ <a href="<%= file_link(entry['file_full_path']) %>"><%= entry['name'] %></a>
30
+ <% else %>
31
+ <%= form_tag actions_path, class: "form" do %>
32
+ <button name="cmd" title="rake db:migrate:down VERSION=<%= entry['time'] %>" type="submit" value="rake db:migrate:down VERSION=<%= entry['time'] %>" class="btn btn-info btn-xs btn-fill">
33
+ ROLLBACK
34
+ </button>
35
+ <a href="<%= file_link(entry['file_full_path']) %>"><%= entry['name'] %></a>
36
+ <% end %>
37
+ <% end %>
38
+ </h5>
39
+ </div>
40
+ </div>
41
+ <div class="row">
42
+ <div class="col-md-12">
43
+ <pre><code class="language-ruby"><%= entry['content'] %></code></pre>
44
+ </div>
45
+ </div>
46
+ </div>
47
+ <% end %>
48
+ <% else %>
49
+ <div class="card">
50
+ <div class="">
51
+ </div>
52
+ <div class="alert alert-info">
53
+ <span>No migrations found</span>
54
+ </div>
55
+ </div>
56
+ <% end %>
85
57
  </div>
86
- <% end %>
87
58
  </div>
88
59
  </div>
89
-
90
- <%= render partial: "migrations", locals: { migrations: @migrations } %>
91
60
  </div>
92
61
  </div>
@@ -1,80 +1,63 @@
1
1
  <% content_for :title do %>Models<% end %>
2
-
3
2
  <div class="row">
4
3
  <div class="col-md-12">
5
- <div class="card">
6
- <div class="header">
7
- <h4 class="title"></h4>
8
- </div>
9
-
10
- <div class="content">
11
- <%= form_tag models_path, class: "form" do %>
12
-
13
- <div class="row">
14
- <div class="col-md-6">
15
- <div class="form-group">
16
- <label>Name of the Model</label>
17
- <input type="text" data-sain name="models[model_name]" class="form-control">
18
- </div>
19
- </div>
20
- </div>
21
-
22
- <table class="table table-hover table-striped">
23
- <thead>
24
- <th>Column Name</th>
25
- <th>Type</th>
26
- <th>Default</th>
27
- <th>Index?</th>
28
- <th>Can be null?</th>
29
- <th></th>
30
- </thead>
31
-
32
- <tbody data-selector="tbody">
33
- <tr data-selector="tr">
34
- <td>
35
- <input type="text" name="models[attributes][][attribute_name]" class="form-control">
36
- </td>
37
- <td>
38
- <%= select_tag "models[attributes][][attribute_type]", options_for_select(::Localtower::Generators::Migration::TYPES), class: "form-control" %>
39
- </td>
40
- <td>
41
- <%= select_tag "models[attributes][][defaults]", options_for_select(::Localtower::Generators::Migration::DEFAULTS), include_blank: true, class: "form-control" %>
42
- </td>
43
- <td>
44
- <input type="checkbox" value="true" name="models[attributes][][index]" class="form-control">
45
- </td>
46
- <td>
47
- <input type="checkbox" value="true" name="models[attributes][][nullable]" class="form-control" checked>
48
- </td>
49
- <td>
50
- <div class="pull-right">
51
- <button class="btn btn-danger btn-xs pointer" data-selector="remove">Remove</button>
52
- </div>
53
- </td>
54
- </tr>
55
- </tbody>
56
- </table>
57
-
58
- <div class="row">
59
- <div class="col-md-12 text-center">
60
- <i class="pe-7s-plus pointer" data-selector="duplicate" style="font-size: 3em;"></i>
4
+ <div class="content">
5
+ <div class="">
6
+ <div class="card">
7
+ <div class="">
8
+ <% if @models.empty? %>
9
+ <%= render partial: 'alert_no_models' %>
10
+ <% end %>
61
11
  </div>
62
12
  </div>
63
-
64
- <hr>
65
-
66
- <!-- multiple lines: -->
67
- <div class="row">
68
- <div class="col-md-12 text-center">
69
- <button type="submit" value="true" class="btn btn-success" data-selector="submit">
70
- Create the model Only
71
- </button>
72
- </div>
13
+ <div class="grid">
14
+ <div class="grid-sizer"></div>
15
+ <% @models.each do |model| %>
16
+ <div class="grid-item text-small card">
17
+ <div class="text-center">
18
+ <h5><%= model[:name] %></h5>
19
+ </div>
20
+ <table class="table table-hover table-striped table-condensed">
21
+ <thead>
22
+ <th>Field</th>
23
+ <th>Type</th>
24
+ <th>Belongs To</th>
25
+ <th>Index?</th>
26
+ </thead>
27
+ <tbody>
28
+ <% model[:attributes_list].each do |attribute_data| %>
29
+ <tr>
30
+ <td>
31
+ <code>
32
+ <%= attribute_data["name"] %>
33
+ </code>
34
+ </td>
35
+ <td>
36
+ <%= attribute_data["type_clean"] %>
37
+ </td>
38
+ <td>
39
+ <% if attribute_data["belongs_to"] %>
40
+ <span class="label label-primary">
41
+ <%= attribute_data["belongs_to"] %>
42
+ </span>
43
+ <% end %>
44
+ </td>
45
+ <td>
46
+ <% if attribute_data["index"].any? %>
47
+ <span class="label label-success">Yes</span>
48
+ <% else %>
49
+ <span class="label label-default">No</span>
50
+ <% end %>
51
+ </td>
52
+ </tr>
53
+ <% end %>
54
+ </tbody>
55
+ </table>
56
+ </div>
57
+ <% end %>
58
+ <div class="clearfix"></div>
73
59
  </div>
74
- <% end %>
75
60
  </div>
76
61
  </div>
77
-
78
- <%= render partial: "migrations", locals: { migrations: @migrations } %>
79
62
  </div>
80
63
  </div>