Matthias Mullie has uploaded a new change for review. https://gerrit.wikimedia.org/r/101001
Change subject: Fetch latest title content from API instead of relying on (old)
html
......................................................................
Fetch latest title content from API instead of relying on (old) html
When starting to edit, fetch the latest content from API (similar to how it's
already done for header & post)
Change-Id: I98a767c3946a5789a572bcc56cc5cc192e46d2f2
---
M modules/discussion/forms.js
M modules/moderation/moderation.js
M templates/topic.html.php
3 files changed, 91 insertions(+), 69 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/01/101001/1
diff --git a/modules/discussion/forms.js b/modules/discussion/forms.js
index 9f91361..f9c9bb1 100644
--- a/modules/discussion/forms.js
+++ b/modules/discussion/forms.js
@@ -200,85 +200,108 @@
var $topicContainer = $( this ).closest(
'.flow-topic-container' ),
$titleBar = $topicContainer.find(
'.flow-topic-title' ),
- oldTitle = $topicContainer.data( 'title' ),
$titleEditForm = $( '<form />' ),
- $realTitle = $titleBar.find( '.flow-realtitle'
);
+ $realTitle = $titleBar.find( '.flow-realtitle'
),
+ workflowId = $topicContainer.data( 'topic-id' ),
+ pageName = $( this ).closest( '.flow-container'
).data( 'page-title' );
// check if form has not already been opened
if ( !$realTitle.is( ':visible' ) ) {
return;
}
- $realTitle.hide();
+ mw.flow.api.readTopic(
+ pageName,
+ workflowId,
+ {
+ 'topic' : {
+ 'no-children' : true,
+ 'postId' : workflowId,
+ 'contentFormat' :
mw.flow.editor.getFormat()
+ }
+ }
+ )
+ .done( function ( data ) {
+ if ( !data[0] || data[0]['post-id'] !==
workflowId ) {
+ console.dir( data );
+ $( '<div/>' )
+ .addClass( 'flow-error' )
+ .text( mw.msg(
'flow-error-other' ) )
+ .hide()
+ .insertAfter( $topicContainer )
+ .slideDown();
+ return;
+ }
- $titleEditForm
- .addClass( 'flow-edit-title-form' )
- .append(
- $( '<input />' )
- .addClass( 'mw-ui-input' )
- .addClass(
'flow-edit-title-textbox' )
- .attr( 'type', 'text' )
- .byteLimit( mw.config.get(
'wgFlowMaxTopicLength' ) )
- .val( oldTitle )
- )
- .append(
- $( '<div
class="flow-edit-title-controls"></div>' )
- .append(
- $( '<a/>' )
- .addClass(
'flow-cancel-link' )
- .addClass(
'mw-ui-button' )
- .addClass(
'mw-ui-text' )
- .attr( 'href',
'#' )
- .text( mw.msg(
'flow-cancel' ) )
- .click(
function ( e ) {
-
e.preventDefault();
-
$titleBar.children( 'form' )
-
.remove();
-
$realTitle
-
.show();
-
$titleEditForm.remove();
-
$titleEditForm.flow( 'hidePreview' );
- } )
- )
- .append( ' ' )
- .append(
- $( '<input />' )
- .addClass(
'flow-edit-title-submit' )
- .addClass(
'mw-ui-button' )
- .addClass(
'mw-ui-constructive' )
- .attr( 'type',
'submit' )
- .val( mw.msg(
'flow-edit-title-submit' ) )
- )
- )
- .appendTo( $titleBar )
- .find( '.flow-edit-title-textbox' )
- .focus()
- .select();
- $titleEditForm.flow( 'setupPreview', {
'.flow-edit-title-textbox': 'plain' } );
- $titleEditForm.flow( 'setupFormHandler',
- '.flow-edit-title-submit',
- mw.flow.api.changeTitle,
- function () {
- var workflowId =
$topicContainer.data( 'topic-id' ),
- content =
$titleEditForm.find( '.flow-edit-title-textbox' ).val();
+ $realTitle.hide();
- return [ workflowId, content ];
- },
- function ( workflowId, content ) {
- return content && true;
- },
- function ( promise ) {
- promise.done( function ( output
) {
- $realTitle
- .empty()
- .text(
output.rendered )
- .show();
+ $titleEditForm
+ .addClass( 'flow-edit-title-form' )
+ .append(
+ $( '<input />' )
+ .addClass(
'mw-ui-input' )
+ .addClass(
'flow-edit-title-textbox' )
+ .attr( 'type', 'text' )
+ .byteLimit(
mw.config.get( 'wgFlowMaxTopicLength' ) )
+ .val(
data[0].content['*'] )
+ )
+ .append(
+ $( '<div
class="flow-edit-title-controls"></div>' )
+ .append(
+ $( '<a/>' )
+
.addClass( 'flow-cancel-link' )
+
.addClass( 'mw-ui-button' )
+
.addClass( 'mw-ui-text' )
+ .attr(
'href', '#' )
+ .text(
mw.msg( 'flow-cancel' ) )
+ .click(
function ( e ) {
+
e.preventDefault();
+
$titleBar.children( 'form' )
+
.remove();
+
$realTitle
+
.show();
+
$titleEditForm.remove();
+
$titleEditForm.flow( 'hidePreview' );
+ } )
+ )
+ .append( ' ' )
+ .append(
+ $( '<input />' )
+
.addClass( 'flow-edit-title-submit' )
+
.addClass( 'mw-ui-button' )
+
.addClass( 'mw-ui-constructive' )
+ .attr(
'type', 'submit' )
+ .val(
mw.msg( 'flow-edit-title-submit' ) )
+ )
+ )
+ .appendTo( $titleBar )
+ .find( '.flow-edit-title-textbox' )
+ .focus()
+ .select();
+ $titleEditForm.flow( 'setupPreview', {
'.flow-edit-title-textbox': 'plain' } );
+ $titleEditForm.flow( 'setupFormHandler',
+ '.flow-edit-title-submit',
+ mw.flow.api.changeTitle,
+ function () {
+ var workflowId =
$topicContainer.data( 'topic-id' ),
+ content =
$titleEditForm.find( '.flow-edit-title-textbox' ).val();
- $topicContainer.data(
'title', output.rendered );
+ return [ workflowId,
content ];
+ },
+ function ( workflowId, content
) {
+ return content && true;
+ },
+ function ( promise ) {
+ promise.done( function
( output ) {
+ $realTitle
+ .empty()
+ .text(
output.rendered )
+ .show();
- $titleEditForm.remove();
+
$titleEditForm.remove();
+ } );
} );
- } );
+ } );
} );
} );
} )( jQuery, mediaWiki );
diff --git a/modules/moderation/moderation.js b/modules/moderation/moderation.js
index 1ac028d..1ac387b 100644
--- a/modules/moderation/moderation.js
+++ b/modules/moderation/moderation.js
@@ -11,7 +11,7 @@
$.fn._flow.showModerationDialog = function( moderationType ) {
var $postContainer = $( this ).closest( '.flow-post-container'
),
$topicContainer = $( this ).closest(
'.flow-topic-container' ),
- subject = $topicContainer.data( 'title' ),
+ subject = $topicContainer.find( '.flow-realtitle'
).text(),
$dialog = $( '<div />' ),
$form = $( '<form/>' ),
targetType, apiCallback, $resultContainer, user;
diff --git a/templates/topic.html.php b/templates/topic.html.php
index b0808cd..a945a2b 100644
--- a/templates/topic.html.php
+++ b/templates/topic.html.php
@@ -72,7 +72,6 @@
'id' => 'flow-topic-' . $topic->getId()->getHex(),
'data-topic-id' => $topic->getId()->getHex(),
'data-creator-name' => $this->getCreatorText( $root, $user ),
- 'data-title' => $root->isModerated() ? '' : $title,
) );
?>
<div class="flow-element-container">
--
To view, visit https://gerrit.wikimedia.org/r/101001
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I98a767c3946a5789a572bcc56cc5cc192e46d2f2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
