Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editable Index #4239

Merged
merged 4 commits into from
Aug 1, 2024
Merged

Editable Index #4239

merged 4 commits into from
Aug 1, 2024

Conversation

kaise-lafrai
Copy link
Contributor

@kaise-lafrai kaise-lafrai commented Jul 24, 2024

fixes [org/repo/issue#]

  • Test coverage exists
  • Documentation exists

QA Steps

Test Data File:
test_data.csv

PART 1

  • Navigate to form /node/add/data?schema=data-dictionary
  • Enter a Title: Data Dictionary and Index
  • Select 'Add Field'
  • Enter the following Name: termination_date
  • Enter the following Title: Termination Date
  • Select 'date' for the Data Type
  • Select 'other' Format
  • Enter the following for Other Format: %m/%d/%Y
  • Enter the following description: Termination Date
  • Select Add
  • Select Add field
  • Enter the following Name: fda_approval_date
  • Enter the following Title: FDA Approval Date
  • Select 'date' for the Data Type
  • Select 'other' Format
  • Enter the following for Other Format: %m/%d/%Y
  • Enter the following description: FDA Approval Date
  • Select Add
  • Select Add Index
  • Enter Name: Index
  • Select Add field within the 'Fields' fieldset
  • Enter the following Name: termination_date
  • Enter the following Length: 20
  • Select Add field to enter another field
  • Enter the following Name: fda_approval_date
  • Enter the following Length: 20
  • Select Add
  • Select Submit Index
  • Confirm the Data Dictionary Fields Added are correct
  • Confirm the Indexes and fields added are correct
  • Save the node

PART 2

  • Navigate to: /node/add/data?schema=dataset
  • Enter a Title: Dataset Test
  • Enter a Description: Description Test
  • Enter a Last Update date and time
  • Enter a Publisher Name
  • Enter a Contact Name and Email
  • Enter a Tag under Tags
  • Enter the following for File Title:
  • Enter the following for File Description
  • Enter the following File Format: CSV
  • Upload a Data File, you can use the Test Data File provided
  • Save the dataset
  • Navigate back to the previously created Data Dictionary and Index from PART 1
  • Grab the identifier. It will look something like this example: fc034f0d-c96d-484e-b1e4-79a9aed7c2e6
  • Navigate to the endpoint api/1/metastore/schemas/data-dictionary/items/{identifier goes here}
  • Confirm the endpoint json looks like this:
    { "identifier": "fc034f0d-c96d-484e-b1e4-79a9aed7c2e6", "data": { "title": "Data Dictionary and Index", "fields": [ { "name": "termination_date", "title": "Termination Date", "type": "date", "format": "%m/%d/%Y", "description": "Termination Date" }, { "name": "fda_approval_date", "title": "FDA Approval Date", "type": "date", "format": "%m/%d/%Y", "description": "FDA Approval Date" } ], "indexes": [ { "description": "Data Index", "type": "index", "fields": [ { "name": "termination_date", "length": 20 }, { "name": "fda_approval_date", "length": 20 } ] } ] } }

PART 3

  • Navigate to /admin/dkan/data-dictionary/settings
  • Select Dictionary Mode : Sitewide
  • Enter the identifier into the Sitewide Dictionary ID
  • Save Configuration

PART 4

  • Navigate to /admin/dkan/datastore/status
  • Confirm you see the Dataset row with the Title 'Dataset Test' from PART 2 and that the FETCH, STORE and POST IMPORT are all in 'Waiting'
  • You should now run CRON twice
  • Navigate to /admin/dkan/datastore/status
  • Confirm the FETCH, STORE, POST IMPORT are all in 'done'

PART 5

  • Navigate to /admin/dkan/datastore/status
  • Grab the Dataset uuid from the row you created
  • Navigate to your terminal and use the following command to see the dataset info: ddev drush dkan:dataset-info {{uuid here}}
  • Take note of the "table_name"
  • Navigate to your db 'example: ddev drush sqlc'
  • Enter the following sql describe {{table_name goes here}};
  • Confirm that the termination_date and fda_approval_date has a type of date

PART 6

  • In the same terminal enter the following sql: show index from datastore_0dbbe7015bf8d423d859697cff8fe729;
  • Confirm you see the index created for both the termination_date and fda_approval_date

@kaise-lafrai kaise-lafrai changed the title Index edit v2 Editable Index Jul 24, 2024
@kaise-lafrai kaise-lafrai self-assigned this Jul 24, 2024
/**
* Ajax callback to return index fields.
*/
public static function subIndexFormAjax(array &$form, FormStateInterface $form_state) {
return $form["field_json_metadata"]["widget"][0]["indexes"]["fields"];
//return $form["field_json_metadata"]["widget"][0]["indexes"]["edit_index"]["index_key_0"]["group"]["fields"]["fields"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove at later date.

$current_index_fields = $index_data_results ?? NULL;
// Creating ajax buttons/fields to be placed in correct location later.
foreach ($index_data_results as $indexKey => $data) {
if (self::checkIndexEditingField('index_field_key_' . $indexKey, $op_index, $index_fields_being_modified)) {
$element['edit_index_fields']['index_field_key_' . $indexKey] = IndexFieldEditCreation::editIndexFields('index_field_key_' . $indexKey, $current_index_fields, $index_fields_being_modified);
}
else {
//$element['edit_index_fields_buttons']['index_field_key_' . $indexKey]['edit_index_fields_button'] = IndexFieldButtons::editIndexButtons('index_field_key_' . $indexKey);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up later.

// Set access to index fields Add button when index fields being modified.
$element['indexes']['add_row_button']['#access'] = $index_being_modified == NULL ? TRUE : FALSE;

// if ($index_field_values || $current_index_fields || $index_being_modified || $index_fields_being_modified) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up later.

@@ -20,6 +20,7 @@
<td>{{ row.length }}</td>
<td>
{{ row.edit_index_button }}
{# {{ row.edit_index_fields_button }} #}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up later.

Copy link
Contributor

@rovcase rovcase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work Kaise! I just put notes for future reference to mark commented out code for cleaning.

@rovcase rovcase merged commit f6f5384 into Data-Dictionary-Index-Working Aug 1, 2024
9 checks passed
@rovcase rovcase deleted the Index-Edit-V2 branch August 1, 2024 19:49
dmundra pushed a commit that referenced this pull request Aug 9, 2024
dmundra pushed a commit that referenced this pull request Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants