Lines 84-90
Link Here
|
84 |
* single subfield, '@'. |
84 |
* single subfield, '@'. |
85 |
*/ |
85 |
*/ |
86 |
|
86 |
|
87 |
require( [ 'widget' ], function( Widget ) { |
87 |
require( [ 'koha-backend', 'widget' ], function( KohaBackend, Widget ) { |
88 |
Widget.Register( '000@', { |
88 |
Widget.Register( '000@', { |
89 |
makeTemplate: function() { |
89 |
makeTemplate: function() { |
90 |
return ' nam a22 7a 4500'; |
90 |
return ' nam a22 7a 4500'; |
Lines 112-117
require( [ 'widget' ], function( Widget ) {
Link Here
|
112 |
}, |
112 |
}, |
113 |
} ); |
113 |
} ); |
114 |
|
114 |
|
|
|
115 |
Widget.Register( '001@', { |
116 |
init: function() { |
117 |
var $result = $( |
118 |
'<span class="subfield-widget">' |
119 |
+ _("Control number: ") |
120 |
+ '<span class="control-number-widget-contents"></span>' |
121 |
+ '<button class="control-number-widget-assign">' + _("Assign next") + '</button>' |
122 |
+ '<select class="control-number-widget-sequence"></select>' |
123 |
+ '<button class="control-number-widget-override">' + _("Override") + '</button>' |
124 |
+ '</span>' |
125 |
); |
126 |
|
127 |
return $result[0]; |
128 |
}, |
129 |
setControlNumber: function( text ) { |
130 |
if ( text ) this.setText( text ); |
131 |
$( this.node ).find('.control-number-widget-contents') |
132 |
.html( text == '<empty>' ? ( '<span class="hint">' + _("unset") + '</span>' ) : text ); |
133 |
this.mark.changed(); |
134 |
}, |
135 |
postCreate: function( node, mark ) { |
136 |
var widget = this; |
137 |
this.setControlNumber( this.text ); |
138 |
$( this.node ) |
139 |
.find('.control-number-widget-assign').click( function() { |
140 |
var sequence = $( widget.node ).find('.control-number-widget-sequence').val(); |
141 |
$.post( |
142 |
'/cgi-bin/koha/svc/cataloguing/control_num_sequences/' + sequence |
143 |
).done( function( result ) { |
144 |
if ( result.next_value ) widget.setControlNumber( result.next_value ); |
145 |
} ); |
146 |
} ).end() |
147 |
.find('.control-number-widget-override').click( function() { |
148 |
var result = prompt( _("Enter new control number") ); |
149 |
|
150 |
if ( result ) widget.setControlNumber( result ); |
151 |
} ).end(); |
152 |
var sequence_list = $.map( KohaBackend.GetAuthorisedValues( 'CONTROL_NUM_SEQUENCE' ), function( authval ) { |
153 |
return authval.lib; |
154 |
} ); |
155 |
sequence_list.sort(); |
156 |
if(sequence_list.length){ |
157 |
$.each( sequence_list, function( undef, sequence ) { |
158 |
$( widget.node ).find('.control-number-widget-sequence').append( '<option>' + sequence + '</option>' ); |
159 |
} ); |
160 |
} else { |
161 |
$(".control-number-widget-assign").remove() |
162 |
$(".control-number-widget-sequence").remove(); |
163 |
$(".control-number-widget-override").text( _('Manually assign') ); |
164 |
$(".control-number-widget-override").attr('title', _('Define a CONTROL_NUM_SEQUENCE authorised value category with value set to initial value to enable auto-generation') ); |
165 |
} |
166 |
// TODO: Make Enter on select click "Assign" |
167 |
} |
168 |
} ); |
169 |
|
115 |
Widget.Register( '005@', { |
170 |
Widget.Register( '005@', { |
116 |
init: function() { |
171 |
init: function() { |
117 |
var $result = $( '<span class="subfield-widget fixed-widget">' + _("Updated: ") + '</span>' ); |
172 |
var $result = $( '<span class="subfield-widget fixed-widget">' + _("Updated: ") + '</span>' ); |