Browse Source

fixed showroom field form bug, removed ordering, fixed card js in node page

Bachir Soussi Chiadmi 7 years ago
parent
commit
c56a523286

+ 11 - 11
sites/all/modules/features/materio_content_types/materio_content_types.features.field_instance.inc

@@ -2394,7 +2394,7 @@ function materio_content_types_field_default_field_instances() {
         'label' => 'hidden',
         'settings' => array(),
         'type' => 'hidden',
-        'weight' => 15,
+        'weight' => 16,
       ),
       'cardsmall' => array(
         'label' => 'above',
@@ -2489,7 +2489,7 @@ function materio_content_types_field_default_field_instances() {
           'viewmode' => 'cardmedium',
         ),
         'type' => 'tode',
-        'weight' => 10,
+        'weight' => 23,
       ),
       'cardsmall' => array(
         'label' => 'above',
@@ -2586,7 +2586,7 @@ function materio_content_types_field_default_field_instances() {
           'viewmode' => 'cardmedium',
         ),
         'type' => 'tode',
-        'weight' => 9,
+        'weight' => 22,
       ),
       'cardsmall' => array(
         'label' => 'above',
@@ -2763,7 +2763,7 @@ function materio_content_types_field_default_field_instances() {
         'label' => 'above',
         'settings' => array(),
         'type' => 'hidden',
-        'weight' => 10,
+        'weight' => 11,
       ),
       'cardsmall' => array(
         'label' => 'above',
@@ -2844,7 +2844,7 @@ function materio_content_types_field_default_field_instances() {
         'label' => 'above',
         'settings' => array(),
         'type' => 'hidden',
-        'weight' => 11,
+        'weight' => 12,
       ),
       'cardsmall' => array(
         'label' => 'above',
@@ -2924,7 +2924,7 @@ function materio_content_types_field_default_field_instances() {
         'label' => 'hidden',
         'settings' => array(),
         'type' => 'hidden',
-        'weight' => 16,
+        'weight' => 17,
       ),
       'cardsmall' => array(
         'label' => 'hidden',
@@ -3219,7 +3219,7 @@ function materio_content_types_field_default_field_instances() {
         'label' => 'above',
         'settings' => array(),
         'type' => 'hidden',
-        'weight' => 13,
+        'weight' => 14,
       ),
       'cardsmall' => array(
         'label' => 'above',
@@ -3395,7 +3395,7 @@ function materio_content_types_field_default_field_instances() {
         'label' => 'above',
         'settings' => array(),
         'type' => 'hidden',
-        'weight' => 12,
+        'weight' => 13,
       ),
       'cardsmall' => array(
         'label' => 'above',
@@ -3574,7 +3574,7 @@ Vous devez avant d\'utiliser un nouveau tag le créer <a href="/admin/structure/
         'label' => 'above',
         'settings' => array(),
         'type' => 'hidden',
-        'weight' => 14,
+        'weight' => 15,
       ),
       'cardsmall' => array(
         'label' => 'above',
@@ -3660,7 +3660,7 @@ Vous devez avant d\'utiliser un nouveau tag le créer <a href="/admin/structure/
         'label' => 'hidden',
         'settings' => array(),
         'type' => 'hidden',
-        'weight' => 8,
+        'weight' => 9,
       ),
       'cardsmall' => array(
         'label' => 'above',
@@ -3743,7 +3743,7 @@ Vous devez avant d\'utiliser un nouveau tag le créer <a href="/admin/structure/
         'label' => 'above',
         'settings' => array(),
         'type' => 'hidden',
-        'weight' => 9,
+        'weight' => 10,
       ),
       'cardsmall' => array(
         'label' => 'above',

+ 1 - 1
sites/all/modules/features/materio_content_types/materio_content_types.strongarm.inc

@@ -412,7 +412,7 @@ function materio_content_types_strongarm() {
         'workflow' => array(
           'cardmedium' => array(
             'weight' => '8',
-            'visible' => TRUE,
+            'visible' => FALSE,
           ),
           'cardbig' => array(
             'weight' => '15',

+ 13 - 1
sites/all/modules/features/showroom/showroom.features.user_permission.inc

@@ -210,10 +210,22 @@ function showroom_user_default_permissions() {
     'module' => 'override_node_options',
   );
 
+  // Exported permission: 'materio showroom edit all samples fields'.
+  $permissions['materio showroom edit all samples fields'] = array(
+    'name' => 'materio showroom edit all samples fields',
+    'roles' => array(
+      'administrator' => 'administrator',
+      'root' => 'root',
+    ),
+    'module' => 'materio_showroom',
+  );
+
   // Exported permission: 'materio showroom migrate fields'.
   $permissions['materio showroom migrate fields'] = array(
     'name' => 'materio showroom migrate fields',
-    'roles' => array(),
+    'roles' => array(
+      'root' => 'root',
+    ),
     'module' => 'materio_showroom',
   );
 

+ 1 - 0
sites/all/modules/features/showroom/showroom.info

@@ -71,6 +71,7 @@ features[user_permission][] = edit own showroom content
 features[user_permission][] = edit terms in showroom
 features[user_permission][] = edit users with role 13
 features[user_permission][] = enter showroom revision log entry
+features[user_permission][] = materio showroom edit all samples fields
 features[user_permission][] = materio showroom migrate fields
 features[user_permission][] = merge showroom terms
 features[user_permission][] = override showroom authored by option

+ 16 - 0
sites/all/modules/gui/materiobasemod/js/materio_showroom.js

@@ -0,0 +1,16 @@
+/**
+ * @file
+ * Javascript for Field Example.
+ */
+
+/**
+ * Provides a farbtastic colorpicker for the fancier widget.
+ */
+(function ($) {
+  Drupal.behaviors.field_materio_showroom_location = {
+    attach: function(context) {
+      // console.log('hello materio_showroom');
+      $(".field-multiple-drag", ".field-type-field-materio-showroom-location").hide();
+    }
+  }
+})(jQuery);

+ 42 - 23
sites/all/modules/gui/materiobasemod/materio_showroom.module

@@ -182,16 +182,13 @@ function materio_showroom_field_widget_info() {
  * 'rgb' form element.
  */
 function materio_showroom_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
-  $locval = isset($items[$delta]['location']) ? $items[$delta]['location'] : '';
-  $showroom_tid = isset($items[$delta]['showroom_tid']) ? $items[$delta]['showroom_tid'] : 0;
-
   $widget = $element;
   $widget['#delta'] = $delta;
 
   switch ($instance['widget']['type']) {
- // TODO: loop through showrooms and don't allow more than one field by show room
-
-    case 'materio_showroom_location_text':
+     case 'materio_showroom_location_text':
+      $locval = isset($items[$delta]['location']) ? $items[$delta]['location'] : '';
+      $showroom_tid = isset($items[$delta]['showroom_tid']) ? $items[$delta]['showroom_tid'] : 0;
 
       $widget['showroom_tid'] = array(
         '#type' => 'hidden',
@@ -211,6 +208,11 @@ function materio_showroom_field_widget_form(&$form, &$form_state, $field, $insta
         '#maxlength' => 255,
       );
 
+      $widget['#attached'] = array(
+        // Add javascript to remove the draggable behaviour.
+        'js' => array(drupal_get_path('module', 'materio_showroom') . '/js/materio_showroom.js'),
+      );
+
       break;
   }
 
@@ -279,6 +281,8 @@ function _materio_showroom_alter_location_field_form(&$form, &$form_state, $form
   $node = $form['#node'];
   $nodetype = $form['type']['#value'];
 
+  // dsm($form_state, 'form_state');
+
   global $user;
   $user = user_load($user->uid); // Make sure the user object is fully loaded
   // dsm($user, 'user');
@@ -311,13 +315,14 @@ function _materio_showroom_alter_location_field_form(&$form, &$form_state, $form
     foreach ($showroomfieldinstances as $field_name) {
       // retrive various field infos
       $field_info = field_info_field($field_name);
-      $field_instance = field_info_instance('node', $field_name, $nodetype);
       // dsm($field_info, 'field_info');
+      $field_instance = field_info_instance('node', $field_name, $nodetype);
 
       // get all terms from chosen vocabulary in field instance widget settings
       $vid = $field_instance['widget']['settings']['vocabulary'];
       $voc = taxonomy_vocabulary_load($vid);
       $tree = taxonomy_get_tree($vid);
+      // dsm($tree, 'tree');
       foreach ($tree as $key => $term) {
         $terms[$term->tid] = $term->name;
       }
@@ -334,44 +339,58 @@ function _materio_showroom_alter_location_field_form(&$form, &$form_state, $form
 
       // get already recorded values
       $old_items = field_get_items('node', $node, $field_name);
+      // dsm($old_items, 'old_items');
       foreach ($old_items as $i => $value) {
         $values[$value['showroom_tid']] = $value['location'];
       }
       // dsm($values, 'values');
 
       // build new item list
-      foreach ($terms as $tid => $name) {
-        $items[] = array(
-          'showroom_tid' => $tid,
-          'location' => isset($values[$tid]) ? $values[$tid] : ''
-        );
-      }
+      // for ($k=0; $k < 3; $k++) {
+        foreach ($terms as $tid => $name) {
+          $items[] = array(
+            'showroom_tid' => "$tid",
+            'location' => isset($values[$tid]) ? $values[$tid] : ''
+          );
+        }
+      // }
       // dsm($items, 'items');
 
+      // change form_state items count
+      // without this, form wont populated with all wanted items
+      $form_state['field'][$field_name][LANGUAGE_NONE]['items_count'] = count($items);
+
       // retrieve new field form with our custom items
-      $new_field_form = field_default_form('node', $node, $field_info, $field_instance, LANGUAGE_NONE, $items, $form, $form_state);
-      // dsm($new_field_form, 'default_form');
+      $new_field_form = field_default_form('node', null, $field_info, $field_instance, LANGUAGE_NONE, $items, $form, $form_state)[$field_name];
+      // dsm($new_field_form, 'new_field_form');
+
+
+      // $elements = field_multiple_value_form($field_info, $field_instance, LANGUAGE_NONE, $items, $form, $form_state);
+      // dsm($elements, 'elements');
+
 
       // change items location field title
       // and check access comparing term id with user taged with
       $i = 0;
       foreach ($terms as $tid => $name) {
-        $item = $new_field_form[$field_name][LANGUAGE_NONE][$i];
-        $new_field_form[$field_name][LANGUAGE_NONE][$i]['location']['#title'] = $terms[$item['showroom_tid']['#default_value']];
+        $item = $new_field_form[LANGUAGE_NONE][$i];
+        $new_field_form[LANGUAGE_NONE][$i]['location']['#title'] = $terms[$item['showroom_tid']['#default_value']];
         $disabled = !user_access('materio showroom edit all samples fields', $user) && !in_array($tid, $user_showrooms);
-        $new_field_form[$field_name][LANGUAGE_NONE][$i]['location']['#disabled'] = $disabled;
+        $new_field_form[LANGUAGE_NONE][$i]['location']['#disabled'] = $disabled;
         $i++;
       }
 
       // remove the last one more item added by default
-      unset($new_field_form[$field_name][LANGUAGE_NONE][$i]);
+      unset($new_field_form[LANGUAGE_NONE][$i]);
+
+      // remove "add more" button
+      unset($new_field_form[LANGUAGE_NONE]['add_more']);
+
+      // dsm($new_field_form, 'new_field_form');
 
       // delete normal field form and replace it with our new custom field form
       unset($form[$field_name]);
-      $form[$field_name] = $new_field_form[$field_name];
-
-      // remove "add more" button
-      unset($form[$field_name]['und']['add_more']);
+      $form[$field_name] = $new_field_form;
     }
   }
 }

+ 30 - 30
sites/all/themes/gui/materiobasetheme/css/styles.css

@@ -4176,16 +4176,16 @@ article.node-materiau.vm-bookmark, article.node-breve.vm-bookmark {
         height: 17px; }
   article.node-materiau.vm-bookmark div.workflow, article.node-breve.vm-bookmark div.workflow {
     position: absolute;
-    top: 0;
-    left: 0;
+    bottom: 0;
+    right: 0;
     z-index: 11;
     padding: 5px;
-    border-radius: 5px 0 3px 0;
+    border-radius: 3px 0 5px 0;
     background-clip: padding-box;
     font-size: 10px;
     vertical-align: top;
-    background-color: rgba(255, 255, 255, 0.9);
-    color: #000; }
+    background-color: rgba(20, 20, 20, 0.9);
+    color: #fff; }
     article.node-materiau.vm-bookmark div.workflow span, article.node-breve.vm-bookmark div.workflow span {
       padding: 3px 0 0 4px;
       display: moz-inline-stack;
@@ -4378,16 +4378,16 @@ article.node-materiau.vm-cardsmall, article.node-breve.vm-cardsmall {
         height: 17px; }
   article.node-materiau.vm-cardsmall div.workflow, article.node-breve.vm-cardsmall div.workflow {
     position: absolute;
-    top: 0;
-    left: 0;
+    bottom: 0;
+    right: 0;
     z-index: 11;
     padding: 5px;
-    border-radius: 5px 0 3px 0;
+    border-radius: 3px 0 5px 0;
     background-clip: padding-box;
     font-size: 10px;
     vertical-align: top;
-    background-color: rgba(255, 255, 255, 0.9);
-    color: #000; }
+    background-color: rgba(20, 20, 20, 0.9);
+    color: #fff; }
     article.node-materiau.vm-cardsmall div.workflow span, article.node-breve.vm-cardsmall div.workflow span {
       padding: 3px 0 0 4px;
       display: moz-inline-stack;
@@ -4642,16 +4642,16 @@ article.node-materiau.vm-cardmedium, article.node-breve.vm-cardmedium {
         height: 17px; }
   article.node-materiau.vm-cardmedium div.workflow, article.node-breve.vm-cardmedium div.workflow {
     position: absolute;
-    top: 0;
-    left: 0;
+    bottom: 0;
+    right: 0;
     z-index: 11;
     padding: 5px;
-    border-radius: 5px 0 3px 0;
+    border-radius: 3px 0 5px 0;
     background-clip: padding-box;
     font-size: 10px;
     vertical-align: top;
-    background-color: rgba(255, 255, 255, 0.9);
-    color: #000; }
+    background-color: rgba(20, 20, 20, 0.9);
+    color: #fff; }
     article.node-materiau.vm-cardmedium div.workflow span, article.node-breve.vm-cardmedium div.workflow span {
       padding: 3px 0 0 4px;
       display: moz-inline-stack;
@@ -4998,16 +4998,16 @@ article.node-materiau.vm-cardbig, article.node-breve.vm-cardbig {
         height: 17px; }
   article.node-materiau.vm-cardbig div.workflow, article.node-breve.vm-cardbig div.workflow {
     position: absolute;
-    top: 0;
-    left: 0;
+    bottom: 0;
+    right: 0;
     z-index: 11;
     padding: 5px;
-    border-radius: 5px 0 3px 0;
+    border-radius: 3px 0 5px 0;
     background-clip: padding-box;
     font-size: 10px;
     vertical-align: top;
-    background-color: rgba(255, 255, 255, 0.9);
-    color: #000; }
+    background-color: rgba(20, 20, 20, 0.9);
+    color: #fff; }
     article.node-materiau.vm-cardbig div.workflow span, article.node-breve.vm-cardbig div.workflow span {
       padding: 3px 0 0 4px;
       display: moz-inline-stack;
@@ -5350,16 +5350,16 @@ article.node-materiau.vm-cardfull, article.node-breve.vm-cardfull {
         height: 17px; }
   article.node-materiau.vm-cardfull div.workflow, article.node-breve.vm-cardfull div.workflow {
     position: absolute;
-    top: 0;
-    left: 0;
+    bottom: 0;
+    right: 0;
     z-index: 11;
     padding: 5px;
-    border-radius: 5px 0 3px 0;
+    border-radius: 3px 0 5px 0;
     background-clip: padding-box;
     font-size: 10px;
     vertical-align: top;
-    background-color: rgba(255, 255, 255, 0.9);
-    color: #000; }
+    background-color: rgba(20, 20, 20, 0.9);
+    color: #fff; }
     article.node-materiau.vm-cardfull div.workflow span, article.node-breve.vm-cardfull div.workflow span {
       padding: 3px 0 0 4px;
       display: moz-inline-stack;
@@ -5648,16 +5648,16 @@ article.node-materiau.vm-cardfull, article.node-breve.vm-cardfull {
             height: 17px; }
       .print-node-materiau div.workflow {
         position: absolute;
-        top: 0;
-        left: 0;
+        bottom: 0;
+        right: 0;
         z-index: 11;
         padding: 5px;
-        border-radius: 5px 0 3px 0;
+        border-radius: 3px 0 5px 0;
         background-clip: padding-box;
         font-size: 10px;
         vertical-align: top;
-        background-color: rgba(255, 255, 255, 0.9);
-        color: #000; }
+        background-color: rgba(20, 20, 20, 0.9);
+        color: #fff; }
         .print-node-materiau div.workflow span {
           padding: 3px 0 0 4px;
           display: moz-inline-stack;

+ 6 - 9
sites/all/themes/gui/materiobasetheme/js/script.js

@@ -1,6 +1,3 @@
-// @koala-prepend "gui_ck_fw/gui.js"
-// @codekit-prepend "gui.js"
-
 (function($) {
 
 
@@ -48,13 +45,13 @@
         // touch scroll
         position = {x:null,y:null},
         translate3d_content = 0,
-        _isLoggedIn = !$('body').is('.not-logged-in'),
-        _isFrontNotLogged = $('body').is('.front.not-logged-in'),
+        _isLoggedIn = !_$body.is('.not-logged-in'),
+        _isFrontNotLogged = _$body.is('.front.not-logged-in'),
         _isFrontHomeV2 = _$body.is('.home-v2'),
         _skrollr,
-        _isMembershipForm = $('body').is('.page-node-11186'), //$('body').is('.page-node-11187') || ,
-        // _isBreveMateriauNodePage = $('body').is('.node-type-breve') || $('body').is('.node-type-materiau');
-        _isBreveMateriauNodePage = _themeSettings.page_callback == 'node_page_view' && (_themeSettings.node_type == 'materiau' || _themeSettings.node_type == 'breve'),
+        _isMembershipForm = _$body.is('.page-node-11186'), //$('body').is('.page-node-11187') || ,
+        _isBreveMateriauNodePage = _$body.is('.node-type-breve') || _$body.is('.node-type-materiau'),
+        // _isBreveMateriauNodePage = _themeSettings.page_callback == 'node_page_view' && (_themeSettings.node_type == 'materiau' || _themeSettings.node_type == 'breve'),
         _resizeTimer,
         _max_480 = function(){ return (viewport().width < 479); },
         _480_768 = function(){ return ( !_max_480() && _max_768() ); },
@@ -531,7 +528,7 @@
     };
 
     function onResultsChanged(event){
-      // trace('MaterioBaseTheme :: onResultsChanged',event);
+      trace('MaterioBaseTheme :: onResultsChanged',event);
       $(document).scrollTop(0);
 
       focusCard($('#content .search-results, #content .actuality-items').children('.node:first-child'));

File diff suppressed because it is too large
+ 0 - 0
sites/all/themes/gui/materiobasetheme/js/script.min.js


+ 1 - 3
sites/all/themes/gui/materiobasetheme/preprocess/html.pre.php

@@ -71,8 +71,8 @@ foreach ($heads as $type=>$head)
 	drupal_add_html_head($head, $type);
 
 
+// this is not working anymore, node object don't shows up on vars
 $node = isset($vars['node']) ? $vars['node'] : false;
-
 # add body classes
 if($node){
 
@@ -142,5 +142,3 @@ foreach ($vars['head_title_array'] as $key => $value){
   }
 }
 $vars['head_title'] = $vars['head_array']['title'] =  strip_tags(implode(' | ',  $head_title_array));
-
-

+ 3 - 3
sites/all/themes/gui/materiobasetheme/scss/styles.scss

@@ -1305,11 +1305,11 @@ $cardfull_h:610px;
   // &:hover{nav.nav{display:block;}}
 
   div.workflow{
-    position:absolute; top:0; left:0; z-index:11;
+    position:absolute; bottom:0; right:0; z-index:11;
     padding: 5px;
-    @include border-radius(5px, 0, 3px, 0);
+    @include border-radius(3px, 0, 5px, 0);
     @include fs11; vertical-align: top;
-    background-color: rgba(255, 255, 255, 0.9); color:#000;
+    background-color: rgba(20, 20, 20, 0.9); color:#fff;
     span{padding: 3px 0 0 4px; @include inlineblock();}
   }
 

Some files were not shown because too many files changed in this diff