mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
Allow to restrict availability of variations by date, sales channel, and voucher (#2202)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
setup_collapsible_details = function (el) {
|
||||
var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
|
||||
el.find("details summary, details summary a[data-toggle=variations]").click(function (e) {
|
||||
if (this.tagName !== "A" && $(e.target).closest("a").length > 0) {
|
||||
if (this.tagName !== "A" && $(e.target).closest("a, button").length > 0) {
|
||||
return true;
|
||||
}
|
||||
var $details = $(this).closest("details");
|
||||
|
||||
58
src/pretix/static/pretixcontrol/js/ui/variations.js
Normal file
58
src/pretix/static/pretixcontrol/js/ui/variations.js
Normal file
@@ -0,0 +1,58 @@
|
||||
/*global $, Morris, gettext*/
|
||||
$(function () {
|
||||
// Question view
|
||||
if (!$("#item_variations").length) {
|
||||
return;
|
||||
}
|
||||
|
||||
function update_variation_summary($el) {
|
||||
var var_name = $el.find("input[name*=-value_]").filter(function () {return !!this.value}).first().val();
|
||||
var price = $el.find("input[name*=-default_price]").val();
|
||||
|
||||
|
||||
$el.find(".variation-name").text(var_name);
|
||||
$el.find(".variation-price").text(price);
|
||||
$el.find(".variation-timeframe").toggleClass("variation-icon-hidden", !(
|
||||
!!$el.find("input[name$=-available_from_0]").val() ||
|
||||
!!$el.find("input[name$=-available_until_0]").val()
|
||||
));
|
||||
$el.find(".variation-name").toggleClass("variation-disabled", !(
|
||||
!!$el.find("input[name$=-active]").prop("checked")
|
||||
));
|
||||
$el.find(".variation-voucher").toggleClass("variation-icon-hidden", !(
|
||||
!!$el.find("input[name$=-hide_without_voucher]").prop("checked")
|
||||
));
|
||||
$el.find(".variation-membership").toggleClass("variation-icon-hidden", !(
|
||||
!!$el.find("input[name$=-require_membership]").prop("checked")
|
||||
));
|
||||
$el.find(".variation-warning").toggleClass("hidden", !(
|
||||
$el.find(".alert-warning").length
|
||||
));
|
||||
$el.find(".variation-error").toggleClass("hidden", !(
|
||||
$el.find(".alert-danger, .has-error").length
|
||||
));
|
||||
$el.find("input[name$=-sales_channels]").each(function () {
|
||||
$el.find(".variation-channel-" + $(this).val()).toggleClass("variation-icon-hidden", !(
|
||||
$(this).prop("checked") && $("input[name=sales_channels][value=" + $(this).val() + "]").prop("checked")
|
||||
));
|
||||
})
|
||||
}
|
||||
|
||||
$("#item_variations [data-formset-form]").each(function () {
|
||||
var $el = $(this);
|
||||
update_variation_summary($el);
|
||||
$(this).on("change dp.change", "input", function () {update_variation_summary($el)});
|
||||
});
|
||||
$("input[name=sales_channels]").on("change", function() {
|
||||
$("#item_variations [data-formset-form]").each(function () {
|
||||
update_variation_summary($(this));
|
||||
});
|
||||
});
|
||||
$("#item_variations").on("formAdded", "details", function (event) {
|
||||
console.log("added", event.target)
|
||||
var $el = $(event.target);
|
||||
update_variation_summary($el);
|
||||
$(this).on("change dp.change", "input", function () {update_variation_summary($el)});
|
||||
setup_collapsible_details($("#item_variations"));
|
||||
});
|
||||
});
|
||||
@@ -46,7 +46,7 @@ td > .form-group > .checkbox {
|
||||
@include box-shadow(none);
|
||||
}
|
||||
|
||||
div[data-formset-body], div[data-formset-form], div[data-nested-formset-form], div[data-nested-formset-body] {
|
||||
div[data-formset-body], div[data-formset-form], div[data-nested-formset-form], div[data-nested-formset-body], details[data-formset-form] {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@@ -813,3 +813,26 @@ table td > .checkbox input[type="checkbox"] {
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
details {
|
||||
summary .chevron::before {
|
||||
content: $fa-var-caret-right;
|
||||
}
|
||||
&[open] .chevron::before {
|
||||
content: $fa-var-caret-down;
|
||||
}
|
||||
}
|
||||
|
||||
#item_variations {
|
||||
summary small {
|
||||
display: inline-block;
|
||||
margin-left: 2.1em;
|
||||
}
|
||||
.variation-icon-hidden {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
.variation-disabled {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user