ponytail 0.3.0 → 0.4.0

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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +11 -0
  4. data/Gemfile +8 -0
  5. data/Gemfile.lock +191 -0
  6. data/README.md +6 -0
  7. data/Rakefile +10 -6
  8. data/app/assets/javascripts/ponytail/models/column.coffee +41 -0
  9. data/app/assets/javascripts/ponytail/models/command.coffee +5 -0
  10. data/app/assets/javascripts/ponytail/models/create_table_command.coffee +11 -0
  11. data/app/assets/javascripts/ponytail/models/drop_table_command.coffee +5 -0
  12. data/app/assets/javascripts/ponytail/models/migration_file.coffee +38 -0
  13. data/app/assets/javascripts/ponytail/models/rename_table_command.coffee +5 -0
  14. data/app/assets/javascripts/ponytail/models/table.coffee +42 -0
  15. data/app/assets/javascripts/ponytail/ponytail.coffee +5 -0
  16. data/app/assets/javascripts/ponytail/views/column.coffee +70 -0
  17. data/app/assets/javascripts/ponytail/views/index.coffee +29 -0
  18. data/app/assets/javascripts/ponytail/views/migration_file.coffee +25 -0
  19. data/app/assets/javascripts/ponytail/views/new.coffee +58 -0
  20. data/app/assets/javascripts/ponytail/views/table.coffee +56 -0
  21. data/app/assets/stylesheets/ponytail/_base.scss +38 -0
  22. data/app/assets/stylesheets/ponytail/_index.scss +68 -0
  23. data/app/assets/stylesheets/ponytail/_new.scss +133 -0
  24. data/app/assets/stylesheets/ponytail/application.scss +5 -0
  25. data/app/views/ponytail/migrations/index.html.erb +49 -9
  26. data/app/views/ponytail/migrations/new.html.erb +84 -13
  27. data/app/views/ponytail/{migrations/_column_view_template.html.erb → templates/_column.html.erb} +7 -5
  28. data/app/views/ponytail/templates/_table.html.erb +14 -0
  29. data/bin/rails +3 -0
  30. data/lib/ponytail/version.rb +1 -1
  31. data/lib/ponytail.rb +3 -0
  32. data/lib/rails/mapper.rb +2 -2
  33. data/ponytail.gemspec +4 -1
  34. data/spec/dummy/config/environments/production.rb +1 -1
  35. data/spec/dummy/config/initializers/ponytail_on_heroku.rb +21 -0
  36. data/spec/features/migrations/index_spec.rb +1 -0
  37. data/spec/javascripts/ponytail/models/command_spec.coffee +5 -0
  38. data/spec/javascripts/ponytail/models/create_command_spec.js +0 -1
  39. data/spec/javascripts/ponytail/models/migration_file_spec.js +1 -1
  40. data/spec/javascripts/support/boots/boot.coffee +16 -0
  41. data/spec/javascripts/support/coffee-script.js +12 -0
  42. data/spec/javascripts/support/jasmine.yml +6 -5
  43. data/spec/javascripts/support/jasmine_helper.rb +16 -0
  44. data/spec/javascripts/support/run.html.erb +22 -0
  45. data/spec/rails/mapper_spec.rb +1 -1
  46. metadata +79 -28
  47. data/app/assets/javascripts/ponytail/models/column.js +0 -43
  48. data/app/assets/javascripts/ponytail/models/command.js +0 -8
  49. data/app/assets/javascripts/ponytail/models/create_table_command.js +0 -16
  50. data/app/assets/javascripts/ponytail/models/drop_table_command.js +0 -8
  51. data/app/assets/javascripts/ponytail/models/migration_file.js +0 -40
  52. data/app/assets/javascripts/ponytail/models/rename_table_command.js +0 -9
  53. data/app/assets/javascripts/ponytail/models/table.js +0 -44
  54. data/app/assets/javascripts/ponytail/ponytail.js +0 -15
  55. data/app/assets/javascripts/ponytail/views/column.js +0 -36
  56. data/app/assets/javascripts/ponytail/views/migration_file.js +0 -24
  57. data/app/assets/javascripts/ponytail/views/new_migrations.js +0 -36
  58. data/app/assets/javascripts/ponytail/views/table.js +0 -61
  59. data/app/assets/stylesheets/ponytail/application.css +0 -126
  60. data/app/views/ponytail/migrations/_column.html.erb +0 -22
  61. data/app/views/ponytail/migrations/_migration.html.erb +0 -13
  62. data/app/views/ponytail/migrations/_migration_file.html.erb +0 -23
  63. data/app/views/ponytail/migrations/_new_errors.html.erb +0 -10
  64. data/app/views/ponytail/migrations/_notice.html.erb +0 -6
  65. data/app/views/ponytail/migrations/_table.html.erb +0 -18
  66. data/app/views/ponytail/migrations/_table_view_template.html.erb +0 -23
  67. data/spec/javascripts/ponytail/models/command_spec.js +0 -8
