Henning Snater has uploaded a new change for review.
https://gerrit.wikimedia.org/r/157817
Change subject: Moved edit functionality to fingerprintgroupview
......................................................................
Moved edit functionality to fingerprintgroupview
Removed edittoolbar definition from fingerprintview and added definition for
fingerprintgroupview. Necessary edit functionality has been implemented
in fingerprintlistview and fingerprintgroupview.
Change-Id: I19c1bbda6a06b8b2147c266540b63a7f6de195d1
---
M lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
M lib/resources/jquery.wikibase/jquery.wikibase.fingerprintgroupview.js
M lib/resources/jquery.wikibase/jquery.wikibase.fingerprintlistview.js
M lib/resources/jquery.wikibase/jquery.wikibase.fingerprintview.js
M lib/resources/jquery.wikibase/resources.php
M
lib/resources/jquery.wikibase/themes/default/jquery.wikibase.fingerprintgroupview.css
M lib/resources/templates.php
M lib/tests/qunit/jquery.wikibase/jquery.wikibase.fingerprintgroupview.tests.js
M lib/tests/qunit/jquery.wikibase/jquery.wikibase.fingerprintlistview.tests.js
M repo/i18n/en.json
M repo/i18n/qqq.json
M repo/includes/View/TermBoxView.php
M repo/resources/wikibase.ui.entityViewInit.js
13 files changed, 512 insertions(+), 98 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/17/157817/1
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
index f9a47a5..14925e8 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
@@ -207,7 +207,8 @@
this.$fingerprints.fingerprintgroupview( {
value: value,
entityId: this.options.value.getId(),
- api: this.options.api
+ api: this.options.api,
+ helpMessage: mw.msg(
'wikibase-fingerprintgroupview-input-help-message' )
} );
},
diff --git
a/lib/resources/jquery.wikibase/jquery.wikibase.fingerprintgroupview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.fingerprintgroupview.js
index 42f252d..207a316 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.fingerprintgroupview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.fingerprintgroupview.js
@@ -21,6 +21,28 @@
* @options {string} entityId
*
* @option {wikibase.RepoApi} api
+ *
+ * @option {string} [helpMessage]
+ * Default: 'Edit label, description and aliases per
language.'
+ *
+ * @event change
+ * - {jQuery.Event}
+ *
+ * @event afterstartediting
+ * - [jQuery.Event}
+ *
+ * @event stopediting
+ * - {jQuery.Event}
+ * - {boolean} Whether to drop the value.
+ * - {Function} Callback function.
+ *
+ * @event afterstopediting
+ * - {jQuery.Event}
+ * - {boolean} Whether to drop the value.
+ *
+ * @event toggleerror
+ * - {jQuery.Event}
+ * - {Error|null}
*/
$.widget( 'wikibase.fingerprintgroupview', PARENT, {
options: {
@@ -36,8 +58,14 @@
},
value: [],
entityId: null,
- api: null
+ api: null,
+ helpMessage: 'Edit label, description and aliases per language.'
},
+
+ /**
+ * @type {boolean}
+ */
+ _isInEditMode: false,
/**
* @type {jQuery}
@@ -89,11 +117,121 @@
* Creates and initializes the fingerprintlistview widget.
*/
_createFingerprintlistview: function() {
- this.$fingerprintlistview.fingerprintlistview( {
+ var self = this,
+ prefix =
$.wikibase.fingerprintlistview.prototype.widgetEventPrefix;
+
+ this.$fingerprintlistview
+ .fingerprintlistview( {
value: this.options.value,
entityId: this.options.entityId,
api: this.options.api
- } );
+ } )
+ .on( prefix + 'change', function( event ) {
+ event.stopPropagation();
+ self._trigger( 'change' );
+ } )
+ .on( prefix + 'toggleerror.' + self.widgetName, function(
event, error ) {
+ event.stopPropagation();
+ self.setError( error );
+ } )
+ .on(
+ [
+ prefix + 'create.' + self.widgetName,
+ prefix + 'afterstartediting.' + self.widgetName,
+ prefix + 'stopediting.' + self.widgetName,
+ prefix + 'afterstopediting.' + self.widgetName,
+ prefix + 'disable.' + self.widgetName
+ ].join( ' ' ),
+ function( event ) {
+ event.stopPropagation();
+ }
+ );
+ },
+
+ /**
+ * @return {boolean}
+ */
+ isValid: function() {
+ return this.$fingerprintlistview.data( 'fingerprintlistview'
).isValid();
+ },
+
+ /**
+ * @return {boolean}
+ */
+ isInitialValue: function() {
+ return this.$fingerprintlistview.data( 'fingerprintlistview'
).isInitialValue();
+ },
+
+ startEditing: function() {
+ if( this._isInEditMode ) {
+ return;
+ }
+
+ this._isInEditMode = true;
+ this.element.addClass( 'wb-edit' );
+
+ this.$fingerprintlistview.data( 'fingerprintlistview'
).startEditing();
+
+ this._trigger( 'afterstartediting' );
+ },
+
+ /**
+ * @param {boolean} [dropValue]
+ */
+ stopEditing: function( dropValue ) {
+ var self = this;
+
+ if( !this._isInEditMode || ( !this.isValid() ||
this.isInitialValue() ) && !dropValue ) {
+ return;
+ }
+
+ dropValue = !!dropValue;
+
+ this._trigger( 'stopediting', null, [dropValue] );
+
+ this.disable();
+
+ this.$fingerprintlistview.one(
+ 'fingerprintlistviewafterstopediting',
+ function( dropValue ) {
+ self._afterStopEditing( dropValue );
+ }
+ );
+
+ this.$fingerprintlistview.data( 'fingerprintlistview'
).stopEditing( dropValue );
+ },
+
+ /**
+ * @param {boolean} dropValue
+ */
+ _afterStopEditing: function( dropValue ) {
+ this._isInEditMode = false;
+ this.enable();
+ this.element.removeClass( 'wb-edit' );
+ this._trigger( 'afterstopediting', null, [dropValue] );
+ },
+
+ cancelEditing: function() {
+ this.stopEditing( true );
+ },
+
+ focus: function() {
+ this.$fingerprintlistview.data( 'fingerprintlistview' ).focus();
+ },
+
+ /**
+ * Applies/Removes error state.
+ *
+ * @param {Error} [error]
+ */
+ setError: function( error ) {
+ if( error ) {
+ this.element.addClass( 'wb-error' );
+ this._trigger( 'toggleerror', null, [error] );
+ } else {
+ this.element.removeClass( 'wb-error' );
+ this._trigger( 'toggleerror' );
+ }
},
/**
@@ -107,4 +245,67 @@
}
} );
+$.wikibase.toolbarcontroller.definition( 'edittoolbar', {
+ id: 'fingerprintgroupview',
+ selector: ':' + $.wikibase.fingerprintgroupview.prototype.namespace
+ + '-' + $.wikibase.fingerprintgroupview.prototype.widgetName,
+ events: {
+ fingerprintgroupviewcreate: function( event, toolbarcontroller
) {
+ var $fingerprintgroupview = $( event.target ),
+ fingerprintgroupview =
$fingerprintgroupview.data( 'fingerprintgroupview' );
+
+ $fingerprintgroupview.edittoolbar( {
+ $container: $( '<div/>' )
+ .appendTo( $fingerprintgroupview.find(
+
'.wikibase-fingerprintgroupview-heading-container'
+ ) ),
+ interactionWidgetName:
$.wikibase.fingerprintgroupview.prototype.widgetName,
+ enableRemove: false
+ } );
+
+ $fingerprintgroupview.on( 'keyup', function( event ) {
+ if( fingerprintgroupview.option( 'disabled' ) )
{
+ return;
+ }
+ if( event.keyCode === $.ui.keyCode.ESCAPE ) {
+ fingerprintgroupview.stopEditing( true
);
+ } else if( event.keyCode === $.ui.keyCode.ENTER
) {
+ fingerprintgroupview.stopEditing( false
);
+ }
+ } );
+ },
+ 'fingerprintgroupviewchange
fingerprintgroupviewafterstartediting': function( event ) {
+ var $fingerprintgroupview = $( event.target ),
+ fingerprintgroupview =
$fingerprintgroupview.data( 'fingerprintgroupview' ),
+ toolbar = $fingerprintgroupview.data(
'edittoolbar' ).toolbar,
+ $btnSave = toolbar.editGroup.getButton( 'save'
),
+ btnSave = $btnSave.data( 'toolbarbutton' ),
+ enable = fingerprintgroupview.isValid() &&
!fingerprintgroupview.isInitialValue();
+
+ btnSave[enable ? 'enable' : 'disable']();
+ },
+ fingerprintgroupviewdisable: function( event ) {
+ var $fingerprintgroupview = $( event.target ),
+ fingerprintgroupview =
$fingerprintgroupview.data( 'fingerprintgroupview' ),
+ toolbar = $fingerprintgroupview.data(
'edittoolbar' ).toolbar,
+ $btnSave = toolbar.editGroup.getButton( 'save'
),
+ btnSave = $btnSave.data( 'toolbarbutton' ),
+ enable = fingerprintgroupview.isValid() &&
!fingerprintgroupview.isInitialValue();
+
+ btnSave[enable ? 'enable' : 'disable']();
+ },
+ toolbareditgroupedit: function( event, toolbarcontroller ) {
+ var $fingerprintgroupview = $( event.target ).closest(
':wikibase-edittoolbar' ),
+ fingerprintgroupview =
$fingerprintgroupview.data( 'fingerprintgroupview' );
+
+ if( !fingerprintgroupview ) {
+ return;
+ }
+
+ fingerprintgroupview.focus();
+ }
+ }
+} );
+
+
}( mediaWiki, jQuery ) );
diff --git
a/lib/resources/jquery.wikibase/jquery.wikibase.fingerprintlistview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.fingerprintlistview.js
index 46b40aa..efd13e2 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.fingerprintlistview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.fingerprintlistview.js
@@ -21,6 +21,25 @@
* @options {string} entityId
*
* @option {wikibase.RepoApi} api
+ *
+ * @event change
+ * - {jQuery.Event}
+ *
+ * @event afterstartediting
+ * - [jQuery.Event}
+ *
+ * @event stopediting
+ * - {jQuery.Event}
+ * - {boolean} Whether to drop the value.
+ * - {Function} Callback function.
+ *
+ * @event afterstopediting
+ * - {jQuery.Event}
+ * - {boolean} Whether to drop the value.
+ *
+ * @event toggleerror
+ * - {jQuery.Event}
+ * - {Error|null}
*/
$.widget( 'wikibase.fingerprintlistview', PARENT, {
options: {
@@ -33,6 +52,11 @@
entityId: null,
api: null
},
+
+ /**
+ * @type {boolean}
+ */
+ _isInEditMode: false,
/**
* @see jQuery.ui.TemplatedWidget._create
@@ -68,12 +92,37 @@
* Creates the listview widget managing the fingerprintview widgets
*/
_createListView: function() {
- var self = this;
+ var self = this,
+ listItemWidget = $.wikibase.fingerprintview,
+ prefix = listItemWidget.prototype.widgetEventPrefix;
+
+ // Fully encapsulate child widgets by suppressing their events:
+ this.element
+ .on( prefix + 'change', function( event ) {
+ event.stopPropagation();
+ self._trigger( 'change' );
+ } )
+ .on( prefix + 'toggleerror.' + self.widgetName, function(
event, error ) {
+ event.stopPropagation();
+ self.setError( error );
+ } )
+ .on(
+ [
+ prefix + 'create.' + self.widgetName,
+ prefix + 'afterstartediting.' + self.widgetName,
+ prefix + 'stopediting.' + self.widgetName,
+ prefix + 'afterstopediting.' + self.widgetName,
+ prefix + 'disable.' + self.widgetName
+ ].join( ' ' ),
+ function( event ) {
+ event.stopPropagation();
+ }
+ );
this.element
.listview( {
listItemAdapter: new
$.wikibase.listview.ListItemAdapter( {
- listItemWidget: $.wikibase.fingerprintview,
+ listItemWidget: listItemWidget,
listItemWidgetValueAccessor: 'value',
newItemOptionsFn: function( value ) {
return {
@@ -93,6 +142,157 @@
},
/**
+ * @return {boolean}
+ */
+ isValid: function() {
+ var listview = this.element.data( 'listview' ),
+ lia = listview.listItemAdapter(),
+ isValid = true;
+
+ listview.items().each( function() {
+ var fingerprintview = lia.liInstance( $( this ) );
+ if( !fingerprintview.isValid() ) {
+ isValid = false;
+ return false;
+ }
+ } );
+
+ return isValid;
+ },
+
+ /**
+ * @return {boolean}
+ */
+ isInitialValue: function() {
+ var listview = this.element.data( 'listview' ),
+ lia = listview.listItemAdapter(),
+ currentValue = [];
+
+ listview.items().each( function() {
+ var fingerprintview = lia.liInstance( $( this ) );
+ currentValue.push( fingerprintview.value() );
+ } );
+
+ if( currentValue.length !== this.options.value.length ) {
+ return false;
+ }
+
+ // TODO: Implement and use Fingerprint in DataModelJavaScript
component
+ for( var i = 0; i < currentValue.length; i++ ) {
+ if(
+ currentValue[i].language !==
this.options.value[i].language
+ || currentValue[i].label !==
this.options.value[i].label
+ || currentValue[i].description !==
this.options.value[i].description
+ || currentValue[i].aliases.length !==
this.options.value[i].aliases.length
+ ) {
+ return false;
+ }
+
+ var currentAliases = currentValue[i].aliases;
+
+ for( var j = 0; j < currentAliases.length; j++ ) {
+ if( $.inArray( currentAliases[j],
this.options.value[i].aliases ) === -1 ) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ },
+
+ startEditing: function() {
+ if( this._isInEditMode ) {
+ return;
+ }
+
+ this._isInEditMode = true;
+ this.element.addClass( 'wb-edit' );
+
+ var listview = this.element.data( 'listview' ),
+ lia = listview.listItemAdapter();
+
+ listview.items().each( function() {
+ var fingerprintview = lia.liInstance( $( this ) );
+ fingerprintview.startEditing();
+ } );
+
+ this._trigger( 'afterstartediting' );
+ },
+
+ /**
+ * @param {boolean} [dropValue]
+ */
+ stopEditing: function( dropValue ) {
+ var self = this;
+
+ if( !this._isInEditMode || ( !this.isValid() ||
this.isInitialValue() ) && !dropValue ) {
+ return;
+ }
+
+ dropValue = !!dropValue;
+
+ this._trigger( 'stopediting', null, [dropValue] );
+
+ this.disable();
+
+ var listview = this.element.data( 'listview' ),
+ lia = listview.listItemAdapter(),
+ expectedEvents = listview.items().length;
+
+ this.element
+ .on( 'fingerprintviewafterstopediting.fingerprintlistview',
function() {
+ if( --expectedEvents === 0 ) {
+ self.element.off(
'fingerprintviewafterstopediting.fingerprintlistview' );
+ self._afterStopEditing( dropValue );
+ }
+ } );
+
+ listview.items().each( function() {
+ var fingerprintview = lia.liInstance( $( this ) );
+ fingerprintview.stopEditing( dropValue ||
fingerprintview.isInitialValue() );
+ } );
+ },
+
+ /**
+ * @param {boolean} dropValue
+ */
+ _afterStopEditing: function( dropValue ) {
+ this._isInEditMode = false;
+ this.enable();
+ this.element.removeClass( 'wb-edit' );
+ this._trigger( 'afterstopediting', null, [dropValue] );
+ },
+
+ cancelEditing: function() {
+ this.stopEditing( true );
+ },
+
+ focus: function() {
+ var listview = this.element.data( 'listview' ),
+ lia = listview.listItemAdapter(),
+ $items = listview.items();
+
+ if( $items.length ) {
+ lia.liInstance( $items.first() ).focus();
+ }
+ },
+
+ /**
+ * Applies/Removes error state.
+ *
+ * @param {Error} [error]
+ */
+ setError: function( error ) {
+ if( error ) {
+ this.element.addClass( 'wb-error' );
+ this._trigger( 'toggleerror', null, [error] );
+ } else {
+ this.element.removeClass( 'wb-error' );
+ this._trigger( 'toggleerror' );
+ }
+ },
+
+ /**
* @see jQuery.ui.TemplatedWidget._setOption
*/
_setOption: function( key, value ) {
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.fingerprintview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.fingerprintview.js
index 9b7df54..532dd53 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.fingerprintview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.fingerprintview.js
@@ -66,13 +66,10 @@
},
'', // additional label CSS classes
'', // label
- '', // label toolbar
'', // additional description CSS classes
'', // description
- '', // description toolbar
'', // additional aliases CSS classes
- '', // aliases
- '' // aliases toolbar
+ '' // aliases
],
templateShortCuts: {
$language: '.wikibase-fingerprintview-language',
@@ -373,56 +370,6 @@
}
}
-} );
-
-$.wikibase.toolbarcontroller.definition( 'edittoolbar', {
- id: 'fingerprintview',
- selector: ':' + $.wikibase.fingerprintview.prototype.namespace
- + '-' + $.wikibase.fingerprintview.prototype.widgetName,
- events: {
- fingerprintviewcreate: function( event, toolbarcontroller ) {
- var $fingerprintview = $( event.target ),
- fingerprintview = $fingerprintview.data(
'fingerprintview' );
-
- $fingerprintview.edittoolbar( {
- $container: $( '<td rowspan="3" />' )
- .appendTo( $fingerprintview.children(
'tr' ).first() ),
- interactionWidgetName:
$.wikibase.fingerprintview.prototype.widgetName,
- enableRemove: false
- } );
-
- $fingerprintview.on( 'keyup', function( event ) {
- if( fingerprintview.option( 'disabled' ) ) {
- return;
- }
- if( event.keyCode === $.ui.keyCode.ESCAPE ) {
- fingerprintview.stopEditing( true );
- } else if( event.keyCode === $.ui.keyCode.ENTER
) {
- fingerprintview.stopEditing( false );
- }
- } );
- },
- 'fingerprintviewchange fingerprintviewafterstartediting':
function( event ) {
- var $fingerprintview = $( event.target ),
- fingerprintview = $fingerprintview.data(
'fingerprintview' ),
- toolbar = $fingerprintview.data( 'edittoolbar'
).toolbar,
- $btnSave = toolbar.editGroup.getButton( 'save'
),
- btnSave = $btnSave.data( 'toolbarbutton' ),
- enable = fingerprintview.isValid() &&
!fingerprintview.isInitialValue();
-
- btnSave[enable ? 'enable' : 'disable']();
- },
- toolbareditgroupedit: function( event, toolbarcontroller ) {
- var $fingerprintview = $( event.target ).closest(
':wikibase-edittoolbar' ),
- fingerprintview = $fingerprintview.data(
'fingerprintview' );
-
- if( !fingerprintview ) {
- return;
- }
-
- fingerprintview.focus();
- }
- }
} );
}( mediaWiki, wikibase, jQuery ) );
diff --git a/lib/resources/jquery.wikibase/resources.php
b/lib/resources/jquery.wikibase/resources.php
index 82195f8..2e99f38 100644
--- a/lib/resources/jquery.wikibase/resources.php
+++ b/lib/resources/jquery.wikibase/resources.php
@@ -164,6 +164,7 @@
'wikibase.templates',
),
'messages' => array(
+
'wikibase-fingerprintgroupview-input-help-message',
'wikibase-terms',
),
),
diff --git
a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.fingerprintgroupview.css
b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.fingerprintgroupview.css
index 1da23c8..3cdf35d 100644
---
a/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.fingerprintgroupview.css
+++
b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.fingerprintgroupview.css
@@ -4,6 +4,7 @@
*/
.wikibase-fingerprintgroupview {
float: left;
+ width: 100%;
}
.wikibase-fingerprintgroupview h2 {
@@ -11,4 +12,14 @@
margin-bottom: 0.2em;
padding-left: 10px;
border-bottom: none;
+ width: auto;
+}
+
+.wikibase-fingerprintgroupview
.wikibase-fingerprintgroupview-heading-container {
+ position: relative;
+}
+
+.wikibase-fingerprintgroupview
.wikibase-fingerprintgroupview-heading-container .wb-editsection {
+ float: right;
+ margin-top: 1.9em;
}
diff --git a/lib/resources/templates.php b/lib/resources/templates.php
index c4c352e..63f063b 100644
--- a/lib/resources/templates.php
+++ b/lib/resources/templates.php
@@ -249,7 +249,10 @@
$templates['wikibase-fingerprintgroupview'] =
<<<HTML
<div class="wikibase-fingerprintgroupview">
- <h2 id="wb-terms" class="wb-section-heading
wikibase-fingerprintgroupview-heading">$1</h2>
+ <div class="wikibase-fingerprintgroupview-heading-container">
+ <h2 id="wb-terms" class="wb-section-heading
wikibase-fingerprintgroupview-heading">$1</h2>
+ <!-- wb-editsection -->$3
+ </div>
<!-- wikibase-fingerprintlistview -->$2
</div>
HTML;
@@ -260,7 +263,6 @@
<colgroup>
<col class="wikibase-fingerprintlistview-language" />
<col class="wikibase-fingerprintlistview-label
wikibase-fingerprintlistview-description wikibase-fingerprintlistview-aliases"
/>
- <col class="wb-editsection" />
</colgroup>
<!-- [0,*] wikibase-fingerprintview -->$1
</table>
@@ -272,15 +274,12 @@
<tr>
<td class="wikibase-fingerprintview-language" rowspan="3"><a
href="$2">$3</a></td>
<td class="wikibase-fingerprintview-label $4">$5</td>
- <!-- wb-edisection -->$6
</tr>
<tr>
- <td class="wikibase-fingerprintview-description $7">$8</td>
- <!-- wb-editsection -->$9
+ <td class="wikibase-fingerprintview-description $6">$7</td>
</tr>
<tr>
- <td class="wikibase-fingerprintview-aliases $10">$11</td>
- <!-- wb-editsection -->$12
+ <td class="wikibase-fingerprintview-aliases $8">$9</td>
</tr>
</tbody>
HTML;
diff --git
a/lib/tests/qunit/jquery.wikibase/jquery.wikibase.fingerprintgroupview.tests.js
b/lib/tests/qunit/jquery.wikibase/jquery.wikibase.fingerprintgroupview.tests.js
index 86ffe90..8c23677 100644
---
a/lib/tests/qunit/jquery.wikibase/jquery.wikibase.fingerprintgroupview.tests.js
+++
b/lib/tests/qunit/jquery.wikibase/jquery.wikibase.fingerprintgroupview.tests.js
@@ -71,4 +71,19 @@
);
} );
+QUnit.test( 'setError()', function( assert ) {
+ var $fingerprintgroupview = createFingerprintgroupview(),
+ fingerprintgroupview = $fingerprintgroupview.data(
'fingerprintgroupview' );
+
+ $fingerprintgroupview
+ .on( 'fingerprintgroupviewtoggleerror', function( event, error ) {
+ assert.ok(
+ true,
+ 'Triggered "toggleerror" event.'
+ );
+ } );
+
+ fingerprintgroupview.setError();
+} );
+
}( jQuery, QUnit ) );
diff --git
a/lib/tests/qunit/jquery.wikibase/jquery.wikibase.fingerprintlistview.tests.js
b/lib/tests/qunit/jquery.wikibase/jquery.wikibase.fingerprintlistview.tests.js
index 28fd6c8..2b3c718 100644
---
a/lib/tests/qunit/jquery.wikibase/jquery.wikibase.fingerprintlistview.tests.js
+++
b/lib/tests/qunit/jquery.wikibase/jquery.wikibase.fingerprintlistview.tests.js
@@ -17,11 +17,13 @@
{
language: 'de',
label: 'de-label',
- description: 'de-description'
+ description: 'de-description',
+ aliases: []
}, {
language: 'en',
label: 'en-label',
- description: 'en-description'
+ description: 'en-description',
+ aliases: []
}
]
}, options || {} );
@@ -71,4 +73,56 @@
);
} );
+QUnit.test( 'isInitialValue()', function( assert ) {
+ var $fingerprintlistview = createFingerprintlistview(),
+ fingerprintlistview = $fingerprintlistview.data(
'fingerprintlistview' );
+
+ fingerprintlistview.startEditing();
+
+ assert.ok(
+ fingerprintlistview.isInitialValue(),
+ 'Verified isInitialValue() returning true.'
+ );
+
+ var $item = $fingerprintlistview.data( 'listview' ).addItem( {
+ language: 'fa',
+ label: 'fa-label',
+ description: 'fa-description',
+ aliases: []
+ } );
+
+ assert.ok(
+ !fingerprintlistview.isInitialValue(),
+ 'Verified isInitialValue() returning false after changing
value.'
+ );
+
+ $fingerprintlistview.data( 'listview' ).removeItem( $item );
+
+ assert.ok(
+ fingerprintlistview.isInitialValue(),
+ 'Verified isInitialValue() returning true after resetting to
initial value.'
+ );
+} );
+
+// TODO: Add test which is kind of pointless without having a method to save a
whole fingerprint
+// which could be overwritten by the test mechanism. Instead, the "save"
functions of labelview,
+// descriptionview and aliasesview for each single fingerprintview would need
to be overwritten
+// (see fingerprintview tests).
+// QUnit.test( 'startEditing() & stopEditing()', function( assert ) {} );
+
+QUnit.test( 'setError()', function( assert ) {
+ var $fingerprintlistview = createFingerprintlistview(),
+ fingerprintlistview = $fingerprintlistview.data(
'fingerprintlistview' );
+
+ $fingerprintlistview
+ .on( 'fingerprintlistviewtoggleerror', function( event, error ) {
+ assert.ok(
+ true,
+ 'Triggered "toggleerror" event.'
+ );
+ } );
+
+ fingerprintlistview.setError();
+} );
+
}( jQuery, QUnit ) );
diff --git a/repo/i18n/en.json b/repo/i18n/en.json
index c4ec5a5..337841e 100644
--- a/repo/i18n/en.json
+++ b/repo/i18n/en.json
@@ -33,6 +33,7 @@
"wikibase-alias-edit-placeholder": "enter an alias",
"wikibase-label-input-help-message": "Enter the label of this entity in
$1.",
"wikibase-description-input-help-message": "Enter a short description
for this entity in $1.",
+ "wikibase-fingerprintgroupview-input-help-message": "Enter label of
this entity, a short description and aliases per language.",
"wikibase-fingerprintview-input-help-message": "Enter the label of this
entity, a short description and aliases in $1",
"wikibase-claims": "Claims",
"wikibase-statements": "Statements",
diff --git a/repo/i18n/qqq.json b/repo/i18n/qqq.json
index a0df14f..113e248 100644
--- a/repo/i18n/qqq.json
+++ b/repo/i18n/qqq.json
@@ -56,9 +56,10 @@
"wikibase-sitelink-site-edit-placeholder": "[[File:Screenshot
WikidataRepo 2012-05-13 E.png|right|0x150px]]\nThis is a generic text used as a
placeholder while defining the site for a new sitelink. See also Wikidatas
glossary on [[d:Wikidata:Glossary#sitelink|sitelink]].\n{{Identical|Site}}",
"wikibase-sitelink-page-edit-placeholder": "[[File:Screenshot
WikidataRepo 2012-05-13 E.png|right|0x150px]]\nThis is a generic text used as a
placeholder while defining the page for a possibly new sitelink. See also
Wikidatas glossary on
[[d:Wikidata:Glossary#sitelink|sitelink]].\n{{Identical|Page}}",
"wikibase-alias-edit-placeholder": "This is a generic placeholder
message used while editing the list of aliases of an item. It is displayed in
an empty input box which can be used to define a new alias.",
- "wikibase-label-input-help-message": "[[File:Screenshot WikidataRepo
2012-05-13 I.png|right|0x150px]]\nBubble help message for entering the label of
the data set used for a specific item. Takes on additional argument ($1) that
is the language name, i.e. \"English\" in nominative singular form. See also
Wikidatas glossary for [[d:Wikidata:Glossary#Label|label]] and
[[d:Wikidata:Glossary#Item|item]].\n\nParameters:\n* $1 - language
name\n{{Related|Wikibase-input-help-message}}",
- "wikibase-description-input-help-message": "[[File:Screenshot
WikidataRepo 2012-05-13 H.png|right|0x150px]]\nBubble help message for entering
the description of the data set used for a specific item. Takes on additional
argument that is the language name, i.e. \"English\" in nominative singular
form. See also Wikidatas glossary for
[[d:Wikidata:Glossary#Description|description]] and
[[d:Wikidata:Glossary#Item|item]].\n\nParameters:\n* $1 - language
name\n{{Related|Wikibase-input-help-message}}",
- "wikibase-fingerprintview-input-help-message": "Bubble help message for
simultaneously editing label, description and aliases of the entity in another
than the user interface language via the \"In other languages\" box. Takes on
additional argument that is the language name, i.e. \"English\" in nominative
singular form. See also Wikidatas glossary for
[[d:Wikidata:Glossary#Language_attributes|language attributes]] and
[[d:Wikidata:Glossary#Item|item]].\n\nParameters:\n* $1 - language
name\n{{Related|Wikibase-input-help-message}}",
+ "wikibase-label-input-help-message": "[[File:Screenshot WikidataRepo
2012-05-13 I.png|right|0x150px]]\nBubble help message for entering the label of
the data set used for a specific item. Takes on additional argument ($1) that
is the language name, i.e. \"English\" in nominative singular form. See also
Wikidata's glossary for [[d:Wikidata:Glossary#Label|label]] and
[[d:Wikidata:Glossary#Item|item]].\n\nParameters:\n* $1 - language
name\n{{Related|Wikibase-input-help-message}}",
+ "wikibase-description-input-help-message": "[[File:Screenshot
WikidataRepo 2012-05-13 H.png|right|0x150px]]\nBubble help message for entering
the description of the data set used for a specific item. Takes on additional
argument that is the language name, i.e. \"English\" in nominative singular
form. See also Wikidata's glossary for
[[d:Wikidata:Glossary#Description|description]] and
[[d:Wikidata:Glossary#Item|item]].\n\nParameters:\n* $1 - language
name\n{{Related|Wikibase-input-help-message}}",
+ "wikibase-fingerprintgroupview-input-help-message": "Bubble help
message for simultaneously editing label, description and aliases of the entity
in multiple languages via the \"In other languages\" box. See also Wikidata's
glossary for [[d:Wikidata:Glossary#Language_attributes|language attributes]]
and
[[d:Wikidata:Glossary#Item|item]].\n\n{{Related|Wikibase-input-help-message}}",
+ "wikibase-fingerprintview-input-help-message": "Bubble help message for
simultaneously editing label, description and aliases of the entity in another
than the user interface language via the \"In other languages\" box. Takes on
additional argument that is the language name, i.e. \"English\" in nominative
singular form. See also Wikidata's glossary for
[[d:Wikidata:Glossary#Language_attributes|language attributes]] and
[[d:Wikidata:Glossary#Item|item]].\n\nParameters:\n* $1 - language
name\n{{Related|Wikibase-input-help-message}}",
"wikibase-claims": "Heading for the list of claims giving specific
information about the currently viewed entity. See also Wikidata's glossary for
[[m:d:Wikidata:Glossary#Claim|claim]].",
"wikibase-statements": "Heading for the list of statements giving
specific information about the currently viewed item. See also Wikidata's
glossary for [[m:d:Wikidata:Glossary#Statement|statements]] and
[[m:d:Wikidata:Glossary#Item|item]].",
"wikibase-attributes": "Heading for the list of claims defining
attributes for the currently viewed property. See also Wikidata's glossary for
[[m:d:Wikidata:Glossary#Claims|claims]] and
[[m:d:Wikidata:Glossary#Property|property]].\n{{Identical|Attribute}}",
diff --git a/repo/includes/View/TermBoxView.php
b/repo/includes/View/TermBoxView.php
index db3c8fc..fd49105 100644
--- a/repo/includes/View/TermBoxView.php
+++ b/repo/includes/View/TermBoxView.php
@@ -64,7 +64,6 @@
wfProfileIn( __METHOD__ );
- $entityId = $entity->getId()->getSerialization();
$fingerprint = $entity->getFingerprint();
$labels = $fingerprint->getLabels();
$descriptions = $fingerprint->getDescriptions();
@@ -76,25 +75,6 @@
$hasLabel = $labels->hasTermForLanguage( $languageCode
);
$hasDescription = $descriptions->hasTermForLanguage(
$languageCode );
- $editLabelSection =
$this->sectionEditLinkGenerator->getHtmlForEditSection(
- 'SetLabel',
- array( $entityId, $languageCode ),
- $this->msg( 'wikibase-edit' ),
- $editable
- );
- $editDescriptionSection =
$this->sectionEditLinkGenerator->getHtmlForEditSection(
- 'SetDescription',
- array( $entityId, $languageCode ),
- $this->msg( 'wikibase-edit' ),
- $editable
- );
- $editAliasesSection =
$this->sectionEditLinkGenerator->getHtmlForEditSection(
- 'SetAliases',
- array( $entityId, $languageCode ),
- $this->msg( 'wikibase-edit' ),
- $editable
- );
-
$tbody .= wfTemplate( 'wikibase-fingerprintview',
$languageCode,
$title->getLocalURL( array( 'setlang' =>
$languageCode ) ),
@@ -104,22 +84,25 @@
? $labels->getByLanguage( $languageCode
)->getText()
: $this->msg( 'wikibase-label-empty'
)->text()
),
- '<td>' . $editLabelSection . '</td>',
$hasDescription ? '' : 'wb-empty',
htmlspecialchars( $hasDescription
? $descriptions->getByLanguage(
$languageCode )->getText()
: $this->msg(
'wikibase-description-empty' )->text()
),
- '<td>' . $editDescriptionSection . '</td>',
$aliasGroups->hasGroupForLanguage(
$languageCode ) ? '' : 'wb-empty',
- $this->getHtmlForAliases( $aliasGroups,
$languageCode ),
- '<td>' . $editAliasesSection . '</td>'
+ $this->getHtmlForAliases( $aliasGroups,
$languageCode )
);
}
$html = wfTemplate( 'wikibase-fingerprintgroupview',
$this->msg( 'wikibase-terms' ),
- wfTemplate( 'wikibase-fingerprintlistview', $tbody )
+ wfTemplate( 'wikibase-fingerprintlistview', $tbody ),
+ $this->sectionEditLinkGenerator->getHtmlForEditSection(
+ 'SpecialPages',
+ array(),
+ $this->msg( 'wikibase-edit' ),
+ $editable
+ )
);
wfProfileOut( __METHOD__ );
diff --git a/repo/resources/wikibase.ui.entityViewInit.js
b/repo/resources/wikibase.ui.entityViewInit.js
index f0689a7..058d600 100644
--- a/repo/resources/wikibase.ui.entityViewInit.js
+++ b/repo/resources/wikibase.ui.entityViewInit.js
@@ -50,7 +50,7 @@
'claimview',
'descriptionview',
'labelview',
- 'fingerprintview',
+ 'fingerprintgroupview',
'referenceview',
'sitelinkview'
],
--
To view, visit https://gerrit.wikimedia.org/r/157817
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I19c1bbda6a06b8b2147c266540b63a7f6de195d1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits