Henning Snater has uploaded a new change for review.

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

Change subject: statementview: Allow adding qualifiers when adding a statement
......................................................................

statementview: Allow adding qualifiers when adding a statement

Change-Id: I015b3022570180a3e9d8d9a4fde6aada6bd4d4d5
---
M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js
M lib/resources/wikibase.css
2 files changed, 14 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/36/189936/1

diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js 
b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js
index 1814258..17dad73 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js
@@ -139,17 +139,6 @@
        _qualifiers: null,
 
        /**
-        * Caches the `SnakList` of the qualifiers the `statementview` has been 
initialized with. The
-        * qualifiers are split into groups featuring the same `Property`. 
Removing one of those groups
-        * results in losing the reference to those qualifiers. Therefore, 
`_initialQualifiers` is used
-        * to rebuild the list of qualifiers when cancelling and is used to 
query whether the qualifiers
-        * represent the initial state.
-        * @property {wikibase.datamodel.SnakList}
-        * @private
-        */
-       _initialQualifiers: null,
-
-       /**
         * @property {wikibase.entityChangers.ReferencesChanger}
         * @private
         */
@@ -174,10 +163,6 @@
                }
 
                PARENT.prototype._create.call( this );
-
-               this._initialQualifiers = this.options.value
-                       ? this.options.value.getClaim().getQualifiers()
-                       : new wb.datamodel.SnakList();
 
                this._referencesChanger = 
this.options.entityChangersFactory.getReferencesChanger();
 
@@ -488,11 +473,13 @@
                                : this.option( 'predefined' ).mainSnak || null
                );
 
-               // TODO: Allow adding qualifiers when adding a new statement.
-               if( this.options.value && ( this.isInEditMode() || 
this._initialQualifiers.length ) ) {
-                       this._createQualifiersListview( 
this.options.value.getClaim().getQualifiers() );
+               if( this.isInEditMode() ) {
+                       this._createQualifiersListview(
+                               this.options.value
+                                       ? 
this.options.value.getClaim().getQualifiers()
+                                       : new wb.datamodel.SnakList()
+                       );
                }
-
                this._createReferences( this.options.value );
 
                return $.Deferred().resolve().promise();
@@ -520,7 +507,7 @@
                                }
                        }
 
-                       if( !qualifiers.equals( this._initialQualifiers ) ) {
+                       if( !qualifiers.equals( 
this.options.value.getClaim().getQualifiers().length ) ) {
                                return false;
                        }
                }
@@ -703,11 +690,6 @@
                if( this._qualifiers ) {
                        snaklistviews = this._qualifiers.value();
 
-                       if( !dropValue ) {
-                               // When saving the qualifier snaks, reset the 
initial qualifiers to the new ones.
-                               this._initialQualifiers = new 
wb.datamodel.SnakList();
-                       }
-
                        if( snaklistviews.length ) {
                                for( i = 0; i < snaklistviews.length; i++ ) {
                                        snaklistviews[i].stopEditing( dropValue 
);
@@ -716,10 +698,6 @@
                                                // Remove snaklistview from 
qualifier listview if no snakviews are left in
                                                // that snaklistview:
                                                this._qualifiers.removeItem( 
snaklistviews[i].element );
-                                       } else if ( !dropValue ) {
-                                               // Gather all the current snaks 
in a single SnakList to set to reset the
-                                               // initial qualifiers:
-                                               this._initialQualifiers.merge( 
snaklistviews[i].value() );
                                        }
                                }
                        }
@@ -730,9 +708,11 @@
                // the "add qualifier" toolbar.
                this._destroyQualifiersListView();
 
-               if( this._initialQualifiers.length > 0 ) {
+               var qualifiers = this.options.value ? 
this.options.value.getClaim().getQualifiers() : [];
+
+               if( qualifiers.length > 0 ) {
                        // Refill the qualifier listview with the initial (or 
new initial) qualifiers:
-                       this._createQualifiersListview( this._initialQualifiers 
);
+                       this._createQualifiersListview( qualifiers );
                }
        },
 
diff --git a/lib/resources/wikibase.css b/lib/resources/wikibase.css
index 1b38612..73cf12f 100644
--- a/lib/resources/wikibase.css
+++ b/lib/resources/wikibase.css
@@ -321,18 +321,18 @@
        margin: 0 18em 0 15em;
 }
 
-.wikibase-statementgrouplistview .wb-new .wikibase-snakview-property {
+.wikibase-statementgrouplistview .wb-new .wikibase-statementview-mainsnak 
.wikibase-snakview-property {
        padding: 10px;
 }
 
-.wikibase-statementgrouplistview .wb-new .wikibase-snakview-property input {
+.wikibase-statementgrouplistview .wb-new .wikibase-statementview-mainsnak 
.wikibase-snakview-property input {
        width: 100%;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
 }
 
-.wikibase-statementgrouplistview .wb-new .wikibase-snakview-value {
+.wikibase-statementgrouplistview .wb-new .wikibase-statementview-mainsnak 
.wikibase-snakview-value {
        min-height: 1.5em;
        max-width: 32em;
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I015b3022570180a3e9d8d9a4fde6aada6bd4d4d5
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

Reply via email to