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

Remove requirement for resource type. #11

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion config/install/context.context.audio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ conditions:
negate: false
context_mapping:
media: '@islandora.media_route_context_provider:media'
uri: 'http://purl.org/coar/resource_type/c_18cc,http://purl.org/dc/dcmitype/Sound'
uri: 'http://purl.org/coar/resource_type/c_18cc'
logic: and
reactions: { }
weight: -13
2 changes: 1 addition & 1 deletion config/install/context.context.basic_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ conditions:
negate: false
context_mapping:
media: '@islandora.media_route_context_provider:media'
uri: 'http://purl.org/coar/resource_type/c_c513,http://purl.org/dc/dcmitype/StillImage'
uri: 'http://purl.org/coar/resource_type/c_c513'
logic: and
reactions: { }
weight: -3
2 changes: 1 addition & 1 deletion config/install/context.context.book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ conditions:
negate: false
context_mapping:
node: '@node.node_route_context:node'
uri: 'https://schema.org/Book,http://purl.org/dc/dcmitype/Collection'
uri: 'https://schema.org/Book'
logic: and
reactions:
view_mode_alter:
Expand Down
2 changes: 1 addition & 1 deletion config/install/context.context.collection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ conditions:
negate: false
context_mapping:
node: '@node.node_route_context:node'
uri: 'http://purl.org/dc/dcmitype/Collection,http://purl.org/dc/dcmitype/Collection#Model'
uri: 'http://purl.org/dc/dcmitype/Collection'
logic: and
reactions:
blocks:
Expand Down
1 change: 0 additions & 1 deletion config/install/context.context.compound_member_object.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ conditions:
parent_reference_field: field_member_of
model_uri: 'http://vocab.getty.edu/aat/300242735'
logic: and
uri: 'http://purl.org/dc/dcmitype/Collection'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The PR is currently failing to do a drush site-install, i'm testing whether this is the line that's causing (sorry for misremembered wording) "Config could not be enabled."

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi Rosie - I'm not able to replicate this. Did you run make local which contains docker-compose exec -T drupal with-contenv bash -lc "drush si -y islandora_install_profile_demo --account-pass $(shell cat secrets/live/DRUPAL_DEFAULT_ACCOUNT_PASSWORD)" or a different function?

