finally rebase done

This commit is contained in:
Peter Cottle 2012-12-20 11:23:32 -08:00
parent 3797fc9d85
commit 46e71d9f49
6 changed files with 232 additions and 79 deletions

View file

@ -8435,35 +8435,30 @@ var GitError = exports.GitError = MyError.extend({
require.define("/src/js/views/rebaseView.js",function(require,module,exports,__dirname,__filename,process,global){var GitError = require('../util/errors').GitError;
var _ = require('underscore');
var Q = require('q');
// horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone;
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
var ModalTerminal = require('../views').ModalTerminal;
var BaseView = require('../views').BaseView;
var ConfirmCancelView = require('../views').ConfirmCancelView;
var InteractiveRebaseView = BaseView.extend({
tagName: 'div',
template: _.template($('#interactive-rebase-template').html()),
events: {
'click #confirmButton': 'confirmed'
},
initialize: function(options) {
this.hasClicked = false;
this.deferred = options.deferred;
this.rebaseArray = options.toRebase;
this.rebaseEntries = new RebaseEntryCollection();
this.rebaseMap = {};
this.entryObjMap = {};
this.rebaseArray.reverse();
// make basic models for each commit
_.each(this.rebaseArray, function(commit) {
this.rebaseEntries = new RebaseEntryCollection();
options.toRebase.reverse();
_.each(options.toRebase, function(commit) {
var id = commit.get('id');
this.rebaseMap[id] = commit;
// make basic models for each commit
this.entryObjMap[id] = new RebaseEntry({
id: id
});
@ -8473,22 +8468,13 @@ var InteractiveRebaseView = BaseView.extend({
this.container = new ModalTerminal({
title: 'Interactive Rebase'
});
this.render();
// show the dialog holder
this.show();
},
confirmed: function() {
// we hide the dialog anyways, but they might be fast clickers
if (this.hasClicked) {
return;
}
this.hasClicked = true;
// first of all hide
this.$('#iRebaseDialog').css('display', 'none');
confirm: function() {
this.hide();
// get our ordering
@ -8500,7 +8486,7 @@ var InteractiveRebaseView = BaseView.extend({
// now get the real array
var toRebase = [];
_.each(uiOrder, function(id) {
// the model
// the model pick check
if (this.entryObjMap[id].get('pick')) {
toRebase.unshift(this.rebaseMap[id]);
}
@ -8513,7 +8499,7 @@ var InteractiveRebaseView = BaseView.extend({
render: function() {
var json = {
num: this.rebaseArray.length
num: _.keys(this.rebaseMap).length
};
var destination = this.container.getInsideElement();
@ -8535,6 +8521,27 @@ var InteractiveRebaseView = BaseView.extend({
placeholder: 'rebaseEntry transitionOpacity ui-state-highlight',
appendTo: 'parent'
});
this.makeButtons();
},
makeButtons: function() {
// control for button
var deferred = Q.defer();
deferred.promise
.then(_.bind(function() {
this.confirm();
}, this))
.fail(_.bind(function() {
this.deferred.reject();
}, this))
.done();
// finally get our buttons
new ConfirmCancelView({
destination: this.$('.confirmCancel'),
deferred: deferred
});
}
});
@ -8589,6 +8596,44 @@ var _ = require('underscore');
// horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
var ConfirmCancelView = Backbone.View.extend({
tagName: 'div',
className: 'box horizontal justify',
template: _.template($('#confirm-cancel-template').html()),
events: {
'click .confirmButton': 'confirmed',
'click .cancelButton': 'cancel'
},
initialize: function(options) {
if (!options.destination || !options.deferred) {
throw new Error('needmore');
}
this.destination = options.destination;
this.deferred = options.deferred;
this.JSON = {
confirm: options.confirm || 'Confirm',
cancel: options.cancel || 'Cancel'
};
this.render();
},
confirmed: function() {
this.deferred.resolve();
},
cancel: function() {
this.deferred.reject();
},
render: function() {
this.$el.html(this.template(this.JSON));
$(this.destination).append(this.el);
}
});
var BaseView = Backbone.View.extend({
render: function() {
var destination = this.container.getInsideElement();
@ -8695,6 +8740,7 @@ exports.ModalView = ModalView;
exports.ModalTerminal = ModalTerminal;
exports.ModalAlert = ModalAlert;
exports.BaseView = BaseView;
exports.ConfirmCancelView = ConfirmCancelView;
});
@ -14423,6 +14469,44 @@ var _ = require('underscore');
// horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
var ConfirmCancelView = Backbone.View.extend({
tagName: 'div',
className: 'box horizontal justify',
template: _.template($('#confirm-cancel-template').html()),
events: {
'click .confirmButton': 'confirmed',
'click .cancelButton': 'cancel'
},
initialize: function(options) {
if (!options.destination || !options.deferred) {
throw new Error('needmore');
}
this.destination = options.destination;
this.deferred = options.deferred;
this.JSON = {
confirm: options.confirm || 'Confirm',
cancel: options.cancel || 'Cancel'
};
this.render();
},
confirmed: function() {
this.deferred.resolve();
},
cancel: function() {
this.deferred.reject();
},
render: function() {
this.$el.html(this.template(this.JSON));
$(this.destination).append(this.el);
}
});
var BaseView = Backbone.View.extend({
render: function() {
var destination = this.container.getInsideElement();
@ -14529,6 +14613,7 @@ exports.ModalView = ModalView;
exports.ModalTerminal = ModalTerminal;
exports.ModalAlert = ModalAlert;
exports.BaseView = BaseView;
exports.ConfirmCancelView = ConfirmCancelView;
});
@ -14690,35 +14775,30 @@ require("/src/js/views/miscViews.js");
require.define("/src/js/views/rebaseView.js",function(require,module,exports,__dirname,__filename,process,global){var GitError = require('../util/errors').GitError;
var _ = require('underscore');
var Q = require('q');
// horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone;
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
var ModalTerminal = require('../views').ModalTerminal;
var BaseView = require('../views').BaseView;
var ConfirmCancelView = require('../views').ConfirmCancelView;
var InteractiveRebaseView = BaseView.extend({
tagName: 'div',
template: _.template($('#interactive-rebase-template').html()),
events: {
'click #confirmButton': 'confirmed'
},
initialize: function(options) {
this.hasClicked = false;
this.deferred = options.deferred;
this.rebaseArray = options.toRebase;
this.rebaseEntries = new RebaseEntryCollection();
this.rebaseMap = {};
this.entryObjMap = {};
this.rebaseArray.reverse();
// make basic models for each commit
_.each(this.rebaseArray, function(commit) {
this.rebaseEntries = new RebaseEntryCollection();
options.toRebase.reverse();
_.each(options.toRebase, function(commit) {
var id = commit.get('id');
this.rebaseMap[id] = commit;
// make basic models for each commit
this.entryObjMap[id] = new RebaseEntry({
id: id
});
@ -14728,22 +14808,13 @@ var InteractiveRebaseView = BaseView.extend({
this.container = new ModalTerminal({
title: 'Interactive Rebase'
});
this.render();
// show the dialog holder
this.show();
},
confirmed: function() {
// we hide the dialog anyways, but they might be fast clickers
if (this.hasClicked) {
return;
}
this.hasClicked = true;
// first of all hide
this.$('#iRebaseDialog').css('display', 'none');
confirm: function() {
this.hide();
// get our ordering
@ -14755,7 +14826,7 @@ var InteractiveRebaseView = BaseView.extend({
// now get the real array
var toRebase = [];
_.each(uiOrder, function(id) {
// the model
// the model pick check
if (this.entryObjMap[id].get('pick')) {
toRebase.unshift(this.rebaseMap[id]);
}
@ -14768,7 +14839,7 @@ var InteractiveRebaseView = BaseView.extend({
render: function() {
var json = {
num: this.rebaseArray.length
num: _.keys(this.rebaseMap).length
};
var destination = this.container.getInsideElement();
@ -14790,6 +14861,27 @@ var InteractiveRebaseView = BaseView.extend({
placeholder: 'rebaseEntry transitionOpacity ui-state-highlight',
appendTo: 'parent'
});
this.makeButtons();
},
makeButtons: function() {
// control for button
var deferred = Q.defer();
deferred.promise
.then(_.bind(function() {
this.confirm();
}, this))
.fail(_.bind(function() {
this.deferred.reject();
}, this))
.done();
// finally get our buttons
new ConfirmCancelView({
destination: this.$('.confirmCancel'),
deferred: deferred
});
}
});

View file

@ -154,10 +154,18 @@
</ul>
</div>
<a id="confirmButton" class="uiButton uiButtonYellow">
Confirm
</a>
<div class="confirmCancel">
</div>
</div>
</script>
<script type="text/html" id="confirm-cancel-template">
<a class="box cancelButton uiButton uiButtonRed">
<%= cancel %>
</a>
<a class="box confirmButton uiButton uiButtonYellow">
<%= confirm %>
</a>
</script>
<script type="text/html" id="interactive-rebase-entry-template">

View file

@ -3,6 +3,44 @@ var _ = require('underscore');
// horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
var ConfirmCancelView = Backbone.View.extend({
tagName: 'div',
className: 'box horizontal justify',
template: _.template($('#confirm-cancel-template').html()),
events: {
'click .confirmButton': 'confirmed',
'click .cancelButton': 'cancel'
},
initialize: function(options) {
if (!options.destination || !options.deferred) {
throw new Error('needmore');
}
this.destination = options.destination;
this.deferred = options.deferred;
this.JSON = {
confirm: options.confirm || 'Confirm',
cancel: options.cancel || 'Cancel'
};
this.render();
},
confirmed: function() {
this.deferred.resolve();
},
cancel: function() {
this.deferred.reject();
},
render: function() {
this.$el.html(this.template(this.JSON));
$(this.destination).append(this.el);
}
});
var BaseView = Backbone.View.extend({
render: function() {
var destination = this.container.getInsideElement();
@ -109,4 +147,5 @@ exports.ModalView = ModalView;
exports.ModalTerminal = ModalTerminal;
exports.ModalAlert = ModalAlert;
exports.BaseView = BaseView;
exports.ConfirmCancelView = ConfirmCancelView;

View file

@ -1,34 +1,29 @@
var GitError = require('../util/errors').GitError;
var _ = require('underscore');
var Q = require('q');
// horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone;
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
var ModalTerminal = require('../views').ModalTerminal;
var BaseView = require('../views').BaseView;
var ConfirmCancelView = require('../views').ConfirmCancelView;
var InteractiveRebaseView = BaseView.extend({
tagName: 'div',
template: _.template($('#interactive-rebase-template').html()),
events: {
'click #confirmButton': 'confirmed'
},
initialize: function(options) {
this.hasClicked = false;
this.deferred = options.deferred;
this.rebaseArray = options.toRebase;
this.rebaseEntries = new RebaseEntryCollection();
this.rebaseMap = {};
this.entryObjMap = {};
this.rebaseArray.reverse();
// make basic models for each commit
_.each(this.rebaseArray, function(commit) {
this.rebaseEntries = new RebaseEntryCollection();
options.toRebase.reverse();
_.each(options.toRebase, function(commit) {
var id = commit.get('id');
this.rebaseMap[id] = commit;
// make basic models for each commit
this.entryObjMap[id] = new RebaseEntry({
id: id
});
@ -38,22 +33,13 @@ var InteractiveRebaseView = BaseView.extend({
this.container = new ModalTerminal({
title: 'Interactive Rebase'
});
this.render();
// show the dialog holder
this.show();
},
confirmed: function() {
// we hide the dialog anyways, but they might be fast clickers
if (this.hasClicked) {
return;
}
this.hasClicked = true;
// first of all hide
this.$('#iRebaseDialog').css('display', 'none');
confirm: function() {
this.hide();
// get our ordering
@ -65,7 +51,7 @@ var InteractiveRebaseView = BaseView.extend({
// now get the real array
var toRebase = [];
_.each(uiOrder, function(id) {
// the model
// the model pick check
if (this.entryObjMap[id].get('pick')) {
toRebase.unshift(this.rebaseMap[id]);
}
@ -78,7 +64,7 @@ var InteractiveRebaseView = BaseView.extend({
render: function() {
var json = {
num: this.rebaseArray.length
num: _.keys(this.rebaseMap).length
};
var destination = this.container.getInsideElement();
@ -100,6 +86,27 @@ var InteractiveRebaseView = BaseView.extend({
placeholder: 'rebaseEntry transitionOpacity ui-state-highlight',
appendTo: 'parent'
});
this.makeButtons();
},
makeButtons: function() {
// control for button
var deferred = Q.defer();
deferred.promise
.then(_.bind(function() {
this.confirm();
}, this))
.fail(_.bind(function() {
this.deferred.reject();
}, this))
.done();
// finally get our buttons
new ConfirmCancelView({
destination: this.$('.confirmCancel'),
deferred: deferred
});
}
});

View file

@ -53,6 +53,10 @@ body,
-webkit-box-pack: center;
}
.justify {
-webkit-box-pack: justify;
}
/* Transition */
.transitionBackground {
-webkit-transition: background 700ms cubic-bezier(0.260, 0.860, 0.440, 0.985);

View file

@ -8,8 +8,8 @@ Big Graphic things:
Medium things:
~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ ] rebase entries styling
[ ] check animation for command entry fading nicely wtf
[ ] no more CSS ids
Small things to implement:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -29,6 +29,9 @@ Big Bugs to fix:
Done things:
(I only started this on Dec 17th 2012 to get a better sense of what was done)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[x] promise-based confirm cnacel
[x] rebase buttons view & styling
[x] rebase entries styling
[x] view for anything above the fold (modal view)
[x] rebase styling (get it better. even cuter -- make it like a command window)
[x] fix multiple rebases