diff --git a/resources/celerity/map.php b/resources/celerity/map.php --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -13,7 +13,7 @@ 'core.pkg.js' => 'ab3502fe', 'dark-console.pkg.js' => '187792c2', 'differential.pkg.css' => 'ffb69e3d', - 'differential.pkg.js' => '5e0c7197', + 'differential.pkg.js' => '29ad8828', 'diffusion.pkg.css' => '42c75c37', 'diffusion.pkg.js' => '78c9885d', 'maniphest.pkg.css' => '35995d6d', @@ -385,8 +385,8 @@ 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8', 'rsrc/js/application/diff/DiffChangeset.js' => 'd7d3ba75', 'rsrc/js/application/diff/DiffChangesetList.js' => 'cc2c5de5', - 'rsrc/js/application/diff/DiffInline.js' => '09e0c6e5', - 'rsrc/js/application/diff/DiffInlineContentState.js' => 'cb9e5396', + 'rsrc/js/application/diff/DiffInline.js' => 'a5f196da', + 'rsrc/js/application/diff/DiffInlineContentState.js' => 'a06e8af4', 'rsrc/js/application/diff/DiffPathView.js' => '8207abf9', 'rsrc/js/application/diff/DiffTreeView.js' => '5d83623b', 'rsrc/js/application/differential/behavior-diff-radios.js' => '925fe8cd', @@ -788,8 +788,8 @@ 'phabricator-dashboard-css' => '5a205b9d', 'phabricator-diff-changeset' => 'd7d3ba75', 'phabricator-diff-changeset-list' => 'cc2c5de5', - 'phabricator-diff-inline' => '09e0c6e5', - 'phabricator-diff-inline-content-state' => 'cb9e5396', + 'phabricator-diff-inline' => 'a5f196da', + 'phabricator-diff-inline-content-state' => 'a06e8af4', 'phabricator-diff-path-view' => '8207abf9', 'phabricator-diff-tree-view' => '5d83623b', 'phabricator-drag-and-drop-file-upload' => '4370900d', @@ -1000,10 +1000,6 @@ 'herald-rule-editor', 'javelin-behavior', ), - '09e0c6e5' => array( - 'javelin-dom', - 'phabricator-diff-inline-content-state', - ), '0ad8d31f' => array( 'javelin-behavior', 'javelin-stratcom', @@ -1836,6 +1832,9 @@ 'javelin-util', 'phabricator-keyboard-shortcut', ), + 'a06e8af4' => array( + 'javelin-dom', + ), 'a17b84f1' => array( 'javelin-behavior', 'javelin-dom', @@ -1872,6 +1871,10 @@ 'javelin-install', 'javelin-dom', ), + 'a5f196da' => array( + 'javelin-dom', + 'phabricator-diff-inline-content-state', + ), 'a77e2cbd' => array( 'javelin-behavior', 'javelin-stratcom', @@ -2089,9 +2092,6 @@ 'javelin-workflow', 'javelin-json', ), - 'cb9e5396' => array( - 'javelin-dom', - ), 'cc2c5de5' => array( 'javelin-install', 'phuix-button-view', diff --git a/webroot/rsrc/js/application/diff/DiffInline.js b/webroot/rsrc/js/application/diff/DiffInline.js --- a/webroot/rsrc/js/application/diff/DiffInline.js +++ b/webroot/rsrc/js/application/diff/DiffInline.js @@ -416,25 +416,12 @@ .send(); }, - _getContentState: function() { - var state; - - if (this._editRow) { - state = this._readFormState(this._editRow); - } else { - state = this._originalState; - } - - return state; - }, - reply: function(with_quote) { this._closeMenu(); var content_state = this._newContentState(); if (with_quote) { - var text = this._getContentState().text; - text = '> ' + text.replace(/\n/g, '\n> ') + '\n\n'; + var text = this._getActiveContentState().getTextForQuote(); content_state.text = text; } @@ -607,6 +594,9 @@ _readInlineState: function(state) { this._id = state.id; this._originalState = state.contentState; + + this._getActiveContentState().readWireFormat(state.contentState); + this._canSuggestEdit = state.canSuggestEdit; }, @@ -790,7 +780,13 @@ }, _getActiveContentState: function() { - return this._activeContentState; + var state = this._activeContentState; + + if (this._editRow) { + state.readForm(this._editRow); + } + + return state; }, setHasSuggestion: function(has_suggestion) { @@ -819,12 +815,13 @@ }, save: function() { + var state = this._getActiveContentState(); var handler = JX.bind(this, this._onsubmitresponse); this.setLoading(true); var uri = this._getInlineURI(); - var data = this._newRequestData('save', this._getContentState()); + var data = this._newRequestData('save', state.getWireFormat()); new JX.Request(uri, handler) .setData(data) diff --git a/webroot/rsrc/js/application/diff/DiffInlineContentState.js b/webroot/rsrc/js/application/diff/DiffInlineContentState.js --- a/webroot/rsrc/js/application/diff/DiffInlineContentState.js +++ b/webroot/rsrc/js/application/diff/DiffInlineContentState.js @@ -17,6 +17,55 @@ }, members: { + readForm: function(row) { + var node; + + try { + node = JX.DOM.find(row, 'textarea', 'inline-content-text'); + this.setText(node.value); + } catch (ex) { + this.setText(null) + } + + node = this._getSuggestionNode(row); + if (node) { + this.setSuggestionText(node.value); + } else { + this.setSuggestionText(null); + } + + return this; + }, + + getWireFormat: function() { + return { + text: this.getText(), + suggestionText: this.getSuggestionText(), + hasSuggestion: this.getHasSuggestion() + }; + }, + + readWireFormat: function(map) { + this.setText(map.text || null); + this.setSuggestionText(map.suggestionText || null); + this.setHasSuggestion(!!map.hasSuggestion); + + return this; + }, + + getTextForQuote: function() { + var text = this.getText(); + text = '> ' + text.replace(/\n/g, '\n> ') + '\n\n'; + return text; + }, + + _getSuggestionNode: function(row) { + try { + return JX.DOM.find(row, 'textarea', 'inline-content-suggestion'); + } catch (ex) { + return null; + } + } } });