@@ -, +, @@ export file as cataloger saves --- .../lib/koha/cateditor/preferences.js | 1 + koha-tmpl/intranet-tmpl/prog/css/cateditor.css | 90 +++++++++++- .../prog/en/includes/cateditor-ui.inc | 152 ++++++++++++++++++++- .../prog/en/modules/cataloguing/editor.tt | 25 ++++ tools/export.pl | 7 + 5 files changed, 272 insertions(+), 3 deletions(-) --- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/preferences.js +++ a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/preferences.js @@ -33,6 +33,7 @@ define( function() { font: 'monospace', fontSize: '1em', macros: {}, + exportRecords: (); selected_search_targets: {}, }, saved_prefs ); }, --- a/koha-tmpl/intranet-tmpl/prog/css/cateditor.css +++ a/koha-tmpl/intranet-tmpl/prog/css/cateditor.css @@ -224,7 +224,7 @@ body { /*> Search */ -#advanced-search-ui .modal-lg, #search-results-ui .modal-lg, #macro-ui .modal-lg { +#advanced-search-ui .modal-lg, #search-results-ui .modal-lg, #macro-ui .modal-lg, #export-ui .modal-lg { width: 90%; } @@ -372,6 +372,92 @@ body { z-index: 9001; } +/*> Export Records UI */ +#export-save-message { + color: #666; + font-size: 13px; + float: right; + line-height: 26px; +} + +#export-list > li { + border: 2px solid #F0F0F0; + border-radius: 6px; + display: block; + font-size: 115%; +} + +#export-list > li + li { + margin-top: -2px; +} + +#export-list .active { + background: #EDF4F6; + border-color: none; +} + +#export-list a { + display: block; + padding: 6px; +} + +#export-list a:focus { + outline: none; +} + +.export-info { + background-color: #F4F4F4; + display: none; + margin: 0; + padding: 10px; + text-align: right; +} + +.export-info li { + color: #666; + font-size: 75%; + list-style-type: none; +} + +.export-info .label { + clear: left; + font-weight: bold; + float: left; +} + +#export-list .active .export-info { + display: block; +} + +.btn-toolbar label, .btn-toolbar select { + font-size: 13px; + vertical-align: middle; +} + +.btn-toolbar label { + margin-left: 1em; +} + +.btn-toolbar select { + padding: 2px; +} + +#export-editor { + display: flex; + flex-direction: column; + height: 100%; +} + +#export-editor .CodeMirror { + flex: 1; + font-size: 13px; +} + +/* Hotpatch from latest CodeMirror: Fix gutter positioning */ +.CodeMirror-gutter-wrapper { + position: absolute; +} + /*> Macros */ #macro-save-message { color: #666; @@ -477,4 +563,4 @@ body { .ui-keyboard-accept { display: none; -} +} --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc @@ -82,6 +82,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr var editor; var macroEditor; + var exportRecordEditor; function makeAuthorisedValueWidgets( frameworkCode ) { $.each( KohaBackend.GetAllTagsInfo( frameworkCode ), function( tag, tagInfo ) { @@ -279,6 +280,17 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr done( { error: data.error, newRecord: data.marcxml && data.marcxml[0], newId: data.biblionumber && [ 'catalog', data.biblionumber ] } ); } + //Add the record to the exportRecords list if there is one + if(Preferences.user.exportRecords) { + var export_list = $.map (Preferences.user.exportRecords, function (exportRecord, name) { + return $.extend( { name: name}, exportRecord ); + }); + $.each (export_list, function ( undef, exportRecord ) { + exportRecord.contents += "\n" + state.recordID; + storeExportRecord( exportRecord.name, { contents: exportRecord.contents} ); + } ); + } + if ( id ) { KohaBackend.SaveRecord( id, record, finishCb ); } else { @@ -643,6 +655,9 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr case 'macros': // Macros loaded on first show of modal break; + case 'exportRecords': + //Export records loaded on first show of modal + break; case 'selected_search_targets': $.each( z3950Servers, function( index, server ) { var saved_val = Preferences.user.selected_search_targets[server.server_id]; @@ -696,6 +711,88 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr } ); } + //> Export record functions + function loadExportRecord( name ) { + $( '#export-list li' ).removeClass ('active' ); + exportRecordEditor.activeExportRecord = name; + + if ( !name ) { + exportRecordEditor.setValue ( '' ); + return; + } + + $( '#export-list li[data-name="' + name + '"]' ).addClass( 'active' ); + var exportRecord = Preferences.user.exportRecords[name]; + exportRecord.contents = dedupeString( exportRecord.contents ); + exportRecordEditor.setValue( exportRecord.contents ); + exportRecordEditor.setOption( 'readOnly', false ); + if ( exportRecord.history ) exportRecordEditor.setHistory( exportRecord.history ); + } + + function dedupeString( strg ) { + var pieces = strg.split("\n"); + var output = []; //Output array + for (var i = 0; i < pieces.length; i++) { + if (output.indexOf(pieces[i]) < 0 && pieces[i].length > 0) { + output.push(pieces[i]); + } + } + + return output.join("\n"); + } + + function storeExportRecord( name, exportRecord ) { + if ( exportRecord ) { + Preferences.user.exportRecords[name] = exportRecord; + } else { + delete Preferences.user.exportRecords[name]; + } + + Preferences.Save( [% logged_in_user.borrowernumber | html %] ); + } + + function showSavedExportRecords ( exportRecords ) { + var scrollTop = $('#export-list').scrollTop(); + $( '#export-list').empty(); + var export_list = $.map (Preferences.user.exportRecords, function (exportRecord, name) { + return $.extend( { name: name }, exportRecord ); + } ); + export_list.sort (function ( a, b ) { + return a.name.localeCompare(b.name); + } ); + $.each ( export_list, function ( undef, exportRecord ) { + var $li = $( '