Jelajahi Sumber

Ticket #3399 - Group cards.

AntonLV 5 tahun lalu
induk
melakukan
0604416e08

+ 5 - 0
inc/classes/BxDolConnection.php

@@ -7,6 +7,11 @@
  * @{
  */
 
+/**
+ * Default limit for connections list in Counter.
+ */
+define('BX_CONNECTIONS_LIST_COUNTER', 5);
+
 /**
  * Default limit for connections lists
  */

+ 7 - 0
modules/boonex/artificer/data/template/system/connection_counter_label.html

@@ -4,6 +4,13 @@
             __name__
         </span>
     </bx_if:show_icon>
+    <bx_if:show_profiles>
+        <span class="sys-action-counter-profiles __style_prefix__-counter-profiles flex">
+            <bx_repeat:profiles>
+                <span class="sys-action-counter-profile __style_prefix__-counter-profile block -ml-2 first:ml-0">__unit__</span>
+            </bx_repeat:profiles>
+        </span>
+    </bx_if:show_profiles>
     <bx_if:show_text>
         <span class="sys-action-counter-text __style_prefix__-counter-text ml-1">__text__</span>
     </bx_if:show_text>

+ 10 - 0
modules/boonex/artificer/data/template/system/css/connection.css

@@ -0,0 +1,10 @@
+/*--
+import url(../../../../../../../template/css/connection.css);
+--*/
+
+
+/*-- Counter --*/
+.sys-action-counter-profile .bx-def-icon-size {
+    width: 1.5rem;
+    height: 1.5rem;
+}

File diff ditekan karena terlalu besar
+ 0 - 0
modules/boonex/artificer/template/css/tailwind.min.css


+ 7 - 0
template/connection_counter_label.html

@@ -4,6 +4,13 @@
             __name__
         </span>
     </bx_if:show_icon>
+    <bx_if:show_profiles>
+        <span class="sys-action-counter-profiles __style_prefix__-counter-profiles">
+            <bx_repeat:profiles>
+                <span class="sys-action-counter-profile __style_prefix__-counter-profile">__unit__</span>
+            </bx_repeat:profiles>
+        </span>
+    </bx_if:show_profiles>
     <bx_if:show_text>
         <span class="sys-action-counter-text __style_prefix__-counter-text bx-def-margin-sec-left-auto">__text__</span>
     </bx_if:show_text>

+ 27 - 0
template/css/connection.css

@@ -0,0 +1,27 @@
+/*-- Counter --*/
+.sys-action-counter-profiles {
+    display: flex;
+}
+.sys-action-counter-profile {
+    display: block;
+    margin-left: -0.25rem;
+}
+.sys-action-counter-profile:first-child {
+    margin-left: 0;
+}
+.sys-action-counter-profile .bx-def-icon-size {
+    width: 1rem;
+    height: 1rem;
+}
+.sys-action-counter-profile div.bx-def-unit-img, 
+.sys-action-counter-profile div.bx-def-unit-img img {
+    display: block;
+}
+.sys-action-counter-profile div.bx-def-unit-img .bx-base-pofile-unit-thumb {
+    border-radius: 1rem;
+    line-height: normal;
+    font-size: 0.6rem;
+}
+.sys-action-counter-profile .bx-base-pofile-unit-online {
+    display: none;
+}

+ 35 - 7
template/scripts/BxBaseConnection.php

@@ -57,7 +57,10 @@ class BxBaseConnection extends BxDolConnection
     {
         if (!$iProfileId)
             $iProfileId = bx_get_logged_profile_id();
-        
+
+        if(empty($aParams))
+            $aParams = [];
+
         $this->_sStylePrefix = 'bx_conn_' . $this->_sObject;
         
         $aHtmlIds = array(
@@ -70,11 +73,12 @@ class BxBaseConnection extends BxDolConnection
             'dynamic_mode' => true,
             'show_do_as_button_small' => true,
             'show_do_as_button' => true,
+            'show_counter_label_with_profiles' => true,
             'show_script' => true,
         ];
         
         $aParams = array_merge($aParams, $aParamsDefault);
-        
+
         $iCount = $sContentType == BX_CONNECTIONS_CONTENT_TYPE_INITIATORS ? $this->getConnectedInitiatorsCount($iProfileId, $bIsMutual) : $this->getConnectedContentCount($iProfileId, $bIsMutual);
         
         if ($iCount > 0){   
@@ -91,8 +95,9 @@ class BxBaseConnection extends BxDolConnection
             if($bShowDoAsButton)
                 $sClass .= ' bx-btn-height';
         
-            $sContent =$this->_getCounterLabel($iCount, $aParams);
-            
+            $sContent = $this->_getCounterLabel($iCount, $iProfileId, $bIsMutual, $aParams, $sContentType);
+
+            $this->_oTemplate->addCss(array('connection.css'));
             return $this->_oTemplate->parseHtmlByName('connection_counter.html', array(
                 'html_id' => $aHtmlIds['counter'],
                 'style_prefix' => $this->_sStylePrefix,
@@ -144,17 +149,40 @@ class BxBaseConnection extends BxDolConnection
         return $this->_oTemplate->_wrapInTagJsCode($sCode);
     }
     
-    protected function _getCounterLabel($iCount, $aParams = array())
+    protected function _getCounterLabel($iCount, $iProfileId, $bIsMutual, $aParams, $sContentType)
     {
-       return $this->_oTemplate->parseHtmlByName('connection_counter_label.html', array(
+        $bShowWithProfiles = isset($aParams['show_counter_label_with_profiles']) && $aParams['show_counter_label_with_profiles'] === true;
+        $bShowWithIcon = (!isset($aParams['show_counter_label_icon']) || $aParams['show_counter_label_icon'] === true) && !$bShowWithProfiles;
+
+        $aTmplVarsWithProfiles = array();
+        if($bShowWithProfiles) {
+            $aTmplVarsWithProfiles = [
+                'style_prefix' => $this->_sStylePrefix,
+                'bx_repeat:profiles' => []
+            ];
+
+            $aIds = $this->{BX_CONNECTIONS_CONTENT_TYPE_INITIATORS == $sContentType ? 'getConnectedInitiators' : 'getConnectedContent'}($iProfileId, $bIsMutual, 0, BX_CONNECTIONS_LIST_COUNTER);
+            foreach($aIds as $iId)
+                if(($oProfile = BxDolProfile::getInstanceMagic($iId)) !== false)
+                    $aTmplVarsWithProfiles['bx_repeat:profiles'][] = [
+                        'style_prefix' => $this->_sStylePrefix,
+                        'unit' => $oProfile->getUnit(0, ['template' => ['name' => 'unit_wo_info_links', 'size' => 'icon']])
+                    ];
+        }
+
+        return $this->_oTemplate->parseHtmlByName('connection_counter_label.html', array(
             'style_prefix' => $this->_sStylePrefix,
             'bx_if:show_icon' => array(
-                'condition' => !isset($aParams['show_counter_label_icon']) || $aParams['show_counter_label_icon'] === true,
+                'condition' => $bShowWithIcon,
                 'content' => array(
                     'style_prefix' => $this->_sStylePrefix,
                     'name' => isset($aParams['custom_icon']) && $aParams['custom_icon'] != '' ? $aParams['custom_icon'] : BxTemplFunctions::getInstanceWithTemplate($this->_oTemplate)->getFontIconAsHtml($this->_getIconDo())
                 )
             ),
+            'bx_if:show_profiles' => array(
+                'condition' => $bShowWithProfiles,
+                'content' => $aTmplVarsWithProfiles
+            ),
             'bx_if:show_text' => array(
                 'condition' => !isset($aParams['show_counter_label_text']) || $aParams['show_counter_label_text'] === true,
                 'content' => array(

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini