Subevents: Bulk editor (#1918)

Co-authored-by: Richard Schreiber <wiffbi@gmail.com>
This commit is contained in:
Raphael Michel
2021-02-22 15:22:40 +01:00
committed by GitHub
parent eb0123e350
commit 7562f333cf
14 changed files with 2330 additions and 723 deletions

View File

@@ -546,6 +546,25 @@ var form_handlers = function (el) {
);
});
el.find(".bulk-edit-field-group").each(function () {
var $checkbox = $(this).find("input[type=checkbox][name=_bulk]");
var $content = $(this).find(".field-content");
var $fields = $content.find("input, select, textarea, button");
var update = function () {
var isChecked = $checkbox.prop("checked");
$content.toggleClass("enabled", isChecked);
$fields.attr("tabIndex", isChecked ? 0 : -1);
}
$content.on("focusin change click", function () {
if ($checkbox.prop("checked")) return;
$checkbox.prop("checked", true);
update();
});
$checkbox.on('change', update)
update();
});
el.find("input[name*=question], select[name*=question]").change(questions_toggle_dependent);
questions_toggle_dependent();
};
@@ -563,7 +582,6 @@ $(function () {
}
);
$("[data-formset]").on("formAdded", "div", function (event) {
console.log("formAdded")
form_handlers($(event.target));
});
$(document).on("click", ".variations .variations-select-all", function (e) {
@@ -676,7 +694,7 @@ $(function () {
var update = function () {
var all_true = true;
var all_false = true;
$toggle.closest("table").find("td:first-child input[type=checkbox]").each(function () {
$toggle.closest("table").find("tbody td:first-child input[type=checkbox]").each(function () {
if ($(this).prop("checked")) {
all_false = false;
} else {
@@ -690,11 +708,29 @@ $(function () {
} else {
$toggle.prop("checked", false).prop("indeterminate", true);
}
var is_incomplete = $toggle.prop("indeterminate") || !$toggle.prop("checked")
$toggle.closest("table").find(".table-select-all").toggleClass(
"hidden", is_incomplete
)
if (is_incomplete) {
$toggle.closest("table").find(".table-select-all input").prop(
"checked", false
)
}
};
$(this).closest("table").find("td:first-child input[type=checkbox]").change(update);
$(this).change(function (ev) {
$(this).closest("table").find("td:first-child input[type=checkbox]").prop("checked", $(this).prop("checked"));
$(this).closest("table").find("tbody td:first-child input[type=checkbox]").prop("checked", $(this).prop("checked"));
var is_incomplete = $(this).prop("indeterminate") || !$(this).prop("checked")
$(this).closest("table").find(".table-select-all").toggleClass(
"hidden", is_incomplete
)
if (is_incomplete) {
$(this).closest("table").find(".table-select-all input").prop(
"checked", false
)
}
});
});

View File

@@ -613,3 +613,33 @@ table td > .checkbox input[type="checkbox"] {
border-bottom: 1px solid $input-border;
padding-bottom: 5px;
}
.bulk-edit-field-group {
.field-toggle {
font-weight: normal;
display: inline-block;
background: $gray-lighter;
padding: 2px 8px 4px;
border-top-left-radius: $border-radius-base;
border-top-right-radius: $border-radius-base;
margin-bottom: 0;
input {
position: relative;
top: 2px;
}
}
.field-content {
border: 2px solid $gray-lighter;
padding: 15px;
opacity: 0.5;
.datepickerfield::placeholder, .timepickerfield::placeholder {
opacity: 0;
}
&.enabled {
opacity: 1;
.datepickerfield::placeholder, .timepickerfield::placeholder {
opacity: 1;
}
}
}
}