jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/370835 )

Change subject: Remove redundant CalendarHint from TimeInput expert
......................................................................


Remove redundant CalendarHint from TimeInput expert

This code was meant to show the calendar model, along with a button
to switch between Julian and Gregorian. All this is entirely redundant
for a while now, because:

* We are showing the calendar model as a superscript text in the preview.
* The dropdown to manually change the calendar model is not hidden in a
  collapsed section any more.
* The link to toggle the calendar model is partially broken anyways (it
  only updates the dropdown).

Right now the calendar model is shown 3 (!) times, and there are 2 UI
elements to change it.

This is already approved by Jan (UX).

Bug: T172916
Change-Id: I55a3f09f8ac7bc6329e75ab5d738130c4984b61b
---
M i18n/en.json
M i18n/qqq.json
D src/ExpertExtender/ExpertExtender.CalendarHint.css
D src/ExpertExtender/ExpertExtender.CalendarHint.js
M src/ExpertExtender/resources.php
M src/experts/TimeInput.js
M src/experts/resources.php
D tests/src/ExpertExtender/ExpertExtender.CalendarHint.tests.js
M tests/src/ExpertExtender/resources.php
9 files changed, 2 insertions(+), 358 deletions(-)

Approvals:
  Krinkle: Looks good to me, but someone else must approve
  Lucas Werkmeister (WMDE): Looks good to me, approved
  jenkins-bot: Verified



diff --git a/i18n/en.json b/i18n/en.json
index 5200c8f..676208b 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -17,10 +17,6 @@
        "valueview-expert-timevalue-calendar-julian": "Julian",
        "valueview-expert-timeinput-precision": "Precision:",
        "valueview-expert-timeinput-calendar": "Calendar:",
-       "valueview-expertextender-calendarhint-gregorian": "(Gregorian 
calendar)",
-       "valueview-expertextender-calendarhint-julian": "(Julian calendar)",
-       "valueview-expertextender-calendarhint-switch-gregorian": "→ 
change to Gregorian",
-       "valueview-expertextender-calendarhint-switch-julian": "→ change 
to Julian",
        "valueview-expertextender-languageselector-languagetemplate": "$1 ($2)",
        "valueview-expertextender-languageselector-label": "Language 
(mandatory): ",
        "valueview-expertextender-unitsuggester-label": "Unit (optional): ",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 0d40f13..58ec425 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -17,14 +17,10 @@
        "valueview-expert-globecoordinateinput-precision": "Label for the user 
interface element used to set a specific precision (e.g. 1, 0.1, 0.001) when 
entering a coordinate value.\n{{Identical|Precision}}",
        "valueview-expert-globecoordinateinput-nullprecision": "Label 
describing the meaning of the coordinate precision \"null\". Usually it means 
there was no precision specified when the value was entered, other than the 
precision that can be guessed based on the number of fractional digits of the 
latitude and longitude values.\n{{Identical|Unspecified}}",
        "valueview-expert-globecoordinateinput-customprecision": "Label 
wrapping a custom precision the user can not select when entering 
coordinates.\n\nParameters\n* $1 - the precision value as a decimal 
number\n{{Identical|Special}}",
-       "valueview-expert-timevalue-calendar-gregorian": "Label of the 
GREGORIAN calendar. The label is used for selecting the GREGORIAN calendar 
model when entering a date and is displayed with dates that refer to that 
calendar model.\n\nSee also:\n* 
{{msg-mw|Valueview-expert-timeinput-calendarhint-gregorian}}\n* 
{{msg-mw|Valueview-expert-timeinput-calendarhint-switch-gregorian}}\n{{Identical|Gregorian}}",
-       "valueview-expert-timevalue-calendar-julian": "Label of the JULIAN 
calendar. The label is used for selecting the JULIAN calendar model when 
entering a date and is displayed with dates that refer to that calendar 
model.\n\nSee also:\n* 
{{msg-mw|Valueview-expert-timeinput-calendarhint-julian}}\n* 
{{msg-mw|Valueview-expert-timeinput-calendarhint-switch-julian}}\n{{Identical|Julian}}",
+       "valueview-expert-timevalue-calendar-gregorian": "Label of the 
GREGORIAN calendar. The label is used for selecting the GREGORIAN calendar 
model when entering a date and is displayed with dates that refer to that 
calendar model.\n{{Identical|Gregorian}}",
+       "valueview-expert-timevalue-calendar-julian": "Label of the JULIAN 
calendar. The label is used for selecting the JULIAN calendar model when 
entering a date and is displayed with dates that refer to that calendar 
model.\n{{Identical|Julian}}",
        "valueview-expert-timeinput-precision": "Label for the user interface 
