Project

General

Profile

Revision e8074ec5

IDe8074ec5cb608ebb0d3ab76aa29fdd41544f0ee6
Parent 92e38dee
Child f35d3f4a

Added by Patrick Plitzner over 5 years ago

#5890 Pass classification uuid and taxon uuid to csv export

View differences:

modules/cdm_dataportal/cdm_csv_export/cdm_csv_export.module
73 73
  return $block;
74 74
}
75 75

  
76
function taxon_selection_update($form, &$form_state) {
77
  unset($form_state['input']['taxon_select'], $form_state['values']['taxon_select']);
78
  $tree = $form_state['input']['taxonNode'];
79
  $form['taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest/'.$tree.'///';
80
  $form['taxon_select']['#value'] = '';
81
  return form_builder($form['#id'], $form['taxon_select'], $form_state);
76
function update_classification_selected($form, &$form_state) {
77
  unset($form_state['input']['csv_export_taxon_select'], $form_state['values']['csv_export_taxon_select']);
78
  $tree = $form_state['input']['classificationUuid'];
79
  $form['csv_export_taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest/'.$tree.'///';
80
  $form['csv_export_taxon_select']['#value'] = '';
81
    return form_builder($form['#id'], $form['csv_export_taxon_select'], $form_state);
82 82
}
83 83

  
84 84
/**
......
90 90
 */
91 91
function cdm_csv_export_my_form($form_state) {
92 92
    $tree = variable_get(CDM_TAXONOMICTREE_UUID, FALSE);
93
    $form['combobox'] = array(
93
    $form['csv_export_classification_select'] = array(
94 94
        '#type' => 'select',
95 95
        '#title' => t('Classification').':',
96 96
        '#default_value' => $tree,
97 97
        '#options' => cdm_get_taxontrees_as_options(FALSE, TRUE),
98 98
        '#attributes' => array(
99
            'name' => 'taxonNode',
99
            'name' => 'classificationUuid',
100 100
            'onchange' => 'return validateForm()'
101 101
        ),
102 102
        '#ajax' => array(
103
          'callback' => 'taxon_selection_update',
103
          'callback' => 'update_classification_selected',
104 104
          'wrapper' => 'taxon-selection',
105 105
          'progress' => array(
106 106
            'message' => '',
......
108 108
          ),
109 109
        )
110 110
    );
111
    $form['taxon_select'] = array(
111
    $form['csv_export_taxon_select'] = array(
112 112
        '#title' => t('Taxon'),
113 113
        '#type' => 'textfield',
114 114
        '#prefix' => '<div id="taxon-selection">',
115
        '#suffix' => '</div>'
115
        '#suffix' => '</div>',
116
        '#attributes' => array(
117
            'onchange' => 'return validateForm()'
118
        ),
116 119
    );
117 120
    if(variable_get('cdm_dataportal_taxon_auto_suggest')){
118
        $form['taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest////';
121
        $form['csv_export_taxon_select']['#autocomplete_path'] = 'cdm_dataportal/taxon/autosuggest////';
119 122
    }
123
    $form['taxonUuidStore'] = array(
124
        '#type' => 'hidden',
125
        '#value' => '',
126
        '#name' => taxonUuid,
127
        '#attributes' => array(
128
            'id' => 'taxonUuid',
129
        )
130
    );
120 131

  
121 132
    $form['redListField'] = array(
122 133
        '#type' => 'fieldset',
modules/cdm_dataportal/cdm_csv_export/js/cdm_csv_export.js
32 32
 * 
33 33
 */
34 34
function validateForm(){
35
	var select = document.getElementById("edit-combobox");
36
	if(select.value==null || select.value == -1|| select.value==""){
37
		//alert('Please select a valid classification');
38
		//jQuery('#edit-combobox').addClass("error");
39
		select.selectedIndex = 0;
40
	}
35
    var classification_select = document.getElementById("edit-csv-export-classification-select");
36
    if(classification_select.value==null || classification_select.value == -1|| classification_select.value==""){
37
        classification_select.selectedIndex = 0;
38
    }
39
    var taxon_select = document.getElementById("edit-csv-export-taxon-select");
40
    var taxon_uuid = document.getElementById("taxonUuid");
41
    var selectedTaxon = taxon_select.value.toString();
42
    if(selectedTaxon!=null){
43
        uuid = selectedTaxon.substring(selectedTaxon.indexOf("[[")+2);
44
		selectedTaxon = selectedTaxon.substring(0, selectedTaxon.indexOf("[["));
45
        taxon_select.value = selectedTaxon;
46
        taxon_uuid.value = uuid;
47
    }
41 48
}
42 49

  
43 50

  
modules/cdm_dataportal/cdm_dataportal.search.php
147 147
      $titleCache = $record->entity->titleCache;
148 148
      preg_match('/(.*) sec.*/', $titleCache, $trimmedTitle); //remove sec reference
149 149
      $trimmedTitle = trim($trimmedTitle[1]);
150
      $matches[$trimmedTitle] = check_plain($trimmedTitle);
150
      $matches[$trimmedTitle.'[['.$record->entity->uuid] = check_plain($trimmedTitle).'[['.$record->entity->uuid;
151 151
  }
152 152
  drupal_json_output($matches);
153 153
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)