Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from drip/delete_repository
Delete repository
- Loading branch information
Showing
10 changed files
with
165 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,7 @@ D.RepositoryList = Backbone.Collection.extend({ | |
} | ||
|
||
}); | ||
}, | ||
|
||
addOrUpdateRepository: function () { | ||
} | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,80 @@ | ||
D.RepositoryView = Backbone.View.extend({ | ||
|
||
tagName: 'div', | ||
className: 'pane', | ||
className: 'pane main_pane', | ||
|
||
events: { | ||
'click #show_add_new_repo' : 'showAdd' | ||
"click .wrench_icon": "showSettings" | ||
}, | ||
|
||
initialize: function (options) { | ||
_.bindAll(this); | ||
this.model.bind("change", this.render); | ||
this.model.bind("destroy", this.remove); | ||
this.selectedBuild = options.selectedBuild; | ||
}, | ||
|
||
render: function () { | ||
var el = $(".pane"), | ||
frag = $(_.template($("#repository_show_template").html(), {name: this.model.get("name")})); | ||
var frag = $(_.template($("#repository_show_template").html(), {name: this.model.get("name")})); | ||
|
||
frag.find(".build_result").addClass(this.model.status()); | ||
|
||
if (el.length === 0) { | ||
el = this.el = $(this.el); | ||
} | ||
this.el = $(this.el); | ||
|
||
el.html(frag); | ||
this.el.html(frag); | ||
|
||
if (this.model.get('buildList')) { | ||
el.append(new D.BuildListView({ | ||
this.el.append(new D.BuildListView({ | ||
collection: this.model.get("buildList"), | ||
selectedBuild: this.selectedBuild | ||
}).render().el); | ||
} | ||
else { | ||
el.append("<div class='no_builds'>This repository has no builds yet ☹</div>"); | ||
this.el.append("<div class='no_builds'>This repository has no builds yet ☹</div>"); | ||
} | ||
|
||
$(".pane").replaceWith(this.el); | ||
|
||
return this; | ||
}, | ||
|
||
showAdd: function() { | ||
D.appRouter.navigate("/repositories/new", true); | ||
showSettings: function () { | ||
var deleteButton = $("<a class='btn danger'>Delete repository</a>'"), | ||
popoverNav = new D.PopoverNav({items: [deleteButton]}), | ||
popoverEl = $(popoverNav.render().el), | ||
that = this, | ||
left; | ||
|
||
// delete link handler | ||
deleteButton.bind("click", function () { | ||
popoverNav.hide(); | ||
that.deleteRepository(); | ||
}); | ||
|
||
// append to dom | ||
$(this.el).find(".repository_name").append(popoverEl); | ||
|
||
// find and set the correct position | ||
left = ($(this.el).find(".wrench_icon").position().left - (parseInt(popoverEl.css("width")) / 2)) + 10; | ||
$(popoverNav.el).css({"top": 40, "left": left}); | ||
|
||
// show | ||
popoverNav.show(); | ||
}, | ||
|
||
deleteRepository: function () { | ||
if (confirm("Are you sure you want to delete " + this.model.get("name"))) { | ||
$(".main_pane").html("Deleting repository, please wait .."); | ||
this.model.destroy(); | ||
} | ||
}, | ||
|
||
remove: function () { | ||
var pane = $('<div class="pane"></div>'); | ||
pane.html('<div class="select_repository">Please select a repository on the left</div>'); | ||
$(".main_pane").replaceWith(pane); | ||
|
||
D.appRouter.navigate("/repositories"); | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
D.PopoverNav = Backbone.View.extend({ | ||
tagName: 'div', | ||
className: 'popover_nav', | ||
|
||
events: { | ||
"clickoutside": "hide" | ||
}, | ||
|
||
initialize: function (options) { | ||
this.items = options.items; | ||
}, | ||
|
||
render: function () { | ||
var ul = $("<ul class='unstyled'>"); | ||
|
||
_.each(this.items, function (item) { | ||
var li = $("<li>"); | ||
li.html(item); | ||
ul.append(li); | ||
}); | ||
|
||
$(this.el).html(ul); | ||
$(this.el).hide(); | ||
|
||
return this; | ||
}, | ||
|
||
show: function () { | ||
$(this.el).fadeIn(200); | ||
}, | ||
|
||
hide: function () { | ||
$(this.el).fadeOut(200, function () { | ||
$(this).remove(); | ||
}); | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters