Werdna has uploaded a new change for review. https://gerrit.wikimedia.org/r/140068
Change subject: [WIP] Wire edit title action in new frontend. ...................................................................... [WIP] Wire edit title action in new frontend. Currently broken, and I don't think it's my fault. Get the following error: Uncaught Error: The partial flow_topic could not be found Change-Id: I1337a181d02322ac25fb5e34bad99b66c77a673a --- M Resources.php M handlebars/Makefile M handlebars/compiled/flow_block_topic.handlebars.php M handlebars/compiled/flow_block_topic_edit_title.handlebars.php M handlebars/compiled/flow_block_topiclist.handlebars.php M handlebars/flow_block_topic_edit_title.handlebars A handlebars/flow_edit_topic_title.handlebars M handlebars/flow_topic.handlebars M modules/new/components/flow-board.js 9 files changed, 104 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/68/140068/1 diff --git a/Resources.php b/Resources.php index 07e9ee2..36e8b22 100644 --- a/Resources.php +++ b/Resources.php @@ -39,6 +39,7 @@ "flow_board_collapsers_subcomponent.handlebars", "flow_board_navigation.handlebars", "flow_edit_post.handlebars", + "flow_edit_topic_title.handlebars", "flow_errors.handlebars", "flow_moderate_post.handlebars", "flow_moderate_topic.handlebars", @@ -57,6 +58,7 @@ 'messages' => array( 'flow-cancel', 'flow-edit-header-submit', + 'flow-edit-title-submit', 'flow-load-more', 'flow-newest-topics', 'flow-newtopic-content-placeholder', diff --git a/handlebars/Makefile b/handlebars/Makefile index a3a5d39..cbf0c30 100644 --- a/handlebars/Makefile +++ b/handlebars/Makefile @@ -104,7 +104,7 @@ compiled/flow_block_topic_edit_title.handlebars.php: \ flow_block_topic_edit_title.handlebars \ - flow_edit_post.handlebars + flow_edit_topic_title.handlebars $(COMPILE) flow_block_topic_edit_title compiled/flow_block_topic_moderate_post.handlebars.php: \ diff --git a/handlebars/compiled/flow_block_topic.handlebars.php b/handlebars/compiled/flow_block_topic.handlebars.php index 3c81ae4..25e915b 100644 --- a/handlebars/compiled/flow_block_topic.handlebars.php +++ b/handlebars/compiled/flow_block_topic.handlebars.php @@ -47,7 +47,7 @@ <h2 class="flow-moderated-topic-title">'.LCRun3::ch($cx, 'l10n', Array('post_moderation_state',((is_array($in) && isset($in['moderateState'])) ? $in['moderateState'] : null),((is_array($in) && isset($in['replyToId'])) ? $in['replyToId'] : null),((is_array($in['moderator']) && isset($in['moderator']['name'])) ? $in['moderator']['name'] : null)), 'encq').'</h2> <div>@Todo - Add css to toggle between "xxx is hidden by xxx" and real title</div> ' : '').' - <h2 class="flow-topic-title">'.htmlentities(((is_array($in) && isset($in['content'])) ? $in['content'] : null), ENT_QUOTES, 'UTF-8').'</h2> + <h2 class="flow-topic-title" data-title="'.htmlentities(((is_array($in) && isset($in['content'])) ? $in['content'] : null), ENT_QUOTES, 'UTF-8').'">'.htmlentities(((is_array($in) && isset($in['content'])) ? $in['content'] : null), ENT_QUOTES, 'UTF-8').'</h2> <span class="flow-author">'.LCRun3::ch($cx, 'l10n', Array('started_with_participants',$in), 'encq').'</span> <div class="flow-topic-meta"> <a class="flow-ui-button flow-ui-progressive flow-ui-quiet flow-ui-inline" href="#flow-post-'.htmlentities(((is_array($in) && isset($in['postId'])) ? $in['postId'] : null), ENT_QUOTES, 'UTF-8').'-form-content">'.LCRun3::ch($cx, 'l10n', Array('Reply',((is_array($in) && isset($in['author'])) ? $in['author'] : null)), 'encq').'</a> @@ -67,7 +67,9 @@ <li> <a class="flow-ui-button flow-ui-regressive flow-ui-quiet flow-ui-thin" href="'.htmlentities(((is_array($in['actions']['edit']) && isset($in['actions']['edit']['url'])) ? $in['actions']['edit']['url'] : null), ENT_QUOTES, 'UTF-8').'" - title="'.htmlentities(((is_array($in['actions']['edit']) && isset($in['actions']['edit']['title'])) ? $in['actions']['edit']['title'] : null), ENT_QUOTES, 'UTF-8').'"> + title="'.htmlentities(((is_array($in['actions']['edit']) && isset($in['actions']['edit']['title'])) ? $in['actions']['edit']['title'] : null), ENT_QUOTES, 'UTF-8').'" + data-flow-interactive-handler="editTopicTitle" + > <span class="wikiglyph wikiglyph-pencil"></span> '.LCRun3::ch($cx, 'l10n', Array('flow-topic-action-edit-title'), 'encq').' </a> diff --git a/handlebars/compiled/flow_block_topic_edit_title.handlebars.php b/handlebars/compiled/flow_block_topic_edit_title.handlebars.php index 0fd7dd7..7a08a1f 100644 --- a/handlebars/compiled/flow_block_topic_edit_title.handlebars.php +++ b/handlebars/compiled/flow_block_topic_edit_title.handlebars.php @@ -32,9 +32,9 @@ <input type="hidden" name="wpEditToken" value="'.htmlentities(((is_array($cx['scopes'][0]) && isset($cx['scopes'][0]['editToken'])) ? $cx['scopes'][0]['editToken'] : null), ENT_QUOTES, 'UTF-8').'" /> <input type="hidden" name="topic_prev_revision" value="'.htmlentities(((is_array($in) && isset($in['revisionId'])) ? $in['revisionId'] : null), ENT_QUOTES, 'UTF-8').'" /> - <textarea name="topic_content" class="mw-ui-input flow-form-collapsible">'.((LCRun3::ifvar($cx, ((is_array($cx['scopes'][0]['submitted']) && isset($cx['scopes'][0]['submitted']['content'])) ? $cx['scopes'][0]['submitted']['content'] : null))) ? ''.htmlentities(((is_array($cx['scopes'][0]['submitted']) && isset($cx['scopes'][0]['submitted']['content'])) ? $cx['scopes'][0]['submitted']['content'] : null), ENT_QUOTES, 'UTF-8').'' : ''.htmlentities(((is_array($in) && isset($in['content'])) ? $in['content'] : null), ENT_QUOTES, 'UTF-8').'').'</textarea> + <input name="topic_content" class="mw-ui-input" value="'.((LCRun3::ifvar($cx, ((is_array($cx['scopes'][0]['submitted']) && isset($cx['scopes'][0]['submitted']['content'])) ? $cx['scopes'][0]['submitted']['content'] : null))) ? ''.htmlentities(((is_array($cx['scopes'][0]['submitted']) && isset($cx['scopes'][0]['submitted']['content'])) ? $cx['scopes'][0]['submitted']['content'] : null), ENT_QUOTES, 'UTF-8').'' : ''.htmlentities(((is_array($in) && isset($in['content'])) ? $in['content'] : null), ENT_QUOTES, 'UTF-8').'').'" /> <div class="flow-form-actions flow-form-collapsible"> - <button data-role="submit" class="flow-ui-button flow-ui-constructive">'.LCRun3::ch($cx, 'l10n', Array('flow-post-action-edit-post',((is_array($in) && isset($in['author'])) ? $in['author'] : null)), 'encq').'</button> + <button data-role="submit" data-flow-api-handler="submitTopicTitle" class="flow-ui-button flow-ui-constructive">'.LCRun3::ch($cx, 'l10n', Array('flow-edit-title-submit'), 'encq').'</button> <button data-role="action" class="flow-ui-button flow-ui-progressive flow-ui-quiet">'.LCRun3::ch($cx, 'l10n', Array('flow-preview'), 'encq').'</button> <button data-flow-interactive-handler="cancelForm" data-role="cancel" class="flow-ui-button flow-ui-destructive flow-ui-quiet">'.LCRun3::ch($cx, 'l10n', Array('flow-cancel'), 'encq').'</button> <small class="flow-terms-of-use plainlinks">'.LCRun3::ch($cx, 'l10n', Array('flow-terms-of-use-edit'), 'encq').'</small> diff --git a/handlebars/compiled/flow_block_topiclist.handlebars.php b/handlebars/compiled/flow_block_topiclist.handlebars.php index 131f257..3f0971e 100644 --- a/handlebars/compiled/flow_block_topiclist.handlebars.php +++ b/handlebars/compiled/flow_block_topiclist.handlebars.php @@ -83,7 +83,7 @@ <h2 class="flow-moderated-topic-title">'.LCRun3::ch($cx, 'l10n', Array('post_moderation_state',((is_array($in) && isset($in['moderateState'])) ? $in['moderateState'] : null),((is_array($in) && isset($in['replyToId'])) ? $in['replyToId'] : null),((is_array($in['moderator']) && isset($in['moderator']['name'])) ? $in['moderator']['name'] : null)), 'encq').'</h2> <div>@Todo - Add css to toggle between "xxx is hidden by xxx" and real title</div> ' : '').' - <h2 class="flow-topic-title">'.htmlentities(((is_array($in) && isset($in['content'])) ? $in['content'] : null), ENT_QUOTES, 'UTF-8').'</h2> + <h2 class="flow-topic-title" data-title="'.htmlentities(((is_array($in) && isset($in['content'])) ? $in['content'] : null), ENT_QUOTES, 'UTF-8').'">'.htmlentities(((is_array($in) && isset($in['content'])) ? $in['content'] : null), ENT_QUOTES, 'UTF-8').'</h2> <span class="flow-author">'.LCRun3::ch($cx, 'l10n', Array('started_with_participants',$in), 'encq').'</span> <div class="flow-topic-meta"> <a class="flow-ui-button flow-ui-progressive flow-ui-quiet flow-ui-inline" href="#flow-post-'.htmlentities(((is_array($in) && isset($in['postId'])) ? $in['postId'] : null), ENT_QUOTES, 'UTF-8').'-form-content">'.LCRun3::ch($cx, 'l10n', Array('Reply',((is_array($in) && isset($in['author'])) ? $in['author'] : null)), 'encq').'</a> @@ -103,7 +103,9 @@ <li> <a class="flow-ui-button flow-ui-regressive flow-ui-quiet flow-ui-thin" href="'.htmlentities(((is_array($in['actions']['edit']) && isset($in['actions']['edit']['url'])) ? $in['actions']['edit']['url'] : null), ENT_QUOTES, 'UTF-8').'" - title="'.htmlentities(((is_array($in['actions']['edit']) && isset($in['actions']['edit']['title'])) ? $in['actions']['edit']['title'] : null), ENT_QUOTES, 'UTF-8').'"> + title="'.htmlentities(((is_array($in['actions']['edit']) && isset($in['actions']['edit']['title'])) ? $in['actions']['edit']['title'] : null), ENT_QUOTES, 'UTF-8').'" + data-flow-interactive-handler="editTopicTitle" + > <span class="wikiglyph wikiglyph-pencil"></span> '.LCRun3::ch($cx, 'l10n', Array('flow-topic-action-edit-title'), 'encq').' </a> diff --git a/handlebars/flow_block_topic_edit_title.handlebars b/handlebars/flow_block_topic_edit_title.handlebars index a7b50b7..244faa5 100644 --- a/handlebars/flow_block_topic_edit_title.handlebars +++ b/handlebars/flow_block_topic_edit_title.handlebars @@ -11,7 +11,7 @@ {{#each roots}} {{#eachPost @root this}} - {{> flow_edit_post}} + {{> flow_edit_topic_title}} {{/eachPost}} {{/each}} </div> diff --git a/handlebars/flow_edit_topic_title.handlebars b/handlebars/flow_edit_topic_title.handlebars new file mode 100644 index 0000000..62700bb --- /dev/null +++ b/handlebars/flow_edit_topic_title.handlebars @@ -0,0 +1,18 @@ +<form method="POST" action="{{actions.edit.url}}"> + <input type="hidden" name="wpEditToken" value="{{@root.editToken}}" /> + {{!-- @todo should this be a part of the url? --}} + <input type="hidden" name="topic_prev_revision" value="{{revisionId}}" /> + <input name="topic_content" class="mw-ui-input" value=" + {{~#if @root.submitted.content~}} + {{~@root.submitted.content~}} + {{~else~}} + {{~content~}} + {{~/if~}} + " /> + <div class="flow-form-actions flow-form-collapsible"> + <button data-role="submit" data-flow-api-handler="submitTopicTitle" class="flow-ui-button flow-ui-constructive">{{l10n "flow-edit-title-submit"}}</button> + <button data-role="action" class="flow-ui-button flow-ui-progressive flow-ui-quiet">{{l10n "flow-preview"}}</button> + <button data-flow-interactive-handler="cancelForm" data-role="cancel" class="flow-ui-button flow-ui-destructive flow-ui-quiet">{{l10n "flow-cancel"}}</button> + <small class="flow-terms-of-use plainlinks">{{l10n "flow-terms-of-use-edit"}}</small> + </div> +</form> diff --git a/handlebars/flow_topic.handlebars b/handlebars/flow_topic.handlebars index df3ac22..7c421fc 100644 --- a/handlebars/flow_topic.handlebars +++ b/handlebars/flow_topic.handlebars @@ -4,7 +4,7 @@ <h2 class="flow-moderated-topic-title">{{l10n "post_moderation_state" moderateState replyToId moderator.name}}</h2> <div>@Todo - Add css to toggle between "xxx is hidden by xxx" and real title</div> {{/if}} - <h2 class="flow-topic-title">{{content}}</h2> + <h2 class="flow-topic-title" data-title="{{content}}">{{content}}</h2> <span class="flow-author">{{l10n "started_with_participants" this}}</span> <div class="flow-topic-meta"> <a class="flow-ui-button flow-ui-progressive flow-ui-quiet flow-ui-inline" href="#flow-post-{{postId}}-form-content">{{l10n "Reply" author}}</a> @@ -24,7 +24,9 @@ <li> <a class="flow-ui-button flow-ui-regressive flow-ui-quiet flow-ui-thin" href="{{actions.edit.url}}" - title="{{actions.edit.title}}"> + title="{{actions.edit.title}}" + data-flow-interactive-handler="editTopicTitle" + > <span class="wikiglyph wikiglyph-pencil"></span> {{l10n "flow-topic-action-edit-title"}} </a> diff --git a/modules/new/components/flow-board.js b/modules/new/components/flow-board.js index 1345af7..e1d9495 100644 --- a/modules/new/components/flow-board.js +++ b/modules/new/components/flow-board.js @@ -282,6 +282,31 @@ } }; + FlowBoardComponent.UI.events.apiHandlers.submitTopicTitle = function( status, data, jqxhr ) { + var result, + newTitle, + $this = $( this ), + $topic = $this.closest( '.flow-topic' ), + $newTopic, + flowBoard = FlowBoardComponent.prototype.getInstanceByElement( $this ); + + if ( data && data.flow && data.flow['edit-title'] && data.flow['edit-title'].status === 'ok' ) { + $newTopic = $( + flowBoard.TemplateEngine.processTemplateGetFragment( + 'flow_topiclist_loop', + data.flow['edit-title'].result.topic + ) + ).children(); + + $topic + .replaceWith( $newTopic ) + .conditionalScrollIntoView(); + } else { + // @todo + alert( "Error" ); + } + }; + //////////////////////////////////////////////////////////// // FlowBoardComponent.UI on-element-load handlers @@ -475,6 +500,43 @@ event.preventDefault(); }; + FlowBoardComponent.UI.events.interactiveHandlers.editTopicTitle = function( event ) { + var $link = $( this ), + $topic = $link.closest( '.flow-topic' ), + $title = $topic + .children( '.flow-topic-titlebar' ) + .find( '.flow-topic-title' ), + flowBoard = FlowBoardComponent.prototype.getInstanceByElement( $link ), + $form, + cancelCallback = function() { + $form.remove(); + $title.show(); + }, + linkParams = flowBoard.API.getQueryMap( $link.attr( 'href' ) ); + + $title.hide(); + + $form = $( flowBoard.TemplateEngine.processTemplateGetFragment( + 'flow_edit_topic_title', + { + 'actions' : { + 'edit' : { + 'url' : $link.attr( 'href' ) + } + }, + 'content' : $title.data( 'title' ), + 'revisionId' : linkParams.etrevId + } + ) ).children(); + + $form + .data( 'flow-cancel-callback', cancelCallback ) + .data( 'flow-initial-state', 'hidden' ) + .insertAfter( $title ); + + event.preventDefault(); + }; + /** * Triggers an API request based on URL and form data, and triggers the callbacks based on flow-api-handler. * @example <a data-flow-interactive-handler="apiRequest" data-flow-api-handler="loadMore" data-flow-api-target="$container" href="...">...</a> @@ -580,11 +642,14 @@ return; } - var handlerName = $( this ).data( 'flow-interactive-handler' ); + var interactiveHandler = $( this ).data( 'flow-interactive-handler' ), + apiHandler = $( this ).data( 'flow-api-handler' ); // If this has a special click handler, run it. - if ( FlowBoardComponent.UI.events.interactiveHandlers[ handlerName ] ) { - FlowBoardComponent.UI.events.interactiveHandlers[ handlerName ].apply( this, arguments ); + if ( FlowBoardComponent.UI.events.interactiveHandlers[ interactiveHandler ] ) { + FlowBoardComponent.UI.events.interactiveHandlers[ interactiveHandler ].apply( this, arguments ); + } else if ( FlowBoardComponent.UI.events.apiHandlers[ apiHandler ] ) { + FlowBoardComponent.UI.events.interactiveHandlers.apiRequest.apply( this, arguments ); } }; -- To view, visit https://gerrit.wikimedia.org/r/140068 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1337a181d02322ac25fb5e34bad99b66c77a673a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: frontend-rewrite Gerrit-Owner: Werdna <agarr...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits