Merge "Add tags for undo edits"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / mw.rcfilters.ui.FilterWrapperWidget.js
index db7acaa..1cd7bef 100644 (file)
@@ -28,6 +28,7 @@
                this.controller = controller;
                this.model = model;
                this.queriesModel = savedQueriesModel;
+               this.changesListModel = changesListModel;
                this.$overlay = config.$overlay || this.$element;
 
                this.filterTagWidget = new mw.rcfilters.ui.FilterTagMultiselectWidget(
 
                this.liveUpdateButton = new mw.rcfilters.ui.LiveUpdateButtonWidget(
                        this.controller,
-                       changesListModel
+                       this.changesListModel
                );
 
-               this.numChangesWidget = new mw.rcfilters.ui.ChangesLimitButtonWidget(
+               this.numChangesWidget = new mw.rcfilters.ui.ChangesLimitAndDateButtonWidget(
                        this.controller,
                        this.model,
                        {
                        }
                );
 
-               this.dateWidget = new mw.rcfilters.ui.DateButtonWidget(
-                       this.controller,
-                       this.model,
-                       {
-                               $overlay: this.$overlay
-                       }
-               );
+               this.showNewChangesLink = new OO.ui.ButtonWidget( {
+                       icon: 'reload',
+                       framed: false,
+                       label: mw.msg( 'rcfilters-show-new-changes' ),
+                       flags: [ 'progressive' ],
+                       classes: [ 'mw-rcfilters-ui-filterWrapperWidget-showNewChanges' ]
+               );
 
                // Initialize
                this.$top = $( '<div>' )
                $bottom = $( '<div>' )
                        .addClass( 'mw-rcfilters-ui-filterWrapperWidget-bottom' )
                        .append(
-                               this.numChangesWidget.$element,
-                               this.dateWidget.$element
+                               this.showNewChangesLink.$element,
+                               this.numChangesWidget.$element
                        );
 
                if ( mw.rcfilters.featureFlags.liveUpdate ) {
-                       $bottom.append( this.liveUpdateButton.$element );
+                       $bottom.prepend( this.liveUpdateButton.$element );
                }
 
+               // Events
+               this.filterTagWidget.menu.connect( this, { toggle: [ 'emit', 'menuToggle' ] } );
+               this.changesListModel.connect( this, { newChangesExist: 'onNewChangesExist' } );
+               this.showNewChangesLink.connect( this, { click: 'onShowNewChangesClick' } );
+               this.showNewChangesLink.toggle( false );
+
                this.$element
                        .addClass( 'mw-rcfilters-ui-filterWrapperWidget' )
                        .append(
        mw.rcfilters.ui.FilterWrapperWidget.prototype.setTopSection = function ( $topSectionElement ) {
                this.$top.append( $topSectionElement );
        };
+
+       /**
+        * Respond to the user clicking the 'show new changes' button
+        */
+       mw.rcfilters.ui.FilterWrapperWidget.prototype.onShowNewChangesClick = function () {
+               this.controller.showNewChanges();
+       };
+
+       /**
+        * Respond to changes list model newChangesExist
+        *
+        * @param {boolean} newChangesExist Whether new changes exist
+        */
+       mw.rcfilters.ui.FilterWrapperWidget.prototype.onNewChangesExist = function ( newChangesExist ) {
+               this.showNewChangesLink.toggle( newChangesExist );
+       };
 }( mediaWiki ) );