element used to set a specific precision (e.g. hour, day, month, year) when 
entering a time value.\n{{Identical|Precision}}",
        "valueview-expert-timeinput-calendar": "Label for the user interface 
element used to select a specific calendar (e.g. Gregorian, Julian) entering a 
time value.\n\nThe calendar is not localized at this 
time.\n{{Identical|Calendar}}",
-       "valueview-expertextender-calendarhint-gregorian": "Message informing 
that the GREGORIAN calendar has been detected automatically while specifying a 
date. The message is shown only when the specified date lies within a time 
frame when multiple calendars had been in use.\n\nSee also:\n* 
{{msg-mw|Valueview-expert-timevalue-calendar-gregorian}}\n* 
{{msg-mw|Valueview-expert-timeinput-calendarhint-switch-gregorian}}",
-       "valueview-expertextender-calendarhint-julian": "Message informing that 
the JULIAN calendar has been detected automatically while specifying a date. 
The message is shown only when the specified date lies within a time frame when 
multiple calendars had been in use.\n\nSee also:\n* 
{{msg-mw|Valueview-expert-timevalue-calendar-julian}}\n* 
{{msg-mw|Valueview-expert-timeinput-calendarhint-switch-julian}}",
-       "valueview-expertextender-calendarhint-switch-gregorian": "Label of the 
link manually switching to the GREGORIAN calendar. The link is located directly 
at the preview (in combination with the calendar hint message).\n\nSee also:\n* 
{{msg-mw|Valueview-expert-timevalue-calendar-gregorian}}\n* 
{{msg-mw|Valueview-expert-timeinput-calendarhint-gregorian}}",
-       "valueview-expertextender-calendarhint-switch-julian": "Label of the 
link manually switching to the JULIAN calendar. The link is located directly at 
the preview (in combination with the calendar hint message).\n\nSee also:\n* 
{{msg-mw|Valueview-expert-timevalue-calendar-julian}}\n* 
{{msg-mw|Valueview-expert-timeinput-calendarhint-julian}}",
        "valueview-expertextender-languageselector-languagetemplate": "Defines 
how the language should be displayed relative to the text.\n\nParameters:\n* $1 
- the text.\n* $2 - the language name or code.",
        "valueview-expertextender-languageselector-label": "Label displayed 
above the language input. The input is either a plain text field or a search 
with a suggester.",
        "valueview-expertextender-unitsuggester-label": "Label displayed above 
