76
76
<input class="form-control" type="text" name="Description" value="<% $Description %>" size="16" />
80
<div class="label col-4">
81
<span class="prev-icon-helper"><&|/l&>Expires</&>:</span>\
82
<span class="far fa-question-circle icon-helper" data-toggle="tooltip" data-placement="top" data-original-title="<% loc("Set an optional Expires date?") %>"></span>
84
<div class="col-8 mt-2">
85
<div class="form-check">
86
<input type="checkbox" id="ExpiresCheckbox" name="ExpiresCheckbox" class="form-check-input checkbox" value="0" />
87
<label class="form-check-label" for="ExpiresCheckbox">Set Expires Date</label>
91
<div class="row mt-2">
92
<div class="label col-4">
95
<select name="ExpiresSelect" id="ExpiresSelect" class="form-control selectpicker">
96
<option value="1M" ><&|/l, 1 &>[quant,_1,Month,Months]</&></option>
97
<option value="3M"><&|/l, 3 &>[quant,_1,Month,Months]</&></option>
98
<option value="6M"><&|/l, 6 &>[quant,_1,Month,Months]</&></option>
99
<option value="1Y"><&|/l, 1 &>[quant,_1,Year,Years]</&></option>
100
<option value="Custom"><&|/l&>Custom Date</&></option>
104
<div class="row mt-2">
105
<div class="label col-4">
108
<& /Elements/SelectDate, Name=>"Expires", id=>"Expires", Default => $Expires, ShowTime => 1 &>
80
112
<& /Elements/Submit, Label => loc("Create"), Name => 'Create', FullWidth => 1 &>
120
jQuery("#ExpiresSelect").prop( "disabled", true );
121
jQuery("#Expires").prop( "disabled", true );
123
// Expires input needs to be enabled when the form is submitted to read its value
124
jQuery("#createAuthToken").submit(
126
jQuery("#Expires").prop( "disabled", false );
131
var onExpiresSelectChange = function() {
132
var expiresSelectVal = jQuery("#ExpiresSelect option:selected").val();
133
var expires = jQuery("#Expires");
135
// make sure expires is enabled so we can change value
136
expires.prop( "disabled", false );
137
if ( jQuery("#ExpiresSelect").prop("disabled") ) {
138
// Expires date options are disabled so Expires should be blank
141
// Expires date options are enabled so determine what we should set
142
// Expires value to based on selected Expires option
143
if ( expiresSelectVal != 'Custom' ) {
144
var date = new Date();
145
var regexp = /(\d)(\w)/;
146
var match = expiresSelectVal.match(regexp);
148
if ( match != null ) {
149
if ( match[2] == "M" ) {
150
date.setMonth( date.getMonth() + parseInt( match[1] ) );
152
date.setFullYear( date.getFullYear() + parseInt( match[1] ) );
154
expires.val( date.toISOString().substr(0, 10) + ' 00:00:00' );
159
// now enable/disable expires
160
expires.prop( "disabled", expiresSelectVal != "Custom" );
163
jQuery("#ExpiresCheckbox").click(
165
var expiresSelect = jQuery("#ExpiresSelect");
168
if ( expiresSelect.prop("disabled") ) {
169
// user is enabling the Expires date options
172
// user is disabling the Expires date options
175
// set back to default value
176
expiresSelect.val("1M");
178
jQuery(".selectpicker").selectpicker("refresh");
181
expiresSelect.prop( "disabled", disable );
183
jQuery(".selectpicker").selectpicker("refresh");
184
onExpiresSelectChange();
187
jQuery("#ExpiresSelect").change(
189
onExpiresSelectChange();
88
195
# Don't require password for systems with some form of federated auth,
89
196
# or if configured to not require a password