implement adding and removing scheduler slots

This commit is contained in:
Jakob Ketterl
2021-02-24 21:09:19 +01:00
parent 45a70a1079
commit 2785f43c6a
3 changed files with 93 additions and 49 deletions

View File

@ -98,6 +98,7 @@ table.bookmarks .frequency {
.removable-group.removable .removable-item {
flex: 1 0 auto;
margin-right: .25rem;
}
.removable-group.removable .option-remove-button {

View File

@ -1,6 +1,8 @@
$.fn.schedulerInput = function() {
this.each(function() {
var $container = $(this);
var $template = $container.find('.template');
$template.find('input, select').prop('disabled', true);
var update = function(value){
$container.find('.option').hide();
@ -13,5 +15,19 @@ $.fn.schedulerInput = function() {
update(value);
});
update($select.val());
$container.find('.add-button').on('click', function() {
var row = $template.clone();
row.removeClass('template').show();
row.find('input, select').prop('disabled', false);
$template.before(row);
return false;
});
$container.on('click', '.remove-button', function(e) {
var row = $(e.target).parents('.scheduler-static-time-inputs');
row.remove();
});
});
}