Implement sprint date validation in the client

pull/6827/head
Mark Maglana 14 years ago
parent 85566079fc
commit a01315e30d
  1. 6
      app/controllers/backlogs_controller.rb
  2. 5
      app/models/sprint.rb
  3. 7
      app/views/shared/_validation_errors.html.erb
  4. 13
      assets/javascripts/backlog.js
  5. 6
      assets/javascripts/common.js
  6. 6
      assets/stylesheets/index.css
  7. 4
      config/locales/en.yml

@ -173,7 +173,11 @@ class BacklogsController < ApplicationController
attribs = params.select{|k,v| k != 'id' and Sprint.column_names.include? k }
attribs = Hash[*attribs.flatten]
result = sprint.update_attributes attribs
render :text => result, :status => (result ? 200 : 400)
if result
render :text => 'successfully updated sprint', :status => 200
else
render :partial => 'shared/validation_errors', :object => sprint.errors, :status => 400
end
end
def wiki_page

@ -170,8 +170,9 @@ end
class Sprint < Version
unloadable
validate :correctness
def correctness
validate :start_and_end_dates
def start_and_end_dates
errors.add_to_base("Sprint cannot end before it starts") if self.effective_date && self.sprint_start_date && self.sprint_start_date >= self.effective_date
end

@ -0,0 +1,7 @@
<%= validation_errors.length > 1 ? l(:error_intro_plural) : l(:error_intro_singular) %>
<ul>
<%- validation_errors.each_full do |msg| %>
<li><%= msg %></li>
<%- end %>
</ul>
<%= l(:error_outro ) %>

@ -184,6 +184,10 @@ RB.Backlog = RB.Object.create(RB.Model, {
});
},
markError: function(){
this.$.addClass('error');
},
markSaving: function(){
this.$.addClass('saving');
},
@ -235,8 +239,9 @@ RB.Backlog = RB.Object.create(RB.Model, {
type: "POST",
url: RB.urlFor['update_backlog'],
data: editors.serialize() + "&id=" + j.find('.id').text(),
beforeSend: function(xhr){ me.markSaving() },
complete: function(xhr, textStatus){ me.unmarkSaving(); /* RB.dialog.msg(xhr.responseText) */ }
beforeSend: function(xhr){ me.unmarkError(); me.markSaving() },
success: function(d,t,x){ me.unmarkSaving(); me.unmarkError() },
error: function(x,t,e){ RB.Dialog.msg(x.responseText); me.markError() }
});
me.endEdit();
},
@ -254,6 +259,10 @@ RB.Backlog = RB.Object.create(RB.Model, {
});
},
unmarkError: function(){
this.$.removeClass('error');
},
unmarkSaving: function(){
this.$.removeClass('saving');
}

@ -35,9 +35,9 @@ RB.Model = RB.Object.create({});
RB.Dialog = RB.Object.create({
msg: function(msg){
dialog = $('#msgBox').size()==0 ? $(document.createElement('div')).attr('id', 'msgBox').appendTo('#content') : $('#msgBox');
dialog.text(msg);
dialog.dialog({ title: 'Backlog Plugin',
buttons: { "Ok": function() { $(this).dialog("close"); } },
dialog.html(msg);
dialog.dialog({ title: 'Backlogs Plugin',
buttons: { "OK": function() { $(this).dialog("close"); } },
modal: true
});
},

@ -27,9 +27,13 @@
top:8px;
width:16px;
}
.backlog.saving .header .pureCssMenu{
.backlog.saving .header .pureCssMenu,
.backlog.error .header .pureCssMenu{
display:none;
}
.backlog.error .header .spinner{
background-image:url('../images/warning.png');
}
.backlog .header .name{
font-size:14px;
font-weight:bold;

@ -73,3 +73,7 @@ en:
todo_issue_description: "{{summary}}: {{url}}\n{{description}}"
label_chart_options: "Chart Options"
error_intro_singular: "The following error was encountered:"
error_intro_plural: "The following errors were encountered:"
error_outro: "Please correct the above errors before submitting again."
Loading…
Cancel
Save