if( $options{'syntax'} ){
$chunk->{'syntax'} = $options{'syntax'};
}
+
+ if( $options{'type'} && $options{'type'} eq 'modalselect' ){
+ $chunk->{'source'} = $options{'source'};
+ $chunk->{'type'} = 'modalselect';
+ }
+
if ( $options{'class'} && $options{'class'} eq 'password' ) {
$chunk->{'input_type'} = 'password';
} elsif ( $options{'class'} && $options{'class'} eq 'date' ) {
-.preference-url, .preference-multi, .preference-long, .preference-file {
+.preference-url,
+.preference-multi,
+.preference-long,
+.preference-file,
+.preference-modalselect {
width: 20em;
}
width: 5em;
}
+input[type="text"].modalselect {
+ cursor: pointer;
+}
+
+input[type="text"].modalselect:hover {
+ background-color: #FFC;
+}
+
textarea.preference {
width: 35em;
height: 20em;
resize: vertical;
}
+#prefModal label {
+ display: block;
+ font-weight: bold;
+ line-height: 1.5em;
+}
+
+.dbcolumn {
+ font-weight: normal;
+ font-family: monospace;
+ color: #666;
+}
#menu ul li.active a.pref_sublink {
background: #FFF none;
border: 0;
margin: .5em 0;
}
+.columns-2 {
+ columns: 2 auto;
+ column-gap: 2.5em;
+}
+
.columns-3 {
columns: 3 auto;
column-gap: 2.5em;
</option>
[% END %]
</select>
+ [% ELSIF ( CHUNK.type_modalselect ) %]
+ <input type="text" name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="modalselect preference preference-[% CHUNK.type | html %]" data-source="[% CHUNK.source | html %]" readonly="readonly" value="[% CHUNK.value | html %]"/>
[% ELSIF ( CHUNK.type_multiple ) %]
<select name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="preference preference-[% CHUNK.class or "choice" | html %]" multiple="multiple">
[% FOREACH CHOICE IN CHUNK.CHOICES %][% IF ( CHOICE.selected ) %]<option value="[% CHOICE.value | html %]" selected="selected">[% ELSE %]<option value="[% CHOICE.value | html %]">[% END %][% CHOICE.text | html %]</option>[% END %]
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
</div> <!-- /.row -->
+<!-- Modal -->
+<div class="modal" id="prefModal" tabindex="-1" role="dialog" aria-labelledby="prefModalLabel">
+ <div class="modal-dialog modal-wide" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
+ <h4 class="modal-title" id="prefModalLabel">Modal title</h4>
+ </div>
+ <div class="modal-body">
+ <p>
+ <a href="#" id="select_all"><i class="fa fa-check"></i> Select all</a>
+ |
+ <a href="#" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
+ </p>
+ <form action="#" id="prefModalForm">
+ </form>
+ </div>
+ <div class="modal-footer">
+ <button id="saveModalPrefs" data-target="" type="button" class="btn btn-default">Save</button>
+ <button type="button" class="btn btn-link cancel" data-dismiss="modal">Cancel</button>
+ </div>
+ </div>
+ </div>
+</div>
+
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
[% Asset.js("lib/hc-sticky.js") | $raw %]
<script>
var Sticky;
+ var themelang = "[% themelang | html %]";
$(document).ready(function(){
[% UNLESS ( searchfield ) %]
Sticky = $("#toolbar");
e.preventDefault();
window.location.reload(true);
});
-
});
// This is here because of its dependence on template variables, everything else should go in js/pages/preferences.js - jpw
var to_highlight = "[% To.json( searchfield ) | $raw %]";
--- /dev/null
+{
+ "cardnumber": "cardnumber",
+ "surname": "surname",
+ "firstname": "firstname",
+ "title": "title",
+ "othernames": "othernames",
+ "initials": "initials",
+ "streetnumber": "streetnumber",
+ "streettype": "streettype",
+ "address": "address",
+ "address2": "address2",
+ "city": "city",
+ "state": "state",
+ "zipcode": "zipcode",
+ "country": "country",
+ "email": "email",
+ "phone": "phone",
+ "mobile": "mobile",
+ "fax": "fax",
+ "emailpro": "emailpro",
+ "phonepro": "phonepro",
+ "B_streetnumber": "B_streetnumber",
+ "B_streettype": "B_streettype",
+ "B_address": "B_address",
+ "B_address2": "B_address2",
+ "B_city": "B_city",
+ "B_state": "B_state",
+ "B_zipcode": "B_zipcode",
+ "B_country": "B_country",
+ "B_email": "B_email",
+ "B_phone": "B_phone",
+ "dateofbirth": "dateofbirth",
+ "branchcode": "branchcode",
+ "categorycode": "categorycode",
+ "contactname": "contactname",
+ "contactfirstname": "contactfirstname",
+ "borrowernotes": "borrowernotes",
+ "sex": "sex",
+ "password": "password",
+ "userid": "userid",
+ "opacnote": "opacnote",
+ "contactnote": "contactnote",
+ "altcontactfirstname": "altcontactfirstname",
+ "altcontactsurname": "altcontactsurname",
+ "altcontactaddress1": "altcontactaddress1",
+ "altcontactaddress2": "altcontactaddress2",
+ "altcontactaddress3": "altcontactaddress3",
+ "altcontactstate": "altcontactstate",
+ "altcontactzipcode": "altcontactzipcode",
+ "altcontactcountry": "altcontactcountry",
+ "altcontactphone": "altcontactphone",
+ "smsalertnumber": "smsalertnumber"
+}
\ No newline at end of file
-
- "The following <a href='http://schema.koha-community.org/__VERSION__/tables/borrowers.html' target='blank'>database columns</a> must be filled in on the patron entry screen:"
- pref: PatronSelfRegistrationBorrowerMandatoryField
- class: multi
- - (separate columns with |)
+ type: modalselect
+ source: borrowers
-
- "The following <a href='http://schema.koha-community.org/__VERSION__/tables/borrowers.html' target='blank'>database columns</a> will not appear on the patron self-registration screen:"
- pref: PatronSelfRegistrationBorrowerUnwantedField
- class: multi
- - (separate columns with |)
+ type: modalselect
+ source: borrowers
-
- "The following <a href='http://schema.koha-community.org/__VERSION__/tables/borrowers.html' target='blank'>database columns</a> will not appear on the patron self-modification screen:"
- pref: PatronSelfModificationBorrowerUnwantedField
- class: multi
- - (separate columns with |)
+ type: modalselect
+ source: borrowers
-
- "Display the following additional instructions for patrons who self register via the OPAC ( HTML is allowed ):"
- pref: PatronSelfRegistrationAdditionalInstructions
-
- "The following <a href='http://schema.koha-community.org/__VERSION__/tables/borrowers.html' target='blank'>database columns</a> must be filled in on the patron entry screen:"
- pref: BorrowerMandatoryField
- class: multi
- - (separate columns with |)
+ type: modalselect
+ source: borrowers
- "<strong>NOTE:</strong> If autoMemberNum is enabled, the system preference BorrowerMandatoryField must not contain the field cardnumber."
-
- "The following <a href='http://schema.koha-community.org/__VERSION__/tables/borrowers.html' target='blank'>database columns</a> will not appear on the patron entry screen:"
- pref: BorrowerUnwantedField
- class: multi
+ type: modalselect
+ source: borrowers
- (separate columns with |)
-
- "Borrowers can have the following titles:"
-/* global KOHA MSG_MADE_CHANGES CodeMirror MSG_CLICK_TO_EXPAND MSG_CLICK_TO_COLLAPSE to_highlight search_jumped humanMsg MSG_NOTHING_TO_SAVE MSG_MODIFIED MSG_SAVING MSG_SAVED_PREFERENCE dataTablesDefaults */
+/* global KOHA MSG_MADE_CHANGES CodeMirror MSG_CLICK_TO_EXPAND MSG_CLICK_TO_COLLAPSE to_highlight search_jumped humanMsg MSG_NOTHING_TO_SAVE MSG_MODIFIED MSG_SAVING MSG_SAVED_PREFERENCE dataTablesDefaults themelang */
// We can assume 'KOHA' exists, as we depend on KOHA.AJAX
KOHA.Preferences = {
email: true
});
});
+
+
+ $(".modalselect").on("click", function(){
+ var datasource = $(this).data("source");
+ var pref_name = this.id.replace(/pref_/, '');
+ var pref_value = this.value;
+ var prefs = pref_value.split("|");
+
+ $.getJSON( themelang + "/modules/admin/preferences/" + datasource + ".json", function( data ){
+ var items = [];
+ var checked = "";
+ $.each( data, function( key, val ){
+ if( prefs.indexOf( val ) >= 0 ){
+ checked = ' checked="checked" ';
+ } else {
+ checked = "";
+ }
+ items.push('<label><input class="dbcolumn_selection" type="checkbox" id="' + key + '"' + checked + ' name="pref" value="' + val + '" /> ' + key + '</label>');
+ });
+ $("<div/>", {
+ "class": "columns-2",
+ html: items.join("")
+ }).appendTo("#prefModalForm");
+ });
+ $("#saveModalPrefs").data("target", this.id );
+ $("#prefModalLabel").text( pref_name );
+ $("#prefModal").modal("show");
+ });
+
+ $("#saveModalPrefs").on("click", function(){
+ var formfieldid = $("#" + $(this).data("target") );
+ var prefs = [];
+ $("#prefModal input[type='checkbox']").each(function(){
+ if( $(this).prop("checked") ){
+ prefs.push( this.value );
+ }
+ });
+
+ formfieldid.val( prefs.join("|") )
+ .addClass("modified");
+ mark_modified.call( formfieldid );
+ KOHA.Preferences.Save( formfieldid.closest("form") );
+ $("#prefModal").modal("hide");
+ });
+
+ $("#prefModal").on("hide.bs.modal", function(){
+ $("#prefModalLabel,#prefModalForm").html("");
+ $("#saveModalPrefs").data("target", "" );
+ });
+
+ $("#select_all").on("click",function(e){
+ e.preventDefault();
+ $(".dbcolumn_selection").prop("checked", true);
+ });
+ $("#clear_all").on("click",function(e){
+ e.preventDefault();
+ $(".dbcolumn_selection").prop("checked", false);
+ });
+
} );