Have "limit=1" tokenizers replace tokens instead of disabling "Browse"
Summary: Fixes T9984. When a tokenizer only allows one selection (like "Task Owner:" or "Land Onto Branch:"), keep the browse button active but have it //replace// values. Also, have "Create Subtask" default to the system default status, so subtasks of closed tasks are not also closed. Test Plan: - Browsed an empty limit=1 tokenizer. - Replaced a full limit=1 tokenizer. - Browsed an empty no-limit tokenizer. - Browsed more tokens into the no-limit tokenizer. - Typed some tokens normally. - Created a subtask of a closed task. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9984 Differential Revision: https://secure.phabricator.com/D14785
This commit is contained in:
		| @@ -8,7 +8,7 @@ | |||||||
| return array( | return array( | ||||||
|   'names' => array( |   'names' => array( | ||||||
|     'core.pkg.css' => '6d8c526d', |     'core.pkg.css' => '6d8c526d', | ||||||
|     'core.pkg.js' => '46bc8dbd', |     'core.pkg.js' => 'c60f35d8', | ||||||
|     'darkconsole.pkg.js' => 'e7393ebb', |     'darkconsole.pkg.js' => 'e7393ebb', | ||||||
|     'differential.pkg.css' => '2de124c9', |     'differential.pkg.css' => '2de124c9', | ||||||
|     'differential.pkg.js' => '6223dd9d', |     'differential.pkg.js' => '6223dd9d', | ||||||
| @@ -244,7 +244,7 @@ return array( | |||||||
|     'rsrc/externals/javelin/lib/__tests__/URI.js' => '1e45fda9', |     'rsrc/externals/javelin/lib/__tests__/URI.js' => '1e45fda9', | ||||||
|     'rsrc/externals/javelin/lib/__tests__/behavior.js' => '1ea62783', |     'rsrc/externals/javelin/lib/__tests__/behavior.js' => '1ea62783', | ||||||
|     'rsrc/externals/javelin/lib/behavior.js' => '61cbc29a', |     'rsrc/externals/javelin/lib/behavior.js' => '61cbc29a', | ||||||
|     'rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js' => '9fef18a5', |     'rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js' => 'c431f925', | ||||||
|     'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => '70baed2f', |     'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => '70baed2f', | ||||||
|     'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => 'e6e25838', |     'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => 'e6e25838', | ||||||
|     'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => '503e17fd', |     'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => '503e17fd', | ||||||
| @@ -704,7 +704,7 @@ return array( | |||||||
|     'javelin-scrollbar' => '087e919c', |     'javelin-scrollbar' => '087e919c', | ||||||
|     'javelin-sound' => '949c0fe5', |     'javelin-sound' => '949c0fe5', | ||||||
|     'javelin-stratcom' => '6c53634d', |     'javelin-stratcom' => '6c53634d', | ||||||
|     'javelin-tokenizer' => '9fef18a5', |     'javelin-tokenizer' => 'c431f925', | ||||||
|     'javelin-typeahead' => '70baed2f', |     'javelin-typeahead' => '70baed2f', | ||||||
|     'javelin-typeahead-composite-source' => '503e17fd', |     'javelin-typeahead-composite-source' => '503e17fd', | ||||||
|     'javelin-typeahead-normalizer' => 'e6e25838', |     'javelin-typeahead-normalizer' => 'e6e25838', | ||||||
| @@ -1581,12 +1581,6 @@ return array( | |||||||
|       'javelin-dom', |       'javelin-dom', | ||||||
|       'javelin-vector', |       'javelin-vector', | ||||||
|     ), |     ), | ||||||
|     '9fef18a5' => array( |  | ||||||
|       'javelin-dom', |  | ||||||
|       'javelin-util', |  | ||||||
|       'javelin-stratcom', |  | ||||||
|       'javelin-install', |  | ||||||
|     ), |  | ||||||
|     'a0b57eb8' => array( |     'a0b57eb8' => array( | ||||||
|       'javelin-behavior', |       'javelin-behavior', | ||||||
|       'javelin-dom', |       'javelin-dom', | ||||||
| @@ -1783,6 +1777,12 @@ return array( | |||||||
|       'javelin-dom', |       'javelin-dom', | ||||||
|       'javelin-vector', |       'javelin-vector', | ||||||
|     ), |     ), | ||||||
|  |     'c431f925' => array( | ||||||
|  |       'javelin-dom', | ||||||
|  |       'javelin-util', | ||||||
|  |       'javelin-stratcom', | ||||||
|  |       'javelin-install', | ||||||
|  |     ), | ||||||
|     'c72aa091' => array( |     'c72aa091' => array( | ||||||
|       'javelin-behavior', |       'javelin-behavior', | ||||||
|       'javelin-dom', |       'javelin-dom', | ||||||
|   | |||||||
| @@ -163,7 +163,10 @@ final class ManiphestTaskDetailController extends ManiphestController { | |||||||
|     $can_create = (bool)$edit_config; |     $can_create = (bool)$edit_config; | ||||||
|     if ($can_create) { |     if ($can_create) { | ||||||
|       $form_key = $edit_config->getIdentifier(); |       $form_key = $edit_config->getIdentifier(); | ||||||
|       $edit_uri = "/task/edit/form/{$form_key}/?parent={$id}&template={$id}"; |       $edit_uri = id(new PhutilURI("/task/edit/form/{$form_key}/")) | ||||||
|  |         ->setQueryParam('parent', $id) | ||||||
|  |         ->setQueryParam('template', $id) | ||||||
|  |         ->setQueryParam('status', ManiphestTaskStatus::getDefaultStatus()); | ||||||
|       $edit_uri = $this->getApplicationURI($edit_uri); |       $edit_uri = $this->getApplicationURI($edit_uri); | ||||||
|     } else { |     } else { | ||||||
|       // TODO: This will usually give us a somewhat-reasonable error page, but |       // TODO: This will usually give us a somewhat-reasonable error page, but | ||||||
|   | |||||||
| @@ -428,16 +428,23 @@ JX.install('Tokenizer', { | |||||||
|  |  | ||||||
|       if (this.getBrowseURI()) { |       if (this.getBrowseURI()) { | ||||||
|         var button = JX.DOM.find(this._frame, 'a', 'tokenizer-browse'); |         var button = JX.DOM.find(this._frame, 'a', 'tokenizer-browse'); | ||||||
|         JX.DOM.alterClass(button, 'disabled', !!this._isAtTokenLimit()); |         JX.DOM.alterClass(button, 'disabled', !!this._shouldLockBrowse()); | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       this.invoke('change', this); |       this.invoke('change', this); | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     _isAtTokenLimit: function() { |     _shouldLockBrowse: function() { | ||||||
|       var limit = this.getLimit(); |       var limit = this.getLimit(); | ||||||
|  |  | ||||||
|       if (!limit) { |       if (!limit) { | ||||||
|  |         // If there's no limit, never lock the browse button. | ||||||
|  |         return false; | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       if (limit == 1) { | ||||||
|  |         // If the limit is 1, we'll replace the current token if the | ||||||
|  |         // user selects a new one, so we never need to lock the button. | ||||||
|         return false; |         return false; | ||||||
|       } |       } | ||||||
|  |  | ||||||
| @@ -486,7 +493,7 @@ JX.install('Tokenizer', { | |||||||
|         return; |         return; | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       if (this._isAtTokenLimit()) { |       if (this._shouldLockBrowse()) { | ||||||
|         return; |         return; | ||||||
|       } |       } | ||||||
|  |  | ||||||
| @@ -498,6 +505,14 @@ JX.install('Tokenizer', { | |||||||
|             source.addResult(r.token); |             source.addResult(r.token); | ||||||
|             var result = source.getResult(r.key); |             var result = source.getResult(r.key); | ||||||
|  |  | ||||||
|  |             // If we have a limit of 1 token, replace the current token with | ||||||
|  |             // the new token if we currently have a token. | ||||||
|  |             if (this.getLimit() == 1) { | ||||||
|  |               for (var k in this.getTokens()) { | ||||||
|  |                 this.removeToken(k); | ||||||
|  |               } | ||||||
|  |             } | ||||||
|  |  | ||||||
|             this.addToken(r.key, result.name); |             this.addToken(r.key, result.name); | ||||||
|             this.focus(); |             this.focus(); | ||||||
|           })) |           })) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 epriestley
					epriestley