Skip to content

Commit

Permalink
Release 0.15.5
Browse files Browse the repository at this point in the history
  • Loading branch information
thiemowmde committed Sep 9, 2015
1 parent 55e0f19 commit 987b2f2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
4 changes: 4 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ValueView release notes

## 0.15.5 (2015-09-09)

* Fixed `jQuery.valueview.ExpertExtender.UnitSelector` test.

## 0.15.4 (2015-09-09)

* `jQuery.valueview.experts.QuantityInput` extracts an optional `.wb-unit` node from the formatted value and passes it to the UnitSelector.
Expand Down
2 changes: 1 addition & 1 deletion ValueView.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
return 1;
}

define( 'VALUEVIEW_VERSION', '0.15.4' );
define( 'VALUEVIEW_VERSION', '0.15.5' );

// Include the composer autoloader if it is present.
if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
Expand Down
16 changes: 11 additions & 5 deletions src/ExpertExtender/ExpertExtender.UnitSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,18 @@
* @param {jQuery} $extender
*/
init: function( $extender ) {
var label = this._messageProvider.getMessage(
'valueview-expertextender-unitsuggester-label'
);
var upstreamValue = this._getUpstreamValue(),
label = this._messageProvider.getMessage(
'valueview-expertextender-unitsuggester-label'
);

this.$selector.unitsuggester( {
language: this._options.language || null,
vocabularyLookupApiUrl: this._options.vocabularyLookupApiUrl || null,
change: this._onValueChange,
defaultSelectedUrl: this._getUpstreamValue().conceptUri
defaultSelectedUrl: upstreamValue ? upstreamValue.conceptUri : null
} );

$extender
.append( $( '<span>' ).text( label ) )
.append( this.$selector );
Expand All @@ -87,13 +90,16 @@
* Callback for the `onInitialShow` `ExpertExtender` event.
*/
onInitialShow: function() {
var value = this._getUpstreamValue().label;
var upstreamValue = this._getUpstreamValue(),
value = upstreamValue ? upstreamValue.label : null;

if( value === '1' ||
value === 'http://qudt.org/vocab/unit#Unitless' ||
/^(?:https?:)?\/\/(?:www\.)?wikidata\.org\/\w+\/Q199$/i.test( value )
) {
value = null;
}

this.$selector.val( value );
},

Expand Down
13 changes: 7 additions & 6 deletions tests/src/ExpertExtender/ExpertExtender.UnitSelector.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@
function() {
return new ExpertExtender.UnitSelector(
messageProvider,
function() { }
function() {
return {};
}
);
}
);

QUnit.test( 'getConceptUri() does change if input value changes', function( assert ) {
var upstreamValue = 'en';
var unitSelector = new ExpertExtender.UnitSelector(
messageProvider,
function() {
return upstreamValue;
return { label: 'Ultrameter' };
}
);
var $extender = $( '<div />' );
Expand All @@ -53,7 +54,7 @@
unitSelector.draw();
}

assert.equal( unitSelector.getConceptUri(), 'en' );
assert.equal( unitSelector.getConceptUri(), 'Ultrameter' );

$extender.find( 'input' ).val( 'foobar' );

Expand All @@ -64,7 +65,7 @@
var unitSelector = new ExpertExtender.UnitSelector(
messageProvider,
function() {
return 'en';
return { conceptUri: 'Ultrameter' };
}
);
var $extender = $( '<div />' );
Expand All @@ -79,7 +80,7 @@
unitSelector.draw();
}

assert.equal( unitSelector.getConceptUri(), 'en' );
assert.equal( unitSelector.getConceptUri(), 'Ultrameter' );
} );

} )(
Expand Down

0 comments on commit 987b2f2

Please sign in to comment.