@@ -9,7 +9,7 @@ module ActionDispatch::Routing
9
9
  it "should receive resources" do
10
10
  mapper.should_receive(:resources) { |*args, &block| block.call }
11
11
  mapper.should_receive(:collection) { |*args, &block| block.call }
12
- mapper.should_receive(:post).twice
12
+ mapper.should_receive(:get).twice
13
13
  mapper.mount_ponytail
14
14
  end
15
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ponytail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sinsoku
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-25 00:00:00.000000000 Z
11
+ date: 2013-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: 4.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: coffee-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 4.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 4.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: sass-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 4.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 4.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: compass-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
27
69
  - !ruby/object:Gem::Dependency
28
70
  name: bundler
29
71
  requirement: !ruby/object:Gem::Requirement
@@ -125,7 +167,8 @@ dependencies:
125
167
  description: Ponytail is a Rails engine that shows the migrations.
126
168
  email:
127
169
  - sinsoku.listy@gmail.com
128
- executables: []
170
+ executables:
171
+ - rails
129
172
  extensions: []
130
173
  extra_rdoc_files: []
131
174
  files:
@@ -134,37 +177,37 @@ files:
134
177
  - .rspec
135
178
  - .travis.yml
136
179
  - Gemfile
180
+ - Gemfile.lock
137
181
  - LICENSE.txt
138
182
  - README.md
139
183
  - Rakefile
140
184
  - app/assets/javascripts/ponytail/application.js
141
185
  - app/assets/javascripts/ponytail/collections/.keep
142
- - app/assets/javascripts/ponytail/models/column.js
143
- - app/assets/javascripts/ponytail/models/command.js
144
- - app/assets/javascripts/ponytail/models/create_table_command.js
145
- - app/assets/javascripts/ponytail/models/drop_table_command.js
146
- - app/assets/javascripts/ponytail/models/migration_file.js
147
- - app/assets/javascripts/ponytail/models/rename_table_command.js
148
- - app/assets/javascripts/ponytail/models/table.js
149
- - app/assets/javascripts/ponytail/ponytail.js
186
+ - app/assets/javascripts/ponytail/models/column.coffee
187
+ - app/assets/javascripts/ponytail/models/command.coffee
188
+ - app/assets/javascripts/ponytail/models/create_table_command.coffee
189
+ - app/assets/javascripts/ponytail/models/drop_table_command.coffee
190
+ - app/assets/javascripts/ponytail/models/migration_file.coffee
191
+ - app/assets/javascripts/ponytail/models/rename_table_command.coffee
192
+ - app/assets/javascripts/ponytail/models/table.coffee
193
+ - app/assets/javascripts/ponytail/ponytail.coffee
150
194
  - app/assets/javascripts/ponytail/routers/.keep
151
- - app/assets/javascripts/ponytail/views/column.js
152
- - app/assets/javascripts/ponytail/views/migration_file.js
153
- - app/assets/javascripts/ponytail/views/new_migrations.js
154
- - app/assets/javascripts/ponytail/views/table.js
155
- - app/assets/stylesheets/ponytail/application.css
195
+ - app/assets/javascripts/ponytail/views/column.coffee
196
+ - app/assets/javascripts/ponytail/views/index.coffee
197
+ - app/assets/javascripts/ponytail/views/migration_file.coffee
198
+ - app/assets/javascripts/ponytail/views/new.coffee
199
+ - app/assets/javascripts/ponytail/views/table.coffee
200
+ - app/assets/stylesheets/ponytail/_base.scss
201
+ - app/assets/stylesheets/ponytail/_index.scss
202
+ - app/assets/stylesheets/ponytail/_new.scss
203
+ - app/assets/stylesheets/ponytail/application.scss
156
204
  - app/controllers/ponytail/migrations_controller.rb
