Permalink
Browse files

setting user message when buildid is older than 30 days fixes bug 770878

  • Loading branch information...
1 parent 9053dcf commit 71191430cf7efecca60f1c436a346a146ee6123a @schalkneethling committed Jul 10, 2012
Showing with 61 additions and 11 deletions.
  1. +8 −3 webapp-php/css/screen.css
  2. +34 −1 webapp-php/js/socorro/admin.js
  3. +19 −7 webapp-php/js/socorro/utils.js
@@ -645,9 +645,12 @@ html.production .page-footer {
div#message {
margin: 1em;
}
-div.error, div.success,
+div.error,
+div.success,
+div.info,
p.error,
-p.success {
+p.success,
+p.info {
margin-bottom: .5em;
padding: 1em;
-webkit-border-radius: .25em;
@@ -660,7 +663,9 @@ p.error {
border: 1px solid #333;
}
div.success,
-p.success {
+p.success,
+div.info,
+p.info {
background-color: green;
border: 1px solid #eee;
color: #eee;
@@ -24,9 +24,15 @@ $(document).ready(function(){
optionalFieldToggle.toggleClass("expanded");
optionalFieldToggle.next().toggleClass("optional-collapsed");
},
- clearMessages = function() {
+ clearMessages = function(inputContainer) {
//removing any previous success or error messages
$(".success, .error").remove();
+
+ // remove the buildid info message
+ if(inputContainer) {
+ $("#buildid-range").remove();
+ inputContainer.removeClass("info");
+ }
};
$("#add_release_tab").click(function() {
@@ -49,6 +55,33 @@ $(document).ready(function(){
}
});
+ // When the user moves to another field after entering the buildid,
+ // ensure that the buildid is not more than 30 days ago from today.
+ // If the date is, show a notification to the user to inform them
+ // what the implications will be.
+ $("#build_id").blur(function(event) {
+ var buildID = $.trim($(this).val());
+
+ if(buildID !== "") {
+ var enteredTimeInMilis = socorro.date.convertToDateObj(buildID, "ISO8601").getTime(),
+ thirtyDaysAgoInMilis = socorro.date.now() - (socorro.date.ONE_DAY * 30),
+ inputContainer = $(this).parents(".field"),
+ msgContainer = document.createElement("span");
+ usrInfoMsg = document.createTextNode("The buildid is older than 30 days. You can still add the release but, it will not be viewable from the UI.");
+
+ if(enteredTimeInMilis < thirtyDaysAgoInMilis) {
+ // If the user message has not been added previously, add it now.
+ if(!inputContainer.hasClass("info")) {
+ msgContainer.setAttribute("id", "buildid-range");
+ msgContainer.appendChild(usrInfoMsg);
+ inputContainer.append(msgContainer).addClass("info");
+ }
+ } else {
+ clearMessages(inputContainer);
+ }
+ }
+ });
+
$("#add_product").submit(function() {
var params = $(this).serialize();
@@ -12,7 +12,7 @@
isLoaderSet = document.querySelectorAll("." + loaderClass).length;
if(!isLoaderSet) {
- //set the id, alt and src attributes of the loading image
+ //set the class, alt and src attributes of the loading image
loader.setAttribute("class", loaderClass);
loader.setAttribute("alt", "graph loading...");
loader.setAttribute("src", "/img/icons/ajax-loader.gif");
@@ -36,12 +36,24 @@
now: function() {
return new Date();
},
- //this will be more generic, for now, it expects a date string of the format mm/dd/yyyy
- // it converts this into the formate new Date expects, and returns a unformatted JavaScript
- // date object
- convertToDateObj: function(dateString) {
- var dateStringSplit = dateString.split("/");
- return new Date(dateStringSplit[2], dateStringSplit[1] - 1, dateStringSplit[0]);
+ // This function takes a date string and converts it to an unformatted
+ // JavaScript Date object. Currently one of two possible date string
+ // formats are supported. If nothing is passed to the 'format' parameter
+ // the default of dd/mm/yy will be assumed. The second supported format
+ // is the ISO8601 standard which if of the format yyyymmdd
+ // @param dateString The string to convert to a Date object
+ // @param form The date format of the string
+ convertToDateObj: function(dateString, format) {
+ if(format === "ISO8601") {
+ var origin = dateString,
+ year = origin.substring(0, 4),
+ month = origin.substring(4, 6),
+ day = origin.substring(6, 8);
+ return new Date(year, month - 1, day);
+ } else {
+ var dateStringSplit = dateString.split("/");
+ return new Date(dateStringSplit[2], dateStringSplit[1] - 1, dateStringSplit[0]);
+ }
},
addLeadingZero: function(number) {
return number > 9 ? number : "0" + number;

0 comments on commit 7119143

Please sign in to comment.