the quantity's unit input. The input is a plain text field with an optional 
suggester.",
diff --git a/src/ExpertExtender/ExpertExtender.CalendarHint.css 
b/src/ExpertExtender/ExpertExtender.CalendarHint.css
deleted file mode 100644
index 4d8ce2c..0000000
--- a/src/ExpertExtender/ExpertExtender.CalendarHint.css
+++ /dev/null
@@ -1,13 +0,0 @@
-.ui-inputextender-extension .valueview-expertextender-calendarhint {
-       margin-top: 0;
-}
-
-.ui-inputextender-extension .valueview-expertextender-calendarhint-message {
-       margin-right: 0.5em;
-}
-
-.ui-inputextender-extension .valueview-expertextender-calendarhint-switch {
-       background: none;
-       border: none;
-       cursor: pointer;
-}
diff --git a/src/ExpertExtender/ExpertExtender.CalendarHint.js 
b/src/ExpertExtender/ExpertExtender.CalendarHint.js
deleted file mode 100644
index 4bd44cb..0000000
--- a/src/ExpertExtender/ExpertExtender.CalendarHint.js
+++ /dev/null
@@ -1,144 +0,0 @@
-( function( $, ExpertExtender, TimeValue ) {
-       'use strict';
-
-       /**
-        * An `ExpertExtender` module for showing a hint about the used 
calendar model.
-        * @class jQuery.valueview.ExpertExtender.CalendarHint
-        * @since 0.6
-        * @licence GNU GPL v2+
-        * @author Adrian Heine <adrian.he...@wikimedia.de>
-        *
-        * @constructor
-        *
-        * @param {util.MessageProvider} messageProvider
-        * @param {Function} getUpstreamValue A getter for the current 
`DataValue` instance in use.
-        * @param {Function} setUpstreamCalendar A setter for the current 
calendar name used.
-        */
-       ExpertExtender.CalendarHint = function( messageProvider, 
getUpstreamValue, setUpstreamCalendar ) {
-               this._messageProvider = messageProvider;
-               this._getUpstreamValue = getUpstreamValue;
-               this._setUpstreamCalendar = setUpstreamCalendar;
-
-               this.$calendarhint = $( '<div/>' );
-       };
-
-       $.extend( ExpertExtender.CalendarHint.prototype, {
-               /**
-                * @property {util.MessageProvider}
-                * @private
-                */
-               _messageProvider: null,
-
-               /**
-                * @property {Function}
-                * @private
-                */
-               _getUpstreamValue: null,
-
-               /**
-                * @property {Function}
-                * @private
-                */
-               _setUpstreamCalendar: null,
-
-               /**
-                * @property {jQuery}
-                * @private
-                * @readonly
-                */
-               $calendarhint: null,
-
-               /**
-                * @property {string}
-                * @private
-                */
-               _otherCalendar: null,
-
-               /**
-                * The common prefix for CSS classes and message keys
-                * @property {string} 
[_prefix='valueview-expertextender-calendarhint']
-                * @private
-                */
-               _prefix: 'valueview-expertextender-calendarhint',
-
-               /**
-                * Callback for the `init` `ExpertExtender` event.
-                *
-                * @param {jQuery} $extender
-                */
-               init: function( $extender ) {
-                       var self = this;
-
-                       this.$calendarhint
-                               .addClass( this._prefix )
-                               .append( $( '<span/>' ).addClass( this._prefix 
+ '-message' ) )
-                               .append(
-                                       $( '<a/>' )
-                                       .addClass( this._prefix + '-switch 
ui-state-default' )
-                                       .on( 'click', function( event ) {
-                                               event.preventDefault();
-                                               self._setUpstreamCalendar( 
self._otherCalendar );
-                                       } )
-                               )
-                               .hide();
-
-                       $extender.append( this.$calendarhint );
-               },
-
-               /**
-                * Callback for the `ExpertExtender` draw event.
-                */
-               draw: function() {
-                       /** @var {dataValues.TimeValue} value */
-                       var value = this._getUpstreamValue();
-                       if ( !value ) {
-                               return;
-                       }
-
-                       var assumeCalendar = value.getYear() <= 1581 || 
value.getYear() >= 1930;
-
-                       if ( assumeCalendar || value.getOption( 'precision' ) 
<= 10 ) {
-                               this.$calendarhint.hide();
-                               return;
-                       }
-
-                       var calendarModel = value.getOption( 'calendarModel' ),
-                               msg = this._messageProvider.getMessage(
-                                       this._prefix + '-' + 
TimeValue.getCalendarModelKeyByUri( calendarModel )
-                               );
-
-                       if ( !msg ) {
-                               return;
-                       }
-
-                       this.$calendarhint.children( '.' + this._prefix + 
'-message' ).text( msg );
-
-                       this._otherCalendar = calendarModel === 
TimeValue.CALENDARS.GREGORIAN
-                               ? TimeValue.CALENDARS.JULIAN
-                               : TimeValue.CALENDARS.GREGORIAN;
-
-                       msg = this._messageProvider.getMessage(
-                               this._prefix + '-switch-' + 
TimeValue.getCalendarModelKeyByUri( this._otherCalendar )
-                       );
-                       if ( msg ) {
-                               this.$calendarhint.children( '.' + this._prefix 
+ '-switch' ).html( msg );
-                       }
-
-                       this.$calendarhint.show();
-               },
-
-               /**
-                * Callback for the `ExpertExtender` destroy event.
-                */
-               destroy: function() {
-                       this._messageProvider = null;
-                       this._getUpstreamValue = null;
-                       this._setUpstreamCalendar = null;
-
-                       this.$calendarhint.remove();
-                       this.$calendarhint = null;
-
-                       this._otherCalendar = null;
-               }
-       } );
-}( jQuery, jQuery.valueview.ExpertExtender, dataValues.TimeValue ) );
diff --git a/src/ExpertExtender/resources.php b/src/ExpertExtender/resources.php
index 8ef0c91..9e386ca 100644
--- a/src/ExpertExtender/resources.php
+++ b/src/ExpertExtender/resources.php
@@ -25,25 +25,6 @@
                        ),
                ),
 
