Bugzilla – Attachment 190148 Details for
Bug 40906
Change the "Create report from mana" interface, to make it look more like a plugin market place/app store
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40906: Redesign Mana report import UI
Bug-40906-Redesign-Mana-report-import-UI.patch (text/plain), 34.29 KB, created by
elias.lorgnier@biblibre.com
on 2025-12-04 09:33:51 UTC
(
hide
)
Description:
Bug 40906: Redesign Mana report import UI
Filename:
MIME Type:
Creator:
elias.lorgnier@biblibre.com
Created:
2025-12-04 09:33:51 UTC
Size:
34.29 KB
patch
obsolete
>From 8c2b842528dd680e4b60cd8c11c0ea59d1690a49 Mon Sep 17 00:00:00 2001 >From: elias <elias.lorgnier@biblibre.com> >Date: Mon, 27 Oct 2025 08:23:35 +0000 >Subject: [PATCH] Bug 40906: Redesign Mana report import UI > >Why : >This patch is a revamp of the interface of the menue "Import SQL from Mana". It is supposed to make it feel more like a marketplace of plugin or apps. I believe it is more coherent visually and fonctionally with what this feature is doing. Also, reports are immediatly displayed when the modal opens, inviting the user to explore report, while maintaining the ability to search for it. When the patch 40826 will be applied, we'll be able to sort reports based on the number of imports they recieved. > >It also includes : >- Moving the search of report from the deprecated svc to the rest API >- Paginating results so it doesn't load 1300 reports each time we search for reports. >- Pagination makes it future proof in case of an augmentation of available reports. > >Test plan : >- Clone the test-bug-40906 branch from my repo of mana : https://gitlab.com/elorgnier/koha-mana/-/tree/test-bug-40906?ref_type=heads >- Run docker compose up in the repo >- in the .env file of ktd, for the MANA_URL option, use 127.17.0.1:5000 (if you have the default host ip defined in the docker bridge network) >- run ktd >- in koha > Administration, configure a mana account with random username and email (no need to validate it) >- In the report section, select new SQL report, and then in the dropdown menu, New SQL from mana. > >By default there is no report loaded in mana, so you will want to create sample reports to be able to test it, i'll push a sample to the test branch of mana as soon as possible. > >You can create your own sample or mount a dump of the existing database in the docker compose of mana by mounting the sql dump in the place of the /sql/schema.sql >--- > Koha/REST/V1/Mana/Reports.pm | 66 +++++++++ > api/v1/swagger/definitions/mana_comment.yaml | 27 ++++ > api/v1/swagger/definitions/mana_report.yaml | 63 +++++++++ > api/v1/swagger/paths/mana.yaml | 50 +++++++ > api/v1/swagger/swagger.yaml | 12 ++ > koha-tmpl/intranet-tmpl/prog/css/reports.css | 87 ++++++++++++ > .../mana/mana-report-search-result.inc | 130 ----------------- > .../prog/en/includes/reports-toolbar.inc | 32 +++-- > .../en/modules/mana/mana-report-details.tt | 28 ++++ > .../modules/mana/mana-report-search-result.tt | 1 - > .../modules/reports/guided_reports_start.tt | 51 ------- > koha-tmpl/intranet-tmpl/prog/js/mana.js | 132 ++++++++++++++++++ > reports/mana_report_details.pl | 43 ++++++ > svc/mana/search | 6 +- > 14 files changed, 529 insertions(+), 199 deletions(-) > create mode 100644 Koha/REST/V1/Mana/Reports.pm > create mode 100644 api/v1/swagger/definitions/mana_comment.yaml > create mode 100644 api/v1/swagger/definitions/mana_report.yaml > create mode 100644 api/v1/swagger/paths/mana.yaml > delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/mana/mana-report-details.tt > delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/mana/mana-report-search-result.tt > create mode 100644 reports/mana_report_details.pl > >diff --git a/Koha/REST/V1/Mana/Reports.pm b/Koha/REST/V1/Mana/Reports.pm >new file mode 100644 >index 00000000000..a0a2e9c6863 >--- /dev/null >+++ b/Koha/REST/V1/Mana/Reports.pm >@@ -0,0 +1,66 @@ >+ >+package Koha::REST::V1::Mana::Reports; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <https://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Mojo::Base 'Mojolicious::Controller'; >+ >+use Try::Tiny qw( catch try ); >+ >+use Koha::SharedContent; >+ >+=head1 API >+ >+=head2 Methods >+ >+=head3 list >+ >+=cut >+ >+sub list { >+ my $c = shift->openapi->valid_input or return; >+ >+ my $per_page = $c->param('_per_page'); >+ my $page = $c->param('_page'); >+ my $orderby = $c->param('_order_by'); >+ >+ my $query = $c->param('q'); >+ >+ my $params = { >+ per_page => $per_page, >+ page => $page, >+ orderby => $orderby >+ }; >+ >+ if ($query) { >+ $params->{query} = $query; >+ } >+ >+ my $result = Koha::SharedContent::search_entities( 'report', $params ); >+ if ( $result->{pagination} ) { >+ $c->res->headers->header( "x-total-count" => $result->{pagination}->{total} ); >+ } >+ >+ return try { >+ return $c->render( status => 200, openapi => $result->{data} ); >+ } catch { >+ $c->unhandled_exception($_); >+ }; >+} >+ >+1; >\ No newline at end of file >diff --git a/api/v1/swagger/definitions/mana_comment.yaml b/api/v1/swagger/definitions/mana_comment.yaml >new file mode 100644 >index 00000000000..bc73cd060ca >--- /dev/null >+++ b/api/v1/swagger/definitions/mana_comment.yaml >@@ -0,0 +1,27 @@ >+--- >+type: object >+properties: >+ id: >+ description: The id of the comment in the mana debit >+ type: integer >+ resource_id: >+ description: The id of the resource in mana the comment is linked to >+ type: integer >+ resource_type: >+ description: The type of resource the comment is attached to >+ type: string >+ message: >+ description: The content of the comment >+ type: string >+ creationdate: >+ description: date of creation >+ type: string >+ format: date >+ >+ >+ >+ >+ >+ >+additionalProperties: false >+ >diff --git a/api/v1/swagger/definitions/mana_report.yaml b/api/v1/swagger/definitions/mana_report.yaml >new file mode 100644 >index 00000000000..7395697073a >--- /dev/null >+++ b/api/v1/swagger/definitions/mana_report.yaml >@@ -0,0 +1,63 @@ >+--- >+type: object >+properties: >+ id: >+ type: integer >+ description: report id in mana >+ readOnly: true >+ report_name: >+ description: The name of the report >+ type: string >+ notes: >+ description: A description of the report >+ type: >+ - string >+ - "null" >+ lastimport: >+ description: The last time the report was imported from mana >+ format: date >+ type: >+ - string >+ - "null" >+ creationdate: >+ description: The day the report was exported to mana >+ type: string >+ format: date >+ savedsql: >+ description: The sql of the report >+ type: >+ - string >+ language: >+ description: The language the sql report has >+ type: >+ - string >+ - "null" >+ report_group: >+ description: The report group the report belongs to >+ type: >+ - string >+ - "null" >+ kohaversion: >+ description: The version of Koha from which the report was exported to mana >+ type: >+ - string >+ - "null" >+ nbofusers: >+ description: The number of import of a report >+ type: >+ - integer >+ # Do not leave as is ! >+ type: >+ description: Type >+ type: >+ - string >+ - "null" >+ comments: >+ description: Comments added by users to the reports >+ type: >+ - array >+ items: >+ $ref: "../swagger.yaml#/definitions/mana_comment" >+ >+additionalProperties: false >+ >diff --git a/api/v1/swagger/paths/mana.yaml b/api/v1/swagger/paths/mana.yaml >new file mode 100644 >index 00000000000..13f5868cd2f >--- /dev/null >+++ b/api/v1/swagger/paths/mana.yaml >@@ -0,0 +1,50 @@ >+--- >+/mana/reports: >+ get: >+ x-mojo-to: Mana::Reports#list >+ operationId: searchReports >+ tags: >+ - mana >+ - reports >+ summary: List reports registered in the mana database >+ produces: >+ - application/json >+ parameters: >+ - $ref: "../swagger.yaml#/parameters/match" >+ - $ref: "../swagger.yaml#/parameters/order_by" >+ - $ref: "../swagger.yaml#/parameters/page" >+ - $ref: "../swagger.yaml#/parameters/per_page" >+ - $ref: "../swagger.yaml#/parameters/q_str" >+ - $ref: "../swagger.yaml#/parameters/request_id_header" >+ responses: >+ "200": >+ description: A List of reports >+ schema: >+ type: array >+ items: >+ $ref: "../swagger.yaml#/definitions/mana_report" >+ "400": >+ description: | >+ Bad request. Possible `error_code` attribute values: >+ >+ * `invalid_query` >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "403": >+ description: Access forbidden >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "500": >+ description: | >+ Internal server error. Possible `error_code` attribute values: >+ >+ * `internal_server_error` >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "503": >+ description: Under maintenance >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ x-koha-authorization: >+ permissions: >+ catalogue: "1" >\ No newline at end of file >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index dcb0a3cc66e..2ccf5ba8354 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -140,6 +140,10 @@ definitions: > $ref: ./definitions/library.yaml > list: > $ref: ./definitions/list.yaml >+ mana_comment: >+ $ref: ./definitions/mana_comment.yaml >+ mana_report: >+ $ref: ./definitions/mana_report.yaml > merge_biblios: > $ref: ./definitions/merge_biblios.yaml > order: >@@ -483,6 +487,8 @@ paths: > $ref: "./paths/libraries.yaml#/~1libraries~1{library_id}~1cash_registers" > "/libraries/{library_id}/desks": > $ref: "./paths/libraries.yaml#/~1libraries~1{library_id}~1desks" >+ "/mana/reports": >+ $ref: "./paths/mana.yaml#/~1mana~1reports" > "/oauth/login/{provider_code}/{interface}": > $ref: ./paths/oauth.yaml#/~1oauth~1login~1{provider_code}~1{interface} > /oauth/token: >@@ -965,6 +971,12 @@ parameters: > items: > type: string > collectionFormat: multi >+ q_str: >+ description: Query string sent as a request parameter >+ in: query >+ name: q >+ required: false >+ type: string > quote_id_pp: > description: Quote internal identifier > in: path >diff --git a/koha-tmpl/intranet-tmpl/prog/css/reports.css b/koha-tmpl/intranet-tmpl/prog/css/reports.css >index 80cc39da514..893884e598e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/reports.css >+++ b/koha-tmpl/intranet-tmpl/prog/css/reports.css >@@ -21,6 +21,93 @@ del { > background-color: #ffe6e6; > } > >+#mana_results_datatable tbody { >+ display:flex; >+ flex-wrap: wrap; >+ justify-content: center; >+} >+ >+#mana-search-result-modal-body { >+ height: 80vh; >+} >+ >+#overlay-report-details { >+ display: none; >+} >+ >+#overlay-report-details .CodeMirror { >+ height: auto; >+} >+ >+.return-div { >+ font-size: 13px; >+ cursor: pointer; >+} >+ >+#mana_results_datatable td{ >+ width: 100%; >+ display: inline-block; >+ border: none; >+ background-color: transparent; >+ text-align: left; >+} >+ >+#mana_results_datatable tr { >+ display: flex; >+ flex-wrap: wrap; >+ justify-content: space-between; >+ clear:both; >+ text-align:left; >+ width: 19rem; >+ padding: 0.25rem; >+ margin: 0.25rem; >+ background-color: #E6E6E6; >+ border: none; >+ border-radius: 0.25rem; >+ margin-top: 1rem; >+ font-size: 11px; >+ height: 14rem; >+} >+ >+#mana_results_datatable tr:hover { >+ cursor: pointer; >+} >+ >+.report_name { >+ height: 3rem; >+ font-weight: bold; >+} >+ >+ >+ >+.mana-report-comments { >+ padding: 1rem; >+ margin: 4px; >+ background-color: #E6E6E6; >+ border: none; >+ display: flex; >+ align-items: center; >+ justify-content: space-between; >+} >+ >+.report-description { >+ height:5rem; >+} >+ >+#mana_results_datatable .w-40 { >+ width: 40%; >+} >+ >+.report_info { >+ color: #696969; >+ text-align: right; >+ margin: 0 5px; >+} >+ >+#mana_results_datatable .text-end { >+ text-align: right; >+} >+ > #col1, > #col2 { > float: left; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc >deleted file mode 100644 >index 8edca6cc48a..00000000000 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc >+++ /dev/null >@@ -1,130 +0,0 @@ >-[% USE Asset %] >-[% USE KohaDates %] >-[% USE Koha %] >-[% USE AuthorisedValues %] >-[% USE Branches %] >-[% USE raw %] >-[% PROCESS 'i18n.inc' %] >-[% INCLUDE 'doc-head-open.inc' %] >-<title >- >[% FILTER collapse %] >- [% t("Mana Knowledge Base reports search") | html %] >- › [% t("Reports") | html %] › [% t("Koha") | html %] >- [% END %]</title >-> >-[% INCLUDE 'doc-head-close.inc' %] >-[% Asset.css("css/reports.css") | $raw %] >-</head> >- >-<body id="rep_mana_search" class="rep"> >-[% WRAPPER 'header.inc' %] >- [% INCLUDE 'circ-search.inc' %] >-[% END %] >- >-<div id="breadcrumbs"> >- <a href="/cgi-bin/koha/mainpage.pl">Home</a> >- › <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a> › <a href="/cgi-bin/koha/reports/guided_reports.pl">Guided reports wizard</a> >- › Mana Knowledge Base report search results >-</div> >- >-<div class="main container-fluid"> >- <div class="row"> >- <div class="col-md-10 order-md-2 order-sm-1"> >- <main> >- <h2>Mana Knowledge Base report search results</h2> >- >- <div id="mana_results"> >- [% IF statuscode == "200" AND reports %] >- <table id="mana_results_datatable"> >- <thead> >- <tr> >- <th>Report name</th> >- <th class="anti-the">Notes</th> >- <th>Type</th> >- <th title="Number of libraries using this pattern"># of users</th> >- <th title="Last time a library used this pattern">Last import</th> >- <th> Comments </th> >- [% UNLESS search_only %] >- <th class="no-sort no-export">Actions</th> >- [% END %] >- </tr> >- </thead> >- <tbody> >- [% FOREACH report IN reports %] >- [% UNLESS report.cannotdisplay %] >- [% IF report.nbofcomment > highWarned %] >- [% SET tr_class = 'high-warned-row' %] >- [% ELSIF report.nbofcomment > warned %] >- [% SET tr_class = 'warned-row' %] >- [% ELSIF report.nbofcomment > lowWarned %] >- [% SET tr_class = 'highlighted-row' %] >- [% ELSE %] >- [% SET tr_class = '' %] >- [% END %] >- <tr id="[% report.id | html %]" class="[% tr_class | html %]"> >- <td> >- <input type="hidden" class="rowid" value="[% report.id | $raw %]" /> >- [% IF ( report.report_name ) %] >- [% report.report_name | html %] >- [% END %] >- </td> >- <td title="[% report.savedsql | html %]"> >- [% IF report.notes.length > 200 %] >- <div> >- [% report.notes.substr(0,200) | html %]... <a href="#" class="btn btn-link btn-sm showbutton"><i class="fa-solid fa-square-plus"></i> Show more</a> >- </div> >- <div style="display:none"> >- [% report.notes | html %] >- <a href="#" class="btn btn-link btn-sm hidebutton"><i class="fa-solid fa-square-minus"></i> Show less</a> >- </div> >- [% ELSE %] >- [% report.notes | html %] >- [% END %] >- </td> >- <td> [% report.type | html %] </td> >- <td> >- [% IF ( report.nbofusers ) %] >- [% report.nbofusers | html %] >- [% END %] >- </td> >- <td data-order="[% report.lastimport | html %]"> [% report.lastimport | $KohaDates %] </td> >- <td> >- [% FOREACH comment IN report.comments %] >- [% comment.message | html %] >- ([% comment.nb | html %])<br /> >- [% END %] >- </td> >- >- [% UNLESS search_only %] >- <td> >- <button type="button" class="btn btn-default btn-xs mana-use" id="mana-use-[% report.id | html %]" data-report_id="[% report.id | html %]"><i class="fa fa-download"></i> Import</button> >- </td> >- [% END %] >- </tr> >- [% END %] >- [% END %] >- </tbody> >- </table> >- [% ELSE %] >- <h4> >- [% IF ( msg ) %] >- [% msg | html %] <span>(Status code: [% statuscode | html %])</span> >- [% ELSE %] >- <span>No results found</span> >- [% END %] >- </h4> >- [% END %] >- </div> >- </main> >- </div> >- <!-- /.col-md-10.order-md-2 --> >- >- <div class="col-md-2 order-sm-2 order-md-1"> >- <aside> [% INCLUDE 'guided-reports-view.inc' %] </aside> >- </div> >- <!-- /.col-md-2.order-md-1 --> >- </div> >- <!-- /.row --> >- >- [% INCLUDE 'intranet-bottom.inc' %] >-</div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc >index 37f73fcee21..853c73f45b5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc >@@ -186,14 +186,15 @@ > > [% IF Koha.Preference('Mana')==1 %] > <div id="mana_search_result" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label"> >- <div class="modal-dialog modal-lg"> >+ <div class="modal-dialog modal-xl"> > <form method="get" id="mana_search_form"> >- <div class="modal-content"> >+ <div class="modal-content" style="position:relative;"> > <div class="modal-header"> > <h1 class="modal-title" id="mana_search_result_label">Mana search</h1> > <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> > </div> >- <div class="modal-body"> >+ <div id="mana-search-result-modal-body" class="modal-body"> >+ <div id="overlay-report-details" class="modal-body"></div> > <div id="mana_search_failed" class="alert alert-warning mana_search_status" style="display:none"> > Your search could not be completed. Please try again later. > <div id="mana_search_errortext"></div> >@@ -202,21 +203,28 @@ > This report could not be imported. Please try again later. > <div id="mana_use_errortext"></div> > </div> >- <fieldset> >- <p> >- Search reports by keyword: >- <input type="text" id="mana_search_field" /> >- <input type="submit" class="mana_search_button" value="Search" /> >- <span id="mana-loading" style="display:none"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </span> >- </p> >- </fieldset> >- <div id="mana_result_content"> </div> >+ <div id="mana_results_datatable"> >+ <table id="mana_result_content"></table> >+ </div> > </div> > <div class="modal-footer"> > <button type="button" class="btn btn-default" data-bs-dismiss="modal">Cancel</button> > </div> > </div> > </form> >+ <template id="report-details-template"> >+ <td class="report_name"> >+ <span class="font-weight-bold"></span> >+ </td> >+ <td class="report-description"> </td> >+ <td class="w-40 report_info"> >+ <i class="fa fa-cloud-arrow-down"></i> >+ </td> >+ <td class="w-40 report_info text-end ms-auto" data-order=""> </td> >+ <td> >+ <button type="button" class="btn btn-default btn-xs mana-use w-100" data-report_id=""><i class="fa fa-download"></i> Import</button> >+ </td> >+ </template> > </div> > </div> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/mana/mana-report-details.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/mana/mana-report-details.tt >new file mode 100644 >index 00000000000..c6fe755b8d6 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/mana/mana-report-details.tt >@@ -0,0 +1,28 @@ >+[% USE KohaDates %] >+ >+<div class="return-div"><i class="fa-regular fa-arrow-left"></i> Return to market place</div> >+<hr /> >+<div class="p-3"> >+ <h1>[% title | html %]</h1> >+ >+ <p class="report_info"><i class="fa fa-cloud-arrow-down"></i> [% nbofusers %] </p> >+ <p class="report_info">Created : [% lastimport | $KohaDates %]</p> >+ <button type="button" class="btn btn-default btn-xs mana-use" id="mana-use-[% id | html %]" data-report_id="[% id | html %]"><i class="fa fa-download"></i> Import</button> >+ >+ <h3>SQL</h3> >+ <textarea id="sql-mana" name="sql" required="required">[% savedsql | html %]</textarea> >+ >+ [% IF note %] >+ <h3>Note</h3> >+ <p>[% note | html %]</p> >+ [% END %] >+ [% IF comments %] >+ <h3>Comments</h3> >+ [% FOREACH comment IN comments %] >+ <div class="mana-report-comments"> >+ <p>[% comment.message %]</p><p>[% comment.creationdate %]</p> >+ </div> >+ [% END %] >+ [% END %] >+ >+</div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/mana/mana-report-search-result.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/mana/mana-report-search-result.tt >deleted file mode 100644 >index a2a929857ab..00000000000 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/mana/mana-report-search-result.tt >+++ /dev/null >@@ -1 +0,0 @@ >-[% INCLUDE 'mana/mana-report-search-result.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >index 2e6a91ed68e..59e3fd14381 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >@@ -2144,10 +2144,6 @@ > window.history.back(); > }); > >- $("body").on("click", ".mana_search_button", function(){ >- $("#mana-loading").show(); >- mana_search($("#mana_search_field").val()); >- }); > > $(".ShareButton").on("click", function(){ > $("#note-error").hide(); >@@ -2443,15 +2439,6 @@ > mana_use( $(this).data("report_id") ); > }); > >- $("#mana_search_result").on("shown.bs.modal", function(){ >- $("#mana_search_field").focus(); >- }); >- >- $("#mana_search_result").on("hide.bs.modal", function(){ >- $("#mana_result_content").html(""); >- $("#mana_search_field").val(""); >- }); >- > $(".batch_op").on("click", function(e){ > e.preventDefault(); > var target_form = $(this).data("submit"); >@@ -2567,44 +2554,6 @@ > }); > } > >- function mana_search( textquery ){ >- $(".mana_search_status").hide(); >- $("#mana_result_content").load("/cgi-bin/koha/svc/mana/search #mana_results", "resource=report&usecomments=1&id=" + textquery, function( response, status, xhr ) { >- >- if ( status == "error" ) { >- $("#mana_search_errortext").html( xhr.status + " " + xhr.statusText ); >- $("#mana_search_failed").show(); >- $("#mana-loading").hide(); >- } else { >- $(".mana_search_status").hide(); >- $("#mana_search_result_label").text(_("Results from Mana Knowledge Base")); >- $("#mana-loading").hide(); >- $("#mana_results_datatable").kohaTable({ >- "pagingType": "full", >- "autoWidth": false, >- "columnDefs": [ >- { "width": "35%", "targets": 1 } >- ], >- }); >- >- $(".showbutton").on("click", function(e){ >- e.preventDefault(); >- $(this).parent().hide(); >- $(this).parent().next().show(); >- }); >- >- $(".hidebutton").on("click", function(e){ >- e.preventDefault(); >- $(this).parent().hide(); >- $(this).parent().prev().show(); >- }); >- >- if($("td.dataTables_empty").length == 0){ >- $("#mana_search_message").show(); >- } >- } >- }); >- } > > function addToList() { > var biblionumbers = []; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/mana.js b/koha-tmpl/intranet-tmpl/prog/js/mana.js >index cb272706fa2..4c641c2a0e7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/mana.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/mana.js >@@ -93,4 +93,136 @@ $(document).ready(function () { > mana_increment(commentid, "resource_comment", "nb"); > } > }); >+ >+ //Open mana report details >+ $("body").on("click", "#mana_results_datatable tr", function (e) { >+ let targeted_element = e.currentTarget; >+ >+ if (targeted_element.classList.contains("mana-use")) { >+ return; >+ } >+ >+ const id_ = targeted_element.id; >+ let overlay_detail = $("#overlay-report-details")[0]; >+ overlay_detail.style.display = "block"; >+ >+ let table = $("#mana_results_datatable")[0]; >+ table.style.display = "none"; >+ >+ $.ajax({ >+ url: "/cgi-bin/koha/reports/mana_report_details.pl", >+ >+ data: { >+ id: id_, >+ }, >+ dataType: "html", >+ }).done(function (data) { >+ overlay_detail.innerHTML = data; >+ let modal_body = $(".modal-body"); >+ let sql = $("#sql-mana")[0]; >+ >+ modal_body.scrollTop(0); >+ >+ showsql = CodeMirror.fromTextArea(sql, { >+ lineNumbers: false, >+ mode: "text/x-sql", >+ lineWrapping: true, >+ readOnly: true, >+ }); >+ }); >+ >+ $("body").on("click", ".return-div", function (e) { >+ let overlay_detail = $("#overlay-report-details")[0]; >+ overlay_detail.style.display = "none"; >+ overlay_detail.innerHTML = ""; >+ >+ let table = $("#mana_results_datatable")[0]; >+ table.style.display = "block"; >+ }); >+ >+ $("#mana_search_result")[0].addEventListener( >+ "hidden.bs.modal", >+ event => { >+ let overlay_detail = $("#overlay-report-details")[0]; >+ overlay_detail.style.display = "none"; >+ overlay_detail.innerHTML = ""; >+ >+ let table = $("#mana_results_datatable")[0]; >+ table.style.display = "block"; >+ } >+ ); >+ }); >+ >+ //Creates datatable >+ $("#mana_search_result")[0].addEventListener("show.bs.modal", event => { >+ if ($.fn.dataTable.isDataTable("#mana_result_content")) { >+ return; >+ } >+ >+ let table = $("#mana_result_content").kohaTable({ >+ autoWidth: false, >+ fixedHeader: false, >+ serverSide: true, >+ ajax: { >+ url: "/api/v1/mana/reports", >+ data: function (data, setting) { >+ var length = data.length; >+ var start = data.start; >+ var dataSet = { >+ _page: Math.floor(start / length) + 1, >+ _per_page: length, >+ _order_by: "", >+ }; >+ >+ //This is why the kohaTables data function is overwritten, to allow passing the search query as a string. >+ if (data.search) { >+ dataSet.q = data.search.value; >+ } >+ return dataSet; >+ }, >+ }, >+ createdRow: function (row, data, dataIndex) { >+ let template = $("#report-details-template")[0]; >+ const clone = document.importNode(template.content, true); >+ //changer id de la row >+ const title = clone.querySelector("span"); >+ const description = clone.querySelectorAll("td")[1]; >+ const nbofuser_place = clone.querySelector(".report_info"); >+ const lastimport_place = >+ clone.querySelectorAll(".report_info")[1]; >+ const button = clone.querySelector("button"); >+ >+ title.textContent = data.report_name; >+ if (data.notes.length > 100) { >+ data.notes = data.notes.slice(0, 100) + "..."; >+ } >+ description.textContent = data.notes; >+ >+ nbofuser_place.append(data.nbofusers); >+ lastimport_place.textContent = data.lastimport; >+ button.id = "mana-use-".concat(data.id); >+ button.setAttribute("data-report_id", data.id); >+ >+ row.id = data.id; >+ row.innerHTML = ""; >+ row.appendChild(clone); >+ }, >+ >+ columns: [ >+ { data: "id" }, >+ { data: "report_name" }, >+ { data: "notes" }, >+ { data: "nbofusers" }, >+ { data: "lastimport" }, >+ ], >+ }); >+ >+ let thead = $("#mana_results_datatable thead"); >+ thead.addClass("visually-hidden"); >+ >+ table.on("draw", function () { >+ let thead = $("#mana_results_datatable thead")[0]; >+ thead.addClass("visually-hidden"); >+ }); >+ }); > }); >diff --git a/reports/mana_report_details.pl b/reports/mana_report_details.pl >new file mode 100644 >index 00000000000..e5e0d0c6055 >--- /dev/null >+++ b/reports/mana_report_details.pl >@@ -0,0 +1,43 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use Koha::SharedContent; >+use C4::Auth qw(check_cookie_auth); >+use Koha::Report; >+ >+use C4::Auth qw(get_template_and_user); >+use C4::Output qw( output_html_with_http_headers ); >+ >+use CGI; >+use JSON; >+ >+my $input = CGI->new; >+ >+my $templatename = 'mana/mana-report-details.tt'; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => $templatename, >+ query => $input, >+ type => 'intranet' >+ } >+); >+ >+my $result = Koha::SharedContent::get_entity_by_id( >+ "report", >+ scalar $input->param('id'), >+ { usecomments => 1 } >+); >+ >+$template->param( >+ id => $result->{data}->{id}, >+ title => $result->{data}->{report_name}, >+ savedsql => $result->{data}->{savedsql}, >+ note => $result->{data}->{notes}, >+ nbofusers => $result->{data}->{nbofusers}, >+ lastimport => $result->{data}->{lastimport}, >+ comments => $result->{data}->{comments} >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/svc/mana/search b/svc/mana/search >index 2cda2d3096e..d31bdf4ef8b 100755 >--- a/svc/mana/search >+++ b/svc/mana/search >@@ -30,11 +30,7 @@ use CGI; > my $input = CGI->new; > > my $templatename; >-if ( $input->param("resource") eq 'report' ) { >- $templatename = "mana/mana-report-search-result.tt"; >-} else { >- $templatename = "mana/mana-subscription-search-result.tt"; >-} >+$templatename = "mana/mana-subscription-search-result.tt"; > > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40906
: 190148