From 9e791e4e92868a44adf9fc2fa59a897f881ceb40 Mon Sep 17 00:00:00 2001 From: Oleksandr Yermolenko Date: Wed, 20 Nov 2024 11:47:56 +0100 Subject: [PATCH] PROD-31065, Rework of reports page to add delete option, filters and fix error on view action --- .../install/views.view.report_overview.yml | 1057 +++++++++++------ .../social_content_report_update_130003.yml | 150 +++ .../social_content_report.install | 209 +++- .../src/Controller/ReportController.php | 3 +- .../Plugin/views/field/LinkReportClose.php | 7 + 5 files changed, 1062 insertions(+), 364 deletions(-) create mode 100644 modules/social_features/social_content_report/config/update/social_content_report_update_130003.yml diff --git a/modules/social_features/social_content_report/config/install/views.view.report_overview.yml b/modules/social_features/social_content_report/config/install/views.view.report_overview.yml index 9c394849703..6fec4f798fe 100644 --- a/modules/social_features/social_content_report/config/install/views.view.report_overview.yml +++ b/modules/social_features/social_content_report/config/install/views.view.report_overview.yml @@ -8,16 +8,17 @@ dependencies: - flag.flag.report_node - flag.flag.report_post - system.menu.admin - enforced: - module: - - social_content_report module: + - better_exposed_filters - comment - flag - node - social_content_report - social_post - user + enforced: + module: + - social_content_report id: report_overview label: 'Report overview' module: views @@ -27,237 +28,12 @@ base_table: flagging base_field: id display: default: - display_plugin: default id: default display_title: Master + display_plugin: default position: 0 display_options: - access: - type: perm - options: - perm: 'view inappropriate reports' - cache: - type: tag - options: { } - query: - type: views_query - options: - disable_sql_rewrite: true - distinct: false - replica: false - query_comment: '' - query_tags: { } - exposed_form: - type: basic - options: - submit_button: Filter - reset_button: false - reset_button_label: Reset - exposed_sorts_label: 'Sort by' - expose_sort_order: true - sort_asc_label: Asc - sort_desc_label: Desc - pager: - type: full - options: - items_per_page: 25 - offset: 0 - id: 0 - total_pages: null - tags: - previous: ‹‹ - next: ›› - first: '« First' - last: 'Last »' - expose: - items_per_page: false - items_per_page_label: 'Items per page' - items_per_page_options: '5, 10, 25, 50' - items_per_page_options_all: false - items_per_page_options_all_label: '- All -' - offset: false - offset_label: Offset - quantity: 9 - style: - type: table - options: - grouping: { } - row_class: '' - default_row_class: true - override: true - sticky: false - caption: '' - summary: '' - description: '' - columns: - uid: uid - created: created - entity_type: entity_type - user_id: user_id - changed: changed - uid_1: uid_1 - changed_1: changed_1 - uid_2: uid_2 - changed_2: changed_2 - nothing: nothing - nothing_1: nothing_1 - field_reason: field_reason - field_other_reason: field_other_reason - view_comment: view_comment - view_post: view_post - view_node: view_node - edit_comment: edit_comment - edit_post: edit_post - edit_node: edit_node - dropbutton: dropbutton - info: - uid: - sortable: true - default_sort_order: desc - align: '' - separator: '' - empty_column: false - responsive: '' - created: - sortable: true - default_sort_order: desc - align: '' - separator: '' - empty_column: false - responsive: '' - entity_type: - sortable: true - default_sort_order: desc - align: '' - separator: '' - empty_column: false - responsive: '' - user_id: - sortable: false - default_sort_order: desc - align: '' - separator: '' - empty_column: false - responsive: '' - changed: - sortable: false - default_sort_order: desc - align: '' - separator: '' - empty_column: false - responsive: '' - uid_1: - sortable: false - default_sort_order: desc - align: '' - separator: '' - empty_column: false - responsive: '' - changed_1: - sortable: false - default_sort_order: desc - align: '' - separator: '' - empty_column: false - responsive: '' - uid_2: - sortable: false - default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' - changed_2: - sortable: false - default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' - nothing: - sortable: true - default_sort_order: desc - align: '' - separator: '' - empty_column: false - responsive: '' - nothing_1: - sortable: true - default_sort_order: desc - align: '' - separator: '' - empty_column: false - responsive: '' - field_reason: - sortable: true - default_sort_order: desc - align: '' - separator: '' - empty_column: false - responsive: '' - field_other_reason: - align: '' - separator: '' - empty_column: false - responsive: '' - view_comment: - sortable: false - default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' - view_post: - sortable: false - default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' - view_node: - sortable: false - default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' - edit_comment: - sortable: false - default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' - edit_post: - sortable: false - default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' - edit_node: - sortable: false - default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' - dropbutton: - sortable: false - default_sort_order: asc - align: '' - separator: '' - empty_column: false - responsive: '' - default: created - empty_table: false - row: - type: fields - options: - default_field_elements: true - inline: { } - separator: '' - hide_empty: false + title: 'Report overview' fields: uid: id: uid @@ -266,6 +42,9 @@ display: relationship: none group_type: group admin_label: '' + entity_type: flagging + entity_field: uid + plugin_id: field label: Reporter exclude: false alter: @@ -320,9 +99,6 @@ display: multi_type: separator separator: ', ' field_api_classes: false - entity_type: flagging - entity_field: uid - plugin_id: field created: id: created table: flagging @@ -330,6 +106,9 @@ display: relationship: none group_type: group admin_label: '' + entity_type: flagging + entity_field: created + plugin_id: field label: Reported exclude: false alter: @@ -377,6 +156,15 @@ display: date_format: medium custom_date_format: '' timezone: '' + tooltip: + date_format: '' + custom_date_format: '' + time_diff: + enabled: false + future_format: '@interval hence' + past_format: '@interval ago' + granularity: 2 + refresh: 60 group_column: value group_columns: { } group_rows: true @@ -387,9 +175,6 @@ display: multi_type: separator separator: ', ' field_api_classes: false - entity_type: flagging - entity_field: created - plugin_id: field entity_bundle_type: id: entity_bundle_type table: flagging @@ -397,6 +182,8 @@ display: relationship: none group_type: group admin_label: '' + entity_type: flagging + plugin_id: flagging_entity_bundle_type label: 'Content Type' exclude: false alter: @@ -438,8 +225,6 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true - entity_type: flagging - plugin_id: flagging_entity_bundle_type user_id: id: user_id table: post_field_data @@ -447,6 +232,9 @@ display: relationship: flag_report_post group_type: group admin_label: '' + entity_type: post + entity_field: user_id + plugin_id: field label: '' exclude: true alter: @@ -502,9 +290,6 @@ display: multi_type: separator separator: ', ' field_api_classes: false - entity_type: post - entity_field: user_id - plugin_id: field changed: id: changed table: post_field_data @@ -512,7 +297,10 @@ display: relationship: flag_report_post group_type: group admin_label: '' - label: '' + entity_type: post + entity_field: changed + plugin_id: field + label: '' exclude: true alter: alter_text: false @@ -559,6 +347,15 @@ display: date_format: medium custom_date_format: '' timezone: '' + tooltip: + date_format: '' + custom_date_format: '' + time_diff: + enabled: false + future_format: '@interval hence' + past_format: '@interval ago' + granularity: 2 + refresh: 60 group_column: value group_columns: { } group_rows: true @@ -569,9 +366,6 @@ display: multi_type: separator separator: ', ' field_api_classes: false - entity_type: post - entity_field: changed - plugin_id: field uid_1: id: uid_1 table: comment_field_data @@ -579,6 +373,9 @@ display: relationship: flag_report_comment group_type: group admin_label: '' + entity_type: comment + entity_field: uid + plugin_id: field label: '' exclude: true alter: @@ -634,9 +431,6 @@ display: multi_type: separator separator: ', ' field_api_classes: false - entity_type: comment - entity_field: uid - plugin_id: field changed_1: id: changed_1 table: comment_field_data @@ -644,6 +438,9 @@ display: relationship: flag_report_comment group_type: group admin_label: '' + entity_type: comment + entity_field: changed + plugin_id: field label: '' exclude: true alter: @@ -691,6 +488,15 @@ display: date_format: medium custom_date_format: '' timezone: '' + tooltip: + date_format: '' + custom_date_format: '' + time_diff: + enabled: false + future_format: '@interval hence' + past_format: '@interval ago' + granularity: 2 + refresh: 60 group_column: value group_columns: { } group_rows: true @@ -701,9 +507,6 @@ display: multi_type: separator separator: ', ' field_api_classes: false - entity_type: comment - entity_field: changed - plugin_id: field uid_2: id: uid_2 table: node_field_data @@ -711,6 +514,9 @@ display: relationship: flag_report_node group_type: group admin_label: '' + entity_type: node + entity_field: uid + plugin_id: field label: '' exclude: true alter: @@ -766,9 +572,6 @@ display: multi_type: separator separator: ', ' field_api_classes: false - entity_type: node - entity_field: uid - plugin_id: field changed_2: id: changed_2 table: node_field_data @@ -776,6 +579,9 @@ display: relationship: flag_report_node group_type: group admin_label: '' + entity_type: node + entity_field: changed + plugin_id: field label: '' exclude: true alter: @@ -823,6 +629,15 @@ display: date_format: medium custom_date_format: '' timezone: '' + tooltip: + date_format: '' + custom_date_format: '' + time_diff: + enabled: false + future_format: '@interval hence' + past_format: '@interval ago' + granularity: 2 + refresh: 60 group_column: value group_columns: { } group_rows: true @@ -833,9 +648,6 @@ display: multi_type: separator separator: ', ' field_api_classes: false - entity_type: node - entity_field: changed - plugin_id: field nothing: id: nothing table: views @@ -843,6 +655,7 @@ display: relationship: none group_type: group admin_label: '' + plugin_id: custom label: Author exclude: false alter: @@ -884,7 +697,6 @@ display: hide_empty: false empty_zero: false hide_alter_empty: false - plugin_id: custom nothing_1: id: nothing_1 table: views @@ -892,6 +704,7 @@ display: relationship: none group_type: group admin_label: '' + plugin_id: custom label: Updated exclude: false alter: @@ -933,7 +746,6 @@ display: hide_empty: false empty_zero: false hide_alter_empty: false - plugin_id: custom field_reason: id: field_reason table: flagging__field_reason @@ -941,6 +753,7 @@ display: relationship: none group_type: group admin_label: '' + plugin_id: field label: Reason exclude: false alter: @@ -996,7 +809,6 @@ display: multi_type: separator separator: ', ' field_api_classes: false - plugin_id: field field_other_reason: id: field_other_reason table: flagging__field_other_reason @@ -1004,6 +816,7 @@ display: relationship: none group_type: group admin_label: '' + plugin_id: field label: Description exclude: false alter: @@ -1058,7 +871,6 @@ display: multi_type: separator separator: ', ' field_api_classes: false - plugin_id: field view_comment: id: view_comment table: comment @@ -1066,12 +878,14 @@ display: relationship: flag_report_comment group_type: group admin_label: '' + entity_type: comment + plugin_id: entity_link label: '' exclude: true alter: alter_text: false text: '' - make_link: false + make_link: true path: '' absolute: false external: false @@ -1083,7 +897,7 @@ display: link_class: '' prefix: '' suffix: '' - target: '' + target: _blank nl2br: false max_length: 0 word_boundary: true @@ -1110,8 +924,6 @@ display: text: 'View Comment' output_url_as_text: false absolute: false - entity_type: comment - plugin_id: entity_link view_post: id: view_post table: post @@ -1119,6 +931,8 @@ display: relationship: flag_report_post group_type: group admin_label: '' + entity_type: post + plugin_id: entity_link label: '' exclude: true alter: @@ -1163,8 +977,6 @@ display: text: 'View Post' output_url_as_text: false absolute: false - entity_type: post - plugin_id: entity_link view_node: id: view_node table: node @@ -1172,6 +984,8 @@ display: relationship: flag_report_node group_type: group admin_label: '' + entity_type: node + plugin_id: entity_link label: '' exclude: true alter: @@ -1216,8 +1030,6 @@ display: text: 'View Content' output_url_as_text: false absolute: false - entity_type: node - plugin_id: entity_link edit_comment: id: edit_comment table: comment @@ -1225,6 +1037,8 @@ display: relationship: flag_report_comment group_type: group admin_label: '' + entity_type: comment + plugin_id: entity_link_edit label: '' exclude: true alter: @@ -1269,8 +1083,6 @@ display: text: 'Edit Comment' output_url_as_text: false absolute: false - entity_type: comment - plugin_id: entity_link_edit edit_post: id: edit_post table: post @@ -1278,6 +1090,8 @@ display: relationship: flag_report_post group_type: group admin_label: '' + entity_type: post + plugin_id: entity_link_edit label: '' exclude: true alter: @@ -1322,8 +1136,6 @@ display: text: 'Edit Post' output_url_as_text: false absolute: false - entity_type: post - plugin_id: entity_link_edit edit_node: id: edit_node table: node @@ -1331,6 +1143,8 @@ display: relationship: flag_report_node group_type: group admin_label: '' + entity_type: node + plugin_id: entity_link_edit label: '' exclude: true alter: @@ -1375,8 +1189,6 @@ display: text: 'Edit Content' output_url_as_text: false absolute: false - entity_type: node - plugin_id: entity_link_edit close_report: id: close_report table: flagging @@ -1384,6 +1196,8 @@ display: relationship: none group_type: group admin_label: '' + entity_type: flagging + plugin_id: flagging_link_close label: '' exclude: true alter: @@ -1426,8 +1240,165 @@ display: empty_zero: false hide_alter_empty: true text: 'Close Report' - entity_type: flagging - plugin_id: flagging_link_close + delete_comment: + id: delete_comment + table: comment + field: delete_comment + relationship: flag_report_comment + group_type: group + admin_label: '' + entity_type: comment + plugin_id: entity_link_delete + label: 'Delete Comment' + exclude: true + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + text: 'Delete Comment' + output_url_as_text: false + absolute: false + delete_post: + id: delete_post + table: post + field: delete_post + relationship: flag_report_post + group_type: group + admin_label: '' + entity_type: post + plugin_id: entity_link_delete + label: '' + exclude: true + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + text: 'Delete Post' + output_url_as_text: false + absolute: false + delete_node: + id: delete_node + table: node + field: delete_node + relationship: flag_report_node + group_type: group + admin_label: '' + entity_type: node + plugin_id: entity_link_delete + label: '' + exclude: true + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + text: 'Delete Content' + output_url_as_text: false + absolute: false dropbutton: id: dropbutton table: views @@ -1435,6 +1406,7 @@ display: relationship: none group_type: group admin_label: '' + plugin_id: dropbutton label: Operations exclude: false alter: @@ -1476,6 +1448,7 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true + destination: false fields: view_comment: view_comment view_post: view_post @@ -1484,6 +1457,9 @@ display: edit_post: edit_post edit_node: edit_node close_report: close_report + delete_comment: delete_comment + delete_post: delete_post + delete_node: delete_node uid: '0' created: '0' entity_bundle_type: '0' @@ -1497,51 +1473,114 @@ display: nothing_1: '0' field_reason: '0' field_other_reason: '0' - destination: true - plugin_id: dropbutton - filters: - flag_id: - id: flag_id - table: flagging - field: flag_id - relationship: none - group_type: group - admin_label: '' - operator: in - value: - report_comment: report_comment - report_node: report_node - report_post: report_post - group: 1 - exposed: false + pager: + type: full + options: + offset: 0 + pagination_heading_level: h4 + items_per_page: 25 + total_pages: null + id: 0 + tags: + next: ›› + previous: ‹‹ + first: '« First' + last: 'Last »' expose: - operator_id: '' - label: '' - description: '' - use_operator: false - operator: '' - identifier: '' - required: false - remember: false - multiple: false - remember_roles: - authenticated: authenticated - reduce: false - is_grouped: false - group_info: - label: '' - description: '' - identifier: '' - optional: true - widget: select - multiple: false - remember: false - default_group: All - default_group_multiple: { } - group_items: { } + items_per_page: false + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 25, 50' + items_per_page_options_all: false + items_per_page_options_all_label: '- All -' + offset: false + offset_label: Offset + quantity: 9 + exposed_form: + type: bef + options: + submit_button: Filter + reset_button: true + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: true + sort_asc_label: Asc + sort_desc_label: Desc + text_input_required: 'Select any filter and click on Apply to see results' + text_input_required_format: basic_html + bef: + general: + autosubmit: false + autosubmit_exclude_textfield: false + autosubmit_textfield_delay: 500 + autosubmit_hide: false + input_required: false + allow_secondary: false + secondary_label: 'Advanced options' + secondary_open: false + reset_button_always_show: false + filter: + flag_id: + plugin_id: bef + advanced: + sort_options: false + rewrite: + filter_rewrite_values: "Report inappropriate comment|Comment\r\nReport inappropriate nodes|Nodes\r\nReport inappropriate post|Post" + filter_rewrite_values_key: false + collapsible: false + collapsible_disable_automatic_open: false + is_secondary: false + select_all_none: false + select_all_none_nested: false + display_inline: true + field_status_value: + plugin_id: default + advanced: + sort_options: false + rewrite: + filter_rewrite_values: "True|Open\r\nFalse|Closed" + filter_rewrite_values_key: false + collapsible: false + collapsible_disable_automatic_open: false + is_secondary: false + access: + type: perm + options: + perm: 'view inappropriate reports' + cache: + type: tag + options: { } + empty: + area: + id: area + table: views + field: area + relationship: none + group_type: group + admin_label: '' + plugin_id: text + empty: true + content: + value: 'No reports available.' + format: basic_html + tokenize: false + sorts: + created: + id: created + table: flagging + field: created + relationship: none + group_type: group + admin_label: '' entity_type: flagging - entity_field: flag_id - plugin_id: bundle + entity_field: created + plugin_id: date + order: DESC + expose: + label: '' + exposed: false + granularity: second + arguments: { } + filters: field_status_value: id: field_status_value table: flagging__field_status @@ -1549,22 +1588,28 @@ display: relationship: none group_type: group admin_label: '' + plugin_id: boolean operator: '=' value: '1' group: 1 - exposed: false + exposed: true expose: operator_id: '' - label: '' + label: 'Report Status' description: '' use_operator: false - operator: '' - identifier: '' + operator: field_status_value_op + operator_limit_selection: false + operator_list: { } + identifier: field_status_value required: false remember: false multiple: false remember_roles: authenticated: authenticated + anonymous: '0' + administrator: '0' + verified: '0' is_grouped: false group_info: label: '' @@ -1577,40 +1622,242 @@ display: default_group: All default_group_multiple: { } group_items: { } - plugin_id: boolean - sorts: - created: - id: created + flag_id: + id: flag_id table: flagging - field: created + field: flag_id relationship: none group_type: group admin_label: '' - order: DESC - exposed: false + entity_type: flagging + entity_field: flag_id + plugin_id: bundle + operator: in + value: + report_comment: report_comment + report_node: report_node + report_post: report_post + group: 1 + exposed: true expose: + operator_id: flag_id_op + label: 'Content Type' + description: '' + use_operator: false + operator: flag_id_op + operator_limit_selection: false + operator_list: { } + identifier: flag_id + required: false + remember: false + multiple: true + remember_roles: + authenticated: authenticated + reduce: true + is_grouped: false + group_info: label: '' - granularity: second - entity_type: flagging - entity_field: created - plugin_id: date - title: 'Report overview' - header: { } - footer: { } - empty: - area: - id: area - table: views - field: area - relationship: none - group_type: group - admin_label: '' - empty: true - tokenize: false - content: - value: 'No reports available.' - format: basic_html - plugin_id: text + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + filter_groups: + operator: AND + groups: + 1: AND + style: + type: table + options: + grouping: { } + row_class: '' + default_row_class: true + columns: + uid: uid + created: created + entity_type: entity_type + user_id: user_id + changed: changed + uid_1: uid_1 + changed_1: changed_1 + uid_2: uid_2 + changed_2: changed_2 + nothing: nothing + nothing_1: nothing_1 + field_reason: field_reason + field_other_reason: field_other_reason + view_comment: view_comment + view_post: view_post + view_node: view_node + edit_comment: edit_comment + edit_post: edit_post + edit_node: edit_node + dropbutton: dropbutton + default: created + info: + uid: + sortable: true + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' + created: + sortable: true + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' + entity_type: + sortable: true + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' + user_id: + sortable: false + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' + changed: + sortable: false + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' + uid_1: + sortable: false + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' + changed_1: + sortable: false + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' + uid_2: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + changed_2: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + nothing: + sortable: true + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' + nothing_1: + sortable: true + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' + field_reason: + sortable: true + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' + field_other_reason: + align: '' + separator: '' + empty_column: false + responsive: '' + view_comment: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + view_post: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + view_node: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + edit_comment: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + edit_post: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + edit_node: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + dropbutton: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + override: true + sticky: false + summary: '' + empty_table: false + caption: '' + description: '' + row: + type: fields + options: + default_field_elements: true + inline: { } + separator: '' + hide_empty: false + query: + type: views_query + options: + query_comment: '' + disable_sql_rewrite: true + distinct: false + replica: false + query_tags: { } relationships: flag_report_post: id: flag_report_post @@ -1619,9 +1866,9 @@ display: relationship: none group_type: group admin_label: Post - required: false entity_type: flagging plugin_id: standard + required: false flag_report_comment: id: flag_report_comment table: flagging @@ -1629,9 +1876,9 @@ display: relationship: none group_type: group admin_label: Comment - required: false entity_type: flagging plugin_id: standard + required: false flag_report_node: id: flag_report_node table: flagging @@ -1639,44 +1886,132 @@ display: relationship: none group_type: group admin_label: Content - required: false entity_type: flagging plugin_id: standard - arguments: { } + required: false + header: { } + footer: { } display_extenders: { } cache_metadata: max-age: -1 contexts: - 'languages:language_content' - 'languages:language_interface' + - url - url.query_args - user.permissions tags: - 'config:field.storage.flagging.field_other_reason' - 'config:field.storage.flagging.field_reason' overview: - display_plugin: page id: overview display_title: Overview + display_plugin: page position: 1 display_options: - display_extenders: { } + display_description: '' + display_extenders: + views_ef_fieldset: + views_ef_fieldset: + enabled: false + options: + sort: + root: + container_type: details + depth: '0' + description: '' + id: root + open: true + pid: '' + title: Filters + type: container + weight: '0' + reset: + depth: '1' + id: reset + pid: root + type: buttons + weight: '-7' + flag_id: + depth: '1' + id: flag_id + pid: root + type: filter + weight: '-6' + field_status_value: + depth: '1' + id: field_status_value + pid: root + type: filter + weight: '-6' + submit: + depth: '1' + id: submit + pid: root + type: buttons + weight: '-6' + container-0: + container_type: details + depth: '1' + description: '' + id: container-0 + open: false + pid: root + title: 'Container 0' + type: container + weight: '-5' + container-1: + container_type: details + depth: '1' + description: '' + id: container-1 + open: false + pid: root + title: 'Container 1' + type: container + weight: '-4' + container-2: + container_type: details + depth: '1' + description: '' + id: container-2 + open: false + pid: root + title: 'Container 2' + type: container + weight: '-3' + container-3: + container_type: details + depth: '1' + description: '' + id: container-3 + open: false + pid: root + title: 'Container 3' + type: container + weight: '-3' path: admin/content/reports menu: type: normal title: Reports description: '' + weight: 0 expanded: true + menu_name: admin parent: system.admin_content - weight: 0 context: '0' - menu_name: admin - display_description: '' + form_blocks: + facets: 0 + items: + _form: + weight: '0' + enabled: '1' cache_metadata: max-age: -1 contexts: - 'languages:language_content' - 'languages:language_interface' + - url - url.query_args - user.permissions tags: diff --git a/modules/social_features/social_content_report/config/update/social_content_report_update_130003.yml b/modules/social_features/social_content_report/config/update/social_content_report_update_130003.yml new file mode 100644 index 00000000000..02f63e3f8c3 --- /dev/null +++ b/modules/social_features/social_content_report/config/update/social_content_report_update_130003.yml @@ -0,0 +1,150 @@ +views.view.report_overview: + expected_config: { } + update_actions: + add: + dependencies: + module: + - better_exposed_filters + display: + default: + display_options: + filters: + field_status_value: + id: field_status_value + table: flagging__field_status + field: field_status_value + relationship: none + group_type: group + admin_label: '' + plugin_id: boolean + operator: '=' + value: '1' + group: 1 + exposed: true + expose: + operator_id: '' + label: 'Report Status' + description: '' + use_operator: false + operator: field_status_value_op + operator_limit_selection: false + operator_list: { } + identifier: field_status_value + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + anonymous: '0' + administrator: '0' + verified: '0' + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + flag_id: + id: flag_id + table: flagging + field: flag_id + relationship: none + group_type: group + admin_label: '' + entity_type: flagging + entity_field: flag_id + plugin_id: bundle + operator: in + value: + report_comment: report_comment + report_node: report_node + report_post: report_post + group: 1 + exposed: true + expose: + operator_id: flag_id_op + label: 'Content Type' + description: '' + use_operator: false + operator: flag_id_op + operator_limit_selection: false + operator_list: { } + identifier: flag_id + required: false + remember: false + multiple: true + remember_roles: + authenticated: authenticated + reduce: true + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + exposed_form: + type: bef + options: + submit_button: Filter + reset_button: true + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: true + sort_asc_label: Asc + sort_desc_label: Desc + text_input_required: 'Select any filter and click on Apply to see results' + text_input_required_format: basic_html + bef: + general: + autosubmit: false + autosubmit_exclude_textfield: false + autosubmit_textfield_delay: 500 + autosubmit_hide: false + input_required: false + allow_secondary: false + secondary_label: 'Advanced options' + secondary_open: false + reset_button_always_show: false + filter: + flag_id: + plugin_id: bef + advanced: + sort_options: false + rewrite: + filter_rewrite_values: "Report inappropriate comment|Comment\r\nReport inappropriate nodes|Nodes\r\nReport inappropriate post|Post" + filter_rewrite_values_key: false + collapsible: false + collapsible_disable_automatic_open: false + is_secondary: false + select_all_none: false + select_all_none_nested: false + display_inline: true + field_status_value: + plugin_id: default + advanced: + sort_options: false + rewrite: + filter_rewrite_values: "True|Open\r\nFalse|Closed" + filter_rewrite_values_key: false + collapsible: false + collapsible_disable_automatic_open: false + is_secondary: false + cache_metadata: + contexts: + - url + overview: + cache_metadata: + contexts: + - url diff --git a/modules/social_features/social_content_report/social_content_report.install b/modules/social_features/social_content_report/social_content_report.install index 7c556ed997d..0bd3d13b462 100644 --- a/modules/social_features/social_content_report/social_content_report.install +++ b/modules/social_features/social_content_report/social_content_report.install @@ -39,7 +39,8 @@ function social_content_report_install() { } } catch (EntityStorageException $exception) { - \Drupal::logger('social_content_report')->error(t('The term "@term" could not be created.', ['@term' => $name])); + \Drupal::logger('social_content_report') + ->error(t('The term "@term" could not be created.', ['@term' => $name])); } } @@ -89,7 +90,7 @@ function social_content_report_install() { /** * Implements hook_update_last_removed(). */ -function social_content_report_update_last_removed() : int { +function social_content_report_update_last_removed(): int { return 11401; } @@ -145,3 +146,207 @@ function social_content_report_update_130002(): void { ->save(); } } + +/** + * Update Reports page views, adding filters and "remove" button. + */ +function social_content_report_update_130003(): string { + // This is skipping the update helper because we need to add fields to the + // exact place of the fields list. Unfortunately, this is only controlled by + // the order in which the fields are added, not by the weight attribute. When + // adding it via the update helper, the new field is appended to the bottom of + // the fields list. + $config = \Drupal::configFactory()->getEditable('views.view.report_overview'); + + $fields = $config->get('display.default.display_options.fields'); + + // Set new field in the beginning, so it can be used in the "dropdown" field. + $new_field = [ + 'delete_comment' => [ + 'id' => 'delete_comment', + 'table' => 'comment', + 'field' => 'delete_comment', + 'relationship' => 'flag_report_comment', + 'group_type' => 'group', + 'admin_label' => '', + 'entity_type' => 'comment', + 'plugin_id' => 'entity_link_delete', + 'label' => 'Delete Comment', + 'exclude' => TRUE, + 'alter' => [ + 'alter_text' => FALSE, + 'text' => '', + 'make_link' => FALSE, + 'path' => '', + 'absolute' => FALSE, + 'external' => FALSE, + 'replace_spaces' => FALSE, + 'path_case' => 'none', + 'trim_whitespace' => FALSE, + 'alt' => '', + 'rel' => '', + 'link_class' => '', + 'prefix' => '', + 'suffix' => '', + 'target' => '', + 'nl2br' => FALSE, + 'max_length' => 0, + 'word_boundary' => TRUE, + 'ellipsis' => TRUE, + 'more_link' => FALSE, + 'more_link_text' => '', + 'more_link_path' => '', + 'strip_tags' => FALSE, + 'trim' => FALSE, + 'preserve_tags' => '', + 'html' => FALSE, + ], + 'element_type' => '', + 'element_class' => '', + 'element_label_type' => '', + 'element_label_class' => '', + 'element_label_colon' => FALSE, + 'element_wrapper_type' => '', + 'element_wrapper_class' => '', + 'element_default_classes' => TRUE, + 'empty' => '', + 'hide_empty' => FALSE, + 'empty_zero' => FALSE, + 'hide_alter_empty' => TRUE, + 'text' => 'Delete Comment', + 'output_url_as_text' => FALSE, + 'absolute' => FALSE, + ], + 'delete_post' => [ + 'id' => 'delete_post', + 'table' => 'post', + 'field' => 'delete_post', + 'relationship' => 'flag_report_post', + 'group_type' => 'group', + 'admin_label' => '', + 'entity_type' => 'post', + 'plugin_id' => 'entity_link_delete', + 'label' => '', + 'exclude' => TRUE, + 'alter' => [ + 'alter_text' => FALSE, + 'text' => '', + 'make_link' => FALSE, + 'path' => '', + 'absolute' => FALSE, + 'external' => FALSE, + 'replace_spaces' => FALSE, + 'path_case' => 'none', + 'trim_whitespace' => FALSE, + 'alt' => '', + 'rel' => '', + 'link_class' => '', + 'prefix' => '', + 'suffix' => '', + 'target' => '', + 'nl2br' => FALSE, + 'max_length' => 0, + 'word_boundary' => TRUE, + 'ellipsis' => TRUE, + 'more_link' => FALSE, + 'more_link_text' => '', + 'more_link_path' => '', + 'strip_tags' => FALSE, + 'trim' => FALSE, + 'preserve_tags' => '', + 'html' => FALSE, + ], + 'element_type' => '', + 'element_class' => '', + 'element_label_type' => '', + 'element_label_class' => '', + 'element_label_colon' => FALSE, + 'element_wrapper_type' => '', + 'element_wrapper_class' => '', + 'element_default_classes' => TRUE, + 'empty' => '', + 'hide_empty' => FALSE, + 'empty_zero' => FALSE, + 'hide_alter_empty' => TRUE, + 'text' => 'Delete Post', + 'output_url_as_text' => FALSE, + 'absolute' => FALSE, + ], + 'delete_node' => [ + 'id' => 'delete_node', + 'table' => 'node', + 'field' => 'delete_node', + 'relationship' => 'flag_report_node', + 'group_type' => 'group', + 'admin_label' => '', + 'entity_type' => 'node', + 'plugin_id' => 'entity_link_delete', + 'label' => '', + 'exclude' => TRUE, + 'alter' => [ + 'alter_text' => FALSE, + 'text' => '', + 'make_link' => FALSE, + 'path' => '', + 'absolute' => FALSE, + 'external' => FALSE, + 'replace_spaces' => FALSE, + 'path_case' => 'none', + 'trim_whitespace' => FALSE, + 'alt' => '', + 'rel' => '', + 'link_class' => '', + 'prefix' => '', + 'suffix' => '', + 'target' => '', + 'nl2br' => FALSE, + 'max_length' => 0, + 'word_boundary' => TRUE, + 'ellipsis' => TRUE, + 'more_link' => FALSE, + 'more_link_text' => '', + 'more_link_path' => '', + 'strip_tags' => FALSE, + 'trim' => FALSE, + 'preserve_tags' => '', + 'html' => FALSE, + ], + 'element_type' => '', + 'element_class' => '', + 'element_label_type' => '', + 'element_label_class' => '', + 'element_label_colon' => FALSE, + 'element_wrapper_type' => '', + 'element_wrapper_class' => '', + 'element_default_classes' => TRUE, + 'empty' => '', + 'hide_empty' => FALSE, + 'empty_zero' => FALSE, + 'hide_alter_empty' => TRUE, + 'text' => 'Delete Content', + 'output_url_as_text' => FALSE, + 'absolute' => FALSE, + ], + ]; + $fields = array_merge($new_field, $fields); + + // Update dropdown field. + $fields['dropbutton']['destination'] = FALSE; + $fields['dropbutton']['fields']['delete_comment'] = 'delete_comment'; + $fields['dropbutton']['fields']['delete_post'] = 'delete_post'; + $fields['dropbutton']['fields']['delete_node'] = 'delete_node'; + + // Safe fields values. + $config->set('display.default.display_options.fields', $fields); + $config->save(); + + // Run the rest of configuration as usually. + /** @var \Drupal\update_helper\Updater $updater */ + $updater = \Drupal::service('update_helper.updater'); + + // Execute configuration update definitions with logging of success. + $updater->executeUpdate('social_content_report', __FUNCTION__); + + // Output logged messages to related channel of update execution. + return $updater->logger()->output(); +} diff --git a/modules/social_features/social_content_report/src/Controller/ReportController.php b/modules/social_features/social_content_report/src/Controller/ReportController.php index 0c7b9975022..93d56985ef5 100644 --- a/modules/social_features/social_content_report/src/Controller/ReportController.php +++ b/modules/social_features/social_content_report/src/Controller/ReportController.php @@ -3,6 +3,7 @@ namespace Drupal\social_content_report\Controller; use Drupal\Core\Controller\ControllerBase; +use Drupal\Core\Url; use Drupal\flag\FlaggingInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -32,7 +33,7 @@ public function close(FlaggingInterface $flagging) { $flagging->save(); } - return new RedirectResponse('view.report_overview.overview'); + return new RedirectResponse(Url::fromRoute('view.report_overview.overview')->toString()); } } diff --git a/modules/social_features/social_content_report/src/Plugin/views/field/LinkReportClose.php b/modules/social_features/social_content_report/src/Plugin/views/field/LinkReportClose.php index 54c8f58961c..27561ad40f9 100644 --- a/modules/social_features/social_content_report/src/Plugin/views/field/LinkReportClose.php +++ b/modules/social_features/social_content_report/src/Plugin/views/field/LinkReportClose.php @@ -22,6 +22,13 @@ protected function getUrlInfo(ResultRow $row) { /** @var \Drupal\flag\FlaggingInterface $flagging */ $flagging = $this->getEntity($row); + // If items is already closed (disabled), return nothing to hide the link. + if ($flagging->hasField('field_status') && + empty($flagging->get('field_status')->value) + ) { + return NULL; + } + return Url::fromRoute('social_content_report.close_report', [ 'flagging' => $flagging->id(), ]);