From f61b79a501d371beb370b13db30da5d24753e3e9 Mon Sep 17 00:00:00 2001
From: Alex Arnaud
Date: Tue, 16 Jan 2018 10:41:51 +0000
Subject: [PATCH] Bug 17047 - Fix template code in subscription-add.js Fix
errors when saving a serial Provide a more visible message when sharing a
report without note Fix Internal server error when trying to share a new
report Make update DB idempotent
Rebased-by: Alex Arnaud (2018-07-04)
Signed-off-by: Michal Denar
Signed-off-by: Michal Denar
---
Koha/SharedContent.pm | 1 -
.../mysql/atomicupdate/mana_01-add_mana_id.perl | 13 ++++++++++
.../mana_01-add_mana_id_in_subscription.sql | 2 --
.../atomicupdate/mana_03-add_mana_autoshare.sql | 2 +-
.../mysql/atomicupdate/mana_04-add_mana_token.sql | 2 +-
installer/data/mysql/atomicupdate/skeleton.perl | 2 +-
.../prog/en/includes/reports-toolbar.inc | 6 -----
.../prog/en/includes/serials-toolbar.inc | 2 +-
.../en/modules/reports/guided_reports_start.tt | 29 +++++++++++++++-------
.../prog/en/modules/serials/serials-search.tt | 1 +
.../prog/en/modules/serials/subscription-add.tt | 2 ++
koha-tmpl/intranet-tmpl/prog/js/serials-toolbar.js | 3 +++
.../intranet-tmpl/prog/js/subscription-add.js | 4 +--
serials/subscription-add.pl | 4 +--
14 files changed, 47 insertions(+), 26 deletions(-)
create mode 100644 installer/data/mysql/atomicupdate/mana_01-add_mana_id.perl
delete mode 100644 installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql
diff --git a/Koha/SharedContent.pm b/Koha/SharedContent.pm
index ca484c1..a6b8584 100644
--- a/Koha/SharedContent.pm
+++ b/Koha/SharedContent.pm
@@ -178,7 +178,6 @@ sub buildRequest {
my $url = "$MANA_IP/$resource.json";
my $request = HTTP::Request->new( POST => $url );
- $content->{bulk_import} = 0;
my $json = to_json( $content, { utf8 => 1 } );
$request->content($json);
diff --git a/installer/data/mysql/atomicupdate/mana_01-add_mana_id.perl b/installer/data/mysql/atomicupdate/mana_01-add_mana_id.perl
new file mode 100644
index 0000000..1e5fdbd
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/mana_01-add_mana_id.perl
@@ -0,0 +1,13 @@
+$DBversion = 'XXX';
+if( CheckVersion( $DBversion ) ) {
+ if( !column_exists( 'subscription', 'mana_id' ) ) {
+ $dbh->do( "ALTER TABLE subscription ADD mana_id int(11) NULL DEFAULT NULL" );
+ }
+
+ if( !column_exists( 'saved_sql', 'mana_id' ) ) {
+ $dbh->do( "ALTER TABLE saved_sql ADD mana_id int(11) NULL DEFAULT NULL" );
+ }
+
+ SetVersion( $DBversion );
+ print "Upgrade to $DBversion done (Bug 17047 - Add column mana_id in subscription and saved_sql tables)\n";
+}
diff --git a/installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql b/installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql
deleted file mode 100644
index a7443db..0000000
--- a/installer/data/mysql/atomicupdate/mana_01-add_mana_id_in_subscription.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-ALTER TABLE subscription ADD mana_id int(11) NULL DEFAULT NULL;
-ALTER TABLE saved_sql ADD mana_id int(11) NULL DEFAULT NULL;
diff --git a/installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql b/installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql
index f5cc363..a8b3519 100644
--- a/installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql
+++ b/installer/data/mysql/atomicupdate/mana_03-add_mana_autoshare.sql
@@ -1,2 +1,2 @@
-INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
+INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
('AutoShareWithMana','','','defines datas automatically shared with mana','multiple');
diff --git a/installer/data/mysql/atomicupdate/mana_04-add_mana_token.sql b/installer/data/mysql/atomicupdate/mana_04-add_mana_token.sql
index 200f3e5..3c94ccd 100644
--- a/installer/data/mysql/atomicupdate/mana_04-add_mana_token.sql
+++ b/installer/data/mysql/atomicupdate/mana_04-add_mana_token.sql
@@ -1,2 +1,2 @@
-INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
+INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
('ManaToken','',NULL,'Security token used for authentication on Mana KB service (anti spam)','Textarea');
diff --git a/installer/data/mysql/atomicupdate/skeleton.perl b/installer/data/mysql/atomicupdate/skeleton.perl
index 66e599c..c63e6eb 100644
--- a/installer/data/mysql/atomicupdate/skeleton.perl
+++ b/installer/data/mysql/atomicupdate/skeleton.perl
@@ -1,4 +1,4 @@
-$DBversion = 'XXX'; # will be replaced by the RM
+$DBversion = 'XXX';
if( CheckVersion( $DBversion ) ) {
# you can use $dbh here like:
# $dbh->do( "ALTER TABLE biblio ADD COLUMN badtaste int" );
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 bfb1e0f..41cdcbc 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc
@@ -139,12 +139,6 @@
[% END %]
+
[% IF subscriptionid and ( CAN_user_serials_edit_subscription || CAN_user_serials_create_subscription || CAN_user_serials_delete_subscription || CAN_user_serials_receive_serials ) %]
[% END %]
+
+ Please enter a report name and descriptive note before sharing (minimum 20 characters)
+
[% IF ( languages_loop ) %]
[% UNLESS ( one_language_enabled ) %]
-
-
+
Id:
Name:
@@ -374,7 +376,7 @@ canned reports and writing custom SQL reports.
@@ -1067,6 +1069,7 @@ canned reports and writing custom SQL reports.
[% Asset.js("lib/d3c3/d3.min.js") | $raw %]
[% Asset.js("lib/d3c3/c3.min.js") | $raw %]
[% INCLUDE 'calendar.inc' %]
+ [% INCLUDE 'mana.inc' %]
[% IF ( saved1 ) %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'columns_settings.inc' %]
@@ -1274,11 +1277,15 @@ canned reports and writing custom SQL reports.
window.history.back();
});
+ $(".mana_search_button").on("click",function(){
+ mana_search($("#mana_search_field").val());
+ });
+
$(".ShareButton").on("click", function(){
+ $("#note-error").hide();
if($(this).closest("tr").find(".report_notes").text().length < 20 || $(this).closest("tr").find(".report_name").text().length < 20){
- $("#shared_infos").hide();
- $("#ManaShareButton").hide();
- $("#noterror").show();
+ $(".shared_infos").hide();
+ $("#note-error").show();
}
else{
$("#shared_id").html($(this).closest("tr").find(".report_id").text());
@@ -1290,6 +1297,10 @@ canned reports and writing custom SQL reports.
}
});
+ $("#ManaCloseButton").on("click", function() {
+ $(".shared_infos").show();
+ });
+
$("#addColumn").on("click",function(){
addColumn();
});
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt
index 7e88b10..bcfe355 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt
@@ -416,6 +416,7 @@
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
+ [% INCLUDE 'mana.inc' %]