Skip to content

Commit

Permalink
Delete proposal button at Session page #150
Browse files Browse the repository at this point in the history
  • Loading branch information
akdasa committed Jan 27, 2018
1 parent a6a19f1 commit a0e241b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
18 changes: 16 additions & 2 deletions gem/web/blueprints/sessions/sessions_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@ function createSessionsController() {
var ids = Object.keys(me.proposals);
var html = me.proposalsTemplate({
proposals: controller.proposals,
empty: "No proposals added to session"});
empty: "No proposals added to session",
showDelete: true
})

$("#proposals").html(html);
$("#proposals-ids").val(ids);
$(".session-remove-proposal").on("click", function (e) {
var key = $(this).data("key");
controller.removeProposal(key)
})
$('[data-toggle="tooltip"]').tooltip()
}

me.appendProposalToSession = function(proposalKey, proposalTitle) {
me.proposals[proposalKey] = {title: proposalTitle}
me.proposals[proposalKey] = {title: proposalTitle, "_id": proposalKey}
me.refreshProposalsList()
me.closeAddProposalDialog()
}
Expand All @@ -57,6 +64,13 @@ function createSessionsController() {
$("#proposal-add-modal").modal("hide");
}

me.removeProposal = function(proposalKey) {
if (proposalKey in me.proposals) {
delete me.proposals[proposalKey]
}
me.refreshProposalsList()
}


if (me.isConcreteSessionPage()) {
var source = $("#entry-template").html()
Expand Down
10 changes: 9 additions & 1 deletion gem/web/blueprints/sessions/sessions_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,15 @@ <h4 class="modal-title">Add proposal to session</h4>
<script id="entry-template" type="text/x-handlebars-template">
{% raw %}
{{#each proposals}}
<a href="#" class="list-group-item" data-key="{{key}}">{{title}}</a>
<a href="#" class="list-group-item" data-key="{{key}}">
{{title}}
{{#if ../showDelete }}
<span class="pull-right glyphicon glyphicon-trash session-remove-proposal"
aria-hidden="true" data-toggle="tooltip"
data-placement="left" title="Remove from session"
data-key="{{_id}}"></span>
{{/if}}
</a>
{{else}}
<a href="#" class="list-group-item list-group-item-danger">{{empty}}</a>
{{/each}}
Expand Down

0 comments on commit a0e241b

Please sign in to comment.