From e07b9939475c681e93017c276f6ed8fb14647bfb Mon Sep 17 00:00:00 2001
From: Konstantinos Platis <konstantinos.platis@cern.ch>
Date: Mon, 1 Jul 2019 15:09:55 +0000
Subject: [PATCH] Changed row-class form field to pre-filled / locked value to
 default

---
 src/Plugin/views/style/Accordion.php       |  3 ++-
 src/Plugin/views/style/CardGrid.php        | 22 +++++++++++++++-
 src/Plugin/views/style/Collision.php       |  9 ++++---
 src/Plugin/views/style/Countdown.php       | 17 ++++++++++++-
 src/Plugin/views/style/EventGrid.php       | 18 +++++++++++++-
 src/Plugin/views/style/FeaturedBanner.php  | 23 +++++++++++++++++
 src/Plugin/views/style/HorizontalBoxes.php |  3 ++-
 src/Plugin/views/style/TeaserList.php      |  9 +++++++
 src/Plugin/views/style/VerticalBoxes.php   | 29 +++++++++++++++++++++-
 9 files changed, 123 insertions(+), 10 deletions(-)

diff --git a/src/Plugin/views/style/Accordion.php b/src/Plugin/views/style/Accordion.php
index d5562ab..2ca6ee2 100644
--- a/src/Plugin/views/style/Accordion.php
+++ b/src/Plugin/views/style/Accordion.php
@@ -69,7 +69,8 @@ class Accordion extends DefaultStyle {
 				'#type' => 'textfield',
 				'#title' => t('Row Class'),
 				'#description' => t('For Accordion, make sure you have set carousel-cern-item as one of the row classes'),
-				'#default_value' => (!empty($this->options['row_class'])) ? $this->options['row_class'] : 'carousel-cern-item',
+				'#default_value' => 'carousel-cern-item',
+				'#disabled' => true,
 		);
 
 		// Option to set a color for the accordion title
diff --git a/src/Plugin/views/style/CardGrid.php b/src/Plugin/views/style/CardGrid.php
index 1a67ae7..5614e9c 100644
--- a/src/Plugin/views/style/CardGrid.php
+++ b/src/Plugin/views/style/CardGrid.php
@@ -51,5 +51,25 @@ class CardGrid extends DefaultStyle {
 	 */
 	protected $usesgrouping = true;
 
+		/**
+		 * Overrides the options form of Card Grid
+		 *
+		 * @param $form
+		 * @param FormStateInterface $form_state
+		 */
+	public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+		parent::buildOptionsForm($form, $form_state);
 
-}
\ No newline at end of file
+		$form['row_class'] = array(
+				'#type' => 'textfield',
+				'#title' => t('Row Class'),
+				'#description' => t(''),
+				'#default_value' =>  '',
+				'#disabled' => true,
+		);
+
+	}
+
+
+
+	}
\ No newline at end of file
diff --git a/src/Plugin/views/style/Collision.php b/src/Plugin/views/style/Collision.php
index 8044442..a9f6a7a 100644
--- a/src/Plugin/views/style/Collision.php
+++ b/src/Plugin/views/style/Collision.php
@@ -33,23 +33,24 @@ class Collision extends DefaultStyle {
 	 */
 	protected function defineOptions(){
 		$options = parent::defineOptions();
-		$options['row_class'] = array('default'=> 'events-collision-row') ;
+		$options['row_class'] = array('default'=> 'events-collision-row');
 		return $options;
 	}
 
 	/**
-	 * Overrides the options form of HB
+	 * Overrides the options form of Collision display format
 	 *
 	 * @param $form
 	 * @param FormStateInterface $form_state
 	 */
-	public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+	public function buildOptionsForm(&$form, FormStateInterface $form_state){
 		parent::buildOptionsForm($form, $form_state);
 
 		$form['row_class'] = array(
 				'#type' => 'textfield',
 				'#title' => t('Row Class'),
-				'#default_value' => (!empty($this->options['row_class'])) ? $this->options['row_class'] : 'events-collision-row',
+				'#default_value' => 'events-collision-row',
+				'#disabled' => true,
 		);
 	}
 
diff --git a/src/Plugin/views/style/Countdown.php b/src/Plugin/views/style/Countdown.php
index 5159e6d..307f363 100644
--- a/src/Plugin/views/style/Countdown.php
+++ b/src/Plugin/views/style/Countdown.php
@@ -3,7 +3,7 @@
 
 namespace Drupal\cern_display_formats\Plugin\views\style;
 
-
+use Drupal\core\form\FormStateInterface;
 use Drupal\views\Plugin\views\style\DefaultStyle;
 
 /**
@@ -24,6 +24,11 @@ class Countdown extends DefaultStyle {
 
 	protected $usesoptions = true;
 
+	protected $usesRowPlugin = true;
+
+	//the format should not use row classes
+	protected $usesRowClass = true;
+
 
 	/**
 	 * Defines the initial options for Countdown format
@@ -32,8 +37,18 @@ class Countdown extends DefaultStyle {
 	 */
 	protected function defineOptions(){
 		$options = parent::defineOptions();
+		$options['row_class'] = array('default'=> '');
 		return $options;
 	}
 
+	public function buildOptionsForm(&$form, FormStateInterface $form_state){
+		parent::buildOptionsForm($form, $form_state);
 
+		$form['row_class'] = array(
+				'#type' => 'textfield',
+				'#title' => t('Row Class'),
+				'#default_value' => '',
+				'#disabled' => true,
+		);
+	}
 }
