Commit 6de8eea9 authored by Oliver Bartsch's avatar Oliver Bartsch
Browse files

[BUGFIX] Use optgroup in SelectMultipleSideBySideElement

Instead of using multiple "fake" <option> elements with
the same value `--div--`, the SelectMultipleSideBySideElement
does now use proper HTML <optgroup> elements for grouping
of the available options. This is in line with other
select elements, e.g. the SelectSingleElement.

Besides the improved HTML markup, this also improves
the UI, since the <optgroup> element is non-selectable.
It is also no longer considered by the filter, which
previously led to confusion, especially when filtering
and having the "dividers" as only options left.

Resolves: #95137
Releases: main, 11.5
Change-Id: Ia51e2623217eb0c7abd6c0cd2e9c4a742686641d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72992


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Jochen's avatarJochen <rothjochen@gmail.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Jochen's avatarJochen <rothjochen@gmail.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent 8c5aefaa
......@@ -149,7 +149,7 @@ export = (function() {
$fieldEl = FormEngine.getFieldElement(fieldName);
originalFieldEl = $fieldEl.get(0);
if (originalFieldEl === null || value === '--div--') {
if (originalFieldEl === null || value === '--div--' || originalFieldEl instanceof HTMLOptGroupElement) {
return;
}
......@@ -168,10 +168,11 @@ export = (function() {
// If multiple values are not allowed, clear anything that is in the control already
if (!isMultiple) {
$fieldEl.find('option').each((index: number, el: HTMLElement) => {
$availableFieldEl
.find('option[value="' + $.escapeSelector($(el).attr('value')) + '"]')
.removeClass('hidden')
.prop('disabled', false);
const $option = $availableFieldEl.find('option[value="' + $.escapeSelector($(el).attr('value')) + '"]');
if ($option) {
$option.removeClass('hidden').prop('disabled', false);
FormEngine.enableOptGroup($option.get(0));
}
});
$fieldEl.empty();
}
......@@ -198,6 +199,7 @@ export = (function() {
optionEl.closest('select').querySelectorAll('[disabled]').forEach(function (disabledOption: HTMLOptionElement) {
disabledOption.classList.remove('hidden');
disabledOption.disabled = false;
FormEngine.enableOptGroup(disabledOption);
});
}
}
......@@ -218,6 +220,14 @@ export = (function() {
if (addNewValue && typeof optionEl !== 'undefined') {
optionEl.classList.add('hidden');
optionEl.disabled = true;
// In case the disabled option was the last active option and is in an optGroup, also disable the optGroup
const optGroup = <HTMLOptGroupElement>optionEl.parentElement;
if (optGroup instanceof HTMLOptGroupElement
&& optGroup.querySelectorAll('option:not([disabled]):not([hidden]):not(.hidden)').length === 0
) {
optGroup.disabled = true;
optGroup.classList.add('hidden');
}
}
}
......@@ -1156,6 +1166,18 @@ export = (function() {
});
};
/**
* In case the given option is a child of a disabled optGroup, enable the optGroup
*/
FormEngine.enableOptGroup = function (option: HTMLOptionElement): void {
const optGroup = <HTMLOptGroupElement>option.parentElement;
if (optGroup instanceof HTMLOptGroupElement && optGroup.querySelectorAll('option:not([hidden]):not([disabled]):not(.hidden)').length) {
optGroup.hidden = false;
optGroup.disabled = false;
optGroup.classList.remove('hidden');
}
}
/**
* Close current open document
*/
......
......@@ -87,6 +87,7 @@ export abstract class AbstractSortableSelectItems {
if (originalOption !== null) {
originalOption.classList.remove('hidden');
originalOption.disabled = false;
FormEngine.enableOptGroup(originalOption);
}
fieldElement.removeChild(option);
......
......@@ -27,6 +27,20 @@ class SelectBoxFilter {
private filterText: string = '';
private availableOptions: NodeListOf<HTMLOptionElement> = null;
private static toggleOptGroup(option: HTMLOptionElement): void {
const optGroup = <HTMLOptGroupElement>option.parentElement;
if (!(optGroup instanceof HTMLOptGroupElement)) {
return;
}
if (optGroup.querySelectorAll('option:not([hidden]):not([disabled]):not(.hidden)').length === 0) {
optGroup.hidden = true;
} else {
optGroup.hidden = false;
optGroup.disabled = false;
optGroup.classList.remove('hidden');
}
}
constructor(selectElement: HTMLSelectElement) {
this.selectElement = selectElement;
......@@ -62,6 +76,7 @@ class SelectBoxFilter {
const matchFilter = new RegExp(filterText, 'i');
this.availableOptions.forEach((option: HTMLOptionElement): void => {
option.hidden = filterText.length > 0 && option.textContent.match(matchFilter) === null;
SelectBoxFilter.toggleOptGroup(option);
});
}
}
......
......@@ -87,8 +87,9 @@ declare namespace TYPO3 {
public openPopupWindow(mode: string, params: string): JQuery;
public initializeNullNoPlaceholderCheckboxes(): void;
public initializeNullWithPlaceholderCheckboxes(): void;
public requestFormEngineUpdate(askForUpdate: boolean): void
public processOnFieldChange(items: OnFieldChangeItem[]): void
public requestFormEngineUpdate(askForUpdate: boolean): void;
public processOnFieldChange(items: OnFieldChangeItem[]): void;
public enableOptGroup(option: HTMLOptionElement): void;
}
export class MultiStepWizard {
......
......@@ -168,22 +168,59 @@ class SelectMultipleSideBySideElement extends AbstractFormElement
}
}
$selectableItemCounter = 0;
$selectableItemGroupCounter = 0;
$selectableItemGroups = [];
$selectableItemsHtml = [];
// Initialize groups
foreach ($possibleItems as $possibleItem) {
$disabledAttr = '';
$classAttr = '';
$disableAttributes = [];
if (!$itemCanBeSelectedMoreThanOnce && in_array((string)$possibleItem[1], $selectedItems, true)) {
$disabledAttr = ' disabled="disabled"';
$classAttr = ' class="hidden"';
$disableAttributes = [
'disabled' => 'disabled',
'class' => 'hidden',
];
}
if ($possibleItem[1] === '--div--') {
if ($selectableItemCounter !== 0) {
$selectableItemGroupCounter++;
}
$selectableItemGroups[$selectableItemGroupCounter]['header']['title'] = $possibleItem[0];
} else {
$selectableItemGroups[$selectableItemGroupCounter]['items'][] = [
'label' => $this->appendValueToLabelInDebugMode($possibleItem[0], $possibleItem[1]),
'attributes' => array_merge(['title' => $possibleItem[0], 'value' => $possibleItem[1]], $disableAttributes),
];
// In case the item is not disabled, enable the group (if any)
if ($disableAttributes === [] && isset($selectableItemGroups[$selectableItemGroupCounter]['header'])) {
$selectableItemGroups[$selectableItemGroupCounter]['header']['disabled'] = false;
}
$selectableItemCounter++;
}
}
// Process groups
foreach ($selectableItemGroups as $selectableItemGroup) {
if (!is_array($selectableItemGroup['items'] ?? false) || $selectableItemGroup['items'] === []) {
continue;
}
$optionGroup = isset($selectableItemGroup['header']);
if ($optionGroup) {
$selectableItemsHtml[] = '<optgroup label="' . htmlspecialchars($selectableItemGroup['header']['title']) . '"' . (($selectableItemGroup['header']['disabled'] ?? true) ? 'class="hidden" disabled="disabled"' : '') . '>';
}
foreach ($selectableItemGroup['items'] as $item) {
$selectableItemsHtml[] = '
<option ' . GeneralUtility::implodeAttributes($item['attributes'], true) . '>
' . htmlspecialchars($item['label']) . '
</option>';
}
if ($optionGroup) {
$selectableItemsHtml[] = '</optgroup>';
}
$selectableItemsHtml[] =
'<option value="'
. htmlspecialchars($possibleItem[1])
. '" title="' . htmlspecialchars($possibleItem[0]) . '"'
. $classAttr . $disabledAttr
. '>'
. htmlspecialchars($this->appendValueToLabelInDebugMode($possibleItem[0], $possibleItem[1])) .
'</option>';
}
// Html stuff for filter and select filter on top of right side of multi select boxes
......
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&__createBinding(t,e,n);return __setModuleDefault(t,e),t},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","jquery","TYPO3/CMS/Backend/FormEngineValidation","TYPO3/CMS/Backend/DocumentSaveActions","TYPO3/CMS/Backend/Icons","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Utility/MessageUtility","TYPO3/CMS/Backend/Severity","TYPO3/CMS/Backend/BackendException","TYPO3/CMS/Backend/Event/InteractionRequestMap"],(function(e,t,n,a,o,i,r,l,c,s,d){"use strict";return n=__importDefault(n),l=__importStar(l),s=__importStar(s),function(){function t(e,t){t?f.interactionRequestMap.resolveFor(e):f.interactionRequestMap.rejectFor(e)}const u=new Map;u.set("typo3-backend-form-update-value",(e,t)=>{const n=document.querySelector('[name="'+CSS.escape(e.elementName)+'"]'),o=document.querySelector('[data-formengine-input-name="'+CSS.escape(e.elementName)+'"]');a.updateInputField(e.elementName),null!==n&&(a.markFieldAsChanged(n),a.validateField(n)),null!==o&&o!==n&&a.validateField(o)}),u.set("typo3-backend-form-reload",(e,t)=>{e.confirm?r.confirm(TYPO3.lang["FormEngine.refreshRequiredTitle"],TYPO3.lang["FormEngine.refreshRequiredContent"]).on("button.clicked",e=>{"ok"==e.target.name&&f.saveDocument(),r.dismiss()}):f.saveDocument()}),u.set("typo3-backend-form-update-bitmask",(e,t)=>{const n=t.target,a=document.editform[e.elementName],o=n.checked!==e.invert,i=Math.pow(2,e.position),r=Math.pow(2,e.total)-i-1;a.value=o?a.value|i:a.value&r,a.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))});const f={consumeTypes:["typo3.setUrl","typo3.beforeSetUrl","typo3.refresh"],Validation:a,interactionRequestMap:d,formName:TYPO3.settings.FormEngine.formName,openedPopupWindow:null,legacyFieldChangedCb:function(){!n.default.isFunction(TYPO3.settings.FormEngine.legacyFieldChangedCb)||TYPO3.settings.FormEngine.legacyFieldChangedCb()},browserUrl:"",openPopupWindow:function(e,t){return r.advanced({type:r.types.iframe,content:f.browserUrl+"&mode="+e+"&bparams="+t,size:r.sizes.large})},setSelectOptionFromExternalSource:function(e,t,o,i,r,l){r=String(r);let c,s,d=!1,u=!1;if(c=f.getFieldElement(e),s=c.get(0),null===s||"--div--"===t)return;const m=f.getFieldElement(e,"_list",!0);if(m.length>0&&(c=m,d=c.prop("multiple")&&"1"!=c.prop("size"),u=!0),d||u){const u=f.getFieldElement(e,"_avail");if(d||(c.find("option").each((e,t)=>{u.find('option[value="'+n.default.escapeSelector((0,n.default)(t).attr("value"))+'"]').removeClass("hidden").prop("disabled",!1)}),c.empty()),r){let e=!1,n=new RegExp("(^|,)"+t+"($|,)");r.match(n)?(c.empty(),e=!0):1==c.find("option").length&&(n=new RegExp("(^|,)"+c.find("option").prop("value")+"($|,)"),r.match(n)&&(c.empty(),e=!0)),e&&void 0!==l&&l.closest("select").querySelectorAll("[disabled]").forEach((function(e){e.classList.remove("hidden"),e.disabled=!1}))}let m=!0;const g=f.getFieldElement(e,"_mul",!0);if(0!=g.length&&0!=g.val()||(c.find("option").each((function(e,a){if((0,n.default)(a).prop("value")==t)return m=!1,!1})),m&&void 0!==l&&(l.classList.add("hidden"),l.disabled=!0)),m){const e=(0,n.default)("<option></option>");e.attr({value:t,title:i}).text(o),e.appendTo(c),f.updateHiddenFieldValueFromSelect(c,s),f.legacyFieldChangedCb(),a.markFieldAsChanged(s),f.Validation.validateField(c),f.Validation.validateField(u)}}else{const e=/_(\d+)$/,n=t.toString().match(e);null!=n&&(t=n[1]),c.val(t),f.Validation.validateField(c)}},updateHiddenFieldValueFromSelect:function(e,t){const a=[];(0,n.default)(e).find("option").each((e,t)=>{a.push((0,n.default)(t).prop("value"))}),t.value=a.join(","),t.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},getFormElement:function(e){const t=(0,n.default)('form[name="'+f.formName+'"]:first');if(!e)return t;{const n=f.getFieldElement(e),a=f.getFieldElement(e,"_list");if(n.length>0&&("select-one"===n.prop("type")||a.length>0&&a.prop("type").match(/select-(one|multiple)/)))return t;console.error("Form fields missing: form: "+f.formName+", field name: "+e),alert("Form field is invalid")}},getFieldElement:function(e,t,a){const o=(0,n.default)('form[name="'+f.formName+'"]:first');if(t){let i;switch(t){case"_list":i=(0,n.default)(':input[data-formengine-input-name="'+e+'"]:not([type=hidden])',o);break;case"_avail":i=(0,n.default)(':input[data-relatedfieldname="'+e+'"]',o);break;case"_mul":case"_hr":i=(0,n.default)(':input[type=hidden][data-formengine-input-name="'+e+'"]',o);break;default:i=null}if(i&&i.length>0||!0===a)return i}return(0,n.default)(':input[name="'+e+'"]',o)},initializeEvents:function(){top.TYPO3&&void 0!==top.TYPO3.Backend&&(top.TYPO3.Backend.consumerScope.attach(f),(0,n.default)(window).on("unload",(function(){top.TYPO3.Backend.consumerScope.detach(f)}))),(0,n.default)(document).on("click",".t3js-editform-close",e=>{e.preventDefault(),f.preventExitIfNotSaved(f.preventExitIfNotSavedCallback)}).on("click",".t3js-editform-view",e=>{e.preventDefault(),f.previewAction(e,f.previewActionCallback)}).on("click",".t3js-editform-new",e=>{e.preventDefault(),f.newAction(e,f.newActionCallback)}).on("click",".t3js-editform-duplicate",e=>{e.preventDefault(),f.duplicateAction(e,f.duplicateActionCallback)}).on("click",".t3js-editform-delete-record",e=>{e.preventDefault(),f.deleteAction(e,f.deleteActionCallback)}).on("click",".t3js-editform-submitButton",e=>{const t=(0,n.default)(e.currentTarget),a=t.data("name")||e.currentTarget.name,o=(0,n.default)("<input />").attr("type","hidden").attr("name",a).attr("value","1");t.parents("form").append(o)}).on("change",'.t3-form-field-eval-null-checkbox input[type="checkbox"]',e=>{(0,n.default)(e.currentTarget).closest(".t3js-formengine-field-item").toggleClass("disabled")}).on("change",'.t3js-form-field-eval-null-placeholder-checkbox input[type="checkbox"]',e=>{f.toggleCheckboxField((0,n.default)(e.currentTarget)),a.markFieldAsChanged((0,n.default)(e.currentTarget))}).on("change",(function(e){(0,n.default)(".module-docheader-bar .btn").removeClass("disabled").prop("disabled",!1)})).on("click",".t3js-element-browser",(function(e){e.preventDefault(),e.stopPropagation();const t=(0,n.default)(e.currentTarget),a=t.data("mode"),o=t.data("params");f.openPopupWindow(a,o)})).on("click",'[data-formengine-field-change-event="click"]',e=>{const t=JSON.parse(e.currentTarget.dataset.formengineFieldChangeItems);f.processOnFieldChange(t,e)}).on("change",'[data-formengine-field-change-event="change"]',e=>{const t=JSON.parse(e.currentTarget.dataset.formengineFieldChangeItems);f.processOnFieldChange(t,e)}),document.editform.addEventListener("submit",(function(){if(document.editform.closeDoc.value)return;const e=["button[form]",'button[name^="_save"]','a[data-name^="_save"]','button[name="CMD"][value^="save"]','a[data-name="CMD"][data-value^="save"]'].join(","),t=document.querySelector(e);null!==t&&(t.disabled=!0,i.getIcon("spinner-circle-dark",i.sizes.small).then((function(e){t.querySelector(".t3js-icon").outerHTML=e})))})),window.addEventListener("message",f.handlePostMessage)},consume:function(e){if(!e)throw new s.BackendException("No interaction request given",1496589980);const a=n.default.Deferred();if(e.concernsTypes(f.consumeTypes)){const n=e.outerMostRequest;f.interactionRequestMap.attachFor(n,a),n.isProcessed()?t(n,n.getProcessedData().response):f.hasChange()?f.preventExitIfNotSaved((function(e){n.setProcessedData({response:e}),t(n,e)})):f.interactionRequestMap.resolveFor(n)}return a},handlePostMessage:function(e){if(!l.MessageUtility.verifyOrigin(e.origin))throw"Denied message sent by "+e.origin;if("typo3:elementBrowser:elementAdded"===e.data.actionName){if(void 0===e.data.fieldName)throw"fieldName not defined in message";if(void 0===e.data.value)throw"value not defined in message";const t=e.data.label||e.data.value,n=e.data.title||t,a=e.data.exclusiveValues||"";f.setSelectOptionFromExternalSource(e.data.fieldName,e.data.value,t,n,a)}},initializeRemainingCharacterViews:function(){const e=(0,n.default)("[maxlength]").not(".t3js-datetimepicker").not(".t3js-charcounter-initialized");e.on("focus",e=>{const t=(0,n.default)(e.currentTarget),a=t.parents(".t3js-formengine-field-item:first"),o=f.getCharacterCounterProperties(t);a.append((0,n.default)("<div />",{class:"t3js-charcounter"}).append((0,n.default)("<span />",{class:o.labelClass}).text(TYPO3.lang["FormEngine.remainingCharacters"].replace("{0}",o.remainingCharacters))))}).on("blur",e=>{(0,n.default)(e.currentTarget).parents(".t3js-formengine-field-item:first").find(".t3js-charcounter").remove()}).on("keyup",e=>{const t=(0,n.default)(e.currentTarget),a=t.parents(".t3js-formengine-field-item:first"),o=f.getCharacterCounterProperties(t);a.find(".t3js-charcounter span").removeClass().addClass(o.labelClass).text(TYPO3.lang["FormEngine.remainingCharacters"].replace("{0}",o.remainingCharacters))}),e.addClass("t3js-charcounter-initialized"),(0,n.default)(":password").on("focus",(function(e){(0,n.default)(e.currentTarget).attr({type:"text","data-active-password":"true"}).trigger("select")})).on("blur",(function(e){(0,n.default)(e.currentTarget).attr("type","password").removeAttr("data-active-password")}))},getCharacterCounterProperties:function(e){const t=e.val(),n=e.attr("maxlength")-t.length-(t.match(/\n/g)||[]).length;let a="";return a=n<15?"label-danger":n<30?"label-warning":"label-info",{remainingCharacters:n,labelClass:"label "+a}},initializeNullNoPlaceholderCheckboxes:function(){(0,n.default)(".t3-form-field-eval-null-checkbox").each((function(e,t){const a=(0,n.default)(t),o=a.find('input[type="checkbox"]'),i=a.closest(".t3js-formengine-field-item");o.attr("checked")||i.addClass("disabled")}))},initializeNullWithPlaceholderCheckboxes:function(){(0,n.default)(".t3js-form-field-eval-null-placeholder-checkbox").each((e,t)=>{f.toggleCheckboxField((0,n.default)(t).find('input[type="checkbox"]'))})},toggleCheckboxField:function(e){const t=e.closest(".t3js-formengine-field-item");e.prop("checked")?(t.find(".t3js-formengine-placeholder-placeholder").hide(),t.find(".t3js-formengine-placeholder-formfield").show(),t.find(".t3js-formengine-placeholder-formfield").find(":input").trigger("focus")):(t.find(".t3js-formengine-placeholder-placeholder").show(),t.find(".t3js-formengine-placeholder-formfield").hide())},reinitialize:function(){const t=Array.from(document.querySelectorAll(".t3js-clearable")).filter(e=>!e.classList.contains("t3js-color-picker"));t.length>0&&e(["TYPO3/CMS/Backend/Input/Clearable"],(function(){t.forEach(e=>e.clearable())})),f.initializeNullNoPlaceholderCheckboxes(),f.initializeNullWithPlaceholderCheckboxes(),f.initializeLocalizationStateSelector(),f.initializeRemainingCharacterViews()},initializeLocalizationStateSelector:function(){(0,n.default)(".t3js-l10n-state-container").each((e,t)=>{const a=(0,n.default)(t),o=a.closest(".t3js-formengine-field-item").find("[data-formengine-input-name]"),i=a.find('input[type="radio"]:checked').val();"parent"!==i&&"source"!==i||o.attr("disabled","disabled")})},hasChange:function(){const e=(0,n.default)('form[name="'+f.formName+'"] .has-change').length>0,t=(0,n.default)('[name^="data["].has-change').length>0;return e||t},preventExitIfNotSavedCallback:function(e){f.closeDocument()},preventFollowLinkIfNotSaved:function(e){return f.preventExitIfNotSaved((function(){window.location.href=e})),!1},preventExitIfNotSaved:function(e){if(e=e||f.preventExitIfNotSavedCallback,f.hasChange()){const t=TYPO3.lang["label.confirm.close_without_save.title"]||"Do you want to close without saving?",a=TYPO3.lang["label.confirm.close_without_save.content"]||"You currently have unsaved changes. Are you sure you want to discard these changes?",o=(0,n.default)("<input />").attr("type","hidden").attr("name","_saveandclosedok").attr("value","1"),i=[{text:TYPO3.lang["buttons.confirm.close_without_save.no"]||"No, I will continue editing",btnClass:"btn-default",name:"no"},{text:TYPO3.lang["buttons.confirm.close_without_save.yes"]||"Yes, discard my changes",btnClass:"btn-default",name:"yes"}];0===(0,n.default)(".has-error").length&&i.push({text:TYPO3.lang["buttons.confirm.save_and_close"]||"Save and close",btnClass:"btn-warning",name:"save",active:!0});r.confirm(t,a,c.warning,i).on("button.clicked",(function(t){"no"===t.target.name?r.dismiss():"yes"===t.target.name?(r.dismiss(),e.call(null,!0)):"save"===t.target.name&&((0,n.default)("form[name="+f.formName+"]").append(o),r.dismiss(),f.saveDocument())}))}else e.call(null,!0)},preventSaveIfHasErrors:function(){if((0,n.default)(".has-error").length>0){const e=TYPO3.lang["label.alert.save_with_error.title"]||"You have errors in your form!",t=TYPO3.lang["label.alert.save_with_error.content"]||"Please check the form, there is at least one error in your form.";return r.confirm(e,t,c.error,[{text:TYPO3.lang["buttons.alert.save_with_error.ok"]||"OK",btnClass:"btn-danger",name:"ok"}]).on("button.clicked",(function(e){"ok"===e.target.name&&r.dismiss()})),!1}return!0},requestFormEngineUpdate:function(e){if(e){r.confirm(TYPO3.lang["FormEngine.refreshRequiredTitle"],TYPO3.lang["FormEngine.refreshRequiredContent"]).on("button.clicked",(function(e){"ok"===e.target.name?(f.closeModalsRecursive(),f.saveDocument()):r.dismiss()}))}else f.saveDocument()},processOnFieldChange:function(e,t){e.forEach(e=>{const n=u.get(e.name);n instanceof Function&&n.call(null,e.data||null,t)})},registerOnFieldChangeHandler:function(e,t){u.has(e)&&console.warn("Handler for onFieldChange name `"+e+"` has been overridden."),u.set(e,t)},closeModalsRecursive:function(){void 0!==r.currentModal&&null!==r.currentModal&&(r.currentModal.on("hidden.bs.modal",(function(){f.closeModalsRecursive(r.currentModal)})),r.currentModal.trigger("modal-dismiss"))},previewAction:function(e,t){t=t||f.previewActionCallback;const a=e.target.href,o=e.target.dataset.hasOwnProperty("isNew"),i=(0,n.default)("<input />").attr("type","hidden").attr("name","_savedokview").attr("value","1");f.hasChange()?f.showPreviewModal(a,o,i,t):((0,n.default)("form[name="+f.formName+"]").append(i),window.open("","newTYPO3frontendWindow"),document.editform.submit())},previewActionCallback:function(e,t,a){switch(r.dismiss(),e){case"discard":const e=window.open(t,"newTYPO3frontendWindow");e.focus(),e.location.href===t&&e.location.reload();break;case"save":(0,n.default)("form[name="+f.formName+"]").append(a),window.open("","newTYPO3frontendWindow"),f.saveDocument()}},showPreviewModal:function(e,t,n,a){const o=TYPO3.lang["label.confirm.view_record_changed.title"]||"Do you want to save before viewing?",i={text:TYPO3.lang["buttons.confirm.view_record_changed.cancel"]||"Cancel",btnClass:"btn-default",name:"cancel"},l={text:TYPO3.lang["buttons.confirm.view_record_changed.no-save"]||"View without changes",btnClass:"btn-info",name:"discard"},s={text:TYPO3.lang["buttons.confirm.view_record_changed.save"]||"Save changes and view",btnClass:"btn-info",name:"save",active:!0};let d=[],u="";t?(d=[i,s],u=TYPO3.lang["label.confirm.view_record_changed.content.is-new-page"]||"You need to save your changes before viewing the page. Do you want to save and view them now?"):(d=[i,l,s],u=TYPO3.lang["label.confirm.view_record_changed.content"]||"You currently have unsaved changes. You can either discard these changes or save and view them.");const f=r.confirm(o,u,c.info,d);f.on("button.clicked",(function(t){a(t.target.name,e,n,f)}))},newAction:function(e,t){t=t||f.newActionCallback;const a=(0,n.default)("<input />").attr("type","hidden").attr("name","_savedoknew").attr("value","1"),o=e.target.dataset.hasOwnProperty("isNew");f.hasChange()?f.showNewModal(o,a,t):((0,n.default)("form[name="+f.formName+"]").append(a),document.editform.submit())},newActionCallback:function(e,t){const a=(0,n.default)("form[name="+f.formName+"]");switch(r.dismiss(),e){case"no":a.append(t),document.editform.submit();break;case"yes":a.append(t),f.saveDocument()}},showNewModal:function(e,t,n){const a=TYPO3.lang["label.confirm.new_record_changed.title"]||"Do you want to save before adding?",o=TYPO3.lang["label.confirm.new_record_changed.content"]||"You need to save your changes before creating a new record. Do you want to save and create now?";let i=[];const l={text:TYPO3.lang["buttons.confirm.new_record_changed.cancel"]||"Cancel",btnClass:"btn-default",name:"cancel"},s={text:TYPO3.lang["buttons.confirm.new_record_changed.no"]||"No, just add",btnClass:"btn-default",name:"no"},d={text:TYPO3.lang["buttons.confirm.new_record_changed.yes"]||"Yes, save and create now",btnClass:"btn-info",name:"yes",active:!0};i=e?[l,d]:[l,s,d];r.confirm(a,o,c.info,i).on("button.clicked",(function(e){n(e.target.name,t)}))},duplicateAction:function(e,t){t=t||f.duplicateActionCallback;const a=(0,n.default)("<input />").attr("type","hidden").attr("name","_duplicatedoc").attr("value","1"),o=e.target.dataset.hasOwnProperty("isNew");f.hasChange()?f.showDuplicateModal(o,a,t):((0,n.default)("form[name="+f.formName+"]").append(a),document.editform.submit())},duplicateActionCallback:function(e,t){const a=(0,n.default)("form[name="+f.formName+"]");switch(r.dismiss(),e){case"no":a.append(t),document.editform.submit();break;case"yes":a.append(t),f.saveDocument()}},showDuplicateModal:function(e,t,n){const a=TYPO3.lang["label.confirm.duplicate_record_changed.title"]||"Do you want to save before duplicating this record?",o=TYPO3.lang["label.confirm.duplicate_record_changed.content"]||"You currently have unsaved changes. Do you want to save your changes before duplicating this record?";let i=[];const l={text:TYPO3.lang["buttons.confirm.duplicate_record_changed.cancel"]||"Cancel",btnClass:"btn-default",name:"cancel"},s={text:TYPO3.lang["buttons.confirm.duplicate_record_changed.no"]||"No, just duplicate the original",btnClass:"btn-default",name:"no"},d={text:TYPO3.lang["buttons.confirm.duplicate_record_changed.yes"]||"Yes, save and duplicate this record",btnClass:"btn-info",name:"yes",active:!0};i=e?[l,d]:[l,s,d];r.confirm(a,o,c.info,i).on("button.clicked",(function(e){n(e.target.name,t)}))},deleteAction:function(e,t){t=t||f.deleteActionCallback;const a=(0,n.default)(e.target);f.showDeleteModal(a,t)},deleteActionCallback:function(e,t){r.dismiss(),"yes"===e&&f.invokeRecordDeletion(t)},showDeleteModal:function(e,t){const n=TYPO3.lang["label.confirm.delete_record.title"]||"Delete this record?";let a=TYPO3.lang["label.confirm.delete_record.content"]||"Are you sure you want to delete this record?";e.data("reference-count-message")&&(a+=" "+e.data("reference-count-message")),e.data("translation-count-message")&&(a+=" "+e.data("translation-count-message"));r.confirm(n,a,c.warning,[{text:TYPO3.lang["buttons.confirm.delete_record.no"]||"Cancel",btnClass:"btn-default",name:"no"},{text:TYPO3.lang["buttons.confirm.delete_record.yes"]||"Yes, delete this record",btnClass:"btn-warning",name:"yes",active:!0}]).on("button.clicked",(function(n){t(n.target.name,e)}))},closeDocument:function(){document.editform.closeDoc.value=1,f.dispatchSubmitEvent(),document.editform.submit()},saveDocument:function(){document.editform.doSave.value=1,f.dispatchSubmitEvent(),document.editform.submit()},dispatchSubmitEvent:function(){const e=document.createEvent("Event");e.initEvent("submit",!1,!0),document.editform.dispatchEvent(e)},initialize:function(e,t){o.getInstance().addPreSubmitCallback((function(){(0,n.default)('[data-active-password]:not([type="password"])').each((function(e,t){t.setAttribute("type","password"),t.blur()}))})),f.browserUrl=e,f.Validation.setUsMode(t),(0,n.default)((function(){f.initializeEvents(),f.Validation.initialize(),f.reinitialize(),(0,n.default)("#t3js-ui-block").remove()}))},invokeRecordDeletion:function(e){window.location.href=e.attr("href")}};return void 0!==TYPO3.settings.RequireJS&&void 0!==TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/FormEngine"]&&n.default.each(TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/FormEngine"],(function(t,n){e([n])})),TYPO3.FormEngine=f,f}()}));
\ No newline at end of file
var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n),Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&__createBinding(t,e,n);return __setModuleDefault(t,e),t},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","jquery","TYPO3/CMS/Backend/FormEngineValidation","TYPO3/CMS/Backend/DocumentSaveActions","TYPO3/CMS/Backend/Icons","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Utility/MessageUtility","TYPO3/CMS/Backend/Severity","TYPO3/CMS/Backend/BackendException","TYPO3/CMS/Backend/Event/InteractionRequestMap"],(function(e,t,n,a,o,i,r,l,c,d,s){"use strict";return n=__importDefault(n),l=__importStar(l),d=__importStar(d),function(){function t(e,t){t?f.interactionRequestMap.resolveFor(e):f.interactionRequestMap.rejectFor(e)}const u=new Map;u.set("typo3-backend-form-update-value",(e,t)=>{const n=document.querySelector('[name="'+CSS.escape(e.elementName)+'"]'),o=document.querySelector('[data-formengine-input-name="'+CSS.escape(e.elementName)+'"]');a.updateInputField(e.elementName),null!==n&&(a.markFieldAsChanged(n),a.validateField(n)),null!==o&&o!==n&&a.validateField(o)}),u.set("typo3-backend-form-reload",(e,t)=>{e.confirm?r.confirm(TYPO3.lang["FormEngine.refreshRequiredTitle"],TYPO3.lang["FormEngine.refreshRequiredContent"]).on("button.clicked",e=>{"ok"==e.target.name&&f.saveDocument(),r.dismiss()}):f.saveDocument()}),u.set("typo3-backend-form-update-bitmask",(e,t)=>{const n=t.target,a=document.editform[e.elementName],o=n.checked!==e.invert,i=Math.pow(2,e.position),r=Math.pow(2,e.total)-i-1;a.value=o?a.value|i:a.value&r,a.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))});const f={consumeTypes:["typo3.setUrl","typo3.beforeSetUrl","typo3.refresh"],Validation:a,interactionRequestMap:s,formName:TYPO3.settings.FormEngine.formName,openedPopupWindow:null,legacyFieldChangedCb:function(){!n.default.isFunction(TYPO3.settings.FormEngine.legacyFieldChangedCb)||TYPO3.settings.FormEngine.legacyFieldChangedCb()},browserUrl:"",openPopupWindow:function(e,t){return r.advanced({type:r.types.iframe,content:f.browserUrl+"&mode="+e+"&bparams="+t,size:r.sizes.large})},setSelectOptionFromExternalSource:function(e,t,o,i,r,l){r=String(r);let c,d,s=!1,u=!1;if(c=f.getFieldElement(e),d=c.get(0),null===d||"--div--"===t||d instanceof HTMLOptGroupElement)return;const m=f.getFieldElement(e,"_list",!0);if(m.length>0&&(c=m,s=c.prop("multiple")&&"1"!=c.prop("size"),u=!0),s||u){const u=f.getFieldElement(e,"_avail");if(s||(c.find("option").each((e,t)=>{const a=u.find('option[value="'+n.default.escapeSelector((0,n.default)(t).attr("value"))+'"]');a&&(a.removeClass("hidden").prop("disabled",!1),f.enableOptGroup(a.get(0)))}),c.empty()),r){let e=!1,n=new RegExp("(^|,)"+t+"($|,)");r.match(n)?(c.empty(),e=!0):1==c.find("option").length&&(n=new RegExp("(^|,)"+c.find("option").prop("value")+"($|,)"),r.match(n)&&(c.empty(),e=!0)),e&&void 0!==l&&l.closest("select").querySelectorAll("[disabled]").forEach((function(e){e.classList.remove("hidden"),e.disabled=!1,f.enableOptGroup(e)}))}let m=!0;const p=f.getFieldElement(e,"_mul",!0);if((0==p.length||0==p.val())&&(c.find("option").each((function(e,a){if((0,n.default)(a).prop("value")==t)return m=!1,!1})),m&&void 0!==l)){l.classList.add("hidden"),l.disabled=!0;const e=l.parentElement;e instanceof HTMLOptGroupElement&&0===e.querySelectorAll("option:not([disabled]):not([hidden]):not(.hidden)").length&&(e.disabled=!0,e.classList.add("hidden"))}if(m){const e=(0,n.default)("<option></option>");e.attr({value:t,title:i}).text(o),e.appendTo(c),f.updateHiddenFieldValueFromSelect(c,d),f.legacyFieldChangedCb(),a.markFieldAsChanged(d),f.Validation.validateField(c),f.Validation.validateField(u)}}else{const e=/_(\d+)$/,n=t.toString().match(e);null!=n&&(t=n[1]),c.val(t),f.Validation.validateField(c)}},updateHiddenFieldValueFromSelect:function(e,t){const a=[];(0,n.default)(e).find("option").each((e,t)=>{a.push((0,n.default)(t).prop("value"))}),t.value=a.join(","),t.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},getFormElement:function(e){const t=(0,n.default)('form[name="'+f.formName+'"]:first');if(!e)return t;{const n=f.getFieldElement(e),a=f.getFieldElement(e,"_list");if(n.length>0&&("select-one"===n.prop("type")||a.length>0&&a.prop("type").match(/select-(one|multiple)/)))return t;console.error("Form fields missing: form: "+f.formName+", field name: "+e),alert("Form field is invalid")}},getFieldElement:function(e,t,a){const o=(0,n.default)('form[name="'+f.formName+'"]:first');if(t){let i;switch(t){case"_list":i=(0,n.default)(':input[data-formengine-input-name="'+e+'"]:not([type=hidden])',o);break;case"_avail":i=(0,n.default)(':input[data-relatedfieldname="'+e+'"]',o);break;case"_mul":case"_hr":i=(0,n.default)(':input[type=hidden][data-formengine-input-name="'+e+'"]',o);break;default:i=null}if(i&&i.length>0||!0===a)return i}return(0,n.default)(':input[name="'+e+'"]',o)},initializeEvents:function(){top.TYPO3&&void 0!==top.TYPO3.Backend&&(top.TYPO3.Backend.consumerScope.attach(f),(0,n.default)(window).on("unload",(function(){top.TYPO3.Backend.consumerScope.detach(f)}))),(0,n.default)(document).on("click",".t3js-editform-close",e=>{e.preventDefault(),f.preventExitIfNotSaved(f.preventExitIfNotSavedCallback)}).on("click",".t3js-editform-view",e=>{e.preventDefault(),f.previewAction(e,f.previewActionCallback)}).on("click",".t3js-editform-new",e=>{e.preventDefault(),f.newAction(e,f.newActionCallback)}).on("click",".t3js-editform-duplicate",e=>{e.preventDefault(),f.duplicateAction(e,f.duplicateActionCallback)}).on("click",".t3js-editform-delete-record",e=>{e.preventDefault(),f.deleteAction(e,f.deleteActionCallback)}).on("click",".t3js-editform-submitButton",e=>{const t=(0,n.default)(e.currentTarget),a=t.data("name")||e.currentTarget.name,o=(0,n.default)("<input />").attr("type","hidden").attr("name",a).attr("value","1");t.parents("form").append(o)}).on("change",'.t3-form-field-eval-null-checkbox input[type="checkbox"]',e=>{(0,n.default)(e.currentTarget).closest(".t3js-formengine-field-item").toggleClass("disabled")}).on("change",'.t3js-form-field-eval-null-placeholder-checkbox input[type="checkbox"]',e=>{f.toggleCheckboxField((0,n.default)(e.currentTarget)),a.markFieldAsChanged((0,n.default)(e.currentTarget))}).on("change",(function(e){(0,n.default)(".module-docheader-bar .btn").removeClass("disabled").prop("disabled",!1)})).on("click",".t3js-element-browser",(function(e){e.preventDefault(),e.stopPropagation();const t=(0,n.default)(e.currentTarget),a=t.data("mode"),o=t.data("params");f.openPopupWindow(a,o)})).on("click",'[data-formengine-field-change-event="click"]',e=>{const t=JSON.parse(e.currentTarget.dataset.formengineFieldChangeItems);f.processOnFieldChange(t,e)}).on("change",'[data-formengine-field-change-event="change"]',e=>{const t=JSON.parse(e.currentTarget.dataset.formengineFieldChangeItems);f.processOnFieldChange(t,e)}),document.editform.addEventListener("submit",(function(){if(document.editform.closeDoc.value)return;const e=["button[form]",'button[name^="_save"]','a[data-name^="_save"]','button[name="CMD"][value^="save"]','a[data-name="CMD"][data-value^="save"]'].join(","),t=document.querySelector(e);null!==t&&(t.disabled=!0,i.getIcon("spinner-circle-dark",i.sizes.small).then((function(e){t.querySelector(".t3js-icon").outerHTML=e})))})),window.addEventListener("message",f.handlePostMessage)},consume:function(e){if(!e)throw new d.BackendException("No interaction request given",1496589980);const a=n.default.Deferred();if(e.concernsTypes(f.consumeTypes)){const n=e.outerMostRequest;f.interactionRequestMap.attachFor(n,a),n.isProcessed()?t(n,n.getProcessedData().response):f.hasChange()?f.preventExitIfNotSaved((function(e){n.setProcessedData({response:e}),t(n,e)})):f.interactionRequestMap.resolveFor(n)}return a},handlePostMessage:function(e){if(!l.MessageUtility.verifyOrigin(e.origin))throw"Denied message sent by "+e.origin;if("typo3:elementBrowser:elementAdded"===e.data.actionName){if(void 0===e.data.fieldName)throw"fieldName not defined in message";if(void 0===e.data.value)throw"value not defined in message";const t=e.data.label||e.data.value,n=e.data.title||t,a=e.data.exclusiveValues||"";f.setSelectOptionFromExternalSource(e.data.fieldName,e.data.value,t,n,a)}},initializeRemainingCharacterViews:function(){const e=(0,n.default)("[maxlength]").not(".t3js-datetimepicker").not(".t3js-charcounter-initialized");e.on("focus",e=>{const t=(0,n.default)(e.currentTarget),a=t.parents(".t3js-formengine-field-item:first"),o=f.getCharacterCounterProperties(t);a.append((0,n.default)("<div />",{class:"t3js-charcounter"}).append((0,n.default)("<span />",{class:o.labelClass}).text(TYPO3.lang["FormEngine.remainingCharacters"].replace("{0}",o.remainingCharacters))))}).on("blur",e=>{(0,n.default)(e.currentTarget).parents(".t3js-formengine-field-item:first").find(".t3js-charcounter").remove()}).on("keyup",e=>{const t=(0,n.default)(e.currentTarget),a=t.parents(".t3js-formengine-field-item:first"),o=f.getCharacterCounterProperties(t);a.find(".t3js-charcounter span").removeClass().addClass(o.labelClass).text(TYPO3.lang["FormEngine.remainingCharacters"].replace("{0}",o.remainingCharacters))}),e.addClass("t3js-charcounter-initialized"),(0,n.default)(":password").on("focus",(function(e){(0,n.default)(e.currentTarget).attr({type:"text","data-active-password":"true"}).trigger("select")})).on("blur",(function(e){(0,n.default)(e.currentTarget).attr("type","password").removeAttr("data-active-password")}))},getCharacterCounterProperties:function(e){const t=e.val(),n=e.attr("maxlength")-t.length-(t.match(/\n/g)||[]).length;let a="";return a=n<15?"label-danger":n<30?"label-warning":"label-info",{remainingCharacters:n,labelClass:"label "+a}},initializeNullNoPlaceholderCheckboxes:function(){(0,n.default)(".t3-form-field-eval-null-checkbox").each((function(e,t){const a=(0,n.default)(t),o=a.find('input[type="checkbox"]'),i=a.closest(".t3js-formengine-field-item");o.attr("checked")||i.addClass("disabled")}))},initializeNullWithPlaceholderCheckboxes:function(){(0,n.default)(".t3js-form-field-eval-null-placeholder-checkbox").each((e,t)=>{f.toggleCheckboxField((0,n.default)(t).find('input[type="checkbox"]'))})},toggleCheckboxField:function(e){const t=e.closest(".t3js-formengine-field-item");e.prop("checked")?(t.find(".t3js-formengine-placeholder-placeholder").hide(),t.find(".t3js-formengine-placeholder-formfield").show(),t.find(".t3js-formengine-placeholder-formfield").find(":input").trigger("focus")):(t.find(".t3js-formengine-placeholder-placeholder").show(),t.find(".t3js-formengine-placeholder-formfield").hide())},reinitialize:function(){const t=Array.from(document.querySelectorAll(".t3js-clearable")).filter(e=>!e.classList.contains("t3js-color-picker"));t.length>0&&e(["TYPO3/CMS/Backend/Input/Clearable"],(function(){t.forEach(e=>e.clearable())})),f.initializeNullNoPlaceholderCheckboxes(),f.initializeNullWithPlaceholderCheckboxes(),f.initializeLocalizationStateSelector(),f.initializeRemainingCharacterViews()},initializeLocalizationStateSelector:function(){(0,n.default)(".t3js-l10n-state-container").each((e,t)=>{const a=(0,n.default)(t),o=a.closest(".t3js-formengine-field-item").find("[data-formengine-input-name]"),i=a.find('input[type="radio"]:checked').val();"parent"!==i&&"source"!==i||o.attr("disabled","disabled")})},hasChange:function(){const e=(0,n.default)('form[name="'+f.formName+'"] .has-change').length>0,t=(0,n.default)('[name^="data["].has-change').length>0;return e||t},preventExitIfNotSavedCallback:function(e){f.closeDocument()},preventFollowLinkIfNotSaved:function(e){return f.preventExitIfNotSaved((function(){window.location.href=e})),!1},preventExitIfNotSaved:function(e){if(e=e||f.preventExitIfNotSavedCallback,f.hasChange()){const t=TYPO3.lang["label.confirm.close_without_save.title"]||"Do you want to close without saving?",a=TYPO3.lang["label.confirm.close_without_save.content"]||"You currently have unsaved changes. Are you sure you want to discard these changes?",o=(0,n.default)("<input />").attr("type","hidden").attr("name","_saveandclosedok").attr("value","1"),i=[{text:TYPO3.lang["buttons.confirm.close_without_save.no"]||"No, I will continue editing",btnClass:"btn-default",name:"no"},{text:TYPO3.lang["buttons.confirm.close_without_save.yes"]||"Yes, discard my changes",btnClass:"btn-default",name:"yes"}];0===(0,n.default)(".has-error").length&&i.push({text:TYPO3.lang["buttons.confirm.save_and_close"]||"Save and close",btnClass:"btn-warning",name:"save",active:!0});r.confirm(t,a,c.warning,i).on("button.clicked",(function(t){"no"===t.target.name?r.dismiss():"yes"===t.target.name?(r.dismiss(),e.call(null,!0)):"save"===t.target.name&&((0,n.default)("form[name="+f.formName+"]").append(o),r.dismiss(),f.saveDocument())}))}else e.call(null,!0)},preventSaveIfHasErrors:function(){if((0,n.default)(".has-error").length>0){const e=TYPO3.lang["label.alert.save_with_error.title"]||"You have errors in your form!",t=TYPO3.lang["label.alert.save_with_error.content"]||"Please check the form, there is at least one error in your form.";return r.confirm(e,t,c.error,[{text:TYPO3.lang["buttons.alert.save_with_error.ok"]||"OK",btnClass:"btn-danger",name:"ok"}]).on("button.clicked",(function(e){"ok"===e.target.name&&r.dismiss()})),!1}return!0},requestFormEngineUpdate:function(e){if(e){r.confirm(TYPO3.lang["FormEngine.refreshRequiredTitle"],TYPO3.lang["FormEngine.refreshRequiredContent"]).on("button.clicked",(function(e){"ok"===e.target.name?(f.closeModalsRecursive(),f.saveDocument()):r.dismiss()}))}else f.saveDocument()},processOnFieldChange:function(e,t){e.forEach(e=>{const n=u.get(e.name);n instanceof Function&&n.call(null,e.data||null,t)})},registerOnFieldChangeHandler:function(e,t){u.has(e)&&console.warn("Handler for onFieldChange name `"+e+"` has been overridden."),u.set(e,t)},closeModalsRecursive:function(){void 0!==r.currentModal&&null!==r.currentModal&&(r.currentModal.on("hidden.bs.modal",(function(){f.closeModalsRecursive(r.currentModal)})),r.currentModal.trigger("modal-dismiss"))},previewAction:function(e,t){t=t||f.previewActionCallback;const a=e.target.href,o=e.target.dataset.hasOwnProperty("isNew"),i=(0,n.default)("<input />").attr("type","hidden").attr("name","_savedokview").attr("value","1");f.hasChange()?f.showPreviewModal(a,o,i,t):((0,n.default)("form[name="+f.formName+"]").append(i),window.open("","newTYPO3frontendWindow"),document.editform.submit())},previewActionCallback:function(e,t,a){switch(r.dismiss(),e){case"discard":const e=window.open(t,"newTYPO3frontendWindow");e.focus(),e.location.href===t&&e.location.reload();break;case"save":(0,n.default)("form[name="+f.formName+"]").append(a),window.open("","newTYPO3frontendWindow"),f.saveDocument()}},showPreviewModal:function(e,t,n,a){const o=TYPO3.lang["label.confirm.view_record_changed.title"]||"Do you want to save before viewing?",i={text:TYPO3.lang["buttons.confirm.view_record_changed.cancel"]||"Cancel",btnClass:"btn-default",name:"cancel"},l={text:TYPO3.lang["buttons.confirm.view_record_changed.no-save"]||"View without changes",btnClass:"btn-info",name:"discard"},d={text:TYPO3.lang["buttons.confirm.view_record_changed.save"]||"Save changes and view",btnClass:"btn-info",name:"save",active:!0};let s=[],u="";t?(s=[i,d],u=TYPO3.lang["label.confirm.view_record_changed.content.is-new-page"]||"You need to save your changes before viewing the page. Do you want to save and view them now?"):(s=[i,l,d],u=TYPO3.lang["label.confirm.view_record_changed.content"]||"You currently have unsaved changes. You can either discard these changes or save and view them.");const f=r.confirm(o,u,c.info,s);f.on("button.clicked",(function(t){a(t.target.name,e,n,f)}))},newAction:function(e,t){t=t||f.newActionCallback;const a=(0,n.default)("<input />").attr("type","hidden").attr("name","_savedoknew").attr("value","1"),o=e.target.dataset.hasOwnProperty("isNew");f.hasChange()?f.showNewModal(o,a,t):((0,n.default)("form[name="+f.formName+"]").append(a),document.editform.submit())},newActionCallback:function(e,t){const a=(0,n.default)("form[name="+f.formName+"]");switch(r.dismiss(),e){case"no":a.append(t),document.editform.submit();break;case"yes":a.append(t),f.saveDocument()}},showNewModal:function(e,t,n){const a=TYPO3.lang["label.confirm.new_record_changed.title"]||"Do you want to save before adding?",o=TYPO3.lang["label.confirm.new_record_changed.content"]||"You need to save your changes before creating a new record. Do you want to save and create now?";let i=[];const l={text:TYPO3.lang["buttons.confirm.new_record_changed.cancel"]||"Cancel",btnClass:"btn-default",name:"cancel"},d={text:TYPO3.lang["buttons.confirm.new_record_changed.no"]||"No, just add",btnClass:"btn-default",name:"no"},s={text:TYPO3.lang["buttons.confirm.new_record_changed.yes"]||"Yes, save and create now",btnClass:"btn-info",name:"yes",active:!0};i=e?[l,s]:[l,d,s];r.confirm(a,o,c.info,i).on("button.clicked",(function(e){n(e.target.name,t)}))},duplicateAction:function(e,t){t=t||f.duplicateActionCallback;const a=(0,n.default)("<input />").attr("type","hidden").attr("name","_duplicatedoc").attr("value","1"),o=e.target.dataset.hasOwnProperty("isNew");f.hasChange()?f.showDuplicateModal(o,a,t):((0,n.default)("form[name="+f.formName+"]").append(a),document.editform.submit())},duplicateActionCallback:function(e,t){const a=(0,n.default)("form[name="+f.formName+"]");switch(r.dismiss(),e){case"no":a.append(t),document.editform.submit();break;case"yes":a.append(t),f.saveDocument()}},showDuplicateModal:function(e,t,n){const a=TYPO3.lang["label.confirm.duplicate_record_changed.title"]||"Do you want to save before duplicating this record?",o=TYPO3.lang["label.confirm.duplicate_record_changed.content"]||"You currently have unsaved changes. Do you want to save your changes before duplicating this record?";let i=[];const l={text:TYPO3.lang["buttons.confirm.duplicate_record_changed.cancel"]||"Cancel",btnClass:"btn-default",name:"cancel"},d={text:TYPO3.lang["buttons.confirm.duplicate_record_changed.no"]||"No, just duplicate the original",btnClass:"btn-default",name:"no"},s={text:TYPO3.lang["buttons.confirm.duplicate_record_changed.yes"]||"Yes, save and duplicate this record",btnClass:"btn-info",name:"yes",active:!0};i=e?[l,s]:[l,d,s];r.confirm(a,o,c.info,i).on("button.clicked",(function(e){n(e.target.name,t)}))},deleteAction:function(e,t){t=t||f.deleteActionCallback;const a=(0,n.default)(e.target);f.showDeleteModal(a,t)},deleteActionCallback:function(e,t){r.dismiss(),"yes"===e&&f.invokeRecordDeletion(t)},showDeleteModal:function(e,t){const n=TYPO3.lang["label.confirm.delete_record.title"]||"Delete this record?";let a=TYPO3.lang["label.confirm.delete_record.content"]||"Are you sure you want to delete this record?";e.data("reference-count-message")&&(a+=" "+e.data("reference-count-message")),e.data("translation-count-message")&&(a+=" "+e.data("translation-count-message"));r.confirm(n,a,c.warning,[{text:TYPO3.lang["buttons.confirm.delete_record.no"]||"Cancel",btnClass:"btn-default",name:"no"},{text:TYPO3.lang["buttons.confirm.delete_record.yes"]||"Yes, delete this record",btnClass:"btn-warning",name:"yes",active:!0}]).on("button.clicked",(function(n){t(n.target.name,e)}))},enableOptGroup:function(e){const t=e.parentElement;t instanceof HTMLOptGroupElement&&t.querySelectorAll("option:not([hidden]):not([disabled]):not(.hidden)").length&&(t.hidden=!1,t.disabled=!1,t.classList.remove("hidden"))},closeDocument:function(){document.editform.closeDoc.value=1,f.dispatchSubmitEvent(),document.editform.submit()},saveDocument:function(){document.editform.doSave.value=1,f.dispatchSubmitEvent(),document.editform.submit()},dispatchSubmitEvent:function(){const e=document.createEvent("Event");e.initEvent("submit",!1,!0),document.editform.dispatchEvent(e)},initialize:function(e,t){o.getInstance().addPreSubmitCallback((function(){(0,n.default)('[data-active-password]:not([type="password"])').each((function(e,t){t.setAttribute("type","password"),t.blur()}))})),f.browserUrl=e,f.Validation.setUsMode(t),(0,n.default)((function(){f.initializeEvents(),f.Validation.initialize(),f.reinitialize(),(0,n.default)("#t3js-ui-block").remove()}))},invokeRecordDeletion:function(e){window.location.href=e.attr("href")}};return void 0!==TYPO3.settings.RequireJS&&void 0!==TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/FormEngine"]&&n.default.each(TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/FormEngine"],(function(t,n){e([n])})),TYPO3.FormEngine=f,f}()}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","TYPO3/CMS/Backend/FormEngine","TYPO3/CMS/Backend/FormEngineValidation"],(function(e,t,o,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractSortableSelectItems=void 0;class r{constructor(){this.registerSortableEventHandler=e=>{const t=e.closest(".form-wizards-wrap").querySelector(".form-wizards-items-aside");null!==t&&t.addEventListener("click",t=>{let i;if(null===(i=t.target.closest(".t3js-btn-option")))return void(t.target.matches(".t3js-btn-option")&&(i=t.target));t.preventDefault();const l=i.dataset.fieldname,s=o.getFieldElement(l).get(0),a=o.getFieldElement(l,"_avail").get(0);i.classList.contains("t3js-btn-moveoption-top")?r.moveOptionToTop(e):i.classList.contains("t3js-btn-moveoption-up")?r.moveOptionUp(e):i.classList.contains("t3js-btn-moveoption-down")?r.moveOptionDown(e):i.classList.contains("t3js-btn-moveoption-bottom")?r.moveOptionToBottom(e):i.classList.contains("t3js-btn-removeoption")&&r.removeOption(e,a),o.updateHiddenFieldValueFromSelect(e,s),o.legacyFieldChangedCb(),n.markFieldAsChanged(a),n.validateField(a)})}}static moveOptionToTop(e){Array.from(e.querySelectorAll(":checked")).reverse().forEach(t=>{e.insertBefore(t,e.firstElementChild)})}static moveOptionToBottom(e){e.querySelectorAll(":checked").forEach(t=>{e.insertBefore(t,null)})}static moveOptionUp(e){const t=Array.from(e.children),o=Array.from(e.querySelectorAll(":checked"));for(let n of o){if(0===t.indexOf(n)&&null===n.previousElementSibling)break;e.insertBefore(n,n.previousElementSibling)}}static moveOptionDown(e){const t=Array.from(e.children).reverse(),o=Array.from(e.querySelectorAll(":checked")).reverse();for(let n of o){if(0===t.indexOf(n)&&null===n.nextElementSibling)break;e.insertBefore(n,n.nextElementSibling.nextElementSibling)}}static removeOption(e,t){e.querySelectorAll(":checked").forEach(o=>{const n=t.querySelector('option[value="'+o.value+'"]');null!==n&&(n.classList.remove("hidden"),n.disabled=!1),e.removeChild(o)})}}t.AbstractSortableSelectItems=r}));
\ No newline at end of file
define(["require","exports","TYPO3/CMS/Backend/FormEngine","TYPO3/CMS/Backend/FormEngineValidation"],(function(e,t,o,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractSortableSelectItems=void 0;class r{constructor(){this.registerSortableEventHandler=e=>{const t=e.closest(".form-wizards-wrap").querySelector(".form-wizards-items-aside");null!==t&&t.addEventListener("click",t=>{let i;if(null===(i=t.target.closest(".t3js-btn-option")))return void(t.target.matches(".t3js-btn-option")&&(i=t.target));t.preventDefault();const l=i.dataset.fieldname,s=o.getFieldElement(l).get(0),a=o.getFieldElement(l,"_avail").get(0);i.classList.contains("t3js-btn-moveoption-top")?r.moveOptionToTop(e):i.classList.contains("t3js-btn-moveoption-up")?r.moveOptionUp(e):i.classList.contains("t3js-btn-moveoption-down")?r.moveOptionDown(e):i.classList.contains("t3js-btn-moveoption-bottom")?r.moveOptionToBottom(e):i.classList.contains("t3js-btn-removeoption")&&r.removeOption(e,a),o.updateHiddenFieldValueFromSelect(e,s),o.legacyFieldChangedCb(),n.markFieldAsChanged(a),n.validateField(a)})}}static moveOptionToTop(e){Array.from(e.querySelectorAll(":checked")).reverse().forEach(t=>{e.insertBefore(t,e.firstElementChild)})}static moveOptionToBottom(e){e.querySelectorAll(":checked").forEach(t=>{e.insertBefore(t,null)})}static moveOptionUp(e){const t=Array.from(e.children),o=Array.from(e.querySelectorAll(":checked"));for(let n of o){if(0===t.indexOf(n)&&null===n.previousElementSibling)break;e.insertBefore(n,n.previousElementSibling)}}static moveOptionDown(e){const t=Array.from(e.children).reverse(),o=Array.from(e.querySelectorAll(":checked")).reverse();for(let n of o){if(0===t.indexOf(n)&&null===n.nextElementSibling)break;e.insertBefore(n,n.nextElementSibling.nextElementSibling)}}static removeOption(e,t){e.querySelectorAll(":checked").forEach(n=>{const r=t.querySelector('option[value="'+n.value+'"]');null!==r&&(r.classList.remove("hidden"),r.disabled=!1,o.enableOptGroup(r)),e.removeChild(n)})}}t.AbstractSortableSelectItems=r}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","TYPO3/CMS/Core/Event/RegularEvent"],(function(e,t,l){"use strict";var i;!function(e){e.fieldContainerSelector=".t3js-formengine-field-group",e.filterTextFieldSelector=".t3js-formengine-multiselect-filter-textfield",e.filterSelectFieldSelector=".t3js-formengine-multiselect-filter-dropdown"}(i||(i={}));return class{constructor(e){this.selectElement=null,this.filterText="",this.availableOptions=null,this.selectElement=e,this.initializeEvents()}initializeEvents(){const e=this.selectElement.closest(".form-wizards-element");null!==e&&(new l("input",e=>{this.filter(e.target.value)}).delegateTo(e,i.filterTextFieldSelector),new l("change",e=>{this.filter(e.target.value)}).delegateTo(e,i.filterSelectFieldSelector))}filter(e){this.filterText=e,null===this.availableOptions&&(this.availableOptions=this.selectElement.querySelectorAll("option"));const t=new RegExp(e,"i");this.availableOptions.forEach(l=>{l.hidden=e.length>0&&null===l.textContent.match(t)})}}}));
\ No newline at end of file
define(["require","exports","TYPO3/CMS/Core/Event/RegularEvent"],(function(e,t,l){"use strict";var i;!function(e){e.fieldContainerSelector=".t3js-formengine-field-group",e.filterTextFieldSelector=".t3js-formengine-multiselect-filter-textfield",e.filterSelectFieldSelector=".t3js-formengine-multiselect-filter-dropdown"}(i||(i={}));class n{constructor(e){this.selectElement=null,this.filterText="",this.availableOptions=null,this.selectElement=e,this.initializeEvents()}static toggleOptGroup(e){const t=e.parentElement;t instanceof HTMLOptGroupElement&&(0===t.querySelectorAll("option:not([hidden]):not([disabled]):not(.hidden)").length?t.hidden=!0:(t.hidden=!1,t.disabled=!1,t.classList.remove("hidden")))}initializeEvents(){const e=this.selectElement.closest(".form-wizards-element");null!==e&&(new l("input",e=>{this.filter(e.target.value)}).delegateTo(e,i.filterTextFieldSelector),new l("change",e=>{this.filter(e.target.value)}).delegateTo(e,i.filterSelectFieldSelector))}filter(e){this.filterText=e,null===this.availableOptions&&(this.availableOptions=this.selectElement.querySelectorAll("option"));const t=new RegExp(e,"i");this.availableOptions.forEach(l=>{l.hidden=e.length>0&&null===l.textContent.match(t),n.toggleOptGroup(l)})}}return n}));
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment