Check-in rules: Allow to check for time of day (#2061)

* Add "customtime" option

* Fix time picker output format

* Fix bug in bool_alg

* Fix test
This commit is contained in:
Raphael Michel
2021-05-07 11:29:39 +02:00
committed by GitHub
parent 366395278e
commit b5e41f4c62
8 changed files with 114 additions and 11 deletions

View File

@@ -99,7 +99,8 @@ $(document).ready(function () {
date_from: gettext('Event start'),
date_to: gettext('Event end'),
date_admission: gettext('Event admission'),
date_custom: gettext('custom time'),
date_custom: gettext('custom date and time'),
date_customtime: gettext('custom time'),
date_tolerance: gettext('Tolerance (minutes)'),
condition_add: gettext('Add condition'),
minutes: gettext('minutes'),
@@ -119,4 +120,4 @@ $(document).ready(function () {
},
}
})
});
});

View File

@@ -27,11 +27,14 @@
<option value="date_to">{{texts.date_to}}</option>
<option value="date_admission">{{texts.date_admission}}</option>
<option value="custom">{{texts.date_custom}}</option>
<option value="customtime">{{texts.date_customtime}}</option>
</select>
<datetimefield v-if="vartype == 'datetime' && timeType == 'custom'" :value="timeValue"
v-on:input="setTimeValue"></datetimefield>
<timefield v-if="vartype == 'datetime' && timeType == 'customtime'" :value="timeValue"
v-on:input="setTimeValue"></timefield>
<input class="form-control" required type="number"
v-if="vartype == 'datetime' && timeType && timeType != 'custom'" v-bind:value="timeTolerance"
v-if="vartype == 'datetime' && timeType && timeType != 'customtime' && timeType != 'custom'" v-bind:value="timeTolerance"
v-on:input="setTimeTolerance" :placeholder="texts.date_tolerance">
<input class="form-control" required type="number" v-if="vartype == 'int' && cardinality > 1"
v-bind:value="rightoperand" v-on:input="setRightOperandNumber">
@@ -56,6 +59,7 @@
components: {
LookupSelect2: LookupSelect2.default,
Datetimefield: Datetimefield.default,
Timefield: Timefield.default,
},
props: {
rule: Object,

View File

@@ -0,0 +1,55 @@
<template>
<input class="form-control">
</template>
<script>
export default {
props: ["required", "value"],
template: (''),
mounted: function () {
var vm = this;
var multiple = this.multiple;
$(this.$el)
.datetimepicker(this.opts())
.trigger("change")
.on("dp.change", function (e) {
vm.$emit("input", $(this).data('DateTimePicker').date().format("HH:mm:ss"));
});
if (!vm.value) {
$(this.$el).data("DateTimePicker").viewDate(moment().hour(0).minute(0).second(0).millisecond(0));
} else {
$(this.$el).data("DateTimePicker").date(vm.value);
}
},
methods: {
opts: function () {
return {
format: $("body").attr("data-timeformat"),
locale: $("body").attr("data-datetimelocale"),
useCurrent: false,
showClear: this.required,
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-screenshot',
clear: 'fa fa-trash',
close: 'fa fa-remove'
}
};
}
},
watch: {
value: function (val) {
$(this.$el).data('DateTimePicker').date(val);
},
},
destroyed: function () {
$(this.$el)
.off()
.datetimepicker("destroy");
}
}
</script>

View File

@@ -22,6 +22,9 @@
<span v-if="rightoperand.buildTime[0] === 'custom'">
{{ df(rightoperand.buildTime[1]) }}
</span>
<span v-else-if="rightoperand.buildTime[0] === 'customtime'">
{{ tf(rightoperand.buildTime[1]) }}
</span>
<span v-else>
{{ this.$root.texts[rightoperand.buildTime[0]] }}
</span>
@@ -139,6 +142,10 @@
df (val) {
const format = $("body").attr("data-datetimeformat")
return moment(val).format(format)
},
tf (val) {
const format = $("body").attr("data-timeformat")
return moment(val).format(format)
}
},
}