Mooeypoo has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/216301

Change subject: Use getHashObject to make dm items hashable
......................................................................

Use getHashObject to make dm items hashable

Change the previously used getHash to getHashObject for oojs'
oo.getHash

Change-Id: I8989f793d3a3450059da83df58a9585aec680b11
---
M modules/flow/dm/mw.flow.dm.Board.js
M modules/flow/dm/mw.flow.dm.Item.js
M modules/flow/dm/mw.flow.dm.RevisionedContent.js
M modules/flow/dm/mw.flow.dm.Topic.js
M tests/qunit/flow/dm/test_mw.flow.dm.Board.js
5 files changed, 46 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/01/216301/1

diff --git a/modules/flow/dm/mw.flow.dm.Board.js 
b/modules/flow/dm/mw.flow.dm.Board.js
index 1bd7a81..28d70ad 100644
--- a/modules/flow/dm/mw.flow.dm.Board.js
+++ b/modules/flow/dm/mw.flow.dm.Board.js
@@ -26,11 +26,10 @@
                this.setId( data.id );
                this.pageTitle = data.pageTitle;
                this.deleted = !!data.isDeleted;
+               this.sort = data.sort || 'updated';
 
-               // TODO: Aggregate events for all topics so we can let
-               // widgets listen to events like 'content' change
-               // (For example, the ToC widget should respond and update
-               // itself in case a topic title changes)
+               // PROBLEM: AGGREGATE EVENTS SEEM TO NOT BE WORKING...
+               this.aggregate( { contentChange: 'topicContentChange' } );
        };
 
        /* Initialization */
@@ -54,20 +53,29 @@
         * @param {string} order The order of the topics; 'newest' or 'updated'
         */
 
+       /**
+        * One of the board's topic content changed
+        *
+        * @event topicContentChange
+        * @param {string} topicId Topic UUID
+        * @param {string} content Topic content
+        * @param {string} format Content format
+        */
+
        /* Methods */
 
        /**
         * @inheritdoc
         */
-       mw.flow.dm.Board.prototype.getHash = function () {
+       mw.flow.dm.Board.prototype.getHashObject = function () {
                return $.extend( {
                        isDeleted: this.isDeleted(),
                        pagePrefixedDb: this.getPageTitle().getPrefixedDb(),
                        topicCount: this.getItemCount(),
-                       description: this.getDescription() && 
this.getDescription().getHash()
+                       description: this.getDescription() && 
this.getDescription().getHashObject()
                },
                        // Parent
-                       mw.flow.dm.Board.super.prototype.getHash.call( this )
+                       mw.flow.dm.Board.super.prototype.getHashObject.call( 
this )
                );
        };
 
@@ -110,6 +118,28 @@
        };
 
        /**
+        * Get board sort order, 'newest' or 'updated'
+        *
+        * @return {string} Board sort order
+        */
+       mw.flow.dm.Board.prototype.getSortOrder = function () {
+               return this.sort;
+       };
+
+       /**
+        * Set board sort order, 'newest' or 'updated'
+        *
+        * @param {string} Board sort order
+        * @fires sortOrderChange
+        */
+       mw.flow.dm.Board.prototype.setSortOrder = function ( order ) {
+               if ( this.sort !== order ) {
+                       this.sort = order;
+                       this.emit( 'sortOrderChange', order );
+               }
+       };
+
+       /**
         * Reset the board
         *
         * @param {string} order The order of the topics; 'newest' or 'updated'
diff --git a/modules/flow/dm/mw.flow.dm.Item.js 
b/modules/flow/dm/mw.flow.dm.Item.js
index bc2e37b..e625664 100644
--- a/modules/flow/dm/mw.flow.dm.Item.js
+++ b/modules/flow/dm/mw.flow.dm.Item.js
@@ -25,7 +25,7 @@
         *
         * @return {Object} Hash object
         */
-       mw.flow.dm.Item.prototype.getHash = function () {
+       mw.flow.dm.Item.prototype.getHashObject = function () {
                return {
                        id: this.getId()
                };
@@ -66,7 +66,7 @@
         * be stored
         */
        mw.flow.dm.Item.prototype.storeComparableHash = function ( hash ) {
-               this.comparableHash = hash || $.extend( {}, this.getHash() );
+               this.comparableHash = hash || $.extend( {}, 
this.getHashObject() );
        };
 
        /**
@@ -75,6 +75,6 @@
         * @return {boolean} Item has changed
         */
        mw.flow.dm.Item.prototype.hasBeenChanged = function () {
-               return !OO.compare( this.comparableHash, this.getHash() );
+               return !OO.compare( this.comparableHash, this.getHashObject() );
        };
 }( jQuery ) );
diff --git a/modules/flow/dm/mw.flow.dm.RevisionedContent.js 
b/modules/flow/dm/mw.flow.dm.RevisionedContent.js
index 6f943e4..cc17758 100644
--- a/modules/flow/dm/mw.flow.dm.RevisionedContent.js
+++ b/modules/flow/dm/mw.flow.dm.RevisionedContent.js
@@ -72,7 +72,7 @@
        /**
         * @inheritdoc
         */
-       mw.flow.dm.RevisionedContent.prototype.getHash = function () {
+       mw.flow.dm.RevisionedContent.prototype.getHashObject = function () {
                return $.extend( {
                        content: this.getContent(),
                        contentFormat: this.getContentFormat(),
@@ -88,7 +88,7 @@
                        originalContent: this.isOriginalContent(),
                        watched: this.isWatched(),
                        watchable: this.isWatchable()
-               }, mw.flow.dm.RevisionedContent.super.prototype.getHash.call( 
this ) );
+               }, 
mw.flow.dm.RevisionedContent.super.prototype.getHashObject.call( this ) );
        };
 
        /**
diff --git a/modules/flow/dm/mw.flow.dm.Topic.js 
b/modules/flow/dm/mw.flow.dm.Topic.js
index 8d5b51d..51f8e6e 100644
--- a/modules/flow/dm/mw.flow.dm.Topic.js
+++ b/modules/flow/dm/mw.flow.dm.Topic.js
@@ -70,7 +70,7 @@
         *
         * @return {Object} Hash object
         */
-       mw.flow.dm.Topic.prototype.getHash = function () {
+       mw.flow.dm.Topic.prototype.getHashObject = function () {
                return $.extend(
                        {
                                stub: this.isStub(),
@@ -80,7 +80,7 @@
                                moderator: this.getModerator()
                        },
                        // Parent
-                       mw.flow.dm.Topic.super.prototype.getHash.call( this )
+                       mw.flow.dm.Topic.super.prototype.getHashObject.call( 
this )
                );
        };
 
diff --git a/tests/qunit/flow/dm/test_mw.flow.dm.Board.js 
b/tests/qunit/flow/dm/test_mw.flow.dm.Board.js
index 165ad50..dba06c4 100644
--- a/tests/qunit/flow/dm/test_mw.flow.dm.Board.js
+++ b/tests/qunit/flow/dm/test_mw.flow.dm.Board.js
@@ -10,7 +10,7 @@
                expectCount = 0,
                cases = [
                        {
-                               method: 'getHash',
+                               method: 'getHashObject',
                                expected: {
                                        id: 'xxx123xxx',
                                        isDeleted: false,
@@ -68,7 +68,7 @@
                                ]
                        },
                        {
-                               method: 'getHash',
+                               method: 'getHashObject',
                                expected: {
                                        id: 'xxx123xxx',
                                        isDeleted: false,

-- 
To view, visit https://gerrit.wikimedia.org/r/216301
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8989f793d3a3450059da83df58a9585aec680b11
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <mor...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to