-               'jquery.valueview.ExpertExtender.CalendarHint' => 
$moduleTemplate + array(
-                       'scripts' => array(
-                               'ExpertExtender.CalendarHint.js',
-                       ),
-                       'styles' => array(
-                               'ExpertExtender.CalendarHint.css',
-                       ),
-                       'dependencies' => array(
-                               'dataValues.TimeValue',
-                               'jquery.valueview.ExpertExtender',
-                       ),
-                       'messages' => array(
-                               
'valueview-expertextender-calendarhint-gregorian',
-                               'valueview-expertextender-calendarhint-julian',
-                               
'valueview-expertextender-calendarhint-switch-gregorian',
-                               
'valueview-expertextender-calendarhint-switch-julian'
-                       )
-               ),
-
                'jquery.valueview.ExpertExtender.Container' => $moduleTemplate 
+ array(
                        'scripts' => array(
                                'ExpertExtender.Container.js',
diff --git a/src/experts/TimeInput.js b/src/experts/TimeInput.js
index c779d35..aa80b33 100644
--- a/src/experts/TimeInput.js
+++ b/src/experts/TimeInput.js
@@ -96,18 +96,6 @@
                        this.$input,
                        [
                                this.preview,
-                               new vv.ExpertExtender.CalendarHint(
-                                       this._messageProvider,
-                                       function() {
-                                               return self.viewState().value();
-                                       },
-                                       function( value ) {
-                                               // FIXME: Do not use private 
function:
-                                               
self.calendarRotator.rotator._setValue( value );
-                                               
self.calendarRotator.rotator.value( value );
-                                               
self.calendarRotator.rotator.activate();
-                                       }
-                               ),
                                new vv.ExpertExtender.Container(
                                        $precisionContainer,
                                        this.precisionRotator
diff --git a/src/experts/resources.php b/src/experts/resources.php
index 0018029..c79114d 100644
--- a/src/experts/resources.php
+++ b/src/experts/resources.php
@@ -160,7 +160,6 @@
                        'dependencies' => array(
                                'dataValues.TimeValue',
                                'jquery.valueview.ExpertExtender',
-                               'jquery.valueview.ExpertExtender.CalendarHint',
                                'jquery.valueview.ExpertExtender.Container',
                                'jquery.valueview.ExpertExtender.Listrotator',
                                'jquery.valueview.ExpertExtender.Preview',
diff --git a/tests/src/ExpertExtender/ExpertExtender.CalendarHint.tests.js 
b/tests/src/ExpertExtender/ExpertExtender.CalendarHint.tests.js
deleted file mode 100644
index 17a414d..0000000
--- a/tests/src/ExpertExtender/ExpertExtender.CalendarHint.tests.js
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * @licence GNU GPL v2+
- * @author Adrian Heine <adrian.he...@wikimedia.de>
- */
-/* jshint nonew: false */
-( function(
-       $,
-       ExpertExtender,
-       testExpertExtenderExtension,
-       TimeValue,
-       HashMessageProvider,
-       sinon,
-       QUnit
-) {
-       'use strict';
-
-       QUnit.module( 'jquery.valueview.ExpertExtender.CalendarHint' );
-
-       testExpertExtenderExtension.all(
-               ExpertExtender.CalendarHint,
-               function() {
-                       return new ExpertExtender.CalendarHint();
-               }
-       );
-
-       QUnit.test( 'calendarhint is hidden if it should not be shown', 
function( assert ) {
-               assert.expect( 1 );
-               var calendarHint = new ExpertExtender.CalendarHint(
-                       new HashMessageProvider( {
-                               
'valueview-expertextender-calendarhint-gregorian': 'MSG1',
-                               
'valueview-expertextender-calendarhint-switch-julian': 'MSG2'
-                       } ),
-                       function() {
-                               return new TimeValue( '2014-01-01T00:00:00Z' );
-                       },
-                       null
-               );
-               var $extender = $( '<div />' ).appendTo( 'body' );
-
-               calendarHint.init( $extender );
-               calendarHint.draw();
-
-               assert.assertFalse( $extender.children().is( ':visible' ) );
-
-               $extender.remove();
-       } );
-
-       QUnit.test( 'calendarhint is visible if it should be shown', function( 
assert ) {
-               assert.expect( 1 );
-               var calendarHint = new ExpertExtender.CalendarHint(
-                       new HashMessageProvider( {
-                               
'valueview-expertextender-calendarhint-gregorian': 'MSG1',
-                               
'valueview-expertextender-calendarhint-switch-julian': 'MSG2'
-                       } ),
-                       function() {
-                               return new TimeValue( '1901-01-01T00:00:00Z' );
-                       },
-                       null
-               );
-               var $extender = $( '<div />' ).appendTo( 'body' );
-
-               calendarHint.init( $extender );
-               calendarHint.draw();
-
-               assert.assertTrue( $extender.children().is( ':visible' ) );
-
-               $extender.remove();
-       } );
-
-       QUnit.test( 'switch switches the calendar model', function( assert ) {
-               assert.expect( 3 );
-               var setSpy = sinon.spy();
-               var timeValue = new TimeValue( '1901-01-01T00:00:00Z' );
-               var calendarHint = new ExpertExtender.CalendarHint(
-                       new HashMessageProvider( {
-                               
'valueview-expertextender-calendarhint-gregorian': 'MSG1',
-                               
'valueview-expertextender-calendarhint-switch-julian': 'MSG2'
-                       } ),
-                       function() {
-                               return timeValue;
-                       },
-                       setSpy
-               );
-               var $extender = $( '<div />' ).appendTo( 'body' );
-
-               assert.equal( timeValue.getOption( 'calendarModel' ), 
'http://www.wikidata.org/entity/Q1985727' );
-
-               calendarHint.init( $extender );
-               calendarHint.draw();
-
-               $( '.valueview-expertextender-calendarhint-switch', 
$extender[0] ).click();
-
-               sinon.assert.calledOnce( setSpy );
-               assert.equal( setSpy.firstCall.args[0], 
'http://www.wikidata.org/entity/Q1985786' );
-
-               $extender.remove();
-       } );
-
-       QUnit.test( 'switch twice switches the calendar model back', function( 
assert ) {
-               assert.expect( 4 );
-               var setSpy = sinon.spy();
-               var timeValue = new TimeValue( '1901-01-01T00:00:00Z' );
-               var calendarHint = new ExpertExtender.CalendarHint(
-                       new HashMessageProvider( {
-                               
'valueview-expertextender-calendarhint-gregorian': 'MSG1',
-                               'valueview-expertextender-calendarhint-julian': 
'MSG2',
-                               
'valueview-expertextender-calendarhint-switch-julian': 'MSG3',
-                               
'valueview-expertextender-calendarhint-switch-gregorian': 'MSG4'
-                       } ),
-                       function() {
-                               return timeValue;
-                       },
-                       setSpy
-               );
-               var $extender = $( '<div />' ).appendTo( 'body' );
-
-               calendarHint.init( $extender );
-               calendarHint.draw();
-
-               $( '.valueview-expertextender-calendarhint-switch', 
$extender[0] ).click();
-
-               sinon.assert.calledOnce( setSpy );
-               assert.equal( setSpy.firstCall.args[0], 
'http://www.wikidata.org/entity/Q1985786' );
-
-               timeValue = new TimeValue( timeValue.toJSON().time, {
-                       calendarModel: TimeValue.CALENDARS.JULIAN,
-                       precision: timeValue.getOption( 'precision' )
-               } );
-               calendarHint.draw();
-
-               $( '.valueview-expertextender-calendarhint-switch', 
$extender[0] ).click();
-
-               sinon.assert.calledTwice( setSpy );
-               assert.equal( setSpy.secondCall.args[0], 
'http://www.wikidata.org/entity/Q1985727' );
-
-               $extender.remove();
-       } );
-
-} )(
-       jQuery,
-       jQuery.valueview.ExpertExtender,
-       jQuery.valueview.tests.testExpertExtenderExtension,
-       dataValues.TimeValue,
-       util.HashMessageProvider,
-       sinon,
-       QUnit
-);
diff --git a/tests/src/ExpertExtender/resources.php 
b/tests/src/ExpertExtender/resources.php
index a854652..4abc881 100644
--- a/tests/src/ExpertExtender/resources.php
+++ b/tests/src/ExpertExtender/resources.php
@@ -27,18 +27,6 @@
                        ),
                ),
 
-               'jquery.valueview.ExpertExtender.CalendarHint.tests' => 
$moduleTemplate + array(
-                       'scripts' => array(
-                               'ExpertExtender.CalendarHint.tests.js',
-                       ),
-                       'dependencies' => array(
-                               'dataValues.TimeValue',
-                               'jquery.valueview.ExpertExtender.CalendarHint',
-                               
'jquery.valueview.test.testExpertExtenderExtension',
-                               'util.HashMessageProvider',
-                       ),
-               ),
-
                'jquery.valueview.ExpertExtender.Container.tests' => 
$moduleTemplate + array(
                        'scripts' => array(
                                'ExpertExtender.Container.tests.js',

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I55a3f09f8ac7bc6329e75ab5d738130c4984b61b
Gerrit-PatchSet: 3
Gerrit-Project: data-values/value-view
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Hoo man <h...@online.de>
Gerrit-Reviewer: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: Lucas Werkmeister (WMDE) <lucas.werkmeis...@wikimedia.de>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to