View | Details | Raw Unified | Return to bug 11559
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/koha-backend.js (+28 lines)
Lines 21-26 define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin Link Here
21
    var _authorised_values = defaultFramework.authorised_values;
21
    var _authorised_values = defaultFramework.authorised_values;
22
    var _frameworks = {};
22
    var _frameworks = {};
23
    var _framework_mappings = {};
23
    var _framework_mappings = {};
24
    var _framework_kohafields = {};
24
25
25
    function _fromXMLStruct( data ) {
26
    function _fromXMLStruct( data ) {
26
        result = {};
27
        result = {};
Lines 48-61 define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin Link Here
48
49
49
            $.each( taginfo.subfields, function( i, subfield ) {
50
            $.each( taginfo.subfields, function( i, subfield ) {
50
                subfields[ subfield[0] ] = subfield[1];
51
                subfields[ subfield[0] ] = subfield[1];
52
                if ( frameworkcode == '' && subfield[1].kohafield ) {
53
                    _framework_kohafields[ subfield[1].kohafield ] = [ tagnum, subfield[0] ];
54
                }
51
            } );
55
            } );
52
56
53
            _framework_mappings[frameworkcode][tagnum] = $.extend( {}, taginfo, { subfields: subfields } );
57
            _framework_mappings[frameworkcode][tagnum] = $.extend( {}, taginfo, { subfields: subfields } );
54
        } );
58
        } );
59
60
        console.dir( _framework_kohafields );
55
    }
61
    }
56
62
57
    _importFramework( '', defaultFramework.framework );
63
    _importFramework( '', defaultFramework.framework );
58
64
65
    function _removeBiblionumberFields( record ) {
66
        var bibnumTag = KohaBackend.GetSubfieldForKohaField('biblio.biblionumber')[0];
67
68
        while ( record.removeField(bibnumTag) );
69
    }
70
59
    var KohaBackend = {
71
    var KohaBackend = {
60
        NOT_EMPTY: {}, // Sentinel value
72
        NOT_EMPTY: {}, // Sentinel value
61
73
Lines 72-77 define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin Link Here
72
            return _framework_mappings[frameworkcode][tagnumber];
84
            return _framework_mappings[frameworkcode][tagnumber];
73
        },
85
        },
74
86
87
        GetSubfieldForKohaField: function( kohafield ) {
88
            return _framework_kohafields[kohafield];
89
        },
