Commit 12edc5aa authored by Kevin Ditscheid's avatar Kevin Ditscheid

[FEATURE] Add modals to prevent unsaved changes from getting lost

parent ce3cc4e8
......@@ -381,6 +381,22 @@ Tapio Markula --&gt; finnish translation</description>
<source>XML</source>
<target>XML</target>
</trans-unit>
<trans-unit id="function.langfile.confirmCancel">
<source>All unsaved changes will be lost. Are you sure that you wish to cancel?</source>
<target>Alle ikke-gemte ændringer vil gå tabt. Er du sikker på, at du ønsker at annullere?</target>
</trans-unit>
<trans-unit id="function.langfile.confirmCancel.title">
<source>Warning</source>
<target>Advarsel</target>
</trans-unit>
<trans-unit id="function.langfile.confirmChange">
<source>All unsaved changes will be lost. Are you sure that you wish to change?</source>
<target>Alle ikke-gemte ændringer vil gå tabt. Er du sikker på, at du ønsker at ændre?</target>
</trans-unit>
<trans-unit id="function.langfile.confirmChange.title">
<source>Warning</source>
<target>Advarsel</target>
</trans-unit>
<trans-unit id="function.langfile.edit" approved="yes">
<source>Edit file</source>
<target>Rediger fil</target>
......
......@@ -409,6 +409,18 @@ Tapio Markula --&gt; finnish translation</description>
<source>All unsaved changes will be lost. Are you sure that you wish to cancel?</source>
<target>Alle nicht gespeicherten Änderungen gehen verloren. Bist du dir sicher, dass du abbrechen möchtest?</target>
</trans-unit>
<trans-unit id="function.langfile.confirmCancel.title">
<source>Warning</source>
<target>Warnung</target>
</trans-unit>
<trans-unit id="function.langfile.confirmChange">
<source>All unsaved changes will be lost. Are you sure that you wish to change?</source>
<target>Alle nicht gespeicherten Änderungen gehen verloren. Bist du dir sicher, dass du wechseln möchtest?</target>
</trans-unit>
<trans-unit id="function.langfile.confirmChange.title">
<source>Warning</source>
<target>Warnung</target>
</trans-unit>
<trans-unit id="function.langfile.edit" approved="yes">
<source>Edit file</source>
<target>Sprachdatei editieren</target>
......
......@@ -381,6 +381,22 @@ Tapio Markula --&gt; finnish translation</description>
<source>XML</source>
<target>XML</target>
</trans-unit>
<trans-unit id="function.langfile.confirmCancel">
<source>All unsaved changes will be lost. Are you sure that you wish to cancel?</source>
<target>Kaikki tallentamattomat muutokset menetetään. Oletko varma, että haluat peruuttaa?</target>
</trans-unit>
<trans-unit id="function.langfile.confirmCancel.title">
<source>Warning</source>
<target>Varoitus</target>
</trans-unit>
<trans-unit id="function.langfile.confirmChange">
<source>All unsaved changes will be lost. Are you sure that you wish to change?</source>
<target>Kaikki tallentamattomat muutokset menetetään. Oletko varma, että haluat muuttaa?</target>
</trans-unit>
<trans-unit id="function.langfile.confirmChange.title">
<source>Warning</source>
<target>Varoitus</target>
</trans-unit>
<trans-unit id="function.langfile.edit" approved="yes">
<source>Edit file</source>
<target>Muokkaa tiedostoa</target>
......
......@@ -310,6 +310,15 @@ Tapio Markula --&gt; finnish translation</description>
<trans-unit id="function.langfile.confirmCancel">
<source>All unsaved changes will be lost. Are you sure that you wish to cancel?</source>
</trans-unit>
<trans-unit id="function.langfile.confirmCancel.title">
<source>Warning</source>
</trans-unit>
<trans-unit id="function.langfile.confirmChange">
<source>All unsaved changes will be lost. Are you sure that you wish to change?</source>
</trans-unit>
<trans-unit id="function.langfile.confirmChange.title">
<source>Warning</source>
</trans-unit>
<trans-unit id="function.langfile.edit">
<source>Edit file</source>
</trans-unit>
......
......@@ -409,6 +409,18 @@ Tapio Markula --&gt; finnish translation</description>
<source>All unsaved changes will be lost. Are you sure that you wish to cancel?</source>
<target>Wszystkie niezapisane zmiany zostaną utracone. Czy na pewno chcesz anulować?</target>
</trans-unit>
<trans-unit id="function.langfile.confirmCancel.title">
<source>Warning</source>
<target>Ostrzeżenie</target>
</trans-unit>
<trans-unit id="function.langfile.confirmChange">
<source>All unsaved changes will be lost. Are you sure that you wish to change?</source>
<target>Wszystkie niezapisane zmiany zostaną utracone. Czy na pewno chcesz anulować?</target>
</trans-unit>
<trans-unit id="function.langfile.confirmChange.title">
<source>Warning</source>
<target>Ostrzeżenie</target>
</trans-unit>
<trans-unit id="function.langfile.edit">
<source>Edit file</source>
<target>Edytuj plik</target>
......
{namespace lfe=SGalinski\Lfeditor\ViewHelpers}
<lfe:addJavaScriptFile javaScriptFile="{f:uri.resource(path: 'JavaScript/textareaResize.js')}" />
<lfe:inlineLanguageLabels labels="function.langfile.confirmCancel" />
<lfe:addCssFile cssFile="{f:uri.resource(path: 'StyleSheets/Lfeditor.css')}" />
<f:be.container includeRequireJsModules="{
0: 'TYPO3/CMS/Lfeditor/Lfeditor'
}" addJsInlineLabels="{
0: 'function.langfile.confirmCancel',
1: 'function.langfile.confirmChange',
2: 'function.langfile.confirmCancel.title',
3: 'function.langfile.confirmChange.title'
}">
<div class="module" data-module-id="" data-module-name="">
<div class="module-docheader t3js-module-docheader">
<div class="module-docheader-bar module-docheader-bar-navigation t3js-module-docheader-bar t3js-module-docheader-bar-navigation">
<div class="module-docheader-bar-column-left">
<f:be.menus.actionMenu>
<f:be.menus.actionMenuItem label="{f:translate(key:'function.general.general')}"
controller="General"
action="general" />
<f:be.menus.actionMenuItem label="{f:translate(key:'function.langfile.edit')}"
controller="EditFile"
action="editFile"
arguments="{buttonType: 0}" />
<f:be.menus.actionMenuItem label="{f:translate(key:'function.const.edit.edit')}"
controller="EditConstant"
action="editConstant" />
<f:if condition="{defaultLanguagePermission}">
<f:be.menus.actionMenuItem label="{f:translate(key:'function.const.add.add')}"
controller="AddConstant"
action="addConstant" />
<f:be.menus.actionMenuItem label="{f:translate(key:'function.const.delete.delete')}"
controller="DeleteConstant"
action="deleteConstant" />
<f:be.menus.actionMenuItem label="{f:translate(key:'function.const.rename.rename')}"
controller="RenameConstant"
action="renameConstant" />
</f:if>
<f:be.menus.actionMenuItem label="{f:translate(key:'function.const.search.search')}"
controller="SearchConstant"
action="searchConstant" />
<f:be.menus.actionMenuItem label="{f:translate(key:'function.const.treeview.treeview')}"
controller="ViewTree"
action="viewTree" />
<f:if condition="{editingMode} == 'extension'">
<f:be.menus.actionMenuItem label="{f:translate(key:'function.backupMgr.backupMgr')}"
controller="ManageBackups"
action="manageBackups" />
</f:if>
</f:be.menus.actionMenu>
<f:if condition="{canChangeEditingModes}">
<f:be.menus.actionMenu>
<f:for each="{editingModeOptions}" key="editingModeOption" as="editingModeLabel">
<f:if condition="{editingMode} == {editingModeOption}">
<f:then>
<f:be.menus.actionMenuItem label="{editingModeLabel}"
controller="General"
action="switchEditingMode"
arguments="{editingMode: editingModeOption}"
additionalAttributes="{selected: 'selected'}" />
</f:then>
<f:else>
<f:be.menus.actionMenuItem label="{editingModeLabel}"
controller="General"
action="switchEditingMode"
arguments="{editingMode: editingModeOption}" />
</f:else>
<div class="row">
<div class="col-md-6">
<f:form.select additionalAttributes="{class: 'form-control', onchange: 'TYPO3.lfEditor.jump(this)'}">
<f:be.menus.actionMenuItem label="{f:translate(key:'function.general.general')}"
controller="General"
action="general" />
<f:be.menus.actionMenuItem label="{f:translate(key:'function.langfile.edit')}"
controller="EditFile"
action="editFile"
arguments="{buttonType: 0}" />
<f:be.menus.actionMenuItem label="{f:translate(key:'function.const.edit.edit')}"
controller="EditConstant"
action="editConstant" />
<f:if condition="{defaultLanguagePermission}">
<f:be.menus.actionMenuItem label="{f:translate(key:'function.const.add.add')}"
controller="AddConstant"
action="addConstant" />
<f:be.menus.actionMenuItem label="{f:translate(key:'function.const.delete.delete')}"
controller="DeleteConstant"
action="deleteConstant" />
<f:be.menus.actionMenuItem label="{f:translate(key:'function.const.rename.rename')}"
controller="RenameConstant"
action="renameConstant" />
</f:if>
</f:for>
</f:be.menus.actionMenu>
</f:if>
<f:be.menus.actionMenuItem label="{f:translate(key:'function.const.search.search')}"
controller="SearchConstant"
action="searchConstant" />
<f:be.menus.actionMenuItem label="{f:translate(key:'function.const.treeview.treeview')}"
controller="ViewTree"
action="viewTree" />
<f:if condition="{editingMode} == 'extension'">
<f:be.menus.actionMenuItem label="{f:translate(key:'function.backupMgr.backupMgr')}"
controller="ManageBackups"
action="manageBackups" />
</f:if>
</f:form.select>
</div>
<f:if condition="{canChangeEditingModes}">
<div class="col-md-6">
<f:form.select additionalAttributes="{class: 'form-control', onchange: 'TYPO3.lfEditor.jump(this)'}">
<f:for each="{editingModeOptions}" key="editingModeOption" as="editingModeLabel">
<f:if condition="{editingMode} == {editingModeOption}">
<f:then>
<f:be.menus.actionMenuItem label="{editingModeLabel}"
controller="General"
action="switchEditingMode"
arguments="{editingMode: editingModeOption}"
additionalAttributes="{selected: 'selected'}" />
</f:then>
<f:else>
<f:be.menus.actionMenuItem label="{editingModeLabel}"
controller="General"
action="switchEditingMode"
arguments="{editingMode: editingModeOption}" />
</f:else>
</f:if>
</f:for>
</f:form.select>
</div>
</f:if>
</div>
</div>
</div>
<div class="module-docheader-bar module-docheader-bar-buttons t3js-module-docheader-bar t3js-module-docheader-bar-buttons">
......
......@@ -10,7 +10,7 @@
class="form-control"
value="{constantSelection}"
options="{constantOptions}"
additionalAttributes="{onchange: 'TYPO3.lfEditor.submitForm(\'mainMenuForm\')'}" />
additionalAttributes="{onchange: 'TYPO3.lfEditor.changeForm(\'mainMenuForm\')'}" />
</div>
</div>
</f:if>
......@@ -13,7 +13,7 @@
</strong>
</label>
<div class="input-group">
<lfe:be.menus.actionMenu additionalAttributes="{class: 'form-control'}">
<f:form.select additionalAttributes="{class: 'form-control', onChange: 'TYPO3.lfEditor.jump(this)'}">
<f:for each="{extensions}" as="extension" key="extAddress">
<optgroup label="{extension.extLabel}">
<f:for each="{extension.languageFileOptions}" as="langFileLabel" key="langFileOption">
......@@ -35,7 +35,7 @@
</f:for>
</optgroup>
</f:for>
</lfe:be.menus.actionMenu>
</f:form.select>
<span class="input-group-btn">
<button class="btn btn-default"
onclick="document.getElementById('refreshLanguageFileListForm').submit();"
......
......@@ -13,7 +13,7 @@
class="form-control"
value="{languageSelection}"
options="{languageOptions}"
additionalAttributes="{onchange: 'TYPO3.lfEditor.submitForm(\'mainMenuForm\')'}" />
additionalAttributes="{onchange: 'TYPO3.lfEditor.changeForm(\'mainMenuForm\')'}" />
</div>
</div>
<div class="col-md-6">
......@@ -22,7 +22,7 @@
value="{referenceLanguageSelection}"
class="form-control"
options="{referenceLanguageOptions}"
additionalAttributes="{onchange: 'TYPO3.lfEditor.submitForm(\'mainMenuForm\')'}" />
additionalAttributes="{onchange: 'TYPO3.lfEditor.changeForm(\'mainMenuForm\')'}" />
</div>
</div>
</div>
......
......@@ -11,7 +11,7 @@
class="form-control"
value="{numSiteConstsSelection}"
options="{numSiteConstsOptions}"
additionalAttributes="{onchange: 'TYPO3.lfEditor.submitForm(\'mainMenuForm\')'}" />
additionalAttributes="{onchange: 'TYPO3.lfEditor.changeForm(\'mainMenuForm\')'}" />
</div>
</div>
</div>
......
......@@ -11,7 +11,7 @@
class="form-control"
value="{bottomReferenceLanguageSelection}"
options="{bottomReferenceLanguageOptions}"
additionalAttributes="{onchange: 'TYPO3.lfEditor.submitForm(\'mainMenuForm\')'}" />
additionalAttributes="{onchange: 'TYPO3.lfEditor.changeForm(\'mainMenuForm\')'}" />
</div>
</div>
</div>
......
......@@ -17,7 +17,7 @@
<f:form.select name="constantTypeSelection"
value="{constantTypeSelection}"
options="{constantTypeOptions}"
additionalAttributes="{onchange: 'TYPO3.lfEditor.submitForm(\'mainMenuForm\')', class: 'form-control'}" />
additionalAttributes="{onchange: 'TYPO3.lfEditor.changeForm(\'mainMenuForm\')', class: 'form-control'}" />
</div>
</div>
</f:if>
......
......@@ -10,7 +10,7 @@
<f:form.select name="extensionSelection"
value="{extensionSelection}"
options="{extensionOptions}"
additionalAttributes="{onchange: 'TYPO3.lfEditor.submitForm(\'mainMenuForm\')'}"
additionalAttributes="{onchange: 'TYPO3.lfEditor.changeForm(\'mainMenuForm\')'}"
/>
</f:form>
</f:section>
......
......@@ -23,8 +23,10 @@
***************************************************************/
define([
'jquery'
], function($) {
'jquery',
'TYPO3/CMS/Backend/Modal',
'TYPO3/CMS/Backend/Severity'
], function($, Modal, Severity) {
'use strict';
var lfEditor = {
......@@ -38,6 +40,7 @@ define([
},
submitLanguageFileEdit: function (buttonType) {
document.forms.contentForm.elements['tx_lfeditor_user_lfeditorlfeditor[buttonType]'].value = buttonType;
document.forms.contentForm.submit();
},
/**
* Renders confirmation dialog for cancel button.
......@@ -45,11 +48,15 @@ define([
* @returns {boolean}
*/
confirmCancelFileEdit: function () {
var warningText = AY.lang.Lfeditor['function.langfile.confirmCancel'];
if (window.confirm(warningText)) {
Modal.confirm(
TYPO3.lang['function.langfile.confirmCancel.title'],
TYPO3.lang['function.langfile.confirmCancel']
).on('confirm.button.ok', function() {
Modal.dismiss();
TYPO3.lfEditor.submitLanguageFileEdit(-1);
return true;
}
}).on('confirm.button.cancel', function() {
Modal.dismiss();
});
return false;
},
......@@ -143,8 +150,29 @@ define([
document.getElementById('contentForm').submit();
}
},
submitForm: function (id) {
document.getElementById(id).submit();
changeForm: function (id) {
Modal.confirm(
TYPO3.lang['function.langfile.confirmChange.title'],
TYPO3.lang['function.langfile.confirmChange']
).on('confirm.button.ok', function() {
Modal.dismiss();
document.getElementById(id).submit();
}).on('confirm.button.cancel', function() {
Modal.dismiss();
});
return false;
},
jump: function (select) {
Modal.confirm(
TYPO3.lang['function.langfile.confirmChange.title'],
TYPO3.lang['function.langfile.confirmChange']
).on('confirm.button.ok', function() {
Modal.dismiss();
window.location.href = select.options[select.selectedIndex].value;
}).on('confirm.button.cancel', function() {
Modal.dismiss();
});
}
};
......
Markdown is supported
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