Skip to content

Commit

Permalink
Merge pull request #51 from ksamykandil/master
Browse files Browse the repository at this point in the history
Option to edit/delete a project #4 , Project name/description took the previous created project values #48 & Project description is not saved #49
  • Loading branch information
Ranjan Kumar committed Sep 4, 2014
2 parents 6434c82 + eaa7705 commit 1d6b965
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/resources/static/js/models/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define(function(require) {
description : ''
},
sync : function(method, model, options){
if(method == 'create'){
if(method == 'create' || method == 'update'){
model.urlRoot = APP.config.baseUrl + "/workspaces/" + APP.appView.getCurrentWorkspaceId() + "/projects";
model.unset('projectRef');
return Backbone.sync(method, model, options);
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/static/js/views/app-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ define(function(require) {
},
handleProjectChange : function(id){
console.log('project changed :'+ id);

$.ajax({
url : APP.config.baseUrl + '/workspaces/' + this.workspaceId + '/projects/' + id,
type : 'get',
dataType : 'json',
contentType : "application/json",
success : function(project) {
$("#editProjectTextField").val(project.name);
$("#editProjectTextArea").val(project.description);
}
});

this.projectId = id;
},
handleConversationChange : function(id){
Expand Down
26 changes: 23 additions & 3 deletions src/main/resources/static/js/views/main-menu-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,40 @@ define(function(require) {

$("#saveProjectBtn").unbind("click").bind("click", function(){
var project = new ProjectModel({
name : $("#projectTextField").val()
name : $("#projectTextField").val(),
description: $("#projectTextArea").val()
});
project.save(null, {
success : function(response) {
var projectView = new ProjectView();
projectView.addOne(project);
$('#projectModal').modal("hide");
$('#projectModal').modal("hide");
$("#projectTextField").val("");
$("#projectTextArea").val("");
},
error : function(e) {
alert('Some unexpected error occured Please try later.');
}
});
});

$("#editProjectBtn").unbind("click").bind("click", function(){
var project = new ProjectModel({
id: APP.appView.getCurrentProjectId(),
name: $("#editProjectTextField").val(),
description: $("#editProjectTextArea").val()
});
project.save(null, {
success : function(response) {
$("#editProjectTextField").val("");
$("#editProjectTextArea").val("");
location.reload();
},
error : function(e) {
alert('Some unexpected error occured Please try later.');
}
});
});


$("#saveWorkspaceBtn").bind("click", saveWorkspace);

Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/static/js/views/project-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ define(function(require) {
}
},this);
}

});

var ProjectListView = Backbone.View.extend({
tagName : 'li',
events : {
Expand All @@ -49,7 +49,6 @@ define(function(require) {
console.log('current project id is ' + APP.appView.getCurrentProjectId());
tree.showTree(this.$el.find('a').data('project-ref-id'));
},

render : function() {
this.$el.html(this.template({project : this.model.toJSON()}));
return this;
Expand Down
15 changes: 14 additions & 1 deletion src/main/resources/static/js/views/tree-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ define(function(require) {
}
});
});

$("#deleteProjectBtn").bind("click", function() {
$.ajax({
url : APP.config.baseUrl + '/workspaces/' + APP.appView.getCurrentWorkspaceId() + "/projects/" + APP.appView.getCurrentProjectId(),
type : 'delete',
dataType : 'json',
contentType : "application/json",
success : function(data) {
location.reload();
}
});
});

$('.col-1-toggle-btn').toggle(function() {
$('.rf-col-1').hide();
Expand Down Expand Up @@ -329,6 +341,7 @@ define(function(require) {
return null;
}
};

tree.showTree = function(projectRefNodeId) {
$.ajax({
url : APP.config.baseUrl + '/nodes/' + projectRefNodeId + '/tree',
Expand All @@ -348,6 +361,6 @@ define(function(require) {
}
});
};

return tree;
});
39 changes: 38 additions & 1 deletion src/main/webapp/WEB-INF/jsp/home.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@
<li><a style="font-size: 12px;" data-toggle="modal" data-target="#comingSoon">Sort</a></li>
<li><a style="font-size: 12px;" data-toggle="modal" data-target="#comingSoon">Filter</a></li>
<li class="divider"></li>
<li><a style="font-size: 12px;" data-toggle="modal" data-target="#comingSoon">Delete</a></li>
<li><a style="font-size: 12px;" data-toggle="modal" data-target="#deleteProjectModal">Delete Project</a></li>
<li><a style="font-size: 12px;" data-toggle="modal" data-target="#deleteRequestModal">Delete Request</a></li>
<li><a style="font-size: 12px;" data-toggle="modal" data-target="#editProjectModal">Edit Project</a></li>
</ul>
</div>

Expand Down Expand Up @@ -436,6 +437,25 @@
</div>
</div>
</div>
<div class="modal fade" id="editProjectModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title" id="editProjectModalLabel">Edit Project</h4>
</div>
<div class="modal-body">
<input type="text" id="editProjectTextField" class="form-control" placeholder="Enter Project Name"> <br>
<textarea id="editProjectTextArea" class="form-control" rows="3" placeholder="Enter Description"></textarea>
<br>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button id="editProjectBtn" type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="switchWorkspaceModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
Expand Down Expand Up @@ -467,6 +487,23 @@
</div>
</div>
</div>
<div class="modal fade" id="deleteProjectModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title" id="myModalLabel">Delete Project</h4>
</div>
<div class="modal-body">
Are You Sure You Want To Delete Selected Project?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
<button type="button" class="btn btn-primary" id="deleteProjectBtn">Yes</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="comingSoon" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
Expand Down

0 comments on commit 1d6b965

Please sign in to comment.