90
75
        GetRecord: function( id, callback ) {
91
        GetRecord: function( id, callback ) {
76
            $.get(
92
            $.get(
77
                '/cgi-bin/koha/svc/bib/' + id
93
                '/cgi-bin/koha/svc/bib/' + id
Lines 85-90 define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin Link Here
85
        },
101
        },
86
102
87
        CreateRecord: function( record, callback ) {
103
        CreateRecord: function( record, callback ) {
104
            record = record.clone();
105
            _removeBiblionumberFields( record );
106
88
            $.ajax( {
107
            $.ajax( {
89
                type: 'POST',
108
                type: 'POST',
90
                url: '/cgi-bin/koha/svc/new_bib',
109
                url: '/cgi-bin/koha/svc/new_bib',
Lines 98-103 define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin Link Here
98
        },
117
        },
99
118
100
        SaveRecord: function( id, record, callback ) {
119
        SaveRecord: function( id, record, callback ) {
120
            record = record.clone();
121
            _removeBiblionumberFields( record );
122
101
            $.ajax( {
123
            $.ajax( {
102
                type: 'POST',
124
                type: 'POST',
103
                url: '/cgi-bin/koha/svc/bib/' + id,
125
                url: '/cgi-bin/koha/svc/bib/' + id,
Lines 186-193 define( [ '/cgi-bin/koha/svc/cataloguing/framework?frameworkcode=&callback=defin Link Here
186
            } );
208
            } );
187
209
188
            var seenTags = {};
210
            var seenTags = {};
211
            var itemTag = KohaBackend.GetSubfieldForKohaField('items.itemnumber')[0];
189
212
190
            $.each( record.fields(), function( undef, field ) {
213
            $.each( record.fields(), function( undef, field ) {
214
                if ( field.tagnumber() == itemTag ) {
215
                    errors.push( { type: 'itemTagUnsupported', line: field.sourceLine } );
216
                    return;
217
                }
218
191
                if ( seenTags[ field.tagnumber() ] && nonRepeatableTags[ field.tagnumber() ] ) {
219
                if ( seenTags[ field.tagnumber() ] && nonRepeatableTags[ field.tagnumber() ] ) {
192
                    errors.push( { type: 'unrepeatableTag', line: field.sourceLine, tag: field.tagnumber() } );
220
                    errors.push( { type: 'unrepeatableTag', line: field.sourceLine, tag: field.tagnumber() } );
193
                    return;
221
                    return;
(-)a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js (+13 lines)
Lines 76-81 define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], Link Here
76
        cm.marceditor.startNotify();
76
        cm.marceditor.startNotify();
77
    }
77
    }
78
78
79
    function editorSetOverwriteMode( cm, newState ) {
80
        var editor = cm.marceditor;
81
82
        editor.overwriteMode = newState;
83
    }
84
79
    // Editor helper functions
85
    // Editor helper functions
80
    function activateTabPosition( cm, pos, idx ) {
86
    function activateTabPosition( cm, pos, idx ) {
81
        // Allow tabbing to as-yet-nonexistent positions
87
        // Allow tabbing to as-yet-nonexistent positions
Lines 133-138 define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], Link Here
133
            cm.setCursor( { line: cursor.line + 1, ch: 0 } );
139
            cm.setCursor( { line: cursor.line + 1, ch: 0 } );
134
        },
140
        },
135
141
142
        'Shift-Enter': function( cm ) {
143
            var cur = cm.getCursor();
144
145
            cm.replaceRange( "\n", cur, null );
146
        },
147
136
        'Ctrl-X': function( cm ) {
148
        'Ctrl-X': function( cm ) {
137
            // Delete line (or cut)
149
            // Delete line (or cut)
138
            if ( cm.somethingSelected() ) return true;
150
            if ( cm.somethingSelected() ) return true;
Lines 450-455 define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], Link Here
450
        this.cm.on( 'beforeChange', editorBeforeChange );
462
        this.cm.on( 'beforeChange', editorBeforeChange );
451
        this.cm.on( 'changes', editorChanges );
463
        this.cm.on( 'changes', editorChanges );
452
        this.cm.on( 'cursorActivity', editorCursorActivity );
464
        this.cm.on( 'cursorActivity', editorCursorActivity );
465
        this.cm.on( 'overwriteToggle', editorSetOverwriteMode );
453
466
454
        this.onCursorActivity = options.onCursorActivity;
467
        this.onCursorActivity = options.onCursorActivity;
455
468
(-)a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-record.js (+13 lines)
Lines 61-66 define( function() { Link Here
61
    }
61
    }
62
62
63
    $.extend( MARC.Record.prototype, {
63
    $.extend( MARC.Record.prototype, {
64
        clone: function() {
65
            return new MARC.Record( $.map( this.fields(), function( field ) { return field.clone() } ) );
66
        },
67
64
        leader: function(val) {
68
        leader: function(val) {
65
            var field = this.field('000');
69
            var field = this.field('000');
66
70
Lines 271-276 define( function() { Link Here
271
    };
275
    };
272
276
273
    $.extend( MARC.Field.prototype, {
277
    $.extend( MARC.Field.prototype, {
278
        clone: function() {
279
            return new MARC.Field(
280
                this._tagnumber,
281
                this._indicators[0],
282
                this._indicators[1],
283
                $.extend( true, [], this._subfields ) // Deep copy
284
            );
285
        },
286
274
        tagnumber: function() {
287
        tagnumber: function() {
275
            return this._tagnumber;
288
            return this._tagnumber;
276
        },
289
        },
(-)a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/search.js (-1 / +8 lines)
Lines 17-23 Link Here
17
 * along with Koha; if not, see <http://www.gnu.org/licenses>.
17
 * along with Koha; if not, see <http://www.gnu.org/licenses>.
18
 */
18
 */
19
19
20
define( [ 'marc-record' ], function( MARC ) {
20
define( [ 'koha-backend', 'marc-record' ], function( KohaBackend, MARC ) {
21
    var _options;
21
    var _options;
22
    var _records = {};
22
    var _records = {};
23
    var _last;
23
    var _last;
Lines 71-76 define( [ 'marc-record' ], function( MARC ) { Link Here
71
                options: options,
71
                options: options,
72
            };
72
            };
73
73
74
            var itemTag = KohaBackend.GetSubfieldForKohaField('items.itemnumber')[0];
75
74
            $.each( servers, function ( id, info ) {
76
            $.each( servers, function ( id, info ) {
75
                if ( info.checked ) Search.includedServers.push( id );
77
                if ( info.checked ) Search.includedServers.push( id );
76
            } );
78
            } );
Lines 95-100 define( [ 'marc-record' ], function( MARC ) { Link Here
95
                        var record = new MARC.Record();
97
                        var record = new MARC.Record();
96
                        record.loadMARCXML( hit.record );
98
                        record.loadMARCXML( hit.record );
97
                        hit.record = record;
99
                        hit.record = record;
100
101
                        if ( hit.server == 'koha:biblioserver' ) {
102
                            // Remove item tags
103
                            while ( record.removeField(itemTag) );
104
                        }
98
                    } );
105
                    } );
99
106
100
                    _options.onresults( data );
107
                    _options.onresults( data );
(-)a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/text-marc.js (-1 / +1 lines)
Lines 72-78 define( [ 'marc-record' ], function( MARC ) { Link Here
72
                    field.sourceLine = i;
72
                    field.sourceLine = i;
73
                    record.addField( field );
73
                    record.addField( field );
74
                } else {
74
                } else {
75
                    var indicators = line.match( /^... ([0-9A-Za-z_]) ([0-9A-Za-z_])/ );
75
                    var indicators = line.match( /^... ([0-9A-Za-z_ ]) ([0-9A-Za-z_ ])/ );
76
                    if ( !indicators ) {
76
                    if ( !indicators ) {
77
                        errors.push( { type: 'noIndicators', line: i } );
77
                        errors.push( { type: 'noIndicators', line: i } );
78
                        return;
78
                        return;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc (-1 / +3 lines)
Lines 842-847 require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr Link Here
842
                        case 'unrepeatableSubfield':
842
                        case 'unrepeatableSubfield':
843
                            editor.addError( error.line, _("Subfield $") + error.subfield + _(" cannot be repeated") );
843
                            editor.addError( error.line, _("Subfield $") + error.subfield + _(" cannot be repeated") );
844
                            break;
844
                            break;
845
                        case 'itemTagUnsupported':
846
                            editor.addError( error.line, _("Item tags cannot currently be saved") );
847
                            break;
845
                    }
848
                    }
846
                } );
849
                } );
847
850
848
- 

Return to bug 11559