Skip to content

Commit 1d6b965

Browse files
author
Ranjan Kumar
committed
Merge pull request #51 from ksamykandil/master
Option to edit/delete a project #4 , Project name/description took the previous created project values #48 & Project description is not saved #49
2 parents 6434c82 + eaa7705 commit 1d6b965

File tree

6 files changed

+89
-8
lines changed

6 files changed

+89
-8
lines changed

src/main/resources/static/js/models/project.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ define(function(require) {
1414
description : ''
1515
},
1616
sync : function(method, model, options){
17-
if(method == 'create'){
17+
if(method == 'create' || method == 'update'){
1818
model.urlRoot = APP.config.baseUrl + "/workspaces/" + APP.appView.getCurrentWorkspaceId() + "/projects";
1919
model.unset('projectRef');
2020
return Backbone.sync(method, model, options);

src/main/resources/static/js/views/app-view.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ define(function(require) {
4646
},
4747
handleProjectChange : function(id){
4848
console.log('project changed :'+ id);
49+
50+
$.ajax({
51+
url : APP.config.baseUrl + '/workspaces/' + this.workspaceId + '/projects/' + id,
52+
type : 'get',
53+
dataType : 'json',
54+
contentType : "application/json",
55+
success : function(project) {
56+
$("#editProjectTextField").val(project.name);
57+
$("#editProjectTextArea").val(project.description);
58+
}
59+
});
60+
4961
this.projectId = id;
5062
},
5163
handleConversationChange : function(id){

src/main/resources/static/js/views/main-menu-view.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,40 @@ define(function(require) {
99

1010
$("#saveProjectBtn").unbind("click").bind("click", function(){
1111
var project = new ProjectModel({
12-
name : $("#projectTextField").val()
12+
name : $("#projectTextField").val(),
13+
description: $("#projectTextArea").val()
1314
});
1415
project.save(null, {
1516
success : function(response) {
1617
var projectView = new ProjectView();
1718
projectView.addOne(project);
18-
$('#projectModal').modal("hide");
19+
$('#projectModal').modal("hide");
20+
$("#projectTextField").val("");
21+
$("#projectTextArea").val("");
22+
},
23+
error : function(e) {
24+
alert('Some unexpected error occured Please try later.');
25+
}
26+
});
27+
});
28+
29+
$("#editProjectBtn").unbind("click").bind("click", function(){
30+
var project = new ProjectModel({
31+
id: APP.appView.getCurrentProjectId(),
32+
name: $("#editProjectTextField").val(),
33+
description: $("#editProjectTextArea").val()
34+
});
35+
project.save(null, {
36+
success : function(response) {
37+
$("#editProjectTextField").val("");
38+
$("#editProjectTextArea").val("");
39+
location.reload();
1940
},
2041
error : function(e) {
2142
alert('Some unexpected error occured Please try later.');
2243
}
2344
});
2445
});
25-
2646

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

src/main/resources/static/js/views/project-view.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ define(function(require) {
2626
}
2727
},this);
2828
}
29-
3029
});
30+
3131
var ProjectListView = Backbone.View.extend({
3232
tagName : 'li',
3333
events : {
@@ -49,7 +49,6 @@ define(function(require) {
4949
console.log('current project id is ' + APP.appView.getCurrentProjectId());
5050
tree.showTree(this.$el.find('a').data('project-ref-id'));
5151
},
52-
5352
render : function() {
5453
this.$el.html(this.template({project : this.model.toJSON()}));
5554
return this;

src/main/resources/static/js/views/tree-view.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ define(function(require) {
9898
}
9999
});
100100
});
101+
102+
$("#deleteProjectBtn").bind("click", function() {
103+
$.ajax({
104+
url : APP.config.baseUrl + '/workspaces/' + APP.appView.getCurrentWorkspaceId() + "/projects/" + APP.appView.getCurrentProjectId(),
105+
type : 'delete',
106+
dataType : 'json',
107+
contentType : "application/json",
108+
success : function(data) {
109+
location.reload();
110+
}
111+
});
112+
});
101113

102114
$('.col-1-toggle-btn').toggle(function() {
103115
$('.rf-col-1').hide();
@@ -329,6 +341,7 @@ define(function(require) {
329341
return null;
330342
}
331343
};
344+
332345
tree.showTree = function(projectRefNodeId) {
333346
$.ajax({
334347
url : APP.config.baseUrl + '/nodes/' + projectRefNodeId + '/tree',
@@ -348,6 +361,6 @@ define(function(require) {
348361
}
349362
});
350363
};
351-
364+
352365
return tree;
353366
});

src/main/webapp/WEB-INF/jsp/home.jsp

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@
156156
<li><a style="font-size: 12px;" data-toggle="modal" data-target="#comingSoon">Sort</a></li>
157157
<li><a style="font-size: 12px;" data-toggle="modal" data-target="#comingSoon">Filter</a></li>
158158
<li class="divider"></li>
159-
<li><a style="font-size: 12px;" data-toggle="modal" data-target="#comingSoon">Delete</a></li>
159+
<li><a style="font-size: 12px;" data-toggle="modal" data-target="#deleteProjectModal">Delete Project</a></li>
160160
<li><a style="font-size: 12px;" data-toggle="modal" data-target="#deleteRequestModal">Delete Request</a></li>
161+
<li><a style="font-size: 12px;" data-toggle="modal" data-target="#editProjectModal">Edit Project</a></li>
161162
</ul>
162163
</div>
163164

@@ -436,6 +437,25 @@
436437
</div>
437438
</div>
438439
</div>
440+
<div class="modal fade" id="editProjectModal" tabindex="-1">
441+
<div class="modal-dialog">
442+
<div class="modal-content">
443+
<div class="modal-header">
444+
<button type="button" class="close" data-dismiss="modal">&times;</button>
445+
<h4 class="modal-title" id="editProjectModalLabel">Edit Project</h4>
446+
</div>
447+
<div class="modal-body">
448+
<input type="text" id="editProjectTextField" class="form-control" placeholder="Enter Project Name"> <br>
449+
<textarea id="editProjectTextArea" class="form-control" rows="3" placeholder="Enter Description"></textarea>
450+
<br>
451+
</div>
452+
<div class="modal-footer">
453+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
454+
<button id="editProjectBtn" type="button" class="btn btn-primary">Save changes</button>
455+
</div>
456+
</div>
457+
</div>
458+
</div>
439459
<div class="modal fade" id="switchWorkspaceModal" tabindex="-1">
440460
<div class="modal-dialog">
441461
<div class="modal-content">
@@ -467,6 +487,23 @@
467487
</div>
468488
</div>
469489
</div>
490+
<div class="modal fade" id="deleteProjectModal" tabindex="-1">
491+
<div class="modal-dialog">
492+
<div class="modal-content">
493+
<div class="modal-header">
494+
<button type="button" class="close" data-dismiss="modal">&times;</button>
495+
<h4 class="modal-title" id="myModalLabel">Delete Project</h4>
496+
</div>
497+
<div class="modal-body">
498+
Are You Sure You Want To Delete Selected Project?
499+
</div>
500+
<div class="modal-footer">
501+
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
502+
<button type="button" class="btn btn-primary" id="deleteProjectBtn">Yes</button>
503+
</div>
504+
</div>
505+
</div>
506+
</div>
470507
<div class="modal fade" id="comingSoon" tabindex="-1">
471508
<div class="modal-dialog">
472509
<div class="modal-content">

0 commit comments

Comments
 (0)