\ No newline at end of file
diff --git a/src/Plugin/views/style/EventGrid.php b/src/Plugin/views/style/EventGrid.php
index af00f81..e6a9834 100644
--- a/src/Plugin/views/style/EventGrid.php
+++ b/src/Plugin/views/style/EventGrid.php
@@ -34,5 +34,21 @@ class EventGrid extends DefaultStyle {
 
 	protected $renderFields = true;
 
-
+	/**
+	 * Overrides the options form of Event Grid
+	 *
+	 * @param $form
+	 * @param FormStateInterface $form_state
+	 */
+	public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+		parent::buildOptionsForm($form, $form_state);
+
+		$form['row_class'] = array(
+				'#type' => 'textfield',
+				'#title' => t('Row Class'),
+				'#description' => t(''),
+				'#default_value' => '',
+				'#disabled' => true,
+		);
+	}
 }
\ No newline at end of file
diff --git a/src/Plugin/views/style/FeaturedBanner.php b/src/Plugin/views/style/FeaturedBanner.php
index 32f8303..ebf804b 100644
--- a/src/Plugin/views/style/FeaturedBanner.php
+++ b/src/Plugin/views/style/FeaturedBanner.php
@@ -5,6 +5,7 @@ namespace Drupal\cern_display_formats\Plugin\views\style;
 
 
 use Drupal\views\Plugin\views\style\DefaultStyle;
+use Drupal\core\form\FormStateInterface;
 
 /**
  * Implements the Featured Banner display format
@@ -22,8 +23,12 @@ use Drupal\views\Plugin\views\style\DefaultStyle;
  */
 class FeaturedBanner extends DefaultStyle {
 
+
 	protected $usesoptions = true;
 
+	protected $usesRowPlugin = true;
+
+	protected $usesRowClass = true;
 
 	/**
 	 * Defines the initial options for the Featured Banner format
@@ -35,5 +40,23 @@ class FeaturedBanner extends DefaultStyle {
 		return $options;
 	}
 
+	/**
+	 * Overrides the options form of Featured Banner
+	 *
+	 * @param $form
+	 * @param FormStateInterface $form_state
+	 */
+	public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+		parent::buildOptionsForm($form, $form_state);
+
+		$form['row_class'] = array(
+				'#type' => 'textfield',
+				'#title' => t('Row Class'),
+				'#description' => t(''),
+				'#default_value' => '',
+				'#disabled' => true,
+		);
+	}
+
 
 }
\ No newline at end of file
diff --git a/src/Plugin/views/style/HorizontalBoxes.php b/src/Plugin/views/style/HorizontalBoxes.php
index afb842e..ab74973 100755
--- a/src/Plugin/views/style/HorizontalBoxes.php
+++ b/src/Plugin/views/style/HorizontalBoxes.php
@@ -59,7 +59,8 @@ class HorizontalBoxes extends DefaultStyle
 				'#type' => 'textfield',
 				'#title' => t('Row Class'),
 				'#description' => t('For Horizontal Boxes, make sure you have set horizontal-boxes-row as one of the row classes'),
-				'#default_value' => (!empty($this->options['row_class'])) ? $this->options['row_class'] : 'horizontal-boxes-row',
+				'#default_value' => 'horizontal-boxes-row',
+				'#disabled' => true,
 		);
 	}
 
diff --git a/src/Plugin/views/style/TeaserList.php b/src/Plugin/views/style/TeaserList.php
index f9594e4..47fa4df 100644
--- a/src/Plugin/views/style/TeaserList.php
+++ b/src/Plugin/views/style/TeaserList.php
@@ -39,6 +39,7 @@ class TeaserList extends DefaultStyle
 		$options = parent::defineOptions();
 		$options['title_color'] = array('default'=> '#2574b9') ;
 		$options['title_color_card'] = array('default' => '#FFFFFF');
+		$options['row_class'] = array('default' => '');
 		return $options;
 	}
 
@@ -51,6 +52,14 @@ class TeaserList extends DefaultStyle
 	public function buildOptionsForm(&$form, FormStateInterface $form_state) {
 		parent::buildOptionsForm($form, $form_state);
 
+		$form['row_class'] = array(
+				'#type' => 'textfield',
+				'#title' => t('Row Class'),
+				'#description' => t(''),
+				'#default_value' => '',
+				'#disabled' => true,
+		);
+
 		// Option to set a color for the teaser list title
 		$form['title_color'] = array(
 				'#type' => 'color',
diff --git a/src/Plugin/views/style/VerticalBoxes.php b/src/Plugin/views/style/VerticalBoxes.php
index 2ca695f..357a42b 100644
--- a/src/Plugin/views/style/VerticalBoxes.php
+++ b/src/Plugin/views/style/VerticalBoxes.php
@@ -22,11 +22,20 @@ use Drupal\views\Plugin\views\style\DefaultStyle;
  */
 class VerticalBoxes extends DefaultStyle {
 
+	/**
+	 * {@inheritdoc}
+	 */
+	protected $usesRowPlugin = true;
+
+	protected $usesRowClass = false;
+
 	protected $usesoptions = true;
 
+	protected $renderFields = true;
+
 
 	/**
-	 * Defines the initial options for Countdown format
+	 * Defines the initial options for Vertical Boxes format
 	 *
 	 * @return mixed
 	 */
@@ -35,5 +44,23 @@ class VerticalBoxes extends DefaultStyle {
 		return $options;
 	}
 
+	/**
+	 * Overrides the options form of Vertical Boxes
+	 *
+	 * @param $form
+	 * @param FormStateInterface $form_state
+	 */
+	public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+		parent::buildOptionsForm($form, $form_state);
+
+		$form['row_class'] = array(
+				'#type' => 'textfield',
+				'#title' => t('Row Class'),
+				'#description' => t(''),
+				'#default_value' => '',
+				'#disabled' => true,
+		);
+	}
+
 
 }
\ No newline at end of file
-- 
GitLab