Sha256: 6ced8e35ebb0749a02ca186cffd08994cad78a07aa1a43620f4b6b271c66a074
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
Ponytail.Models.Table = Backbone.Model.extend({ defaults: { name: "new_table", columns: [], isDrop: false, isCreated: false, }, initialize: function (attrs, options) { this.beforeName = attrs.name || ""; }, isCreated: function() { return this.get("isCreated") === true; }, isDrop: function() { return this.get("isDrop") === true; }, isRename: function() { return this.beforeName != this.get("name"); }, addColumn: function(column) { var columns = this.get("columns"); columns.push(column); this.set({columns: columns}); this.trigger("change"); }, getCommands: function() { if (this.isCreated() && this.isDrop()) { return []; } else if (this.isCreated() && !this.isDrop()) { return [new Ponytail.Models.CreateTableCommand(this.get("name"), this.get("columns"))]; } else if (!this.isCreated() && this.isDrop()) { return [new Ponytail.Models.DropTableCommand(this.beforeName)]; } else { var commands = []; if (this.isRename()) { commands.push(new Ponytail.Models.RenameTableCommand(this.beforeName, this.get("name"))); } this.get("columns").forEach(function(column) { commands.push(column.getCommands()); }); return _.compact(_.flatten(commands)); } } });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ponytail-0.3.0 | app/assets/javascripts/ponytail/models/table.js |