context_mapping:
node: '@node.node_route_context:node'
reactions:
Expand Down
2 changes: 1 addition & 1 deletion config/install/context.context.compund_parent_object.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ conditions:
negate: false
context_mapping:
node: '@node.node_route_context:node'
uri: 'http://purl.org/dc/dcmitype/Collection,http://vocab.getty.edu/aat/300242735'
uri: 'http://vocab.getty.edu/aat/300242735'
logic: and
reactions:
view_mode_alter:
Expand Down
2 changes: 1 addition & 1 deletion config/install/context.context.large_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ conditions:
negate: false
context_mapping:
media: '@islandora.media_route_context_provider:media'
uri: 'http://purl.org/coar/resource_type/c_c513,http://purl.org/dc/dcmitype/StillImage'
uri: 'http://purl.org/coar/resource_type/c_c513'
logic: and
reactions: { }
weight: -12
2 changes: 1 addition & 1 deletion config/install/context.context.newspaper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ conditions:
negate: false
context_mapping:
node: '@node.node_route_context:node'
uri: 'http://purl.org/dc/dcmitype/Collection,https://schema.org/Newspaper'
uri: 'https://schema.org/Newspaper'
logic: and
reactions:
blocks:
Expand Down
2 changes: 1 addition & 1 deletion config/install/context.context.newspaper_child_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ conditions:
negate: false
context_mapping:
node: '@node.node_route_context:node'
uri: 'https://schema.org/PublicationIssue,http://purl.org/dc/dcmitype/Collection'
uri: 'https://schema.org/PublicationIssue'
logic: and
reactions:
view_mode_alter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ entity_type: node
bundle: islandora_object
label: 'Resource Type'
description: ''
required: true
required: false
translatable: false
default_value: { }
default_value_callback: ''
Expand Down
2 changes: 1 addition & 1 deletion config/install/field.storage.node.field_resource_type.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ settings:
target_type: taxonomy_term
module: core
locked: false
cardinality: 1
cardinality: -1
translatable: true
indexes: { }
persist_with_no_fields: false
Expand Down
1 change: 1 addition & 0 deletions migrate/tags.csv
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ islandora_models,"Compound Object","A special type of collection where the paren
islandora_models,"Newspaper","A special type of collection which only has Newspaper Issues for children.",https://schema.org/Newspaper
islandora_display,"Open Seadragon","Display using the Open Seadragon viewer",http://openseadragon.github.io
islandora_display,"PDFjs","Display using the PDF.js viewer",http://mozilla.github.io/pdf.js
islandora_display,"Remote Video","Displays video from another site",https://github.com/Islandora/Crayfish/tree/dev/Homarus
resource_types,"Collection","An aggregation of resources",http://purl.org/dc/dcmitype/Collection
resource_types,"Dataset","Data encoded in a defined structure",http://purl.org/dc/dcmitype/Dataset
resource_types,"Image","A visual representation other than text",http://purl.org/dc/dcmitype/Image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,18 +660,17 @@ function islandora_install_profile_demo_core_entity_view(array &$build, EntityIn
//kpr($context_manager->getActiveContexts());
//\Drupal::messenger()->addStatus($view_mode);
// Added to avoid error message.
$empty_field_resource_type = '';
$empty_field_model = '';
$nodeModelType = '';
if ($display->getComponent('object_navigation') || ($entity->bundle() === 'extracted_text')) {
if ($entity->bundle() != 'extracted_text') {
$empty_field_resource_type = (!empty($entity->get('field_resource_type')->entity));
if ($empty_field_resource_type) {
$nodeResourceModelType = $entity->get('field_resource_type')->entity->getName();
$empty_field_model = (!empty($entity->get('field_model')->entity));
if ($empty_field_model) {
$nodeModelType = $entity->get('field_model')->entity->getName();
$immediate_parent_id = ($entity->hasField('field_member_of') && $entity->field_member_of instanceof Drupal\node\Entity\Node) ? $entity->get('field_member_of')->entity->id() : FALSE;
}
} else {
// Manually override for the OCR page.
$nodeResourceModelType = "Text";
$nodeModelType = "OCR";
if (isset($parentNode) && $parentNode->hasField('field_member_of')) {
$grandparent = $parentNode->get('field_member_of')->first();
Expand All @@ -697,17 +696,17 @@ function islandora_install_profile_demo_core_entity_view(array &$build, EntityIn
$url_object = Drupal\Core\Url::fromRoute('entity.node.canonical', ['node' => $entity->id()], $options);
// $displays = ['Full View', 'Pages', 'Page', 'OCR'];

if ($empty_field_resource_type || ($entity->bundle() === 'extracted_text')) {
if ($empty_field_model || ($entity->bundle() === 'extracted_text')) {
$build['object_navigation'] = [
'#theme' => 'islandora_object_links',
'#links' => [ ]
];
// This relies on there being a display media for each of these.
// Admin > Structure > Views > Display media
// The view uses the Taxonomy > islandora_media_use's PCDM URI to assign a page.
switch ("{$nodeModelType}_{$nodeResourceModelType}") {
switch ($nodeModelType) {
// PDF
case 'Digital Document_Text';
case 'Digital Document';
if ($ocrExist) {
$parent_url = Url::fromRoute('entity.node.canonical', ['node' => $immediate_parent_id], ['absolute' => TRUE]);
$build['object_navigation']['#links']['parent']['label'] = t('Full View');
Expand All @@ -719,13 +718,13 @@ function islandora_install_profile_demo_core_entity_view(array &$build, EntityIn
}
break;
// Newspaper
case 'Newspaper_Collection':
case 'Newspaper':
break;
case 'Publication Issue_Collection':
case 'Paged Content_Interactive Resource':
case 'Paged Content_Collection':
case 'Book_Collection':
case 'Content_Interactive Resource':
case 'Publication Issue':
case 'Paged Content':
case 'Paged Content':
case 'Book':
case 'Content':
// Current Page, no need for it to be a link
$parent_url = Url::fromRoute('entity.node.canonical', ['node' => $immediate_parent_id], ['absolute' => TRUE]);
$build['object_navigation']['#links']['parent']['label'] = t('Full View');
Expand All @@ -735,7 +734,7 @@ function islandora_install_profile_demo_core_entity_view(array &$build, EntityIn
$build['object_navigation']['#links']['pages']['label'] = t('Pages');
$build['object_navigation']['#links']['pages']['attributes'] = new Attribute(['class' => ['horizontal-tab-button'] ]);
break;
case 'OCR_Text':
case 'OCR':
$build['object_navigation']['#links']['parent']['url'] = $immediate_parent_id;
$build['object_navigation']['#links']['parent']['label'] = t('Full View');
$build['object_navigation']['#links']['parent']['attributes'] = new Attribute(['class' => ['horizontal-tab-button']]);
Expand All @@ -755,9 +754,7 @@ function islandora_install_profile_demo_core_entity_view(array &$build, EntityIn
$build['object_navigation']['#links']['ocr']['attributes'] = new Attribute(['class' => ['selected', 'horizontal-tab-button']]);
$build['object_navigation']['#links']['ocr']['label'] = t('OCR');
break;
case 'Page_Text':
case 'Page_Still Image':
case 'Page_Image':
case 'Page':
if ($immediate_parent_id) {
$parent_url = Url::fromRoute('entity.node.canonical', ['node' => $immediate_parent_id], ['absolute' => TRUE]);
$build['object_navigation']['#links']['parent']['url'] = $parent_url;
Expand Down Expand Up @@ -831,17 +828,6 @@ function islandora_install_profile_demo_core_module_implements_alter(&$implement
}
}

/**
* Implements hook_preprocess_HOOK().
*/
function islandora_install_profile_demo_core_preprocess_node(&$variables) {
$node = \Drupal::routeMatch()->getParameter('node');
if ($node instanceof \Drupal\node\NodeInterface && $node->hasField('field_resource_type')) {

}
}


/**
* Implements hook_views_pre_view().
* Make sure we overwrite certain views to get information on the parent object to properly display members
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,6 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
'#description' => t("Machine name of field that contains references to parent node."),
];

$form['term_resource_type'] = [
'#type' => 'entity_autocomplete',
'#title' => $this->t('Select Parent taxonomy term(s) reference with URI (resource type)'),
'#description' => $this->t('Only terms that have external URIs/URLs will appear here.'),
'#tags' => TRUE,
'#default_value' => $uri_default,
'#target_type' => 'taxonomy_term',
'#required' => FALSE,
'#selection_handler' => 'islandora:external_uri',
'#selection_settings' => [
'target_bundles' => array('resource_types'),
],

];


$form['term_model'] = array(
'#type' => 'entity_autocomplete',
Expand All @@ -161,7 +146,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// Set URI for term if possible.
$defaults = ['uri' => "term_resource_type", 'model_uri' => 'term_model'];
$defaults = ['model_uri' => 'term_model'];
foreach ($defaults as $field => $result_variable) {
$this->configuration[$field] = NULL;
$value = $form_state->getValue($result_variable);
Expand Down Expand Up @@ -190,7 +175,7 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s
*/
public function evaluate() {
$entity = $this->getContextValue('node');
if ((empty($this->configuration['uri']) && !$this->isNegated()) || (empty($this->configuration['model_uri']) && !$this->isNegated())) {
if ((empty($this->configuration['model_uri']) && !$this->isNegated())) {
return TRUE;
}

Expand Down