Mooeypoo has uploaded a new change for review.

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

Change subject: [wip] Add categories to the sidebar
......................................................................

[wip] Add categories to the sidebar

Bug: T92874
Change-Id: Ib9b766f9125e1e0c95798db46bf29ca7e0ac0408
---
M Resources.php
M handlebars/compiled/flow_block_header.handlebars.php
M handlebars/flow_block_header.handlebars
A handlebars/flow_header_categories.partial.handlebars
M includes/View.php
M modules/styles/board/header.less
6 files changed, 40 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/17/230017/1

diff --git a/Resources.php b/Resources.php
index 508be4d..05f8413 100644
--- a/Resources.php
+++ b/Resources.php
@@ -59,6 +59,7 @@
                        'handlebars/flow_form_cancel_button.partial.handlebars',
                        'handlebars/flow_header_title.partial.handlebars',
                        'handlebars/flow_header_detail.partial.handlebars',
+                       'handlebars/flow_header_categories.partial.handlebars',
                        'handlebars/flow_header_footer.partial.handlebars',
                        // HACK: Get rid of this when the description uses js 
ooui widgets
                        
'handlebars/flow_header_detail_oldsystem.partial.handlebars',
diff --git a/handlebars/compiled/flow_block_header.handlebars.php 
b/handlebars/compiled/flow_block_header.handlebars.php
index 2794751..b7609c8 100644
--- a/handlebars/compiled/flow_block_header.handlebars.php
+++ b/handlebars/compiled/flow_block_header.handlebars.php
@@ -62,6 +62,11 @@
 '.$sp.'        <span class="mw-ui-icon mw-ui-icon-before 
mw-ui-icon-speechBubbles pull-right expand-button"
 '.$sp.'                  title="'.LCRun3::ch($cx, 'l10n', 
array(array('flow-board-expand-description'),array()), 'encq').'"></span>
 '.$sp.'</a>
+';},'flow_header_categories' => function ($cx, $in, $sp) {return ''.$sp.'<div 
class="flow-board-header-category-view">
+'.$sp.'        <ul class="flow-board-header-category-list">
+'.$sp.''.LCRun3::sec($cx, ((isset($cx['sp_vars']['root']['categories']) && 
is_array($cx['sp_vars']['root'])) ? $cx['sp_vars']['root']['categories'] : 
null), $in, true, function($cx, $in)use($sp){return '            
<li>'.LCRun3::ch($cx, 'html', array(array($in),array()), 'encq').'</li>
+'.$sp.'';}).'  </ul>
+'.$sp.'</div>
 ';},'flow_header_footer' => function ($cx, $in, $sp) {return ''.$sp.'<div 
class="flow-board-header-footer">
 '.$sp.'  <hr />
 '.$sp.'  <p>
@@ -79,7 +84,7 @@
     );
     
     return '<div class="flow-board-header flow-load-interactive" 
data-flow-load-handler="loadSideRail">
-'.LCRun3::p($cx, 'flow_header_title', array(array($in),array()), '     
').''.LCRun3::p($cx, 'flow_errors', array(array($in),array()), '        
').''.((LCRun3::ifvar($cx, ((isset($in['oldSystem']) && is_array($in)) ? 
$in['oldSystem'] : null))) ? ''.LCRun3::p($cx, 'flow_header_detail_oldsystem', 
array(array($in),array()), '            ').'' : ''.LCRun3::p($cx, 
'flow_header_detail', array(array($in),array()), '            
').'').''.LCRun3::p($cx, 'flow_header_footer', array(array($in),array()), '     
').'</div>
+'.LCRun3::p($cx, 'flow_header_title', array(array($in),array()), '     
').''.LCRun3::p($cx, 'flow_errors', array(array($in),array()), '        
').''.((LCRun3::ifvar($cx, ((isset($in['oldSystem']) && is_array($in)) ? 
$in['oldSystem'] : null))) ? ''.LCRun3::p($cx, 'flow_header_detail_oldsystem', 
array(array($in),array()), '            ').'' : ''.LCRun3::p($cx, 
'flow_header_detail', array(array($in),array()), '            
').'').''.LCRun3::p($cx, 'flow_header_categories', array(array($in),array()), ' 
').''.LCRun3::p($cx, 'flow_header_footer', array(array($in),array()), ' 
').'</div>
 ';
 }
 ?>
\ No newline at end of file
diff --git a/handlebars/flow_block_header.handlebars 
b/handlebars/flow_block_header.handlebars
index 5dd11cb..b226890 100644
--- a/handlebars/flow_block_header.handlebars
+++ b/handlebars/flow_block_header.handlebars
@@ -6,5 +6,6 @@
        {{else}}
                {{> flow_header_detail}}
        {{/if}}
+       {{> flow_header_categories}}
        {{> flow_header_footer}}
 </div>
diff --git a/handlebars/flow_header_categories.partial.handlebars 
b/handlebars/flow_header_categories.partial.handlebars
new file mode 100644
index 0000000..c6efb31
--- /dev/null
+++ b/handlebars/flow_header_categories.partial.handlebars
@@ -0,0 +1,7 @@
+<div class="flow-board-header-category-view">
+       <ul class="flow-board-header-category-list">
+       {{#each @root.categories}}
+               <li>{{html this}}</li>
+       {{/each}}
+       </ul>
+</div>
diff --git a/includes/View.php b/includes/View.php
index faee0ab..15edf5a 100644
--- a/includes/View.php
+++ b/includes/View.php
@@ -151,6 +151,12 @@
                $workflow = $loader->getWorkflow();
                $title = $workflow->getArticleTitle();
                $user = $this->getUser();
+               $categories = array_keys( $title->getParentCategories() );
+
+               // Transform the raw category names into links
+               foreach ( $categories as $value ) {
+                       $linkedCategories[] = \Linker::link( 
Title::newFromText( $value ), htmlspecialchars( $value ) );
+               }
 
                // @todo This and API should use same code
                $apiResponse = array(
@@ -179,6 +185,7 @@
                                                                        'title' 
=> $apiResponse['title'],
                                                                        
'block-action-template' => $block->getTemplate( $action ),
                                                                        
'editToken' => $editToken,
+                                                                       
'categories' => $linkedCategories
                                                                );
                                if ( $block->getName() == 'topiclist' ) {
                                        $topicListBlock = $block;
diff --git a/modules/styles/board/header.less b/modules/styles/board/header.less
index 586df78..5678079 100644
--- a/modules/styles/board/header.less
+++ b/modules/styles/board/header.less
@@ -48,6 +48,24 @@
        display: none;
 }
 
+.flow-board-header-category-view {
+       background: white;
+       padding: 0.5em;
+
+       ul {
+               list-style-type: none;
+               list-style-image: none;
+
+               li {
+                       display: inline-block;
+               }
+
+               li + li:before {
+                       content: " | ";
+               }
+       }
+}
+
 .side-rail-toggle-button {
        visibility: hidden;
        position: absolute;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib9b766f9125e1e0c95798db46bf29ca7e0ac0408
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <mor...@gmail.com>

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

Reply via email to