ponytail 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/ponytail/index.js +3 -7
- data/app/assets/javascripts/ponytail/models/column.js +6 -0
- data/app/assets/javascripts/ponytail/{create_table.js → models/create_table.js} +0 -0
- data/app/assets/javascripts/ponytail/{migration_file.js → models/migration_file.js} +0 -0
- data/app/assets/javascripts/ponytail/models/rename_table.js +8 -0
- data/app/assets/javascripts/ponytail/models/table.js +40 -0
- data/app/assets/javascripts/ponytail/views/migration_file_view.js +39 -0
- data/app/assets/javascripts/ponytail/views/new_migration_view.js +60 -0
- data/app/assets/javascripts/ponytail/views/table_view.js +68 -0
- data/app/assets/stylesheets/ponytail/application.css +7 -5
- data/app/views/ponytail/migrations/_table.html.erb +16 -8
- data/app/views/ponytail/migrations/index.html.erb +2 -1
- data/app/views/ponytail/migrations/new.html.erb +2 -6
- data/lib/ponytail/version.rb +1 -1
- data/spec/javascripts/ponytail/models/column_spec.js +14 -0
- data/spec/javascripts/ponytail/{migration_file_spec.js → models/migration_file_spec.js} +0 -0
- data/spec/javascripts/ponytail/models/table_spec.js +33 -0
- data/spec/javascripts/ponytail/views/migration_file_view_spec.js +17 -0
- data/spec/javascripts/ponytail/views/new_migration_view_spec.js +17 -0
- data/spec/javascripts/ponytail/views/table_view_spec.js +17 -0
- metadata +22 -7
- data/app/assets/javascripts/ponytail/new.js +0 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63ccf892a7224116f88fbfb4e4464ab153371fb2
|
4
|
+
data.tar.gz: f793e36362e8aa589b1878ad6d32f9c1aa7e9f31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f35510c6f836ea0a6c57ffc51fdfe246d60c030b09a31baac486c9bb75e8dc3197547d8c8c3174e2ab2822b247ba33ef2bc8edb15d6604438002ed861757cb0d
|
7
|
+
data.tar.gz: 44ac79a3da84c19460800b52219301f796ebcb27d0ab47852053aa801db6071ac7f5eb02ad5ebbfca8da59ce6128580ed7d62dcca54076417f746fa5d4fce5f1
|
@@ -10,15 +10,11 @@ function toggleMigrationRawContent() {
|
|
10
10
|
}
|
11
11
|
|
12
12
|
function closeNotice() {
|
13
|
-
var elem = document.
|
14
|
-
if (elem !==
|
13
|
+
var elem = document.querySelector(".pt_close_notice");
|
14
|
+
if (elem !== null) {
|
15
15
|
elem.onclick = function() {
|
16
16
|
this.parentElement.style.display = "none";
|
17
|
+
return false;
|
17
18
|
};
|
18
19
|
}
|
19
20
|
}
|
20
|
-
|
21
|
-
function setupMigrations() {
|
22
|
-
toggleMigrationRawContent();
|
23
|
-
closeNotice();
|
24
|
-
}
|
File without changes
|
File without changes
|
@@ -0,0 +1,40 @@
|
|
1
|
+
function Table(option) {
|
2
|
+
if (option === undefined) { option = {}; }
|
3
|
+
this.beforeTableName = option.tableName;
|
4
|
+
this.tableName = option.tableName;
|
5
|
+
this._isSaved = option.isSaved;
|
6
|
+
this._drop = false;
|
7
|
+
this.columns = [];
|
8
|
+
}
|
9
|
+
Table.prototype = {
|
10
|
+
isSaved: function() {
|
11
|
+
return this._isSaved ? true : false;
|
12
|
+
},
|
13
|
+
isDrop: function() {
|
14
|
+
return this._drop;
|
15
|
+
},
|
16
|
+
drop: function() {
|
17
|
+
this._drop = true;
|
18
|
+
},
|
19
|
+
addColumn: function(column) {
|
20
|
+
this.columns.push(column);
|
21
|
+
},
|
22
|
+
getCommands: function() {
|
23
|
+
if (this.isDrop() && this.isSaved()) {
|
24
|
+
return [new Command("drop_table", ":" + this.beforeTableName)];
|
25
|
+
} else if (this.isDrop() && !this.isSaved()) {
|
26
|
+
return [];
|
27
|
+
} else if (this.isSaved()) {
|
28
|
+
var commands = [];
|
29
|
+
if (this.beforeTableName != this.tableName) {
|
30
|
+
commands.push(new Command("rename_table", ":" + this.beforeTableName, ":" + this.tableName));
|
31
|
+
}
|
32
|
+
// TODO: add_column, ...etc
|
33
|
+
return commands;
|
34
|
+
} else {
|
35
|
+
var command = new CreateTable();
|
36
|
+
command.setTableName(this.tableName);
|
37
|
+
return [command];
|
38
|
+
}
|
39
|
+
}
|
40
|
+
};
|
@@ -0,0 +1,39 @@
|
|
1
|
+
function MigrationFileView(option) {
|
2
|
+
var init = option.init !== undefined ? option.init : true;
|
3
|
+
if (init) { this.init(option); }
|
4
|
+
}
|
5
|
+
MigrationFileView.prototype = {
|
6
|
+
init: function(option) {
|
7
|
+
var _this = this;
|
8
|
+
this.element = option.element;
|
9
|
+
this.callbacks = [];
|
10
|
+
this.checkBox = document.querySelector(".pt_checkbox");
|
11
|
+
this.checkBox.onclick = function() {
|
12
|
+
_this.toggleEditRawContent();
|
13
|
+
};
|
14
|
+
this.classNameElement = document.querySelector(".pt_class_name input");
|
15
|
+
this.classNameElement.onkeyup = function() {
|
16
|
+
_this.callbacks.forEach(function(func) {
|
17
|
+
func();
|
18
|
+
});
|
19
|
+
};
|
20
|
+
this.rawContentElement = document.querySelector(".pt_raw_content textarea");
|
21
|
+
this.submitButton = document.querySelector(".pt_submit");
|
22
|
+
this.submitButton.onclick = function() {
|
23
|
+
_this.rawContentElement.disabled = false;
|
24
|
+
};
|
25
|
+
},
|
26
|
+
toggleEditRawContent: function() {
|
27
|
+
this.rawContentElement.disabled = !(this.rawContentElement.disabled);
|
28
|
+
},
|
29
|
+
getClassName: function() {
|
30
|
+
var elem = document.querySelector(".pt_class_name input");
|
31
|
+
return elem.value;
|
32
|
+
},
|
33
|
+
setRawContent: function(rawContent) {
|
34
|
+
this.rawContentElement.value = rawContent;
|
35
|
+
},
|
36
|
+
addChangeListener: function(callback) {
|
37
|
+
this.callbacks.push(callback);
|
38
|
+
}
|
39
|
+
};
|
@@ -0,0 +1,60 @@
|
|
1
|
+
function NewMigrationView(option) {
|
2
|
+
var init = option.init !== undefined ? option.init : true;
|
3
|
+
if (init) { this.init(option); }
|
4
|
+
}
|
5
|
+
NewMigrationView.prototype = {
|
6
|
+
init: function(option) {
|
7
|
+
this.element = option.element;
|
8
|
+
this.tableViews = [];
|
9
|
+
this.newTableLink = null;
|
10
|
+
this.migrationFileView = null;
|
11
|
+
this.initTableViews();
|
12
|
+
this.initMigrationView();
|
13
|
+
this.initNewTableLink();
|
14
|
+
},
|
15
|
+
initTableViews: function() {
|
16
|
+
var elems = document.querySelectorAll(".pt_table");
|
17
|
+
var _this = this;
|
18
|
+
var func = function() {
|
19
|
+
_this.updateMigrationFileView();
|
20
|
+
};
|
21
|
+
for(var i=0; i<elems.length; i++) {
|
22
|
+
var tableView = new TableView({element: elems[i]});
|
23
|
+
tableView.addChangeListener(func);
|
24
|
+
this.tableViews.push(tableView);
|
25
|
+
}
|
26
|
+
},
|
27
|
+
initNewTableLink: function() {
|
28
|
+
var _this = this;
|
29
|
+
this.newTableLink = document.querySelector(".pt_new_table a");
|
30
|
+
this.newTableLink.onclick = function() {
|
31
|
+
var schema = document.querySelector(".pt_new .pt_schema");
|
32
|
+
var newTable = document.querySelector(".pt_new .pt_new_table");
|
33
|
+
var tableView = new TableView({});
|
34
|
+
tableView.addChangeListener(function() {
|
35
|
+
_this.updateMigrationFileView();
|
36
|
+
});
|
37
|
+
_this.tableViews.push(tableView);
|
38
|
+
schema.insertBefore(tableView.toElement(), newTable);
|
39
|
+
return false;
|
40
|
+
};
|
41
|
+
},
|
42
|
+
initMigrationView: function() {
|
43
|
+
var elem = document.querySelector("form.new_ponytail_migration");
|
44
|
+
this.migrationFileView = new MigrationFileView({element: elem});
|
45
|
+
var _this = this;
|
46
|
+
this.migrationFileView.addChangeListener(function() {
|
47
|
+
_this.updateMigrationFileView();
|
48
|
+
});
|
49
|
+
},
|
50
|
+
updateMigrationFileView: function() {
|
51
|
+
var file = new MigrationFile();
|
52
|
+
file.setClassName(this.migrationFileView.getClassName());
|
53
|
+
this.tableViews.forEach(function(tableView) {
|
54
|
+
tableView.getCommands().forEach(function(command) {
|
55
|
+
file.addCommand(command);
|
56
|
+
});
|
57
|
+
});
|
58
|
+
this.migrationFileView.setRawContent(file.toString());
|
59
|
+
}
|
60
|
+
};
|
@@ -0,0 +1,68 @@
|
|
1
|
+
function TableView(option) {
|
2
|
+
var init = option.init !== undefined ? option.init : true;
|
3
|
+
if (init) { this.init(option); }
|
4
|
+
}
|
5
|
+
TableView.prototype = {
|
6
|
+
init: function(option) {
|
7
|
+
var _this = this;
|
8
|
+
this.element = option.element;
|
9
|
+
var isSaved = true;
|
10
|
+
if (this.element === undefined) {
|
11
|
+
this.element = this.createTable();
|
12
|
+
isSaved = false;
|
13
|
+
}
|
14
|
+
this.tableNameElement = this.element.querySelector(".pt_table_name");
|
15
|
+
this.tableNameSpanElement = this.tableNameElement.querySelector("span");
|
16
|
+
this.inputTableNameElement = this.tableNameElement.querySelector("input");
|
17
|
+
this.tableNameSpanElement.onclick = function() {
|
18
|
+
_this.tableNameSpanElement.style.display = "none";
|
19
|
+
_this.inputTableNameElement.style.display = "block";
|
20
|
+
_this.inputTableNameElement.value = _this.tableNameSpanElement.innerHTML;
|
21
|
+
};
|
22
|
+
this.inputTableNameElement.onblur = function() {
|
23
|
+
_this.tableNameSpanElement.style.display = "block";
|
24
|
+
_this.inputTableNameElement.style.display = "none";
|
25
|
+
_this.setTableName(this.value);
|
26
|
+
_this.callbacks.forEach(function(func) {
|
27
|
+
func();
|
28
|
+
});
|
29
|
+
};
|
30
|
+
this.columnElements = this.element.querySelectorAll(".pt_column");
|
31
|
+
this.dropTableLink = this.element.querySelector("a.pt_drop_table");
|
32
|
+
this.dropTableLink.onclick = function() {
|
33
|
+
_this.table.drop();
|
34
|
+
_this.callbacks.forEach(function(func) {
|
35
|
+
func();
|
36
|
+
});
|
37
|
+
return false;
|
38
|
+
};
|
39
|
+
this.callbacks = [];
|
40
|
+
|
41
|
+
this.table = new Table({tableName: this.tableNameSpanElement.innerHTML, isSaved: isSaved});
|
42
|
+
for(var i=0; i<this.columnElements.length; i++) {
|
43
|
+
var name = this.columnElements[i].querySelector(".pt_column_name");
|
44
|
+
var type = this.columnElements[i].querySelector(".pt_column_type");
|
45
|
+
var column = new Column({name: name.innerHTML, type: type.innerHTML});
|
46
|
+
this.table.addColumn(column);
|
47
|
+
}
|
48
|
+
},
|
49
|
+
setTableName: function(tableName) {
|
50
|
+
this.tableNameSpanElement.innerHTML = tableName;
|
51
|
+
this.table.tableName = tableName;
|
52
|
+
},
|
53
|
+
addChangeListener: function(callback) {
|
54
|
+
this.callbacks.push(callback);
|
55
|
+
},
|
56
|
+
getCommands: function() {
|
57
|
+
return this.table.getCommands();
|
58
|
+
},
|
59
|
+
toElement: function() {
|
60
|
+
return this.element;
|
61
|
+
},
|
62
|
+
createTable: function() {
|
63
|
+
var elem = document.createElement("div");
|
64
|
+
elem.setAttribute("class", "pt_table");
|
65
|
+
elem.innerHTML = '<div class="pt_table_name"><span>tables</span><input type="text" /></div><a href="#" class="pt_drop_table">drop</a><div class="pt_columns"></div>';
|
66
|
+
return elem;
|
67
|
+
}
|
68
|
+
};
|
@@ -79,17 +79,19 @@
|
|
79
79
|
}
|
80
80
|
|
81
81
|
.pt_new .pt_schema .pt_table {
|
82
|
-
font-size: large;
|
83
|
-
font-weight: bold;
|
84
82
|
margin-top: 5px;
|
85
83
|
}
|
86
84
|
|
87
|
-
.pt_new .pt_schema .
|
88
|
-
|
85
|
+
.pt_new .pt_schema .pt_table_name span {
|
86
|
+
font-size: large;
|
87
|
+
font-weight: bold;
|
89
88
|
}
|
90
89
|
|
91
|
-
.pt_new .pt_schema .
|
90
|
+
.pt_new .pt_schema .pt_table_name input {
|
92
91
|
display: none;
|
92
|
+
}
|
93
|
+
|
94
|
+
.pt_new .pt_schema .pt_new_table {
|
93
95
|
margin-top: 5px;
|
94
96
|
}
|
95
97
|
|
@@ -1,9 +1,17 @@
|
|
1
|
-
<div class="pt_table"
|
2
|
-
<div class="
|
3
|
-
|
4
|
-
<
|
5
|
-
|
6
|
-
|
7
|
-
</
|
8
|
-
|
1
|
+
<div class="pt_table">
|
2
|
+
<div class="pt_table_name">
|
3
|
+
<span><%= table.name %></span>
|
4
|
+
<input type="text" />
|
5
|
+
</div>
|
6
|
+
<div>
|
7
|
+
<a href="#" class="pt_drop_table">drop</a>
|
8
|
+
</div>
|
9
|
+
<div class="pt_columns">
|
10
|
+
<% table.columns.each do |column| %>
|
11
|
+
<div class="pt_column">
|
12
|
+
<div class="pt_column_type"><%= column.type %></div>
|
13
|
+
<div class="pt_column_name"><%= column.name %></div>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
16
|
+
</div>
|
9
17
|
</div>
|
@@ -7,11 +7,6 @@
|
|
7
7
|
<div class="pt_new_table">
|
8
8
|
<a href="#">New Table</a>
|
9
9
|
</div>
|
10
|
-
<div class="pt_new_table_form">
|
11
|
-
<div class="pt_new_class_name">
|
12
|
-
<input type="text" />
|
13
|
-
</div>
|
14
|
-
</div>
|
15
10
|
</div>
|
16
11
|
|
17
12
|
<div>
|
@@ -42,5 +37,6 @@
|
|
42
37
|
</div>
|
43
38
|
|
44
39
|
<script type='text/javascript'>
|
45
|
-
|
40
|
+
var elem = document.querySelector(".pt_new");
|
41
|
+
new NewMigrationView({element: elem});
|
46
42
|
</script>
|
data/lib/ponytail/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
describe("Column", function() {
|
2
|
+
describe("#constructor", function() {
|
3
|
+
var column;
|
4
|
+
beforeEach(function() {
|
5
|
+
column = new Column({name: "id", type: "integer"});
|
6
|
+
});
|
7
|
+
it("should be able to set name", function() {
|
8
|
+
expect(column.name).toBe("id");
|
9
|
+
});
|
10
|
+
it("should be able to set type", function() {
|
11
|
+
expect(column.type).toBe("integer");
|
12
|
+
});
|
13
|
+
});
|
14
|
+
});
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
describe("Table", function() {
|
2
|
+
describe("#constructor", function() {
|
3
|
+
it("should be able to set tableName", function() {
|
4
|
+
var table = new Table({tableName: "users"});
|
5
|
+
expect(table.tableName).toBe("users");
|
6
|
+
});
|
7
|
+
});
|
8
|
+
|
9
|
+
describe("#isSaved", function() {
|
10
|
+
describe("don't set isSaved option (default)", function() {
|
11
|
+
it("should be false", function() {
|
12
|
+
var table = new Table();
|
13
|
+
expect(table.isSaved()).toBe(false);
|
14
|
+
});
|
15
|
+
});
|
16
|
+
describe("set isSaved option", function() {
|
17
|
+
it("should be true", function() {
|
18
|
+
var table = new Table({isSaved: true});
|
19
|
+
expect(table.isSaved()).toBe(true);
|
20
|
+
});
|
21
|
+
});
|
22
|
+
});
|
23
|
+
|
24
|
+
describe("#getCommands", function() {
|
25
|
+
describe("isCreated set false", function() {
|
26
|
+
it("commands[0] to equal CreateTable", function() {
|
27
|
+
var table = new Table({isCreated: false});
|
28
|
+
var commands = table.getCommands();
|
29
|
+
expect(commands[0]).toEqual(jasmine.any(CreateTable));
|
30
|
+
});
|
31
|
+
});
|
32
|
+
});
|
33
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
describe("MigrationFileView", function() {
|
2
|
+
describe("#constructor", function() {
|
3
|
+
var init;
|
4
|
+
beforeEach(function() {
|
5
|
+
init = MigrationFileView.prototype.init;
|
6
|
+
spyOn(MigrationFileView.prototype, "init");
|
7
|
+
});
|
8
|
+
afterEach(function() {
|
9
|
+
MigrationFileView.prototype.init = init;
|
10
|
+
});
|
11
|
+
|
12
|
+
it("should be able to initialize without init", function() {
|
13
|
+
var view = new MigrationFileView({init: false});
|
14
|
+
expect(view.init).not.toHaveBeenCalled();
|
15
|
+
});
|
16
|
+
});
|
17
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
describe("NewMigrationView", function() {
|
2
|
+
describe("#constructor", function() {
|
3
|
+
var init;
|
4
|
+
beforeEach(function() {
|
5
|
+
init = NewMigrationView.prototype.init;
|
6
|
+
spyOn(NewMigrationView.prototype, "init");
|
7
|
+
});
|
8
|
+
afterEach(function() {
|
9
|
+
NewMigrationView.prototype.init = init;
|
10
|
+
});
|
11
|
+
|
12
|
+
it("should be able to initialize without init", function() {
|
13
|
+
var view = new NewMigrationView({init: false});
|
14
|
+
expect(view.init).not.toHaveBeenCalled();
|
15
|
+
});
|
16
|
+
});
|
17
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
describe("TableView", function() {
|
2
|
+
describe("#constructor", function() {
|
3
|
+
var init;
|
4
|
+
beforeEach(function() {
|
5
|
+
init = TableView.prototype.init;
|
6
|
+
spyOn(TableView.prototype, "init");
|
7
|
+
});
|
8
|
+
afterEach(function() {
|
9
|
+
TableView.prototype.init = init;
|
10
|
+
});
|
11
|
+
|
12
|
+
it("should be able to initialize without init", function() {
|
13
|
+
var view = new TableView({init: false});
|
14
|
+
expect(view.init).not.toHaveBeenCalled();
|
15
|
+
});
|
16
|
+
});
|
17
|
+
});
|
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.
|
4
|
+
version: 0.2.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-
|
11
|
+
date: 2013-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -110,10 +110,15 @@ files:
|
|
110
110
|
- README.md
|
111
111
|
- Rakefile
|
112
112
|
- app/assets/javascripts/ponytail/application.js
|
113
|
-
- app/assets/javascripts/ponytail/create_table.js
|
114
113
|
- app/assets/javascripts/ponytail/index.js
|
115
|
-
- app/assets/javascripts/ponytail/
|
116
|
-
- app/assets/javascripts/ponytail/
|
114
|
+
- app/assets/javascripts/ponytail/models/column.js
|
115
|
+
- app/assets/javascripts/ponytail/models/create_table.js
|
116
|
+
- app/assets/javascripts/ponytail/models/migration_file.js
|
117
|
+
- app/assets/javascripts/ponytail/models/rename_table.js
|
118
|
+
- app/assets/javascripts/ponytail/models/table.js
|
119
|
+
- app/assets/javascripts/ponytail/views/migration_file_view.js
|
120
|
+
- app/assets/javascripts/ponytail/views/new_migration_view.js
|
121
|
+
- app/assets/javascripts/ponytail/views/table_view.js
|
117
122
|
- app/assets/stylesheets/ponytail/application.css
|
118
123
|
- app/controllers/ponytail/migrations_controller.rb
|
119
124
|
- app/views/layouts/ponytail/application.html.erb
|
@@ -133,7 +138,12 @@ files:
|
|
133
138
|
- ponytail.gemspec
|
134
139
|
- spec/controllers/migrations_controller_spec.rb
|
135
140
|
- spec/javascripts/helpers/.keep
|
136
|
-
- spec/javascripts/ponytail/
|
141
|
+
- spec/javascripts/ponytail/models/column_spec.js
|
142
|
+
- spec/javascripts/ponytail/models/migration_file_spec.js
|
143
|
+
- spec/javascripts/ponytail/models/table_spec.js
|
144
|
+
- spec/javascripts/ponytail/views/migration_file_view_spec.js
|
145
|
+
- spec/javascripts/ponytail/views/new_migration_view_spec.js
|
146
|
+
- spec/javascripts/ponytail/views/table_view_spec.js
|
137
147
|
- spec/javascripts/support/jasmine.yml
|
138
148
|
- spec/javascripts/support/jasmine_helper.rb
|
139
149
|
- spec/ponytail/migration_spec.rb
|
@@ -168,7 +178,12 @@ summary: Ponytail is a Rails engine that shows the migrations.
|
|
168
178
|
test_files:
|
169
179
|
- spec/controllers/migrations_controller_spec.rb
|
170
180
|
- spec/javascripts/helpers/.keep
|
171
|
-
- spec/javascripts/ponytail/
|
181
|
+
- spec/javascripts/ponytail/models/column_spec.js
|
182
|
+
- spec/javascripts/ponytail/models/migration_file_spec.js
|
183
|
+
- spec/javascripts/ponytail/models/table_spec.js
|
184
|
+
- spec/javascripts/ponytail/views/migration_file_view_spec.js
|
185
|
+
- spec/javascripts/ponytail/views/new_migration_view_spec.js
|
186
|
+
- spec/javascripts/ponytail/views/table_view_spec.js
|
172
187
|
- spec/javascripts/support/jasmine.yml
|
173
188
|
- spec/javascripts/support/jasmine_helper.rb
|
174
189
|
- spec/ponytail/migration_spec.rb
|
@@ -1,69 +0,0 @@
|
|
1
|
-
function toggleEditRawContent() {
|
2
|
-
var elem = document.querySelectorAll(".pt_checkbox")[0];
|
3
|
-
elem.onclick = function() {
|
4
|
-
var raw_content = document.querySelectorAll(".pt_raw_content");
|
5
|
-
var text_area = raw_content[0].children[0];
|
6
|
-
text_area.disabled = !(text_area.disabled);
|
7
|
-
};
|
8
|
-
}
|
9
|
-
|
10
|
-
function getMigrationClassName() {
|
11
|
-
var elem = document.querySelectorAll(".pt_class_name input")[0];
|
12
|
-
return elem.value;
|
13
|
-
}
|
14
|
-
|
15
|
-
function getNewTableName() {
|
16
|
-
var elem = document.querySelectorAll(".pt_new_class_name input")[0];
|
17
|
-
return elem.value;
|
18
|
-
}
|
19
|
-
|
20
|
-
function inputClassName() {
|
21
|
-
var elems = document.querySelectorAll(".pt_class_name input");
|
22
|
-
elems[0].onkeyup = function() {
|
23
|
-
var file = new MigrationFile();
|
24
|
-
file.setClassName(this.value);
|
25
|
-
var command = new CreateTable();
|
26
|
-
command.setTableName(getNewTableName());
|
27
|
-
file.addCommand(command);
|
28
|
-
var area = document.querySelectorAll(".pt_raw_content textarea")[0];
|
29
|
-
area.value = file.toString();
|
30
|
-
};
|
31
|
-
}
|
32
|
-
|
33
|
-
function clickNewTable() {
|
34
|
-
var elem = document.querySelectorAll(".pt_new_table")[0];
|
35
|
-
elem.onclick = function() {
|
36
|
-
this.style.display = "none";
|
37
|
-
var form = document.querySelectorAll(".pt_new_table_form")[0];
|
38
|
-
form.style.display = "block";
|
39
|
-
};
|
40
|
-
}
|
41
|
-
|
42
|
-
function inputNewTableName() {
|
43
|
-
var elem = document.querySelectorAll(".pt_new_class_name input")[0];
|
44
|
-
elem.onkeyup = function() {
|
45
|
-
var file = new MigrationFile();
|
46
|
-
file.setClassName(getMigrationClassName());
|
47
|
-
var command = new CreateTable();
|
48
|
-
command.setTableName(this.value);
|
49
|
-
file.addCommand(command);
|
50
|
-
var area = document.querySelectorAll(".pt_raw_content textarea")[0];
|
51
|
-
area.value = file.toString();
|
52
|
-
};
|
53
|
-
}
|
54
|
-
|
55
|
-
function clickSubmitButton() {
|
56
|
-
var elem = document.querySelectorAll(".pt_submit")[0];
|
57
|
-
elem.onclick = function() {
|
58
|
-
var text_area = document.querySelectorAll(".pt_raw_content textarea")[0];
|
59
|
-
text_area.disabled = false;
|
60
|
-
};
|
61
|
-
}
|
62
|
-
|
63
|
-
function setupNewMigration() {
|
64
|
-
toggleEditRawContent();
|
65
|
-
inputClassName();
|
66
|
-
clickNewTable();
|
67
|
-
inputNewTableName();
|
68
|
-
clickSubmitButton();
|
69
|
-
}
|