diff --git a/src/main/resources/static/js/models/project.js b/src/main/resources/static/js/models/project.js index e565754..5415f4f 100644 --- a/src/main/resources/static/js/models/project.js +++ b/src/main/resources/static/js/models/project.js @@ -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); diff --git a/src/main/resources/static/js/views/app-view.js b/src/main/resources/static/js/views/app-view.js index b67d14d..cf22916 100644 --- a/src/main/resources/static/js/views/app-view.js +++ b/src/main/resources/static/js/views/app-view.js @@ -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){ diff --git a/src/main/resources/static/js/views/main-menu-view.js b/src/main/resources/static/js/views/main-menu-view.js index 06aba8b..7792c18 100644 --- a/src/main/resources/static/js/views/main-menu-view.js +++ b/src/main/resources/static/js/views/main-menu-view.js @@ -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); diff --git a/src/main/resources/static/js/views/project-view.js b/src/main/resources/static/js/views/project-view.js index e698c9c..f669efa 100644 --- a/src/main/resources/static/js/views/project-view.js +++ b/src/main/resources/static/js/views/project-view.js @@ -26,8 +26,8 @@ define(function(require) { } },this); } - }); + var ProjectListView = Backbone.View.extend({ tagName : 'li', events : { @@ -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; diff --git a/src/main/resources/static/js/views/tree-view.js b/src/main/resources/static/js/views/tree-view.js index 47f4fd5..950a3fd 100644 --- a/src/main/resources/static/js/views/tree-view.js +++ b/src/main/resources/static/js/views/tree-view.js @@ -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(); @@ -329,6 +341,7 @@ define(function(require) { return null; } }; + tree.showTree = function(projectRefNodeId) { $.ajax({ url : APP.config.baseUrl + '/nodes/' + projectRefNodeId + '/tree', @@ -348,6 +361,6 @@ define(function(require) { } }); }; - + return tree; }); \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/home.jsp b/src/main/webapp/WEB-INF/jsp/home.jsp index aae1e1e..1a5ce5e 100644 --- a/src/main/webapp/WEB-INF/jsp/home.jsp +++ b/src/main/webapp/WEB-INF/jsp/home.jsp @@ -156,8 +156,9 @@
  • Sort
  • Filter
  • -
  • Delete
  • +
  • Delete Project
  • Delete Request
  • +
  • Edit Project
  • @@ -436,6 +437,25 @@ + +