I added a date limiter in the checkout.js file, that prevents the user from making unreasonable dates.
Signed-off-by: Zavier Banks <zbanks@catalyte.io>
lp#
1016102: due date fields allow non-sane due dates
I added in a conditional that checks if the date is valid, and not unreasonable. Additionally,
I added a YAOUS that gives the amount of years maximum, you can check out a book. The code can be changed to
be more specific, if necessary.
Signed-off-by: Zavier Banks <zbanks@catalyte.io>
lp#
1016102 due date fields allow non-sane due dates
I reconfigured the way I found and implemented the maximum due date. In the initialization of the
checkout.js document, I added a way to get the maximum date from the database, and add it to the current date.
In the t_checkout.tt2 file, I added a max_date to the date input as well.
Signed-off-by: Zavier Banks <zbanks@catalyte.io>
-- org_unit setting types
INSERT into config.org_unit_setting_type
( name, grp, label, description, datatype, fm_class ) VALUES
-
-( 'acq.copy_creator_uses_receiver', 'acq',
+( 'circ.maximum_due_date','gui',
+ oils_i18n_gettext(
+ 'circ.maximum_due_date_length',
+ 'Maximum Future Due Date Interval.',
+ 'coust', 'label'),
+ oils_i18n_gettext(
+ 'circ.maximum_due_date_length',
+ 'How far in the future you can set a due date',
+ 'coust', 'label'),
+ 'interval', null )
+,( 'acq.copy_creator_uses_receiver', 'acq',
oils_i18n_gettext('acq.copy_creator_uses_receiver',
'Set copy creator as receiver',
'coust', 'label'),
--- /dev/null
+INSERT into config.org_unit_setting_type\r
+ (name, datatype, grp, label, description)\r
+VALUES (\r
+ 'circ.maximum_due_date', 'interval', 'gui'\r
+ oils_i18n_gettext(\r
+ 'circ.maximum_due_date_length',\r
+ 'Maximum Future Due Date Interval.',\r
+ 'coust', 'label'\r
+ ),\r
+ oils_i18n_gettext(\r
+ 'circ.maximum_due_date_length',\r
+ 'How far in the future you can set a due date'\r
+ 'coust', 'label'\r
+ )\r
+);
\ No newline at end of file
[% l('Specific Due Date') %]
</label>
</div> -->
- <div class="col-md-4">
- <eg-date-input ng-model="checkoutArgs.due_date" ng-disabled="!date_options.has_sticky_date" show-time-picker></eg-date-input>
+ <div class="col-md-4" ng-if="maxDate">
+ <eg-date-input ng-model="checkoutArgs.due_date" ng-disabled="!date_options.has_sticky_date" show-time-picker max-date="maxDate"></eg-date-input>
</div>
</div>
</div>
function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
egGridDataProvider , $location , $timeout , egCirc , ngToast) {
- $scope.initTab('checkout', $routeParams.id).finally(function(){
+ $scope.initTab('checkout', $routeParams.id).then(function(){
+ var dateLimit;
+ var limitedDate;
+ egCore.org.settings([
+ 'circ.maximum_due_date'
+ ]).then(function(settings) { //Then log the maximum date set by the user.
+ dateLimit= settings['circ.maximum_due_date'];
+ if(dateLimit!=null){
+ limitedDate = new Date();
+ limitedDate.setSeconds(limitedDate.getSeconds()+egCore.date.intervalToSeconds(dateLimit))
+ }
+ $scope.maxDate=limitedDate;
+ })
+ }).finally(function(){
$scope.focusMe = true;
});
$scope.checkouts = patronSvc.checkouts;
$scope.checkout = function(args) {
var params = angular.copy(args);
- params.patron_id = patronSvc.current.id();
-
- if (args.sticky_date) {
- params.due_date = args.due_date.toISOString();
+ params.patron_id = patronSvc.current.id();
+
+ if (args.sticky_date) {//If the date, given by the user, is less that the date limit set by the admin
+ params.due_date = args.due_date.toISOString();//Add the due date to the parameters.
} else {
delete params.due_date;
}
- delete params.sticky_date;
-
+ delete params.sticky_date;
if (params.noncat_type == 'barcode') {
if (!args.copy_barcode) return;