Henning Snater has uploaded a new change for review.

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


Change subject: (bug 45673) Removing toolbar node from claimlistview template
......................................................................

(bug 45673) Removing toolbar node from claimlistview template

The toolbar node is generated programmatically by the "add" toolbar widget now.
This change set also gives the claimlist(view) template a proper name.

Change-Id: I7a365522cd4f5f5bc7888dd7dac5c65f7620b0bd
---
M lib/resources/jquery.wikibase/jquery.wikibase.addtoolbar.js
M lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js
M lib/resources/templates.php
M lib/resources/wikibase.css
M repo/includes/EntityView.php
M selenium/lib/modules/entity_selector_module.rb
M selenium/lib/modules/reference_module.rb
M selenium/lib/modules/statement_module.rb
8 files changed, 21 insertions(+), 24 deletions(-)


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

diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.addtoolbar.js 
b/lib/resources/jquery.wikibase/jquery.wikibase.addtoolbar.js
index e8592a8..9fc3894 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.addtoolbar.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.addtoolbar.js
@@ -16,8 +16,9 @@
         * The widget the toolbar shall interact with has to have implemented 
certain methods listed in
         * the _requiredMethods attribute.
         *
-        * @option toolbarParentSelector {string} (REQUIRED) jQuery selector to 
find the node the actual
-        *         toolbar buttons shall be appended to.
+        * @option toolbarParentSelector {string} jQuery selector to find the 
node the actual toolbar
+        *         buttons shall be appended to. If omitted, the DOM structure 
required for the toolbar
+        *         will be created and appended to the node the toolbar is 
initialized on.
         *
         * @option interactionWidgetName {string} Name of the widget the 
toolbar shall interact with.
         *         (That widget needs to be initialized on the same DOM node 
this toolbar is initialized
@@ -91,11 +92,9 @@
                _create: function() {
                        var self = this;
 
-                       if ( !this.options.toolbarParentSelector ) {
-                               throw new Error( 'jquery.wikibase.addtoolbar: 
Missing toolbar parent selector' );
-                       }
-
-                       this.$toolbarParent = this.element.find( 
this.options.toolbarParentSelector );
+                       this.$toolbarParent = ( 
this.options.toolbarParentSelector )
+                               ? this.element.find( 
this.options.toolbarParentSelector )
+                               : mw.template( 'wb-toolbar', '' ).appendTo( 
this.element );
 
                        this.toolbar = new wb.ui.Toolbar();
                        this.toolbar.innerGroup = new wb.ui.Toolbar.Group();
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js 
b/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js
index 74c8eab..69e5a1f 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimlistview.js
@@ -43,7 +43,7 @@
         * @see jQuery.Widget.options
         */
        options: {
-               template: 'wb-claims-section',
+               template: 'wb-claimlist',
                templateParams: [
                        '',
                        ''
@@ -460,8 +460,7 @@
                prototype: widgetPrototype
        },
        options: {
-               interactionWidgetName: widgetPrototype.widgetName,
-               toolbarParentSelector: '.wb-claims-toolbar'
+               interactionWidgetName: widgetPrototype.widgetName
        }
 } );
 
diff --git a/lib/resources/templates.php b/lib/resources/templates.php
index e376e07..c123bbe 100644
--- a/lib/resources/templates.php
+++ b/lib/resources/templates.php
@@ -44,14 +44,12 @@
 <h2 class="wb-section-heading" dir="auto">$1</h2>
 HTML;
 
-       // TODO: rename this to 'wb-claimlist' or 'wb-claims' (in which case 
the widget should also be renamed)
-       $templates['wb-claims-section'] =
+       $templates['wb-claimlist'] =
 <<<HTML
-<div class="wb-claims-section">
+<div class="wb-claimlist">
        <div class="wb-claims">
                $1 <!-- [0,*] wb-claim-section -->
        </div>
-       <div class="wb-claims-toolbar">$2</div> <!-- edit section -->
 </div>
 HTML;
 
diff --git a/lib/resources/wikibase.css b/lib/resources/wikibase.css
index a5c2cc8..2e2f99b 100644
--- a/lib/resources/wikibase.css
+++ b/lib/resources/wikibase.css
@@ -495,7 +495,10 @@
 }
 
 /* General add new claim link */
-div.wb-claims-section div.wb-editsection {
+div.wb-claimlist > span.wb-ui-toolbar {
+       display: block;
+}
+div.wb-claimlist div.wb-editsection {
        position: static;
        float: right;
 }
diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php
index f5cd48b..2d0e403 100644
--- a/repo/includes/EntityView.php
+++ b/repo/includes/EntityView.php
@@ -531,10 +531,8 @@
 
                }
 
-               $html = $html . wfTemplate( 'wb-claims-section',
-                       $claimsHtml,
-                       $this->getHtmlForEditSection( $entity, $lang, '', 
'div', 'add' ) // TODO: add link to SpecialPage
-               );
+               // TODO: Add link to SpecialPage that allows adding a new claim.
+               $html = $html . wfTemplate( 'wb-claimlist', $claimsHtml );
 
                wfProfileOut( __METHOD__ );
                return $html;
