fixed showroom field form bug, removed ordering, fixed card js in node page
This commit is contained in:
@@ -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',
|
||||
|
@@ -412,7 +412,7 @@ function materio_content_types_strongarm() {
|
||||
'workflow' => array(
|
||||
'cardmedium' => array(
|
||||
'weight' => '8',
|
||||
'visible' => TRUE,
|
||||
'visible' => FALSE,
|
||||
),
|
||||
'cardbig' => array(
|
||||
'weight' => '15',
|
||||
|
@@ -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',
|
||||
);
|
||||
|
||||
|
@@ -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
sites/all/modules/gui/materiobasemod/js/materio_showroom.js
Normal file
16
sites/all/modules/gui/materiobasemod/js/materio_showroom.js
Normal file
@@ -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);
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user