From 5fd28d35d9607957b3a3ef66e4bb275d17ed73e4 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 3 Feb 2011 13:20:43 -0800 Subject: [PATCH] Diff-of-diffs radio button logic. --- src/__celerity_resource_map__.php | 42 +++++++---- .../DifferentialRevisionViewController.php | 3 + .../changeset/DifferentialChangesetParser.php | 5 +- .../DifferentialRevisionUpdateHistoryView.php | 75 ++++++++++++++++--- .../view/revisionupdatehistory/__init__.php | 1 + src/storage/lisk/dao/LiskDAO.php | 7 +- .../differential/behavior-diff-radios.js | 34 +++++++++ 7 files changed, 137 insertions(+), 30 deletions(-) create mode 100644 webroot/rsrc/js/application/differential/behavior-diff-radios.js diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 1da3289989..ba1232db01 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -9,7 +9,7 @@ celerity_register_resource_map(array( 'aphront-dark-console-css' => array( - 'uri' => '/res/ac3fc983/rsrc/css/aphront/dark-console.css', + 'uri' => '/res/056b0c12/rsrc/css/aphront/dark-console.css', 'type' => 'css', 'requires' => array( @@ -63,7 +63,7 @@ celerity_register_resource_map(array( ), 'aphront-table-view-css' => array( - 'uri' => '/res/de3a1e4c/rsrc/css/aphront/table-view.css', + 'uri' => '/res/6a70f0f0/rsrc/css/aphront/table-view.css', 'type' => 'css', 'requires' => array( @@ -226,7 +226,7 @@ celerity_register_resource_map(array( ), 'javelin-behavior-dark-console' => array( - 'uri' => '/res/35907b6e/rsrc/js/application/core/behavior-dark-console.js', + 'uri' => '/res/020b0265/rsrc/js/application/core/behavior-dark-console.js', 'type' => 'js', 'requires' => array( @@ -253,6 +253,16 @@ celerity_register_resource_map(array( ), 'disk' => '/rsrc/js/application/differential/behavior-comment-preview.js', ), + 'javelin-behavior-differential-diff-radios' => + array( + 'uri' => '/res/ea6b0062/rsrc/js/application/differential/behavior-diff-radios.js', + 'type' => 'js', + 'requires' => + array( + 0 => 'javelin-lib-dev', + ), + 'disk' => '/rsrc/js/application/differential/behavior-diff-radios.js', + ), 'javelin-behavior-differential-edit-inline-comments' => array( 'uri' => '/res/74747b2e/rsrc/js/application/differential/behavior-edit-inline-comments.js', @@ -358,7 +368,7 @@ celerity_register_resource_map(array( ), array ( 'packages' => array ( - 'c5efa388' => + '1a33af6b' => array ( 'name' => 'core.pkg.css', 'symbols' => @@ -375,7 +385,7 @@ celerity_register_resource_map(array( 9 => 'aphront-typeahead-control-css', 10 => 'phabricator-directory-css', ), - 'uri' => '/res/pkg/c5efa388/core.pkg.css', + 'uri' => '/res/pkg/1a33af6b/core.pkg.css', 'type' => 'css', ), '9d9c881c' => @@ -395,17 +405,17 @@ celerity_register_resource_map(array( ), 'reverse' => array ( - 'phabricator-core-css' => 'c5efa388', - 'phabricator-core-buttons-css' => 'c5efa388', - 'phabricator-standard-page-view' => 'c5efa388', - 'aphront-dialog-view-css' => 'c5efa388', - 'aphront-form-view-css' => 'c5efa388', - 'aphront-panel-view-css' => 'c5efa388', - 'aphront-side-nav-view-css' => 'c5efa388', - 'aphront-table-view-css' => 'c5efa388', - 'aphront-tokenizer-control-css' => 'c5efa388', - 'aphront-typeahead-control-css' => 'c5efa388', - 'phabricator-directory-css' => 'c5efa388', + 'phabricator-core-css' => '1a33af6b', + 'phabricator-core-buttons-css' => '1a33af6b', + 'phabricator-standard-page-view' => '1a33af6b', + 'aphront-dialog-view-css' => '1a33af6b', + 'aphront-form-view-css' => '1a33af6b', + 'aphront-panel-view-css' => '1a33af6b', + 'aphront-side-nav-view-css' => '1a33af6b', + 'aphront-table-view-css' => '1a33af6b', + 'aphront-tokenizer-control-css' => '1a33af6b', + 'aphront-typeahead-control-css' => '1a33af6b', + 'phabricator-directory-css' => '1a33af6b', 'differential-core-view-css' => '9d9c881c', 'differential-changeset-view-css' => '9d9c881c', 'differential-revision-detail-css' => '9d9c881c', diff --git a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php index cc73c7a364..56ab73edb1 100644 --- a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php @@ -37,6 +37,7 @@ class DifferentialRevisionViewController extends DifferentialController { $diffs = $revision->loadDiffs(); + $diff_vs = null; $target = end($diffs); $changesets = $target->loadChangesets(); @@ -78,6 +79,8 @@ class DifferentialRevisionViewController extends DifferentialController { $diff_history = new DifferentialRevisionUpdateHistoryView(); $diff_history->setDiffs($diffs); + $diff_history->setSelectedVersusDiffID($diff_vs); + $diff_history->setSelectedDiffID($target->getID()); $toc_view = new DifferentialDiffTableOfContentsView(); $toc_view->setChangesets($changesets); diff --git a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php index 4612c400e3..5fa6cb54bf 100644 --- a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php @@ -637,7 +637,7 @@ class DifferentialChangesetParser { Filesystem::writeFile($old_tmp, $changeset->makeOldFile()); Filesystem::writeFile($new_tmp, $changeset->makeNewFile()); list($err, $diff) = exec_manual( - 'diff -bw -U9999 %s %s', + 'diff -bw -U65535 %s %s', $old_tmp, $new_tmp); @@ -663,7 +663,8 @@ EOSYNTHETIC; $changes = id(new ArcanistDiffParser())->parseDiff($diff); $diff = DifferentialDiff::newFromRawChanges($changes); - $alt_changeset = reset($diff->getChangesets()); + $changesets = $diff->getChangesets(); + $alt_changeset = reset($changesets); $this->subparser = new DifferentialChangesetParser(); $this->subparser->setChangeset($alt_changeset); diff --git a/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php b/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php index d03ead76b8..b54e1a4e04 100644 --- a/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php +++ b/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php @@ -19,12 +19,24 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { private $diffs = array(); + private $selectedVersusDiffID; + private $selectedDiffID; public function setDiffs($diffs) { $this->diffs = $diffs; return $this; } + public function setSelectedVersusDiffID($id) { + $this->selectedVersusDiffID = $id; + return $this; + } + + public function setSelectedDiffID($id) { + $this->selectedDiffID = $id; + return $this; + } + public function render() { require_celerity_resource('differential-core-view-css'); @@ -35,8 +47,6 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { 'name' => 'Base', 'id' => null, 'desc' => 'Base', - 'old' => false, - 'new' => false, 'age' => null, 'lint' => null, 'unit' => null, @@ -49,14 +59,14 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { 'name' => 'Diff '.(++$seq), 'id' => $diff->getID(), 'desc' => 'TODO',//$diff->getDescription(), - 'old' => false, - 'new' => false, 'age' => $diff->getDateCreated(), 'lint' => $diff->getLintStatus(), 'unit' => $diff->getUnitStatus(), ); } + $max_id = $diff->getID(); + $idx = 0; $rows = array(); foreach ($data as $row) { @@ -64,10 +74,56 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { $name = phutil_escape_html($row['name']); $id = phutil_escape_html($row['id']); + $radios = array(); $lint = '*'; $unit = '*'; - $old = ''; - $new = ''; + + $old_class = null; + $new_class = null; + + if ($max_id != $id) { + $uniq = celerity_generate_unique_node_id(); + $old_checked = ($this->selectedVersusDiffID == $id); + $old = phutil_render_tag( + 'input', + array( + 'type' => 'radio', + 'name' => 'vs', + 'value' => '0', + 'id' => $uniq, + 'checked' => $old_checked ? 'checked' : null, + )); + $radios[] = $uniq; + if ($old_checked) { + $old_class = " revhistory-old-now"; + } + } else { + $old = null; + } + + if ($id) { + $new_checked = ($this->selectedDiffID == $id); + $new = phutil_render_tag( + 'input', + array( + 'type' => 'radio', + 'name' => 'id', + 'value' => $id, + 'checked' => $new_checked ? 'checked' : null, + )); + if ($new_checked) { + $new_class = " revhistory-new-now"; + } + } else { + $new = null; + } + + Javelin::initBehavior( + 'differential-diff-radios', + array( + 'radios' => $radios, + )); + $desc = 'TODO'; $age = '-'; @@ -86,8 +142,8 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { ''.$age.''. ''.$lint.''. ''.$unit.''. - ''.$old.''. - ''.$new.''. + ''.$old.''. + ''.$new.''. ''; } @@ -110,8 +166,7 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { ''. ''. ''. - ''. + ''. ''. ''. ''. diff --git a/src/applications/differential/view/revisionupdatehistory/__init__.php b/src/applications/differential/view/revisionupdatehistory/__init__.php index 513616c042..d615e831fa 100644 --- a/src/applications/differential/view/revisionupdatehistory/__init__.php +++ b/src/applications/differential/view/revisionupdatehistory/__init__.php @@ -7,6 +7,7 @@ phutil_require_module('phabricator', 'infrastructure/celerity/api'); +phutil_require_module('phabricator', 'infrastructure/javelin/api'); phutil_require_module('phabricator', 'view/base'); phutil_require_module('phutil', 'markup'); diff --git a/src/storage/lisk/dao/LiskDAO.php b/src/storage/lisk/dao/LiskDAO.php index 7a821a6cc0..e1622838a8 100644 --- a/src/storage/lisk/dao/LiskDAO.php +++ b/src/storage/lisk/dao/LiskDAO.php @@ -576,7 +576,7 @@ abstract class LiskDAO { if ($properties === null) { $properties = $this->getProperties(); } - + $property = strtolower($property); if (empty($properties[$property])) { return null; @@ -1092,7 +1092,10 @@ abstract class LiskDAO { if (count($args) !== 0) { throw new Exception("Getter call should have zero args: {$method}"); } - return @$this->$property; + if (isset($this->$property)) { + return $this->$property; + } + return null; } if (!strncmp($method, 'set', 3)) { diff --git a/webroot/rsrc/js/application/differential/behavior-diff-radios.js b/webroot/rsrc/js/application/differential/behavior-diff-radios.js new file mode 100644 index 0000000000..b000736591 --- /dev/null +++ b/webroot/rsrc/js/application/differential/behavior-diff-radios.js @@ -0,0 +1,34 @@ +/** + * @provides javelin-behavior-differential-diff-radios + * @requires javelin-lib-dev + */ + +JX.behavior('differential-diff-radios', function(config) { + JX.Stratcom.listen( + 'click', + 'new-radio', + function(e) { + var target = e.getTarget(); + var adjust; + var node; + var reset = false; + for (var ii = 0; ii < config.radios.length; ii++) { + node = JX.$(config.radios[ii]); + if (node.value >= target.value) { + if (node.checked) { + node.checked = false; + reset = true; + } + node.disabled = 'disabled'; + } else { + node.disabled = ''; + if (!adjust || adjust.value < node.value) { + adjust = node; + } + } + } + if (reset && adjust) { + adjust.checked = 'checked'; + } + }); +});