Re-implement task creation and update

pull/6827/head
Mark Maglana 14 years ago
parent 0e249a3c89
commit fb6433e771
  1. 2
      app/views/backlogs/show.html.erb
  2. 2
      app/views/tasks/_impediment.html.erb
  3. 2
      app/views/tasks/_task.html.erb
  4. 2
      assets/javascripts/impediment.js
  5. 1
      assets/javascripts/story.js
  6. 43
      assets/javascripts/task.js
  7. 23
      assets/stylesheets/taskboard.css

@ -71,7 +71,7 @@
<%= render :partial => "tasks/impediment", :object => Task.new %>
</div>
<!-- end of templates -->
<div id="item_editor"> </div>
<div class="meta" id="last_updated"><%= date_string_with_milliseconds( (@last_updated.nil? ? Time.now : @last_updated.updated_on) ) %></div>
<div id="charts"> </div>
<div id="preloader">

@ -1,11 +1,11 @@
<div class="item impediment <%= mark_if_closed(impediment) %>" id="impediment_<%= impediment.id %>" <%= build_inline_style(impediment) %>>
<div class="id"><%= issue_link_or_empty(impediment) %></div>
<div class="subject editable" fieldtype="textarea" fieldname="subject"><%= impediment.subject %></div>
<div class="remaining_hours editable" fieldname="remaining_hours"><%= remaining_hours(impediment) %></div>
<div class="assigned_to_id editable" fieldtype="select" fieldname="assigned_to_id">
<div class="t"><%= assignee_name_or_empty(impediment) %></div>
<div class="v"><%= assignee_id_or_empty(impediment) %></div>
</div>
<div class="remaining_hours editable" fieldname="remaining_hours"><%= remaining_hours(impediment) %></div>
<div class="indicator"> </div>
<%- if @include_meta -%>
<div class="meta">

@ -1,11 +1,11 @@
<div class="item task <%= mark_if_closed(task) %>" id="task_<%= task.id %>" <%= build_inline_style(task) %>>
<div class="id"><%= issue_link_or_empty(task) %></div>
<div class="subject editable" fieldtype="textarea" fieldname="subject"><%= task.subject %></div>
<div class="remaining_hours editable" fieldname="remaining_hours"><%= remaining_hours(task) %></div>
<div class="assigned_to_id editable" fieldtype="select" fieldname="assigned_to_id">
<div class="t"><%= assignee_name_or_empty(task) %></div>
<div class="v"><%= assignee_id_or_empty(task) %></div>
</div>
<div class="remaining_hours editable" fieldname="remaining_hours"><%= remaining_hours(task) %></div>
<div class="indicator"> </div>
<%- if @include_meta -%>
<div class="meta">

@ -14,6 +14,8 @@ RB.Impediment = RB.Object.create(RB.Task, {
// Associate this object with the element for later retrieval
j.data('this', this);
j.bind('mouseup', this.handleClick);
},
// Override saveDirectives of RB.Task

@ -36,6 +36,7 @@ RB.Story = RB.Object.create(RB.Model, {
if(this.isNew()){
this.$.hide('blind');
}
console.log("cancelEdit")
},
checkSubjectLength: function(){

@ -28,7 +28,41 @@ RB.Task = RB.Object.create(RB.Story, {
},
edit: function(){
throw "Edit is not yet implemented";
var editor = $("#item_editor").html("");
var self = this;
this.$.find('.editable').each(function(index){
var field = $(this);
var fieldType = field.attr('fieldtype')!=null ? field.attr('fieldtype') : 'input';
var fieldName = field.attr('fieldname');
var input;
$(document.createElement("label")).text(fieldName.replace(/_/ig, " ").replace(/ id$/ig,"")).appendTo(editor);
input = fieldType=='select' ? $('#' + fieldName + '_options').clone(true) : $(document.createElement(fieldType));
input.removeAttr('id');
input.attr('name', fieldName);
input.addClass(fieldName);
input.addClass('editor');
input.removeClass('template');
input.appendTo(editor);
// input.bind('keyup', j.data('this').handleKeyup);
// Copy the value in the field to the input element
value = ( fieldType=='select' ? field.children('.v').first().text() : field.text() );
input.val(value);
});
editor.dialog({
modal: true,
title: "Edit " + (this.isNew() ? "New " + (this.$.hasClass('task') ? "Task" : "Impediment") : "#" + this.getID()),
buttons: {
"Cancel" : function(){ self.cancelEdit(); $(this).dialog("close") },
"OK" : function(){ self.saveFromDialog(); $(this).dialog("close") }
},
close: function(event, ui){ if(event.which==27) self.cancelEdit() }
});
editor.find(".editor").first().focus();
},
handleClick: function(event){
@ -105,6 +139,13 @@ RB.Task = RB.Object.create(RB.Story, {
if(!this.$.hasClass('editing')) this.saveEdits();
},
saveFromDialog: function(){
var editors = this.$.find(".editors").length==0 ? $(document.createElement("div")).addClass("editors").appendTo(this.$) : this.$.find(".editors").first();
editors.html("");
editors.append($("#item_editor").children(".editor"));
this.saveEdits();
},
// Override RB.Story.storyUpdated()
storyUpdated: function(xhr, textStatus){

@ -235,6 +235,29 @@ See RB.Taskboard.initialize()
border-color:#CC0000;
display:block;
}
.item .editors{
display:none;
}
/* item editor */
#item_editor label{
display:block;
font-size:11px;
text-transform:capitalize;
width:100%;
}
#item_editor .editor{
font-size:11px;
margin-bottom:10px;
width:100%;
}
#item_editor .subject{
height:65px;
width:272px;
}
#item_editor .remaining_hours{
width:268px;
}
/* compact view */
.compact .story,

Loading…
Cancel
Save