From 90431fd101b4bf2fbb6a81914799e9f5ffd7fe83 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Wed, 30 Jul 2014 13:09:09 -0700 Subject: [PATCH] Workboards - fix adding new tasks and sorting Summary: At least on my install, sorting was pretty borked from a type issue. (e.g. "unbreak now" of 100 sorting as less than "High" of 90). Fix this with some parseInt action. Also support adding new cards with the new colsort stuff. The clever bit here is to include the task ID in the sorting vector because the task ID wins ties at the moment I think / new tasks need to show up before older tasks when they are initially created. Fixes T5716. Test Plan: added many "normal" priority cards and saw them fly in correctly. changed priority and moved correctly. made no edits and no moves were made correctly. Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T5716 Differential Revision: https://secure.phabricator.com/D10081 --- .../maniphest/storage/ManiphestTask.php | 1 + .../projects/behavior-project-boards.js | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php index 0a313a5b16..d3f30b03c0 100644 --- a/src/applications/maniphest/storage/ManiphestTask.php +++ b/src/applications/maniphest/storage/ManiphestTask.php @@ -159,6 +159,7 @@ final class ManiphestTask extends ManiphestDAO return array( $this->getPriority(), -$this->getSubpriority(), + $this->getID(), ); } diff --git a/webroot/rsrc/js/application/projects/behavior-project-boards.js b/webroot/rsrc/js/application/projects/behavior-project-boards.js index 90320c60f4..c050562878 100644 --- a/webroot/rsrc/js/application/projects/behavior-project-boards.js +++ b/webroot/rsrc/js/application/projects/behavior-project-boards.js @@ -29,10 +29,11 @@ JX.behavior('project-boards', function(config) { var vd = JX.Stratcom.getData(v).sort || []; for (var ii = 0; ii < ud.length; ii++) { - if (ud[ii] < vd[ii]) { + + if (parseInt(ud[ii]) < parseInt(vd[ii])) { return 1; } - if (ud[ii] > vd[ii]) { + if (parseInt(ud[ii]) > parseInt(vd[ii])) { return -1; } } @@ -108,10 +109,11 @@ JX.behavior('project-boards', function(config) { lists[ii].setGroup(lists); } - var onedit = function(card, column, r) { + var onedit = function(column, r) { var new_card = JX.$H(r.tasks).getNode(); var new_data = JX.Stratcom.getData(new_card); var items = finditems(column); + var edited = false; for (var ii = 0; ii < items.length; ii++) { var item = items[ii]; @@ -122,11 +124,18 @@ JX.behavior('project-boards', function(config) { if (phid == new_data.objectPHID) { items[ii] = new_card; data = new_data; + edited = true; } data.sort = r.data.sortMap[data.objectPHID] || data.sort; } + // this is an add then...! + if (!edited) { + items[items.length + 1] = new_card; + new_data.sort = r.data.sortMap[new_data.objectPHID] || new_data.sort; + } + items.sort(colsort); JX.DOM.setContent(column, items); @@ -137,13 +146,12 @@ JX.behavior('project-boards', function(config) { ['edit-project-card'], function(e) { e.kill(); - var card = e.getNode('project-card'); var column = e.getNode('project-column'); var request_data = { 'responseType' : 'card', 'columnPHID' : JX.Stratcom.getData(column).columnPHID }; new JX.Workflow(e.getNode('tag:a').href, request_data) - .setHandler(JX.bind(null, onedit, card, column)) + .setHandler(JX.bind(null, onedit, column)) .start(); }); @@ -167,7 +175,7 @@ JX.behavior('project-boards', function(config) { } } new JX.Workflow(config.createURI, request_data) - .setHandler(JX.bind(null, onedit, null, column)) + .setHandler(JX.bind(null, onedit, column)) .start(); }); });