Index: lams_central/src/java/org/lamsfoundation/lams/web/qb/QbCollectionController.java =================================================================== diff -u -r399b35bc9ee55acf1d64596c09b96fe5aee73709 -rd5719555b4c16102968655a9e2d2edce72296fa9 --- lams_central/src/java/org/lamsfoundation/lams/web/qb/QbCollectionController.java (.../QbCollectionController.java) (revision 399b35bc9ee55acf1d64596c09b96fe5aee73709) +++ lams_central/src/java/org/lamsfoundation/lams/web/qb/QbCollectionController.java (.../QbCollectionController.java) (revision d5719555b4c16102968655a9e2d2edce72296fa9) @@ -170,6 +170,12 @@ } } + @RequestMapping("/addCollection") + @ResponseBody + public void removeCollectionQuestions(@RequestParam String name) { + qbService.addCollection(getUserId(), name); + } + private Integer getUserId() { HttpSession ss = SessionManager.getSession(); UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); Index: lams_central/web/qb/collection.jsp =================================================================== diff -u -r399b35bc9ee55acf1d64596c09b96fe5aee73709 -rd5719555b4c16102968655a9e2d2edce72296fa9 --- lams_central/web/qb/collection.jsp (.../collection.jsp) (revision 399b35bc9ee55acf1d64596c09b96fe5aee73709) +++ lams_central/web/qb/collection.jsp (.../collection.jsp) (revision d5719555b4c16102968655a9e2d2edce72296fa9) @@ -14,6 +14,22 @@ div.buttons { margin-top: 5px; } + + #addCollectionDiv { + margin-top: 10px; + padding-top: 10px; + border-top: black thin solid; + } + + #addCollectionDiv input { + display: inline; + width: 80%; + margin-right: 10px; + } + + #addCollectionDiv button { + float: right; + } @@ -161,6 +177,31 @@ grid.trigger('reloadGrid'); }); } + + function addCollection() { + var name = $('#addCollectionDiv input').val().trim(), + lower = name.toLowerCase(); + $('.collection-grid').each(function(){ + if ($(this).data('collectionName').trim().toLowerCase() == lower) { + alert('Collection with such name already exists'); + name = null; + return false; + } + }); + if (name) { + $.ajax({ + 'url' : 'qb/collection/addCollection.do', + 'type' : 'POST', + 'dataType' : 'text', + 'data' : { + 'name' : name + }, + 'cache' : false + }).done(function(){ + document.location.reload(); + }); + } + } @@ -173,6 +214,10 @@ +
+ + +
\ No newline at end of file