diff --git a/selenium/lib/modules/entity_selector_module.rb 
b/selenium/lib/modules/entity_selector_module.rb
index 84376c9..8be78fb 100644
--- a/selenium/lib/modules/entity_selector_module.rb
+++ b/selenium/lib/modules/entity_selector_module.rb
@@ -13,8 +13,8 @@
   link(:firstEntitySelectorLink, :xpath => "//ul[contains(@class, 
'ui-entityselector-list')]/li/a")
   span(:firstEntitySelectorLabel, :xpath => "//ul[contains(@class, 
'ui-entityselector-list')]/li/a/span/span[contains(@class, 
'ui-entityselector-label')]")
   span(:firstEntitySelectorDescription, :xpath => "//ul[contains(@class, 
'ui-entityselector-list')]/li/a/span/span[contains(@class, 
'ui-entityselector-description')]")
-  text_field(:entitySelectorInput, :xpath => "//div[contains(@class, 
'wb-claims-section')]//input[contains(@class, 'ui-entityselector-input')]", 
:index => 0)
-  text_field(:entitySelectorInput2, :xpath => "//div[contains(@class, 
'wb-claims-section')]//input[contains(@class, 'ui-entityselector-input')]", 
:index => 1)
+  text_field(:entitySelectorInput, :xpath => "//div[contains(@class, 
'wb-claimlist')]//input[contains(@class, 'ui-entityselector-input')]", :index 
=> 0)
+  text_field(:entitySelectorInput2, :xpath => "//div[contains(@class, 
'wb-claimlist')]//input[contains(@class, 'ui-entityselector-input')]", :index 
=> 1)
 
   def wait_for_entity_selector_list
     wait_until do
diff --git a/selenium/lib/modules/reference_module.rb 
b/selenium/lib/modules/reference_module.rb
index f49f141..ce9dccb 100644
--- a/selenium/lib/modules/reference_module.rb
+++ b/selenium/lib/modules/reference_module.rb
@@ -28,8 +28,8 @@
   link(:reference1ValueLink2, :xpath => "//div[contains(@class, 
'wb-referenceview')][1]/div[contains(@class, 
'wb-listview')]/div[contains(@class, 'wb-snakview')][2]/div[contains(@class, 
'wb-snak-value-container')]/div[contains(@class, 'wb-snak-value')]/div/div/a")
   # TODO: could this lead to problems? for CM & item type properties there is 
an additional "a" element around the textbox; this is not the case for string 
type properies
   #text_area(:referenceValueInput, :xpath => "//div[contains(@class, 
'valueview-ineditmode')]/div/a/textarea[contains(@class, 'valueview-input')]")
-  text_area(:referenceValueInput, :xpath => "//div[contains(@class, 
'wb-claims-section')]//textarea[contains(@class, 'valueview-input')]", :index 
=> 0)
-  text_area(:referenceValueInput2, :xpath => "//div[contains(@class, 
'wb-claims-section')]//textarea[contains(@class, 'valueview-input')]", :index 
=> 1)
+  text_area(:referenceValueInput, :xpath => "//div[contains(@class, 
'wb-claimlist')]//textarea[contains(@class, 'valueview-input')]", :index => 0)
+  text_area(:referenceValueInput2, :xpath => "//div[contains(@class, 
'wb-claimlist')]//textarea[contains(@class, 'valueview-input')]", :index => 1)
   link(:saveReference, :xpath => "//div[contains(@class, 
'wb-referenceview')]/div[contains(@class, 
'wb-snaklistview-heading')]/div/span/span/span[contains(@class, 
'wb-ui-toolbar-editgroup-ineditmode')]/span/a[text()='save']")
   link(:cancelReference, :xpath => "//div[contains(@class, 
'wb-referenceview')]/div[contains(@class, 
'wb-snaklistview-heading')]/div/span/span/span[contains(@class, 
'wb-ui-toolbar-editgroup-ineditmode')]/span/a[text()='cancel']")
   link(:removeReference, :xpath => "//div[contains(@class, 
'wb-referenceview')]/div[contains(@class, 
'wb-snaklistview-heading')]/div/span/span/span[contains(@class, 
'wb-ui-toolbar-editgroup-ineditmode')]/span/a[text()='remove']")
diff --git a/selenium/lib/modules/statement_module.rb 
b/selenium/lib/modules/statement_module.rb
index 22752d8..231023f 100644
--- a/selenium/lib/modules/statement_module.rb
+++ b/selenium/lib/modules/statement_module.rb
@@ -11,7 +11,7 @@
   include EntitySelectorPage
   include ReferencePage
   # statements UI elements
-  link(:addStatement, :xpath => "//div[contains(@class, 
'wb-claims-toolbar')]/div/span/span/a")
+  link(:addStatement, :xpath => "//div[contains(@class, 
'wb-claimlist')]/span[contains(@class, 'wb-ui-toolbar')]/div/span/span/a")
   link(:addClaimToFirstStatement, :xpath => "//div[contains(@class, 
'wb-claim-section')][1]/div[contains(@class, 
'wb-claim-add')]/div[contains(@class, 'wb-claim-toolbar')]/div/span/span/a")
   link(:editFirstStatement, :xpath => "//div[contains(@class, 
'wb-claim-toolbar')]/span/span/span[contains(@class, 
'wb-ui-toolbar-editgroup-innoneditmode')]/span/a")
   link(:saveStatement, :xpath => "//div[contains(@class, 
'wb-claim-toolbar')]/span/span/span[contains(@class, 
'wb-ui-toolbar-editgroup-ineditmode')]/span/a[text()='save']")

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a365522cd4f5f5bc7888dd7dac5c65f7620b0bd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <henning.sna...@wikimedia.de>

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

Reply via email to