157
205
  - app/views/layouts/ponytail/application.html.erb
158
- - app/views/ponytail/migrations/_column.html.erb
159
- - app/views/ponytail/migrations/_column_view_template.html.erb
160
- - app/views/ponytail/migrations/_migration.html.erb
161
- - app/views/ponytail/migrations/_migration_file.html.erb
162
- - app/views/ponytail/migrations/_new_errors.html.erb
163
- - app/views/ponytail/migrations/_notice.html.erb
164
- - app/views/ponytail/migrations/_table.html.erb
165
- - app/views/ponytail/migrations/_table_view_template.html.erb
166
206
  - app/views/ponytail/migrations/index.html.erb
167
207
  - app/views/ponytail/migrations/new.html.erb
208
+ - app/views/ponytail/templates/_column.html.erb
209
+ - app/views/ponytail/templates/_table.html.erb
210
+ - bin/rails
168
211
  - config/routes.rb
169
212
  - lib/ponytail.rb
170
213
  - lib/ponytail/engine.rb
@@ -201,6 +244,7 @@ files:
201
244
  - spec/dummy/config/initializers/filter_parameter_logging.rb
202
245
  - spec/dummy/config/initializers/inflections.rb
203
246
  - spec/dummy/config/initializers/mime_types.rb
247
+ - spec/dummy/config/initializers/ponytail_on_heroku.rb
204
248
  - spec/dummy/config/initializers/secret_token.rb
205
249
  - spec/dummy/config/initializers/session_store.rb
206
250
  - spec/dummy/config/initializers/wrap_parameters.rb
@@ -219,12 +263,15 @@ files:
219
263
  - spec/javascripts/helpers/.keep
220
264
  - spec/javascripts/helpers/build_model.js
221
265
  - spec/javascripts/ponytail/models/column_spec.js
222
- - spec/javascripts/ponytail/models/command_spec.js
266
+ - spec/javascripts/ponytail/models/command_spec.coffee
223
267
  - spec/javascripts/ponytail/models/create_command_spec.js
224
268
  - spec/javascripts/ponytail/models/migration_file_spec.js
225
269
  - spec/javascripts/ponytail/models/table_spec.js
270
+ - spec/javascripts/support/boots/boot.coffee
271
+ - spec/javascripts/support/coffee-script.js
226
272
  - spec/javascripts/support/jasmine.yml
227
273
  - spec/javascripts/support/jasmine_helper.rb
274
+ - spec/javascripts/support/run.html.erb
228
275
  - spec/ponytail/migration_spec.rb
229
276
  - spec/ponytail/schema_spec.rb
230
277
  - spec/ponytail_spec.rb
@@ -287,6 +334,7 @@ test_files:
287
334
  - spec/dummy/config/initializers/filter_parameter_logging.rb
288
335
  - spec/dummy/config/initializers/inflections.rb
289
336
  - spec/dummy/config/initializers/mime_types.rb
337
+ - spec/dummy/config/initializers/ponytail_on_heroku.rb
290
338
  - spec/dummy/config/initializers/secret_token.rb
291
339
  - spec/dummy/config/initializers/session_store.rb
292
340
  - spec/dummy/config/initializers/wrap_parameters.rb
@@ -305,12 +353,15 @@ test_files:
305
353
  - spec/javascripts/helpers/.keep
306
354
  - spec/javascripts/helpers/build_model.js
307
355
  - spec/javascripts/ponytail/models/column_spec.js
308
- - spec/javascripts/ponytail/models/command_spec.js
356
+ - spec/javascripts/ponytail/models/command_spec.coffee
309
357
  - spec/javascripts/ponytail/models/create_command_spec.js
310
358
  - spec/javascripts/ponytail/models/migration_file_spec.js
311
359
  - spec/javascripts/ponytail/models/table_spec.js
360
+ - spec/javascripts/support/boots/boot.coffee
361
+ - spec/javascripts/support/coffee-script.js
312
362
  - spec/javascripts/support/jasmine.yml
313
363
  - spec/javascripts/support/jasmine_helper.rb
364
+ - spec/javascripts/support/run.html.erb
314
365
  - spec/ponytail/migration_spec.rb
