From 969a6a2b38b68618bda26a7f16a94d99addf2538 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 25 May 2015 05:34:23 -0700 Subject: [PATCH] Fix custom field selector control in cases where the user doesn't edit anything Summary: The JS and PHP representations of state can differ; just have the JS write the state out immediately on page load. Test Plan: Saved `diffusion.fields` without making changes, reloaded, saw no effective change. Reviewers: joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D12998 --- resources/celerity/map.php | 18 +++++++++--------- .../PhabricatorCustomFieldConfigOptionType.php | 5 +---- .../config/behavior-reorder-fields.js | 1 + 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index f0f21380d4..e093be5ae8 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -333,7 +333,7 @@ return array( 'rsrc/js/application/auth/behavior-persona-login.js' => '9414ff18', 'rsrc/js/application/calendar/behavior-day-view.js' => '5c46cff2', 'rsrc/js/application/calendar/behavior-event-all-day.js' => '38dcf3c8', - 'rsrc/js/application/config/behavior-reorder-fields.js' => '14a827de', + 'rsrc/js/application/config/behavior-reorder-fields.js' => 'b6993408', 'rsrc/js/application/conpherence/ConpherenceThreadManager.js' => '10246726', 'rsrc/js/application/conpherence/behavior-drag-and-drop-photo.js' => 'cf86d16a', 'rsrc/js/application/conpherence/behavior-durable-column.js' => '16c695bf', @@ -543,7 +543,7 @@ return array( 'javelin-behavior-audio-source' => '59b251eb', 'javelin-behavior-audit-preview' => 'd835b03a', 'javelin-behavior-choose-control' => '6153c708', - 'javelin-behavior-config-reorder-fields' => '14a827de', + 'javelin-behavior-config-reorder-fields' => 'b6993408', 'javelin-behavior-conpherence-drag-and-drop-photo' => 'cf86d16a', 'javelin-behavior-conpherence-menu' => 'c0348cac', 'javelin-behavior-conpherence-pontificate' => '21ba5861', @@ -907,13 +907,6 @@ return array( 'javelin-dom', 'javelin-history', ), - '14a827de' => array( - 'javelin-behavior', - 'javelin-stratcom', - 'javelin-dom', - 'javelin-json', - 'phabricator-draggable-list', - ), '14ac66f5' => array( 'javelin-install', 'javelin-dom', @@ -1728,6 +1721,13 @@ return array( 'javelin-dom', 'javelin-util', ), + 'b6993408' => array( + 'javelin-behavior', + 'javelin-stratcom', + 'javelin-dom', + 'javelin-json', + 'phabricator-draggable-list', + ), 'ba4fa35c' => array( 'javelin-behavior', 'javelin-dom', diff --git a/src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php b/src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php index 6ff9eae1d0..e062d086d0 100644 --- a/src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php +++ b/src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php @@ -12,9 +12,6 @@ final class PhabricatorCustomFieldConfigOptionType $storage_value = $request->getStr('value'); $in_value = phutil_json_decode($storage_value); - if (!is_array($in_value)) { - $in_value = array(); - } // When we submit from JS, we submit a list (since maps are not guaranteed // to retain order). Convert it into a map for storage (since it's far more @@ -113,7 +110,7 @@ final class PhabricatorCustomFieldConfigOptionType 'id' => $input_id, 'type' => 'hidden', 'name' => 'value', - 'value' => json_encode($display_value), + 'value' => '', )); Javelin::initBehavior( diff --git a/webroot/rsrc/js/application/config/behavior-reorder-fields.js b/webroot/rsrc/js/application/config/behavior-reorder-fields.js index 948b248afe..1c041e85f8 100644 --- a/webroot/rsrc/js/application/config/behavior-reorder-fields.js +++ b/webroot/rsrc/js/application/config/behavior-reorder-fields.js @@ -54,4 +54,5 @@ JX.behavior('config-reorder-fields', function(config) { JX.$(config.inputID).value = JX.JSON.stringify(order); }; + write_state_to_form(); });