LP#1700635: enable eg-marc-editor for queued records in MARC Batch Import/Export
authorCesar Velez <cesar.velez@equinoxinitiative.org>
Fri, 15 Sep 2017 21:02:31 +0000 (17:02 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 20 Sep 2017 22:04:17 +0000 (18:04 -0400)
This enables the angular modal marc-editor to be called from
the vandelay dojo UI in the iFrame.

To test:

[1] In the web staff client, go to MARC Batch Import/Export and load
    some records in a Vandelay queue.
[2] Inspect the queue and choose View MARC.
[3] Click the Edit button, and verify that it brings up the
    web staff MARC editor.
[4] Make a change, then click Modify, then click Use Edits.
[5] Verify that the MARC view reflects the updated record.
[6] Go back to the queue. If the bib was /not/ imported into
    Evergreen, the bib attributes may change.
[7] Verify that steps 1-6 in the XUL client work (and that the XUL
    MARC editor is displayed).

Note that this patch doesn't ensure that the modal can save the
record and be dismissed via just a single click of the Modify button;
an issue was discovered with that that could not be resolved in time
for beta2.

Signed-off by: Cesar Velez <cesar.velez@equinoxinitiative.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>

Open-ILS/src/templates/staff/cat/catalog/t_edit_marc_modal.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/cat/catalog/t_vandelay.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js
Open-ILS/web/js/ui/default/vandelay/vandelay.js

diff --git a/Open-ILS/src/templates/staff/cat/catalog/t_edit_marc_modal.tt2 b/Open-ILS/src/templates/staff/cat/catalog/t_edit_marc_modal.tt2
new file mode 100644 (file)
index 0000000..1bc8904
--- /dev/null
@@ -0,0 +1,16 @@
+<div>
+  <div class="modal-header">
+    <button type="button" class="close"
+      ng-click="cancel()" aria-hidden="true">&times;</button>
+    <h4 class="modal-title">[% l('Edit MARC Record') %]</h4>
+  </div>
+  <div class="modal-body">
+    <eg-marc-edit-record dirty-flag="dirty_flag" marc-xml="args.marc_xml"
+                         in-place-mode="true" record-type="bre" save-label="[% l('Modify') %]" />
+  </div>
+  <div class="modal-footer">
+    <input type="submit" ng-click="ok(args)"
+        class="btn btn-primary" value="[% l('Use Edits') %]"/>
+    <button class="btn btn-warning" ng-click="cancel()">[% l('Cancel') %]</button>
+  </div>
+</div>
index 634c7bc..96780ad 100644 (file)
@@ -1 +1 @@
-<eg-embed-frame save-space="150" url="vandelay_url"></eg-embed-frame>
+<eg-embed-frame save-space="150" url="vandelay_url" handlers="funcs"></eg-embed-frame>
index 6952660..af2ea77 100644 (file)
@@ -1830,9 +1830,34 @@ function($scope , $location) {
 }])
 
 .controller('VandelayCtrl',
-       ['$scope','$location',
-function($scope , $location) {
+       ['$scope','$location', 'egCore', '$uibModal',
+function($scope , $location, egCore, $uibModal) {
     $scope.vandelay_url = $location.absUrl().replace(/\/staff\/cat\/catalog\/vandelay/, '/vandelay/vandelay');
+    $scope.funcs = {};
+    $scope.funcs.edit_marc_modal = function(bre, callback){
+        var marcArgs = { 'marc_xml': bre.marc() };
+        var vqbibrecId = bre.id();
+        $uibModal.open({
+            templateUrl: './cat/catalog/t_edit_marc_modal',
+            size: 'lg',
+            controller: ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) {
+                $scope.focusMe = true;
+                $scope.recordId = vqbibrecId;
+                $scope.args = marcArgs;
+                $scope.dirty_flag = false;
+                $scope.ok = function(marg){
+                    $uibModalInstance.close(marg);
+                };
+                $scope.cancel = function(){ $uibModalInstance.dismiss() }
+            }]
+        }).result.then(function(res){
+            var new_xml = res.marc_xml;
+            egCore.pcrud.retrieve('vqbr', vqbibrecId).then(function(vqbib){
+                vqbib.marc(new_xml);
+                egCore.pcrud.update(vqbib).then( function(){ callback(vqbibrecId); });
+            });
+        });
+    };
 }])
 
 .controller('ManageAuthoritiesCtrl',
index 928ef05..8726153 100644 (file)
@@ -1725,6 +1725,11 @@ function vlOpenMarcEditWindow(rec, postReloadHTMLHandler) {
         To run in Firefox directly, must set signed.applets.codebase_principal_support
         to true in about:config
     */
+    if(window.IAMBROWSER){
+        xulG.edit_marc_modal(rec, function(breId){ vlLoadMARCHtml(breId, false, postReloadHTMLHandler); });
+        return;
+    }
+
     win = window.open('/xul/server/cat/marcedit.xul','','chrome'); // XXX version?
 
     var type;