Permalink
Browse files

Revert "WorkItem: 3598 Working implementation"

This reverts commit a129310.
  • Loading branch information...
betelgeuse committed Feb 20, 2012
1 parent 1a2073b commit 710c455e4fdcc99a70548ae035c73de6c2a5faa6
Showing with 54 additions and 154 deletions.
  1. +30 −68 web/static/js/dynamics/controller/StoryInfoBubble.js
  2. +24 −86 web/static/js/dynamics/view/MultiEditWidget.js
@@ -44,70 +44,35 @@ StoryInfoBubble.prototype.checkForMoveStory = function(model) {
}
};
-StoryInfoBubble.prototype.confirmTasksAndChildrenToDone = function(model, storyTree, isTopStory) {
- var tasks = model.getTasks();
- var children = model.getChildren();
- var nonDoneChildren = false;
- var nonDoneTasks = false;
- if (children.length > 0) {
- for (var i = 0; i < children.length; i++) {
- if (children[i].getState() !== "DONE") {
- nonDoneChildren = true;
- }
- }
- }
- if (tasks.length > 0) {
- for (var i = 0; i < tasks.length; i++) {
- if (tasks[i].getState() !== "DONE") {
- nonDoneTasks = true;
- }
- }
- }
- if (nonDoneChildren || nonDoneTasks) {
- if (isTopStory) {
- var msg = new DynamicsConfirmationDialog(
- "Set all tasks' and stories' states to done?",
- "The '" + model.getName() + "' story has undone child tasks/stories! Do you want to set them Done as well?",
- function() {
- for (var i = 0; i < children.length; i++) {
- if (children[i].getState() !== "DONE") {
- children[i].setState("DONE");
- children[i].commit();
- storyTree._getStoryForId(children[i].getId(), function(object) {
- StoryInfoBubble.prototype.confirmTasksAndChildrenToDone(object, storyTree, false);
- });
- storyTree.refresh();
- }
- }
- if (nonDoneTasks)
- model.currentData.tasksToDone = true;
- model.commit();
- storyTree.refresh();
- },
- function() {
- model.commit();
- }
- );
- } else {
- for (var i = 0; i < children.length; i++) {
- if (children[i].getState() !== "DONE") {
- children[i].setState("DONE");
- children[i].commit();
- storyTree._getStoryForId(children[i].getId(), function(object) {
- StoryInfoBubble.prototype.confirmTasksAndChildrenToDone(object, storyTree, false);
- });
- storyTree.refresh();
- }
- }
- if (nonDoneTasks)
- model.currentData.tasksToDone = true;
- model.commit();
- storyTree.refresh();
- }
- } else {
- model.commit();
- storyTree.refresh();
- }
+StoryInfoBubble.prototype.confirmTasksToDone = function(model) {
+ var changedData = model.getChangedData();
+ var tasks = model.getTasks();
+ if (changedData.state && changedData.state === "DONE" && tasks.length > 0) {
+ var nonDoneTasks = false;
+ for (var i = 0; i < tasks.length; i++) {
+ if (tasks[i].getState() !== "DONE") {
+ nonDoneTasks = true;
+ }
+ }
+ if (nonDoneTasks) {
+ var msg = new DynamicsConfirmationDialog(
+ "Set all tasks' states to done?",
+ "Do you want to mark all tasks as done as well?",
+ function() {
+ model.currentData.tasksToDone = true;
+ model.commit();
+ },
+ function() {
+ model.commit();
+ }
+ );
+ } else {
+ model.commit();
+ }
+ }
+ else {
+ model.commit();
+ }
};
StoryInfoBubble.prototype.handleModelEvents = function(event) {
@@ -209,15 +174,12 @@ StoryInfoBubble.prototype.addLinks = function() {
* Create the configuration for the dynamic table.
*/
StoryInfoBubble.prototype._createConfig = function() {
- var toDoneFunction = function (model) {
- StoryInfoBubble.prototype.confirmTasksAndChildrenToDone (model, this.treeController, true);
- }
var config = new DynamicTableConfiguration( {
leftWidth: '25%',
rightWidth: '74%',
closeRowCallback: null,
beforeCommitFunction: StoryInfoBubble.prototype.checkForMoveStory,
- beforeCommitFunction: toDoneFunction,
+ beforeCommitFunction: StoryInfoBubble.prototype.confirmTasksToDone,
validators: [ ]
});
config.addColumnConfiguration(0, {
@@ -17,13 +17,11 @@ MultiEditWidget.prototype = new ViewPart();
* Initialize the content
*/
MultiEditWidget.prototype.init = function() {
- var me = this;
this.content = $('<ul/>');
$('<li>State:</li>').appendTo(this.content);
var stateElement = $('<li><select name="state" /></li>').appendTo(this.content);
this.stateSelect = stateElement.find('select');
-
var states = {'NOT_STARTED':'Not started','STARTED':'Started','PENDING':'Pending','BLOCKED':'Blocked','IMPLEMENTED':'Ready','DONE':'Done', 'DEFERRED':'Deferred' };
$.each(states, jQuery.proxy(function(k,v) {
@@ -60,16 +58,34 @@ MultiEditWidget.prototype.init = function() {
// storyIds, labelNames, ajax/editMultiple.action
var buttonLi = $('<li/>').appendTo(this.content);
$('<button class="dynamics-button">Save</button>').click(jQuery.proxy(function() {
-
+
/* Confirms setting tasks to done */
- if (this.stateSelect.val() === "DONE") {
+ if (this.stateSelect.val() == "DONE") {
for (var i=0; i<this.getSelected().length; i++) { // for each story selected
var storyID = this.getSelected()[i];
- var storyTree = this.storyTreeController;
-
- storyTree._getStoryForId(storyID, function(object) {
- MultiEditWidget.prototype.confirmTasksAndChildrenToDone(object, storyTree, true);
+ this.storyTreeController._getStoryForId(storyID, function(object) {
+ var tasks = object.getTasks(); // get the tasks
+
+ if (tasks.length > 0) { // if tasks exist
+ var nonDoneTasks = false;
+ for (var i = 0; i < tasks.length; i++) {
+ if (tasks[i].getState() != "DONE") {
+ nonDoneTasks = true;
+ }
+ }
+ if (nonDoneTasks) {
+ var msg = new DynamicsConfirmationDialog(
+ "Set all tasks' states to done?",
+ "Do you want to mark all tasks under the '" + object.getName() + "' story as done as well?",
+ function() {
+ object.currentData.tasksToDone = true;
+ object.commit();
+ }
+ );
+ }
+ }
});
+
}
}
@@ -96,84 +112,6 @@ MultiEditWidget.prototype.init = function() {
this.content.appendTo(this.element);
};
-
-MultiEditWidget.prototype.confirmTasksAndChildrenToDone = function(model, storyTree, isTopStory) {
- var tasks = model.getTasks();
- var children = model.getChildren();
- var nonDoneChildren = false;
- var nonDoneTasks = false;
- if (children.length > 0) {
- for (var i = 0; i < children.length; i++) {
- if (children[i].getState() !== "DONE") {
- nonDoneChildren = true;
- }
- }
- }
- if (tasks.length > 0) {
- for (var i = 0; i < tasks.length; i++) {
- if (tasks[i].getState() !== "DONE") {
- nonDoneTasks = true;
- }
- }
- }
- if (nonDoneChildren || nonDoneTasks) {
- if (isTopStory) {
- var msg = new DynamicsConfirmationDialog(
- "Set all tasks' and stories' states to done?",
- "The '" + model.getName() + "' story has undone child tasks/stories! Do you want to set them Done as well?",
- function() {
- if (nonDoneChildren) {
- for (var i = 0; i < children.length; i++) {
- if (children[i].getState() !== "DONE") {
- children[i].setState("DONE");
- children[i].commit();
- storyTree._getStoryForId(children[i].getId(), function(object) {
- MultiEditWidget.prototype.confirmTasksAndChildrenToDone(object, storyTree, false);
- });
- storyTree.refresh();
- }
- }
- } else {
- if (nonDoneTasks)
- model.currentData.tasksToDone = true;
- model.commit();
- storyTree.refresh();
- }
- },
- function() {
- model.commit();
- storyTree.refresh();
- }
- );
- } else {
- if (nonDoneChildren) {
- for (var i = 0; i < children.length; i++) {
- if (children[i].getState() !== "DONE") {
- children[i].setState("DONE");
- children[i].commit();
- storyTree._getStoryForId(children[i].getId(), function(object) {
- MultiEditWidget.prototype.confirmTasksAndChildrenToDone(object, storyTree, false);
- });
- storyTree.refresh();
- }
-
- }
- } else {
- if (nonDoneTasks)
- model.currentData.tasksToDone = true;
- model.commit();
- storyTree.refresh();
- }
- }
- } else {
- model.commit();
- storyTree.refresh();
- }
-};
-
-MultiEditWidget.prototype.getTree = function() {
- return this.storyTreeController;
-};
MultiEditWidget.prototype.getSelected = function() {
return this.storyTreeController.getSelectedIds();
};

0 comments on commit 710c455

Please sign in to comment.