diff --git a/dmp-backend/.classpath b/dmp-backend/.classpath index 6b533711d..c9a85b970 100644 --- a/dmp-backend/.classpath +++ b/dmp-backend/.classpath @@ -17,11 +17,6 @@ - - - - - diff --git a/dmp-backend/src/main/java/rest/BackendInterface.java b/dmp-backend/src/main/java/rest/BackendInterface.java index 2d95ca8e7..5cbfa3a69 100644 --- a/dmp-backend/src/main/java/rest/BackendInterface.java +++ b/dmp-backend/src/main/java/rest/BackendInterface.java @@ -198,10 +198,20 @@ public class BackendInterface { @RequestMapping(method = RequestMethod.POST, value = { "/setDMPByForm" }, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces="text/plain") public @ResponseBody ResponseEntity setDMPByForm(@RequestBody MultiValueMap formData) { + //create the whole dmp structure by the form fields DMP dmp = Transformers.createDMPfromMap(formData); return setDMP(dmp); } + @RequestMapping(method = RequestMethod.POST, value = { "/editDMPByForm" }, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces="text/plain") + public @ResponseBody ResponseEntity editDMPByForm(@RequestBody MultiValueMap formData) { + //get previous DMP by id, replace fields, and update + DMP dmp = dMPDao.read(UUID.fromString(formData.getFirst("dmp-id"))); + dmp.getDataset().getProfile().setDefinition(formData.getFirst("DatasetProfile.definition")); + dmp.getDataset().getProfile().getRuleset().setDefinition(formData.getFirst("DatasetProfileRuleset.definition")); + dmp.getDataset().getProfile().getViewstyle().setDefinition(formData.getFirst("DatasetProfileViewStyle.definition")); + return setDMP(dmp); + } diff --git a/dmp-backend/src/main/webapp/WEB-INF/views/jsp/home.jsp b/dmp-backend/src/main/webapp/WEB-INF/views/jsp/home.jsp index b696ef240..9c1ea52a5 100644 --- a/dmp-backend/src/main/webapp/WEB-INF/views/jsp/home.jsp +++ b/dmp-backend/src/main/webapp/WEB-INF/views/jsp/home.jsp @@ -21,6 +21,9 @@ + + + @@ -32,8 +35,8 @@ - - + +

Digital Management Plans - Backend administration

@@ -78,11 +81,21 @@ - - @@ -364,5 +377,58 @@
+ + + + + + \ No newline at end of file diff --git a/dmp-backend/src/main/webapp/resources/css/home.css b/dmp-backend/src/main/webapp/resources/css/home.css index b6a138711..b59a8f8d3 100644 --- a/dmp-backend/src/main/webapp/resources/css/home.css +++ b/dmp-backend/src/main/webapp/resources/css/home.css @@ -7,6 +7,14 @@ div.form-group{ +.modal-edit-form { + width: 80%; + margin: auto; + /* + background-color: yellow; + */ +} + /* diff --git a/dmp-backend/src/main/webapp/resources/js/home.js b/dmp-backend/src/main/webapp/resources/js/home.js index a26a94ce9..629e60022 100644 --- a/dmp-backend/src/main/webapp/resources/js/home.js +++ b/dmp-backend/src/main/webapp/resources/js/home.js @@ -23,7 +23,7 @@ function clickedDelete(id){ } -function clickedEdit(id){ +function clickedEdit_Disabled(id){ console.log(id); $.notify({ title: "Editing is disabled
", @@ -31,6 +31,45 @@ function clickedEdit(id){ }); } +function clickedEdit(dmp) { + + console.log(dmp); + + var titles = ["DatasetProfileRuleset", "DatasetProfileViewStyle", "DatasetProfile"]; + + + $('#edit-dmp-modal-container').find('.modal-title').html("Edit DMP: "+dmp.id); + + var form = $('#edit-dmp-form'); + + form.find("#dmp-id").val(dmp.id); //set the current id on the hidden form element + + if((dmp.dataset != null) && (dmp.dataset.profile != null)){ + form.find('#dp-definition').val(vkbeautify.xml(dmp.dataset.profile.definition)); + if(dmp.dataset.profile.ruleset != 'undefined') + form.find('#dpr-definition').val(vkbeautify.xml(dmp.dataset.profile.ruleset.definition)); + if(dmp.dataset.profile.viewstyle != 'undefined') + form.find('#dpv-definition').val(vkbeautify.xml(dmp.dataset.profile.viewstyle.definition)); + } + + + + + //var listGroup = $(document.createElement('div')); + //listGroup.addClass("list-group"); + + //listGroup.append( "DatasetProfileRuleset" ); + + + + //console.log(listGroup); + + + //$('#edit-dmp-modal-container').find('.modal-body').html(""); + //$('#edit-dmp-modal-container').find('.modal-body').append(listGroup); + +} + function loadTile(data){ diff --git a/dmp-backend/src/main/webapp/resources/js/vkbeautify.0.99.00.js b/dmp-backend/src/main/webapp/resources/js/vkbeautify.0.99.00.js new file mode 100644 index 000000000..57effaeca --- /dev/null +++ b/dmp-backend/src/main/webapp/resources/js/vkbeautify.0.99.00.js @@ -0,0 +1,358 @@ +/** +* vkBeautify - javascript plugin to pretty-print or minify text in XML, JSON, CSS and SQL formats. +* +* Version - 0.99.00.beta +* Copyright (c) 2012 Vadim Kiryukhin +* vkiryukhin @ gmail.com +* http://www.eslinstructor.net/vkbeautify/ +* +* Dual licensed under the MIT and GPL licenses: +* http://www.opensource.org/licenses/mit-license.php +* http://www.gnu.org/licenses/gpl.html +* +* Pretty print +* +* vkbeautify.xml(text [,indent_pattern]); +* vkbeautify.json(text [,indent_pattern]); +* vkbeautify.css(text [,indent_pattern]); +* vkbeautify.sql(text [,indent_pattern]); +* +* @text - String; text to beatufy; +* @indent_pattern - Integer | String; +* Integer: number of white spaces; +* String: character string to visualize indentation ( can also be a set of white spaces ) +* Minify +* +* vkbeautify.xmlmin(text [,preserve_comments]); +* vkbeautify.jsonmin(text); +* vkbeautify.cssmin(text [,preserve_comments]); +* vkbeautify.sqlmin(text); +* +* @text - String; text to minify; +* @preserve_comments - Bool; [optional]; +* Set this flag to true to prevent removing comments from @text ( minxml and mincss functions only. ) +* +* Examples: +* vkbeautify.xml(text); // pretty print XML +* vkbeautify.json(text, 4 ); // pretty print JSON +* vkbeautify.css(text, '. . . .'); // pretty print CSS +* vkbeautify.sql(text, '----'); // pretty print SQL +* +* vkbeautify.xmlmin(text, true);// minify XML, preserve comments +* vkbeautify.jsonmin(text);// minify JSON +* vkbeautify.cssmin(text);// minify CSS, remove comments ( default ) +* vkbeautify.sqlmin(text);// minify SQL +* +*/ + +(function() { + +function createShiftArr(step) { + + var space = ' '; + + if ( isNaN(parseInt(step)) ) { // argument is string + space = step; + } else { // argument is integer + switch(step) { + case 1: space = ' '; break; + case 2: space = ' '; break; + case 3: space = ' '; break; + case 4: space = ' '; break; + case 5: space = ' '; break; + case 6: space = ' '; break; + case 7: space = ' '; break; + case 8: space = ' '; break; + case 9: space = ' '; break; + case 10: space = ' '; break; + case 11: space = ' '; break; + case 12: space = ' '; break; + } + } + + var shift = ['\n']; // array of shifts + for(ix=0;ix<100;ix++){ + shift.push(shift[ix]+space); + } + return shift; +} + +function vkbeautify(){ + this.step = ' '; // 4 spaces + this.shift = createShiftArr(this.step); +}; + +vkbeautify.prototype.xml = function(text,step) { + + var ar = text.replace(/>\s{0,}<") + .replace(/ or -1) { + str += shift[deep]+ar[ix]; + inComment = true; + // end comment or // + if(ar[ix].search(/-->/) > -1 || ar[ix].search(/\]>/) > -1 || ar[ix].search(/!DOCTYPE/) > -1 ) { + inComment = false; + } + } else + // end comment or // + if(ar[ix].search(/-->/) > -1 || ar[ix].search(/\]>/) > -1) { + str += ar[ix]; + inComment = false; + } else + // // + if( /^<\w/.exec(ar[ix-1]) && /^<\/\w/.exec(ar[ix]) && + /^<[\w:\-\.\,]+/.exec(ar[ix-1]) == /^<\/[\w:\-\.\,]+/.exec(ar[ix])[0].replace('/','')) { + str += ar[ix]; + if(!inComment) deep--; + } else + // // + if(ar[ix].search(/<\w/) > -1 && ar[ix].search(/<\//) == -1 && ar[ix].search(/\/>/) == -1 ) { + str = !inComment ? str += shift[deep++]+ar[ix] : str += ar[ix]; + } else + // ... // + if(ar[ix].search(/<\w/) > -1 && ar[ix].search(/<\//) > -1) { + str = !inComment ? str += shift[deep]+ar[ix] : str += ar[ix]; + } else + // // + if(ar[ix].search(/<\//) > -1) { + str = !inComment ? str += shift[--deep]+ar[ix] : str += ar[ix]; + } else + // // + if(ar[ix].search(/\/>/) > -1 ) { + str = !inComment ? str += shift[deep]+ar[ix] : str += ar[ix]; + } else + // // + if(ar[ix].search(/<\?/) > -1) { + str += shift[deep]+ar[ix]; + } else + // xmlns // + if( ar[ix].search(/xmlns\:/) > -1 || ar[ix].search(/xmlns\=/) > -1) { + str += shift[deep]+ar[ix]; + } + + else { + str += ar[ix]; + } + } + + return (str[0] == '\n') ? str.slice(1) : str; +} + +vkbeautify.prototype.json = function(text,step) { + + var step = step ? step : this.step; + + if (typeof JSON === 'undefined' ) return text; + + if ( typeof text === "string" ) return JSON.stringify(JSON.parse(text), null, step); + if ( typeof text === "object" ) return JSON.stringify(text, null, step); + + return text; // text is not string nor object +} + +vkbeautify.prototype.css = function(text, step) { + + var ar = text.replace(/\s{1,}/g,' ') + .replace(/\{/g,"{~::~") + .replace(/\}/g,"~::~}~::~") + .replace(/\;/g,";~::~") + .replace(/\/\*/g,"~::~/*") + .replace(/\*\//g,"*/~::~") + .replace(/~::~\s{0,}~::~/g,"~::~") + .split('~::~'), + len = ar.length, + deep = 0, + str = '', + ix = 0, + shift = step ? createShiftArr(step) : this.shift; + + for(ix=0;ix/g,"") + .replace(/[ \r\n\t]{1,}xmlns/g, ' xmlns'); + return str.replace(/>\s{0,}<"); +} + +vkbeautify.prototype.jsonmin = function(text) { + + if (typeof JSON === 'undefined' ) return text; + + return JSON.stringify(JSON.parse(text), null, 0); + +} + +vkbeautify.prototype.cssmin = function(text, preserveComments) { + + var str = preserveComments ? text + : text.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\//g,"") ; + + return str.replace(/\s{1,}/g,' ') + .replace(/\{\s{1,}/g,"{") + .replace(/\}\s{1,}/g,"}") + .replace(/\;\s{1,}/g,";") + .replace(/\/\*\s{1,}/g,"/*") + .replace(/\*\/\s{1,}/g,"*/"); +} + +vkbeautify.prototype.sqlmin = function(text) { + return text.replace(/\s{1,}/g," ").replace(/\s{1,}\(/,"(").replace(/\s{1,}\)/,")"); +} + +window.vkbeautify = new vkbeautify(); + +})(); +