Skip to content

Commit

Permalink
feat(ui): Validates that description has 100 words
Browse files Browse the repository at this point in the history
+ Addresses issue in presenting errors for "Request Review" and "Approve" button
  when the dataset does not pass validation.
+ Adds tooltip to description to let users know then need to enter at
  least 100 words for the description

Closes #397
Closes #418
Issue #411
  • Loading branch information
vchendrix committed Oct 26, 2023
1 parent 4b77f96 commit 7a1ebc4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
21 changes: 10 additions & 11 deletions ui/static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ $(document).ready(function () {
}
});

$.getJSON("static/js/metadata/dataset.json?v=20231023", function (data) {
$.getJSON("static/js/metadata/dataset.json?v=20231026", function (data) {
templates.datasets = data;
createEditForm('datasets');
});
Expand Down Expand Up @@ -824,14 +824,12 @@ $(document).ready(function () {
if (xhrResponse.result == true){
alert("Dataset Approved")
$('.js-loading').addClass('hide');

// refreshes the page
history.go(0);
}
else {
alert(xhrResponse.responseJSON.detail)
handleFormErrors(xhrResponse, "Dataset NOT Approved")
}

// refreshes the page
history.go(0);

});
}
Expand All @@ -850,13 +848,11 @@ $(document).ready(function () {
$.when(changeStatus(approveUrl, "submit")).always(function (xhrResponse) {
if (xhrResponse.result == true){
alert("Dataset Review Requested")

// refreshes the page
history.go(0);
}
else {
alert(xhrResponse.responseJSON.detail)
handleFormErrors(xhrResponse, "Dataset review NOT Requested")
}
history.go(0);
});
}

Expand Down Expand Up @@ -2297,7 +2293,7 @@ function handleFormErrors(httpResponse, errorPrefixMessage) {
if (httpResponse.status === 400) {
if (httpResponse.responseText) {

var response = JSON.parse(httpResponse.responseText);
var response = httpResponse.responseJSON;
for (var prop in response) {

// Which fields are missing
Expand All @@ -2313,5 +2309,8 @@ function handleFormErrors(httpResponse, errorPrefixMessage) {
}
}
}
else {
responseStr = httpResponse.responseJSON.detail
}
alert(errorPrefixMessage + '\n\n' + responseStr);
}
2 changes: 1 addition & 1 deletion ui/static/js/metadata/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"label": "Dataset Description",
"sequence": 4,
"multiple": false,
"description": "<p>Dataset description and overview. This should read as an abstract for the dataset, and provide users with adequate information about what the dataset contains, and how to use it. Include details on what data what, when and where data was collected, and if any data processing was done.</p> <p><i>E.g.: Raw output from the data logger connected to 9 sapflow and 5 soil moisture sensors are provided in xxx.dat. The metadata file (BR-Ma2 E-field log_20160501.xls) has information on locations where the sensors were installed, and other installation/maintenance details. No data processing or QA/QC was done on the raw datasets. Processed datasets will be uploaded separately. Contact [email protected] if you need to use this dataset for additional information.</i> <b>This field has a limit of 4,000 characters.</b></p>"
"description": "<p>Dataset description and overview. This should read as an abstract for the dataset, and provide users with adequate information about what the dataset contains, and how to use it. Include details on what data what, when and where data was collected, and if any data processing was done.</p> <p><i>E.g.: Raw output from the data logger connected to 9 sapflow and 5 soil moisture sensors are provided in xxx.dat. The metadata file (BR-Ma2 E-field log_20160501.xls) has information on locations where the sensors were installed, and other installation/maintenance details. No data processing or QA/QC was done on the raw datasets. Processed datasets will be uploaded separately. Contact [email protected] if you need to use this dataset for additional information.</i> <b>This field has a limit of 4,000 characters and must have at least 100 words.</b></p>"
},
"sites": {
"type": "reference_list",
Expand Down
2 changes: 1 addition & 1 deletion ui/templates/ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="stylesheet" href="static/stylesheets/foundation.css">
<script type="text/javascript" src="static/js/jquery-3.5.0.min.js"></script>
<script type="text/javascript" src="static/js/jquery-ui.js"></script>
<script type="text/javascript" src="static/js/app.js?v=20220901"></script>
<script type="text/javascript" src="static/js/app.js?v=20221026"></script>
<link rel="stylesheet" type="text/css" href="static/stylesheets/style.css">
<script type="text/javascript" src="static/js/foundation.js"></script>
<script type="text/javascript" src="static/js/what-input.js"></script>
Expand Down

0 comments on commit 7a1ebc4

Please sign in to comment.