315
366
  - spec/ponytail/schema_spec.rb
316
367
  - spec/ponytail_spec.rb
@@ -1,43 +0,0 @@
1
- Ponytail.Models.Column = Backbone.Model.extend({
2
- defaults: {
3
- type: "string",
4
- name: "new_column",
5
- isRemoved: false,
6
- isAdded: false,
7
- },
8
- initialize: function (attrs, options) {
9
- this.beforeType = attrs.type || "";
10
- this.beforeName = attrs.name || "";
11
- var func = _.bind(attrs.table.trigger, attrs.table, "change");
12
- this.bind("change", func);
13
- },
14
- isRemoved: function() {
15
- return this.get("isRemoved") === true;
16
- },
17
- isAdded: function() {
18
- return this.get("isAdded") === true;
19
- },
20
- isRename: function() {
21
- return this.beforeName != this.get("name");
22
- },
23
- isChangeType: function() {
24
- return this.beforeType != this.get("type");
25
- },
26
- getCommands: function() {
27
- var table = this.get("table");
28
- if (this.isRemoved()) {
29
- return [new Ponytail.Models.Command("remove_column", ":" + table.get("name"), ":" + this.beforeName)];
30
- } else if (this.isAdded()) {
31
- return [new Ponytail.Models.Command("add_column", ":" + table.get("name"), ":" + this.get("name"), ":" + this.get("type"))];
32
- } else {
33
- var commands = [];
34
- if (this.isRename()) {
35
- commands.push(new Ponytail.Models.Command("rename_column", ":" + table.get("name"), ":" + this.beforeName, ":" + this.get("name")));
36
- }
37
- if (this.isChangeType()) {
38
- commands.push(new Ponytail.Models.Command("change_column", ":" + table.get("name"), ":" + this.get("name"), ":" + this.get("type")));
39
- }
40
- return commands;
41
- }
42
- },
43
- });
@@ -1,8 +0,0 @@
1
- Ponytail.Models.Command = function() {
2
- this.args = Array.prototype.slice.call(arguments);
3
- };
4
- Ponytail.Models.Command.prototype = {
5
- toString: function() {
6
- return this.args.shift() + " " + this.args.join(", ");
7
- }
8
- };
@@ -1,16 +0,0 @@
1
- Ponytail.Models.CreateTableCommand = function(tableName, columns) {
2
- this.tableName = tableName;
3
- this.columns = columns;
4
- };
5
- Ponytail.Models.CreateTableCommand.prototype = {
6
- toString: function() {
7
- return [
8
- "create_table :" + this.tableName + " do |t|",
9
- this.columns.map(function(column) {
10
- return "t." + column.get("type") + " :" + column.get("name");
11
- }).join("\n").replace(/^/, " ").replace(/\n/g, "\n "),
12
- " t.timestamps",
13
- "end",
14
- ].join("\n");
15
- }
16
- };
@@ -1,8 +0,0 @@
1
- Ponytail.Models.DropTableCommand = function(tableName) {
2
- this.tableName = tableName;
3
- };
4
- Ponytail.Models.DropTableCommand.prototype = {
5
- toString: function() {
6
- return new Ponytail.Models.Command("drop_table", ":" + this.tableName);
7
- }
8
- };
@@ -1,40 +0,0 @@
1
- Ponytail.Models.MigrationFile = Backbone.Model.extend({
2
- defaults: {
3
- className: "",
4
- rawContent: "",
5
- },
6
- initialize: function(attrs, options) {
7
- this.tables = [];
8
- this.bind("change:className", this.update);
9
- },
10
- updateByTables: function(tables) {
11
- this.tables = tables;
12
- this.update();
13
- },
14
- update: function() {
15
- var rawContent = [
16
- "class " + this.get("className") + " < ActiveRecord::MigrationFile",
17
- this.getContentOfClass(),
18
- "end",
19
- ].join("\n");
20
- this.set({"rawContent": rawContent});
21
- },
22
- getContentOfClass: function() {
23
- return _.compact([
24
- "def change",
25
- this.getStringOfCommands(),
26
- "end",
27
- ]).join("\n").replace(/^/, " ").replace(/\n/g, "\n ");
28
- },
29
- getStringOfCommands: function() {
30
- var commands = this.getCommands();
31
- return commands.map(function(command) {
32
- return command.toString();
33
- }).join("\n").replace(/^/, " ").replace(/\n/g, "\n ");
34
- },
35
- getCommands: function() {
36
- return _.flatten(this.tables.map(function(table) {
37
- return table.getCommands();
38
- }));
39
- },
40
- });
@@ -1,9 +0,0 @@
1
- Ponytail.Models.RenameTableCommand = function(tableName, newName) {
2
- this.tableName = tableName;
3
- this.newName = newName;
4
- };
5
- Ponytail.Models.RenameTableCommand.prototype = {
6
- toString: function() {
7
- return new Ponytail.Models.Command("rename_table", ":" + this.tableName, ":" + this.newName);
8
- }
9
- };
@@ -1,44 +0,0 @@
1
- Ponytail.Models.Table = Backbone.Model.extend({
2
- defaults: {
3
- name: "new_table",
4
- columns: [],
5
- isDrop: false,
6
- isCreated: false,
7
- },
8
- initialize: function (attrs, options) {
9
- this.beforeName = attrs.name || "";
10
- },
11
- isCreated: function() {
12
- return this.get("isCreated") === true;
13
- },
14
- isDrop: function() {
15
- return this.get("isDrop") === true;
16
- },
17
- isRename: function() {
18
- return this.beforeName != this.get("name");
19
- },
20
- addColumn: function(column) {
21
- var columns = this.get("columns");
22
- columns.push(column);
23
- this.set({columns: columns});
24
- this.trigger("change");
25
- },
26
- getCommands: function() {
27
- if (this.isCreated() && this.isDrop()) {
28
- return [];
29
- } else if (this.isCreated() && !this.isDrop()) {
30
- return [new Ponytail.Models.CreateTableCommand(this.get("name"), this.get("columns"))];
31
- } else if (!this.isCreated() && this.isDrop()) {
32
- return [new Ponytail.Models.DropTableCommand(this.beforeName)];
33
- } else {
34
- var commands = [];
35
- if (this.isRename()) {
36
- commands.push(new Ponytail.Models.RenameTableCommand(this.beforeName, this.get("name")));
37
- }
38
- this.get("columns").forEach(function(column) {
39
- commands.push(column.getCommands());
40
- });
41
- return _.compact(_.flatten(commands));
42
- }
43
- }
44
- });
@@ -1,15 +0,0 @@
1
- window.Ponytail = {
2
- Models: {},
3
- Collections: {},
4
- Views: {},
5
- Routers: {},
6
- };
7
-
8
- function setupIndex() {
9
- $(".pt_close_notice").click(function() {
10
- $(".pt_notice").hide();
11
- });
12
- $(".pt_name, .pt_filename").click(function() {
13
- $(".pt_raw_content", $(this).parent().parent()).toggle();
14
- });
15
- }
@@ -1,36 +0,0 @@
1
- Ponytail.Views.ColumnView = Backbone.View.extend({
2
- className: 'pt_column',
3
- events: {
4
- "click .pt_column_type span": "toggleColumnType",
5
- "blur .pt_column_type select": "changeColumnType",
6
- "click .pt_column_name span": "toggleColumnName",
7
- "keyup .pt_column_name input": function(e) { this.model.set({name: e.target.value}); },
8
- "blur .pt_column_name input": "toggleColumnName",
9
- },
10
- initialize: function(options) {
11
- _.bindAll(this, "render");
12
- this.model.bind("change", this.render);
13
- },
14
- render: function() {
15
- if (this.el.parentNode === null) {
16
- $(this.el).html(_.template($("#column_view_template").html(), this.model.attributes));
17
- } else {
18
- $(this.el).find(".pt_column_type span").text(this.model.get("type"));
19
- $(this.el).find(".pt_column_name span").text(this.model.get("name"));
20
- }
21
- $(this.el).find(".pt_column_type option[value='" + this.model.get("type") + "']").attr("selected", true);
22
- return this;
23
- },
24
- toggleColumnType: function() {
25
- $(this.el).find(".pt_column_type span").toggle();
26
- $(this.el).find(".pt_column_type select").toggle();
27
- },
28
- changeColumnType: function(e) {
29
- this.model.set({type: e.target.value});
30
- this.toggleColumnType();
31
- },
32
- toggleColumnName: function() {
33
- $(this.el).find(".pt_column_name span").toggle();
34
- $(this.el).find(".pt_column_name input").toggle();
35
- }
36
- });
@@ -1,24 +0,0 @@
1
- Ponytail.Views.MigrationFileView = Backbone.View.extend({
2
- events: {
3
- "click .pt_edit_checkbox input": "toggleRawContent",
4
- "click .pt_submit": function() { this.setRawContentEnabled(true); },
5
- "keyup .pt_class_name input": function(e) { this.model.set({className: e.target.value}); },
6
- },
7
- initialize: function(options) {
8
- _.bindAll(this, "render");
9
- this.model.bind("change", this.render);
10
- },
11
- render: function() {
12
- $(".pt_raw_content textarea").text(this.model.get("rawContent"));
13
- },
14
- toggleRawContent: function() {
15
- this.setRawContentEnabled($(".pt_raw_content textarea").attr("disabled"));
16
- },
17
- setRawContentEnabled: function(enabled) {
18
- if (enabled) {
19
- $(".pt_raw_content textarea").removeAttr("disabled");
20
- } else {
21
- $(".pt_raw_content textarea").attr("disabled", "disabled");
22
- }
23
- },
24
- });
@@ -1,36 +0,0 @@
1
- Ponytail.Views.NewMigrationView = Backbone.View.extend({
2
- events: {
3
- "click .pt_new_table a": "appendTableView"
4
- },
5
- initialize: function() {
6
- var tables = [];
7
- $(".pt_table").each(function() {
8
- var name = $(this).find(".pt_table_name span").text();
9
- var m = new Ponytail.Models.Table({name: name});
10
- tables.push(m);
11
- new Ponytail.Views.TableView({el: $(this), model: m});
12
- });
13
- var migrationFile = new Ponytail.Models.MigrationFile();
14
- new Ponytail.Views.MigrationFileView({el: $(".migration_file_view"), model: migrationFile});
15
- tables.forEach(function(table) {
16
- table.bind("change", function() {
17
- migrationFile.updateByTables(tables);
18
- });
19
- });
20
- this.tables = tables;
21
- this.migrationFile = migrationFile;
22
- },
23
- appendTableView: function() {
24
- var tables = this.tables;
25
- var migrationFile = this.migrationFile;
26
- var m = new Ponytail.Models.Table({isCreated: true});
27
- tables.push(m);
28
- m.bind("change", function() {
29
- migrationFile.updateByTables(tables);
30
- });
31
- m.trigger("change");
32
- var v = new Ponytail.Views.TableView({model: m});
33
- $(".pt_new_table").before(v.render().el);
34
- return false;
35
- }
36
- });
@@ -1,61 +0,0 @@
1
- Ponytail.Views.TableView = Backbone.View.extend({
2
- className: "pt_table",
3
- events: {
4
- "click .pt_table_name span": "toggleTableName",
5
- "keyup .pt_table_name input": function(e) { this.model.set({name: e.target.value}); },
6
- "blur .pt_table_name input": "toggleTableName",
7
- "click .pt_drop_table": "dropTable",
8
- "click .pt_restore_table": "restoreTable",
9
- "click .pt_add_column": "addColumn",
10
- },
11
- initialize: function(options) {
12
- _.bindAll(this, "render");
13
- this.model.bind("change", this.render);
14
- var table = this.model;
15
- var columns = [];
16
- _.each($(this.el).find(".pt_column"), function(elem) {
17
- var type = $(elem).find(".pt_column_type span").text();
18
- var name = $(elem).find(".pt_column_name span").text();
19
- var m = new Ponytail.Models.Column({table: table, type: type, name: name});
20
- new Ponytail.Views.ColumnView({el: elem, model: m}).render();
21
- columns.push(m);
22
- });
23
- this.model.set({columns: columns}, {silent: true});
24
- },
25
- render: function() {
26
- if (this.el.parentNode === null) {
27
- $(this.el).html(_.template($("#table_view_template").html(), this.model.attributes));
28
- } else {
29
- $(this.el).find(".pt_table_name span").text(this.model.get("name"));
30
- }
31
- return this;
32
- },
33
- updateTableName: function() {
34
- var v = $(this.el).find(".pt_table_name input")[0].value;
35
- $(this.el).find(".pt_table_name span").text(v);
36
- this.model.set({name: v});
37
- },
38
- toggleTableName: function() {
39
- $(this.el).find(".pt_table_name span").toggle();
40
- $(this.el).find(".pt_table_name input").toggle();
41
- },
42
- dropTable: function(e) {
43
- this.model.set({isDrop: true});
44
- $(this.el).find(".pt_drop_table").hide();
45
- $(this.el).find(".pt_restore_table").show();
46
- return false;
47
- },
48
- restoreTable: function(e) {
49
- this.model.set({isDrop: false});
50
- $(this.el).find(".pt_drop_table").show();
51
- $(this.el).find(".pt_restore_table").hide();
52
- return false;
53
- },
54
- addColumn: function(e) {
55
- var column = new Ponytail.Models.Column({table: this.model, isAdded: true});
56
- var view = new Ponytail.Views.ColumnView({model: column});
57
- $(this.el).find(".pt_columns").append(view.render().el);
58
- this.model.addColumn(column);
59
- return false;
60
- }
61
- });
@@ -1,126 +0,0 @@
1
- /* index */
2
- .pt_index {
3
- display: -moz-box;
4
- display: -webkit-box;
5
- -moz-box-orient: vertical;
6
- -webkit-box-orient: vertical;
7
- }
8
-
9
- .pt_actions {
10
- margin: 5px;
11
- }
12
-
13
- .pt_actions .button_to {
14
- float: left;
15
- margin: 0 2px;
16
- }
17
-
18
- /* migration */
19
- .pt_migration {
20
- display: -moz-box;
21
- display: -webkit-box;
22
- }
23
-
24
- .pt_migration .pt_current {
25
- width: 60px;
26
- }
27
-
28
- .pt_migration .pt_migration_file {
29
- margin-left: 5px;
30
- }
31
-
32
- .pt_migration .pt_name {
33
- font-size: large;
34
- font-weight: bold;
35
- }
36
-
37
- .pt_migration .pt_raw_content {
38
- background: whitesmoke;
39
- border-radius: 5px;
40
- display: none;
41
- padding: 5px;
42
- }
43
-
44
- .pt_migration .pt_raw_content pre {
45
- margin: 5px 0;
46
- }
47
-
48
- /* notice */
49
- .pt_notice {
50
- display: -moz-box;
51
- display: -webkit-box;
52
- border-radius: 5px;
53
- margin-bottom: 5px;
54
- padding: 5px;
55
- background: limegreen;
56
- color: white;
57
- }
58
-
59
- .pt_notice_message {
60
- -moz-box-flex: 1;
61
- -webkit-box-flex: 1;
62
- }
63
-
64
- /* errors */
65
- .pt_new_errors ul {
66
- margin: 3px 0;
67
- }
68
-
69
- /* new */
70
- .pt_new {
71
- display: -moz-box;
72
- display: -webkit-box;
73
- width: 1024px;
74
- }
75
-
76
- .pt_new .pt_schema {
77
- -moz-box-flex: 1;
78
- -webkit-box-flex: 1;
79
- }
80
-
81
- .pt_new .pt_schema .pt_table {
82
- margin-top: 5px;
83
- }
84
-
85
- .pt_new .pt_schema .pt_table_name span {
86
- font-size: large;
87
- font-weight: bold;
88
- }
89
-
90
- .pt_new .pt_schema span {
91
- cursor: pointer;
92
- }
93
-
94
- .pt_new .pt_schema .pt_new_table {
95
- margin-top: 5px;
96
- }
97
-
98
- .pt_new .pt_columns {
99
- display: -moz-box;
100
- display: -webkit-box;
101
- -moz-box-orient: vertical;
102
- -webkit-box-orient: vertical;
103
- margin-left: 15px;
104
- }
105
-
106
- .pt_new .pt_columns .pt_column {
107
- display: -moz-box;
108
- display: -webkit-box;
109
- -moz-box-orient: horizontal;
110
- -webkit-box-orient: horizontal;
111
- }
112
-
113
- .pt_new .pt_columns .pt_column .pt_column_type {
114
- width: 100px;
115
- }
116
-
117
- .pt_new .pt_form_header {
118
- display: -moz-box;
119
- display: -webkit-box;
120
- width: 100%;
121
- }
122
-
123
- .pt_new .pt_form_header .pt_class_name {
124
- -moz-box-flex: 1;
125
- -webkit-box-flex: 1;
126
- }