Skip to content
Snippets Groups Projects
Commit f4fab1b3 authored by srosse's avatar srosse
Browse files

OO-4203: last missing translations, enhance account settings panel

parent a79d4f2e
No related branches found
No related tags found
No related merge requests found
......@@ -22,10 +22,13 @@ package org.olat.resource.accesscontrol.provider.paypalcheckout.ui;
import java.util.List;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItem;
import org.olat.core.gui.components.form.flexible.FormItemContainer;
import org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement;
import org.olat.core.gui.components.form.flexible.elements.SingleSelection;
import org.olat.core.gui.components.form.flexible.elements.TextElement;
import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
import org.olat.core.gui.components.form.flexible.impl.FormEvent;
import org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer;
import org.olat.core.gui.components.util.KeyValues;
import org.olat.core.gui.control.Controller;
......@@ -44,9 +47,12 @@ import org.springframework.beans.factory.annotation.Autowired;
*/
public class PaypalCheckoutAccountConfigurationController extends FormBasicController {
private static final String[] onKeys = new String[] { "on" };
private TextElement clientIdEl;
private TextElement clientSecretEl;
private SingleSelection currencyEl;
private MultipleSelectionElement enableEl;
private final List<String> paypalCurrencies;
......@@ -59,6 +65,7 @@ public class PaypalCheckoutAccountConfigurationController extends FormBasicContr
super(ureq, wControl);
paypalCurrencies = paypalModule.getPaypalCurrencies();
initForm(ureq);
updateUI();
}
@Override
......@@ -69,41 +76,90 @@ public class PaypalCheckoutAccountConfigurationController extends FormBasicContr
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("checkout.config.title");
setFormDescription("checkout.config.description");
String[] onValues = new String[] { translate("on") };
enableEl = uifactory.addCheckboxesHorizontal("enable", "paypal.enable", formLayout, onKeys, onValues);
enableEl.select(onKeys[0], acModule.isPaypalCheckoutEnabled());
enableEl.addActionListener(FormEvent.ONCHANGE);
KeyValues currencies = new KeyValues();
paypalCurrencies.forEach(currency -> currencies.add(KeyValues.entry(currency, currency)));
currencyEl = uifactory.addDropdownSingleselect("currency", "currency", formLayout, currencies.keys(), currencies.values(), null);
if(StringHelper.containsNonWhitespace(paypalModule.getPaypalCurrency())) {
currencyEl.select(paypalModule.getPaypalCurrency(), true);
} else {
currencyEl.select("CHF", true);
}
String clientId = paypalModule.getClientId();
clientIdEl = uifactory.addTextElement("checkout.client.id", 128, clientId, formLayout);
String clientSecret = paypalModule.getClientSecret();
clientSecretEl = uifactory.addTextElement("checkout.client.secret", 128, clientSecret, formLayout);
if(acModule.isPaypalEnabled()) {
setFormDescription("checkout.config.description");
setFormContextHelp("PayPal Configuration");
KeyValues currencies = new KeyValues();
paypalCurrencies.forEach(currency -> currencies.add(KeyValues.entry(currency, currency)));
currencyEl = uifactory.addDropdownSingleselect("currency", "currency", formLayout, currencies.keys(), currencies.values(), null);
if(StringHelper.containsNonWhitespace(paypalModule.getPaypalCurrency())) {
currencyEl.select(paypalModule.getPaypalCurrency(), true);
} else {
currencyEl.select("CHF", true);
}
String clientId = paypalModule.getClientId();
clientIdEl = uifactory.addTextElement("checkout.client.id", 128, clientId, formLayout);
String clientSecret = paypalModule.getClientSecret();
clientSecretEl = uifactory.addTextElement("checkout.client.secret", 128, clientSecret, formLayout);
final FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
formLayout.add(buttonGroupLayout);
uifactory.addFormSubmitButton("save", buttonGroupLayout);
}
private void updateUI() {
boolean enabled = enableEl.isAtLeastSelected(1);
currencyEl.setVisible(enabled);
clientIdEl.setVisible(enabled);
clientSecretEl.setVisible(enabled);
}
@Override
protected boolean validateFormLogic(UserRequest ureq) {
boolean allOk = super.validateFormLogic(ureq);
final FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
formLayout.add(buttonGroupLayout);
currencyEl.clearError();
if(enableEl.isAtLeastSelected(1) && !currencyEl.isOneSelected()) {
currencyEl.setErrorKey("form.legende.mandatory", null);
allOk &= false;
}
allOk &= validateId(clientIdEl);
allOk &= validateId(clientSecretEl);
return allOk;
}
private boolean validateId(TextElement element) {
boolean allOk = true;
element.clearError();
if(enableEl.isAtLeastSelected(1)
&& !StringHelper.containsNonWhitespace(element.getValue())) {
element.setErrorKey("form.legende.mandatory", null);
allOk &= false;
uifactory.addFormSubmitButton("save", buttonGroupLayout);
} else {
String fxSupport = "contact@frentix.com";
setFormWarning("config.disabled.warning", new String[]{fxSupport});
}
return allOk;
}
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if(source == enableEl) {
updateUI();
}
super.formInnerEvent(ureq, source, event);
}
@Override
protected void formOK(UserRequest ureq) {
paypalModule.setClientId(clientIdEl.getValue());
paypalModule.setClientSecret(clientSecretEl.getValue());
if(currencyEl.isOneSelected() && paypalCurrencies.contains(currencyEl.getSelectedKey())) {
paypalModule.setPaypalCurrency(currencyEl.getSelectedKey());
boolean enabled = enableEl.isAtLeastSelected(1);
acModule.setPaypalCheckoutEnabled(enabled);
if(enabled) {
paypalModule.setClientId(clientIdEl.getValue());
paypalModule.setClientSecret(clientSecretEl.getValue());
if(currencyEl.isOneSelected() && paypalCurrencies.contains(currencyEl.getSelectedKey())) {
paypalModule.setPaypalCurrency(currencyEl.getSelectedKey());
}
} else {
paypalModule.setClientId(null);
paypalModule.setClientSecret(null);
}
showInfo("saved");
}
......
......@@ -6,7 +6,7 @@ checkout.client.id=Client ID
checkout.client.secret=Client secret
checkout.config.description=Konfigurieren Sie die PayPal API-Berechtigung f\u00FCr den PayPal Zugang mit den Elementen Client ID und Client Secret. Diese zwei Sicherheitselemente m\u00FCssen Sie zuerst in Ihrem PayPal Businesskonto erstellen. <strong>OpenOlat unterst\u00FCtzt nicht nachtr\u00E4gliche Anderungen am Bestellungen von Ihrem Paypal Konto.</strong>
checkout.config.title=Paypal Checkout konfigurieren
config.disabled.warning=Warning
config.disabled.warning=Das PayPal Bezahlungsmodul ist f\u00FCr dieses System nicht freigeschaltet. Um Buchungen \u00FCber PayPal abwickeln zu k\u00F6nnen nehmen Sie bitte Kontakt auf mit <a href="mailto:{0}">{0}</a>.
currency=W\u00E4hrung
currency.error=Fehler in der W\u00E4hrungsauswahl
delivery=Einka\u00FCfer
......@@ -14,13 +14,16 @@ filter.canceled=Abgebrochen
filter.completed=Erfolgreich abgeschlossen
filter.created=Neue Paypal Bestellung
filter.error=Fehler
filter.inprocess=In Bearbeitung
filter.new=Neu (OpenOlat)
filter.pending=Schwenbend
offer.description=$org.olat.resource.accesscontrol.ui\:offer.description
offer.price=Preis
oo.order.nr=Bestellung ID (in OpenOlat)
paypal.before.redirect.error=Unerwarteter Fehler
paypal.capture.id=Capture ID
paypal.checkout.method=Paypal Checkout v2
paypal.enable=Paypal einschalten
paypal.invoice.id=Invoice ID
paypal.menu.title=Paypal
paypal.menu.title.alt=Paypal Checkout konfigurieren
......
......@@ -6,7 +6,7 @@ checkout.client.id=Client ID
checkout.client.secret=Client secret
checkout.config.description=Configure your authorisation to use your Paypal count with the Client ID and Client Secret. These two security elements must be created in your Paypal Business Account. <strong>OpenOlat doesn't support subsequent changes in order from your Paypal Account (yet).</strong>
checkout.config.title=Configure Paypal Checkout
config.disabled.warning=config.disabled.warning
config.disabled.warning=The PayPal payment module is not activated for this system. To handle bookings via PayPal can you please contact <a href="mailto:{0}">{0}</a>.
currency=Currency
currency.error=Currency error
delivery=Buyer
......@@ -14,13 +14,16 @@ filter.canceled=Cancelled
filter.completed=Closed successfully
filter.created=New Paypal order
filter.error=Error
filter.inprocess=In process
filter.new=New order (OpenOlat)
filter.pending=Pending
offer.description=$org.olat.resource.accesscontrol.ui\:offer.description
offer.price=Price
oo.order.nr=Order ID (in OpenOlat)
paypal.before.redirect.error=Unexpected error
paypal.capture.id=Capture ID
paypal.checkout.method=Paypal Checkout v2
paypal.enable=Enable Paypal
paypal.invoice.id=Invoice ID
paypal.menu.title=Paypal
paypal.menu.title.alt=Configure Paypal Checkout
......
......@@ -5,6 +5,7 @@ access.paypal.title=Payer avec Paypal
checkout.client.id=Client ID
checkout.client.secret=Client secret
checkout.config.title=Configurer Paypal Checkout
config.disabled.warning=Le module de paiement PayPal n'est pas activ\u00E9 pour ce syst\u00E8me. Afin de traiter les r\u00E9servations via PayPal, veuillez entrer en contact avec <a href="mailto:{0}">{0}</a>.
currency=Monnaie
currency.error=Erreur, monnaie incorrecte
delivery=Acheteur
......@@ -12,7 +13,9 @@ filter.canceled=Annul\u00E9
filter.completed=Compl\u00E9t\u00E9 avec succ\u00E8s
filter.created=Nouvelle commande Paypal
filter.error=Erreur
filter.inprocess=En cours
filter.new=Nouvelle commande (OpenOlat)
filter.pending=Pendant
offer.description=$org.olat.resource.accesscontrol.ui\:offer.description
offer.price=Prix
oo.order.nr=ID commande (OpenOlat)
......@@ -20,6 +23,7 @@ paypal.before.redirect.error=Erreur inattendue
paypal.capture.id=Capture ID
paypal.checkout.method=Paypal Checkout v2
paypal.config.description=Configurez l'autorisation d'acc\u00E8s \u00E0 l'API PayPal\: Client ID et Client Secret. Ce sont les deux \u00E9l\u00E9ments de s\u00E9curit\u00E9 dont vous avez besoin pour cr\u00E9er votre compte PayPal Business.
paypal.enable=Activ\u00E8 Paypal
paypal.invoice.id=Facture ID
paypal.menu.title=Paypal
paypal.menu.title.alt=Configurer Paypal Checkout
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment