Skip to content

Commit

Permalink
Merge pull request #70 from UN-OCHA/develop
Browse files Browse the repository at this point in the history
UI tweaks
  • Loading branch information
attiks authored Apr 5, 2024
2 parents 768e993 + a0e484b commit 31606fc
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 55 deletions.
50 changes: 16 additions & 34 deletions config/core.entity_form_display.node.action_points.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ mode: default
content:
created:
type: datetime_timestamp
weight: 12
weight: 11
region: content
settings: { }
third_party_settings: { }
field_action_points:
type: text_textarea
weight: 11
weight: 10
region: content
settings:
rows: 5
Expand All @@ -48,7 +48,7 @@ content:
third_party_settings: { }
field_ai_feedback:
type: comment_default
weight: 19
weight: 16
region: content
settings: { }
third_party_settings: { }
Expand All @@ -59,37 +59,30 @@ content:
settings:
display_label: true
third_party_settings: { }
field_automatic_mode:
type: boolean_checkbox
weight: 5
region: content
settings:
display_label: true
third_party_settings: { }
field_document:
type: file_generic
weight: 8
weight: 7
region: content
settings:
progress_indicator: throbber
third_party_settings: { }
field_document_language:
type: options_select
weight: 6
weight: 5
region: content
settings: { }
third_party_settings: { }
field_document_text:
type: string_textarea
weight: 10
weight: 9
region: content
settings:
rows: 5
placeholder: ''
third_party_settings: { }
field_output_language:
type: options_select
weight: 7
weight: 6
region: content
settings: { }
third_party_settings: { }
Expand All @@ -102,13 +95,13 @@ content:
third_party_settings: { }
moderation_state:
type: moderation_state_default
weight: 17
weight: 14
region: content
settings: { }
third_party_settings: { }
path:
type: path
weight: 15
weight: 12
region: content
settings: { }
third_party_settings: { }
Expand All @@ -118,23 +111,9 @@ content:
region: content
settings: { }
third_party_settings: { }
promote:
type: boolean_checkbox
weight: 13
region: content
settings:
display_label: true
third_party_settings: { }
status:
type: boolean_checkbox
weight: 18
region: content
settings:
display_label: true
third_party_settings: { }
sticky:
type: boolean_checkbox
weight: 14
weight: 15
region: content
settings:
display_label: true
Expand All @@ -149,7 +128,7 @@ content:
third_party_settings: { }
uid:
type: entity_reference_autocomplete
weight: 9
weight: 8
region: content
settings:
match_operator: CONTAINS
Expand All @@ -158,8 +137,11 @@ content:
placeholder: ''
third_party_settings: { }
url_redirects:
weight: 16
weight: 13
region: content
settings: { }
third_party_settings: { }
hidden: { }
hidden:
field_automatic_mode: true
promote: true
sticky: true
34 changes: 14 additions & 20 deletions config/core.entity_form_display.node.summary.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mode: default
content:
created:
type: datetime_timestamp
weight: 16
weight: 15
region: content
settings: { }
third_party_settings: { }
Expand All @@ -40,7 +40,7 @@ content:
third_party_settings: { }
field_ai_feedback:
type: comment_default
weight: 18
weight: 17
region: content
settings: { }
third_party_settings: { }
Expand All @@ -51,49 +51,42 @@ content:
settings:
display_label: true
third_party_settings: { }
field_automatic_mode:
type: boolean_checkbox
weight: 5
region: content
settings:
display_label: true
third_party_settings: { }
field_document:
type: file_generic
weight: 9
weight: 8
region: content
settings:
progress_indicator: throbber
third_party_settings: { }
field_document_language:
type: options_select
weight: 7
weight: 6
region: content
settings: { }
third_party_settings: { }
field_document_text:
type: string_textarea
weight: 10
weight: 9
region: content
settings:
rows: 5
placeholder: ''
third_party_settings: { }
field_number_of_paragraphs:
type: options_select
weight: 6
weight: 5
region: content
settings: { }
third_party_settings: { }
field_output_language:
type: options_select
weight: 8
weight: 7
region: content
settings: { }
third_party_settings: { }
field_summary:
type: string_textarea
weight: 11
weight: 10
region: content
settings:
rows: 5
Expand All @@ -108,13 +101,13 @@ content:
third_party_settings: { }
moderation_state:
type: moderation_state_default
weight: 12
weight: 11
region: content
settings: { }
third_party_settings: { }
path:
type: path
weight: 13
weight: 12
region: content
settings: { }
third_party_settings: { }
Expand All @@ -126,7 +119,7 @@ content:
third_party_settings: { }
status:
type: boolean_checkbox
weight: 15
weight: 14
region: content
settings:
display_label: true
Expand All @@ -141,7 +134,7 @@ content:
third_party_settings: { }
uid:
type: entity_reference_autocomplete
weight: 17
weight: 16
region: content
settings:
match_operator: CONTAINS
Expand All @@ -150,10 +143,11 @@ content:
placeholder: ''
third_party_settings: { }
url_redirects:
weight: 14
weight: 13
region: content
settings: { }
third_party_settings: { }
hidden:
field_automatic_mode: true
promote: true
sticky: true
6 changes: 6 additions & 0 deletions config/filter.format.text_editor_simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ name: 'Text Editor - Simple'
format: text_editor_simple
weight: 0
filters:
filter_autop:
id: filter_autop
provider: filter
status: true
weight: 0
settings: { }
filter_url:
id: filter_url
provider: filter
Expand Down
2 changes: 1 addition & 1 deletion config/views.view.my_documents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ display:
plugin_id: text
empty: false
content:
value: 'Welcome to OCHA’s private AI-based document summarization tool. You can upload documents written in any of the 6 UN languages and receive output in any of those languages. Since this is a proof-of-concept that is powered by AI, <strong>please check for mistakes</strong>.'
value: 'Welcome to OCHA’s private AI-based document summarization tool. You can upload documents written in any of the 6 UN languages and receive output in any of those languages. Since this is a proof-of-concept that is powered by AI, <strong>please check for mistakes</strong>.<br>'
format: text_editor_simple
tokenize: false
footer: { }
Expand Down
50 changes: 50 additions & 0 deletions html/modules/custom/ocha_ai_summarize/ocha_ai_summarize.module
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ use Symfony\Component\Process\Process;
function ocha_ai_summarize_node_insert(EntityInterface $entity) {
ocha_ai_summarize_node_update($entity);

\Drupal::messenger()->addMessage(t("Your document has been queued for processing and will be ready in 10 to 15 minutes, you'll receive an email when it's ready."));

// Auto create other nodes?
/** @var \Drupal\node\Entity\Node $entity */
if (!$entity->hasField('field_auto_create')) {
Expand Down Expand Up @@ -394,16 +396,64 @@ function ocha_ai_summarize_node_view(array &$build, EntityInterface $entity, Ent
/** @var \Drupal\node\Entity\Node $entity */
switch ($entity->bundle()) {
case 'summary':
ocha_ai_summarize_node_view_moderation_state($build, $entity, $display, $view_mode);
ocha_ai_summarize_node_view_compare($build, $entity, $display, $view_mode);
break;

case 'action_points':
ocha_ai_summarize_node_view_moderation_state($build, $entity, $display, $view_mode);
ocha_ai_summarize_node_view_action_points_compare($build, $entity, $display, $view_mode);
break;

}
}

/**
* Implements hook_ENTITY_TYPE_view().
*/
function ocha_ai_summarize_node_view_moderation_state(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
/** @var \Drupal\node\Entity\Node $entity */
if ($entity->bundle() !== 'summary' && $entity->bundle() !== 'action_points') {
return;
}

if ($entity->isPublished()) {
return;
}

$content_moderation_state = ContentModerationState::loadFromModeratedEntity($entity);
if (!$content_moderation_state) {
$state = 'document_uploaded';
}
else {
$state = $content_moderation_state->get('moderation_state')->value;
}

// Do not display when in final state.
if ($state == 'summarized' || $state == 'action_points_created') {
return;
}

/** @var \Drupal\content_moderation\ModerationInformation $moderation_information_service */
$moderation_information_service = \Drupal::service('content_moderation.moderation_information');
$workflow = $moderation_information_service->getWorkflowForEntity($entity);
$label = $workflow->getTypePlugin()->getState($state)->label();

$build['moderation_state'] = [
'#type' => 'markup',
'#markup' => $label,
'#prefix' => '<div class="field--label-inline moderation-state-label"><div class="field__label">' . t('Status') . '</div><div class="field__item">',
'#suffix' => '</div></div>',
'#attributes' => [
'class' => [
'cd-button',
],
],
'#weight' => -100,
];

}

/**
* Implements hook_ENTITY_TYPE_view().
*/
Expand Down
8 changes: 8 additions & 0 deletions html/themes/custom/common_design_subtheme/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,11 @@ ol.workflow-steps > li.to-do {
.comment-form-feedback {
margin-top: 2rem;
}

.field--label-inline .field__label {
padding-right: .3rem;
}

.field--label-inline .field__label:after {
content: ':';
}

0 comments on commit 31606fc

Please sign in to comment.