From 8f4d3efb029f109d3dc7dc69cf458c2834c725d6 Mon Sep 17 00:00:00 2001 From: Dan Pearl Date: Mon, 4 Nov 2013 14:18:20 -0500 Subject: [PATCH] LP#1099979 Provide facility to merge parts in the Monograph Parts display A new facility is provided to make it relatively simple to merge parts that should be named the same, but are not. The user will check-off the parts that need to be merged, and click on the new Merge Selected Parts control, at which point the "winner" will be selected from a pop-up. Signed-off-by: Dan Pearl Signed-off-by: Rogan Hamby Signed-off-by: Ben Shum --- .../conify/global/biblio/monograph_part.tt2 | 34 +++-- Open-ILS/web/css/skin/default.css | 1 + Open-ILS/web/css/skin/default/biblio.css | 12 ++ .../dojo/openils/biblio/monographPartMerge.js | 142 ++++++++++++++++++ .../openils/biblio/nls/biblio_messages.js | 5 + .../Cataloging/merge-parts.txt | 17 +++ 6 files changed, 197 insertions(+), 14 deletions(-) create mode 100644 Open-ILS/web/css/skin/default/biblio.css create mode 100755 Open-ILS/web/js/dojo/openils/biblio/monographPartMerge.js create mode 100755 Open-ILS/web/js/dojo/openils/biblio/nls/biblio_messages.js create mode 100644 docs/RELEASE_NOTES_NEXT/Cataloging/merge-parts.txt diff --git a/Open-ILS/src/templates/conify/global/biblio/monograph_part.tt2 b/Open-ILS/src/templates/conify/global/biblio/monograph_part.tt2 index b50420082b..dfc89cccbd 100644 --- a/Open-ILS/src/templates/conify/global/biblio/monograph_part.tt2 +++ b/Open-ILS/src/templates/conify/global/biblio/monograph_part.tt2 @@ -1,37 +1,43 @@ [% WRAPPER base.tt2 %] [% ctx.page_title = l('Configure Monograph Parts') %] -
-
-
[% l('Monograph Parts') %]
-
- - +
+ +
+
[% l('Monograph Parts') %]
+
+ + + +    +
-
-
- +
- + + [% END %] - - diff --git a/Open-ILS/web/css/skin/default.css b/Open-ILS/web/css/skin/default.css index af96f071e7..63bed99317 100644 --- a/Open-ILS/web/css/skin/default.css +++ b/Open-ILS/web/css/skin/default.css @@ -2,6 +2,7 @@ @import "default/acq.css"; @import "default/admin.css"; @import "default/serial.css"; +@import "default/biblio.css"; /* import the dojo CSS */ @import "/js/dojo/dojo/resources/dojo.css"; @import "/js/dojo/dijit/themes/tundra/tundra.css"; diff --git a/Open-ILS/web/css/skin/default/biblio.css b/Open-ILS/web/css/skin/default/biblio.css new file mode 100644 index 0000000000..7da8f15135 --- /dev/null +++ b/Open-ILS/web/css/skin/default/biblio.css @@ -0,0 +1,12 @@ +.biblio-merge-item { + font-family : monospace; + font-weight : bold; + font-size : 16px; +} + +.biblio-merge-item:hover { + background-color : LawnGreen; +} +.biblio-merge-prevail-title { + font-weight : bold; +} diff --git a/Open-ILS/web/js/dojo/openils/biblio/monographPartMerge.js b/Open-ILS/web/js/dojo/openils/biblio/monographPartMerge.js new file mode 100755 index 0000000000..59b557e89e --- /dev/null +++ b/Open-ILS/web/js/dojo/openils/biblio/monographPartMerge.js @@ -0,0 +1,142 @@ +/* --------------------------------------------------------------------------- + * Copyright (C) 2014 C/W MARS Inc. + * Dan Pearl + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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. + * --------------------------------------------------------------------------- + */ + +/* + * Support for the facility to merge multiple part designations into + * one. + */ + +if(!dojo._hasResource["openils.biblio.monographPartMerge"]) { + dojo._hasResource["openils.biblio.monographPartMerge"] = true; + dojo.provide("openils.biblio.monographPartMerge"); + dojo.declare("openils.biblio.monographPartMerge", null, {}); + + /* + * Generate a pop-up to control part merging + */ + openils.biblio.monographPartMerge.showMergeDialog = function(gridControl) { + dojo.requireLocalization("openils.biblio","biblio_messages"); + + var items = gridControl.getSelectedItems(); + var total = items.length; + + if (total < 2 ) // Validate number of selected items + { + alert(dojo.i18n.getLocalization("openils.biblio","biblio_messages").SELECT_TWO); + return; + } + + var mergePartsPopup = new dijit.Dialog({title: + dojo.i18n.getLocalization("openils.biblio","biblio_messages").MERGE_PARTS_TITLE}); + + var mergeDiv = dojo.create("div"); + + /* + * Establish handler when an item is clicked upon + */ + mergeDiv.processMerge = function (obj) { + mergePartsPopup.hide(); + dojo.require('openils.PermaCrud'); + + var searchParams = {}; + searchParams["part"] = new Array() ; + + /* + * Establish a list of id's of monograph_parts that are affected by remap. Later, find + * all copy_part_map items that reference any of these parts + */ + + dojo.forEach (this.items, + function(item) { + searchParams["part"].push(String(item.id)) /* Must be String in json */ + }); + // var testString = searchParams["part"].join(', '); /* DEBUG */ + + var pcrud = new openils.PermaCrud(); + var cpmList = pcrud.search("acpm", searchParams); + + dojo.forEach(cpmList, + function (g) { + g.part(parseInt(obj.itemID)) /* Assign "winner" DB id of mono_part. */ + }); + + if (cpmList.length > 0) { + pcrud.update( cpmList, {}); + } + + /* + * Close the connection and commit the transaction. This is necessary to do before + * the subsequent delete operation (because of ON DELETE CASCADE issues). + */ + + pcrud.disconnect(); + + /* + * Update the AutoGrid to delete the items being mapped out of existence so that + * the display reflects the updated situation. + * Then use a PermaCrud connection to delete/eliminate the object. This + * code is adapted from the delete case in AutoGrid.js. Note that this code + * uses a total==1 as the exit condition (because you are not deleting the + * winning/prevailing/surviving part. + */ + + dojo.forEach (items, + function(item) { + if (item.id != parseInt(obj.itemID)) { + var fmObject = new fieldmapper[gridControl.fmClass]().fromStoreItem(item); + new openils.PermaCrud()['eliminate']( + fmObject, { + oncomplete : function(r) { + gridControl.store.deleteItem(item); + if (--total == 1 && gridControl.onPostSubmit) { + gridControl.onPostSubmit(); + } + } + } + ); + } + } + ); + + }; + + mergeDiv.innerHTML = "
" + + dojo.i18n.getLocalization("openils.biblio","biblio_messages").CLICK_PREVAILING + + "
"; + mergeDiv.items = items; + + /* + * Create a DIV for each selected item, and put in the container DIV + */ + for (var i = 0; i < total; i++) { + var newDiv = dojo.create("div"); + newDiv.className = "biblio-merge-item"; + newDiv.itemID = items[i].id; + newDiv.onclick = function() {mergeDiv.processMerge(this);}; + var newText = new String(items[i].label); + + /* To make spacing more visible, replace spaces with a middot character */ + newText = newText.replace(/ /g, String.fromCharCode(183) /* middot*/); + newDiv.appendChild(document.createTextNode( newText )); + mergeDiv.appendChild(newDiv); + } + mergePartsPopup.setContent(mergeDiv); + + mergePartsPopup.show(); + + }; + +} diff --git a/Open-ILS/web/js/dojo/openils/biblio/nls/biblio_messages.js b/Open-ILS/web/js/dojo/openils/biblio/nls/biblio_messages.js new file mode 100755 index 0000000000..0ad0af3156 --- /dev/null +++ b/Open-ILS/web/js/dojo/openils/biblio/nls/biblio_messages.js @@ -0,0 +1,5 @@ +{ + "SELECT_TWO" : "Select two or more items to merge", + "MERGE_PARTS_TITLE" : "Merge parts", + "CLICK_PREVAILING" : "Click on prevailing item" +} diff --git a/docs/RELEASE_NOTES_NEXT/Cataloging/merge-parts.txt b/docs/RELEASE_NOTES_NEXT/Cataloging/merge-parts.txt new file mode 100644 index 0000000000..e0a9f571d7 --- /dev/null +++ b/docs/RELEASE_NOTES_NEXT/Cataloging/merge-parts.txt @@ -0,0 +1,17 @@ +New Feature: Monograph Part Merging +=================================== + +The monograph part list for a bibliographic record may, over time, diverge from the +proscribed format, resulting in multiple labels for what are essentially the same +item. For instance, ``++Vol.{nbsp}1++'' may have variants like ``++V.1++'', ``++Vol{nbsp}1++'', or ``++{nbsp}Vol.{nbsp}1++'' (leading space). +This feature will allow catalog staff to collapse the variants into one value. + +In the Monograph Parts display: + +. Click the checkbox for all items you wish to merge including the one you wish to prevail when done. +. Click on the ``Merge Selected'' button. A pop-up window will list the selected items in +a monospaced font, with blanks represented by a middle-dot character for more visibility. +. Click on the item you wish to prevail. + +The undesired part labels will be deleted, and any copies that previously used those labels will +now use the prevailing label. -- 2.43.2