mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-24 14:38:45 +00:00
bug5510: implemented register action for FREE plan button (toggle authentication flyout)
- updated price styling - added subscription action to mobile view
This commit is contained in:
+8
-3
@@ -54,6 +54,7 @@ public class TabletAndDesktopApplicationClientFactory extends AbstractApplicatio
|
||||
private final SailingDispatchSystem dispatch = new SailingDispatchSystemImpl();
|
||||
private final AuthenticationPlaceManagementController userManagementWizardController;
|
||||
private final AuthenticationManager authenticationManager;
|
||||
private final FlyoutAuthenticationPresenter flyoutAuthenticationPresenter;
|
||||
|
||||
public TabletAndDesktopApplicationClientFactory(boolean isStandaloneServer) {
|
||||
this(new SimpleEventBus(), isStandaloneServer);
|
||||
@@ -84,7 +85,7 @@ public class TabletAndDesktopApplicationClientFactory extends AbstractApplicatio
|
||||
new AuthenticationClientFactoryImpl(authenticationManager, SharedResources.INSTANCE),
|
||||
new AuthenticationCallbackImpl(getHomePlacesNavigator().getUserProfileNavigation(),
|
||||
signInSuccesfulNavigation), userManagementDisplay, getEventBus());
|
||||
new FlyoutAuthenticationPresenter(userManagementDisplay, getTopLevelView().getAuthenticationMenuView(),
|
||||
this.flyoutAuthenticationPresenter = new FlyoutAuthenticationPresenter(userManagementDisplay, getTopLevelView().getAuthenticationMenuView(),
|
||||
userManagementWizardController, eventBus, authenticationManager.getAuthenticationContext());
|
||||
new DesktopLoginHintPopup(authenticationManager, placesNavigator);
|
||||
}
|
||||
@@ -124,10 +125,10 @@ public class TabletAndDesktopApplicationClientFactory extends AbstractApplicatio
|
||||
getSubscriptionServiceFactory().initializeProviders();
|
||||
return new SubscriptionViewImpl(new SubscriptionView.Presenter() {
|
||||
@Override
|
||||
public void startSubscription(String planId) {
|
||||
public void startSubscription(String priceId) {
|
||||
try {
|
||||
getSubscriptionServiceFactory().getDefaultProvider().getSubscriptionViewPresenter()
|
||||
.startCheckout(planId, new BaseUserSubscriptionView() {
|
||||
.startCheckout(priceId, new BaseUserSubscriptionView() {
|
||||
|
||||
@Override
|
||||
public void updateView(SubscriptionListDTO subscription, Iterable<SubscriptionPlanDTO> planList) {
|
||||
@@ -153,6 +154,10 @@ public class TabletAndDesktopApplicationClientFactory extends AbstractApplicatio
|
||||
// TODO: implement logic
|
||||
GWT.log("manage subscriptions");
|
||||
}
|
||||
@Override
|
||||
public void toggleAuthenticationFlyout() {
|
||||
flyoutAuthenticationPresenter.toggleFlyout();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -109,8 +109,10 @@
|
||||
font-weight: 700;
|
||||
}
|
||||
.price.selected {
|
||||
border-color: #8ab54e;
|
||||
border-width: 2px;
|
||||
border-color: #f0ab00;
|
||||
border-width: 1px;
|
||||
background-color: #f0ab00;
|
||||
color: #fff;
|
||||
}
|
||||
.prices {
|
||||
padding: 1em;
|
||||
|
||||
+15
-1
@@ -7,8 +7,10 @@ import java.util.function.Consumer;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.HeadingElement;
|
||||
import com.google.gwt.dom.client.Style.Display;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.i18n.client.NumberFormat;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
@@ -24,6 +26,8 @@ import com.sap.sailing.gwt.home.shared.places.subscription.SailingSubscriptionSt
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sse.security.shared.StringMessagesKey;
|
||||
import com.sap.sse.security.shared.subscription.SubscriptionPrice;
|
||||
import com.sap.sse.security.ui.authentication.AuthenticationContextEvent;
|
||||
import com.sap.sse.security.ui.authentication.app.AuthenticationContext;
|
||||
import com.sap.sse.security.ui.client.i18n.subscription.SubscriptionStringConstants;
|
||||
import com.sap.sse.security.ui.shared.subscription.SubscriptionPlanDTO;
|
||||
|
||||
@@ -65,7 +69,7 @@ public class SubscriptionCard extends Composite {
|
||||
private final Consumer<SubscriptionPrice> subscriptionCallback;
|
||||
private SubscriptionPrice currentPrice;
|
||||
|
||||
public <T> SubscriptionCard(SubscriptionPlanDTO subscriptionPlanDTO, Type type, Consumer<SubscriptionPrice> subscriptionCallback) {
|
||||
public <T> SubscriptionCard(SubscriptionPlanDTO subscriptionPlanDTO, Type type, Consumer<SubscriptionPrice> subscriptionCallback, EventBus eventBus) {
|
||||
this.subscriptionCallback = subscriptionCallback;
|
||||
SubscriptionCardResources.INSTANCE.css().ensureInjected();
|
||||
SharedResources.INSTANCE.mediaCss().ensureInjected();
|
||||
@@ -142,6 +146,16 @@ public class SubscriptionCard extends Composite {
|
||||
case FREE:
|
||||
addStyleName(FREE_STYLE);
|
||||
button.setText(i18n.signUp());
|
||||
button.getElement().getStyle().setDisplay(Display.BLOCK);
|
||||
eventBus.addHandler(AuthenticationContextEvent.TYPE, event->{
|
||||
AuthenticationContext authContext = event.getCtx();
|
||||
// make it point to the current server if the user has CREATE_OBJECT permission there
|
||||
if (authContext.isLoggedIn()) {
|
||||
button.getElement().getStyle().setDisplay(Display.NONE);
|
||||
} else {
|
||||
button.getElement().getStyle().setDisplay(Display.BLOCK);
|
||||
}
|
||||
});
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
+36
-3
@@ -31,13 +31,19 @@ import com.sap.sailing.gwt.home.shared.places.user.passwordreset.PasswordResetVi
|
||||
import com.sap.sailing.gwt.home.shared.places.user.profile.sailorprofile.ClientFactoryWithDispatchAndErrorAndUserService;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.client.refresh.BusyView;
|
||||
import com.sap.sse.gwt.client.Notification;
|
||||
import com.sap.sse.gwt.client.Notification.NotificationType;
|
||||
import com.sap.sse.gwt.client.mvp.ErrorView;
|
||||
import com.sap.sse.security.shared.subscription.InvalidSubscriptionProviderException;
|
||||
import com.sap.sse.security.ui.authentication.AuthenticationManager;
|
||||
import com.sap.sse.security.ui.authentication.AuthenticationManagerImpl;
|
||||
import com.sap.sse.security.ui.authentication.WithAuthenticationManager;
|
||||
import com.sap.sse.security.ui.authentication.login.LoginHintContent;
|
||||
import com.sap.sse.security.ui.client.SecureClientFactoryImpl;
|
||||
import com.sap.sse.security.ui.client.i18n.StringMessages;
|
||||
import com.sap.sse.security.ui.client.subscription.BaseUserSubscriptionView;
|
||||
import com.sap.sse.security.ui.shared.subscription.SubscriptionListDTO;
|
||||
import com.sap.sse.security.ui.shared.subscription.SubscriptionPlanDTO;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -123,17 +129,44 @@ public class MobileApplicationClientFactory extends
|
||||
|
||||
@Override
|
||||
public SubscriptionView createSubscriptionsView() {
|
||||
getSubscriptionServiceFactory().initializeProviders();
|
||||
return new SubscriptionViewImpl(new SubscriptionView.Presenter() {
|
||||
@Override
|
||||
public void startSubscription(String planId) {
|
||||
// TODO: implement logic
|
||||
GWT.log("start subscription with ID: " + planId);
|
||||
public void startSubscription(String priceId) {
|
||||
try {
|
||||
getSubscriptionServiceFactory().getDefaultProvider().getSubscriptionViewPresenter()
|
||||
.startCheckout(priceId, new BaseUserSubscriptionView() {
|
||||
|
||||
@Override
|
||||
public void updateView(SubscriptionListDTO subscription, Iterable<SubscriptionPlanDTO> planList) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpenCheckoutError(String error) {
|
||||
Notification.notify(error, NotificationType.ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCloseCheckoutModal() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
}, () -> getUserService().updateUser(true));
|
||||
} catch (InvalidSubscriptionProviderException e) {
|
||||
Notification.notify(e.toString(), NotificationType.ERROR);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void manageSubscriptions() {
|
||||
// TODO: implement logic
|
||||
GWT.log("manage subscriptions");
|
||||
}
|
||||
@Override
|
||||
public void toggleAuthenticationFlyout() {
|
||||
// TODO Auto-generated method stub
|
||||
GWT.log("toggle authentication flyout");
|
||||
navigator.goToPlace(navigator.getSignInNavigation());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+30
-26
@@ -7,7 +7,6 @@ import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.gwt.activity.shared.AbstractActivity;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
@@ -38,7 +37,35 @@ public class SubscriptionActivity extends AbstractActivity {
|
||||
.getAllSubscriptionPlans(new AsyncCallback<ArrayList<SubscriptionPlanDTO>>() {
|
||||
@Override
|
||||
public void onSuccess(final ArrayList<SubscriptionPlanDTO> result) {
|
||||
GWT.log("onSuccess");
|
||||
addFreePlan(view);
|
||||
result.forEach(plan -> {
|
||||
if (checkIfUserIsOwnerOfThePlan(plan)) {
|
||||
view.addSubscriptionPlan(plan, Type.OWNER, eventBus);
|
||||
} else if (subscriptionsPlace.getPlansToHighlight().contains(plan.getId())) {
|
||||
view.addSubscriptionPlan(plan, Type.HIGHLIGHT, eventBus);
|
||||
} else {
|
||||
view.addSubscriptionPlan(plan, Type.DEFAULT, eventBus);
|
||||
}
|
||||
});
|
||||
addIndividual(eventBus, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(final Throwable caught) {
|
||||
clientFactory.createErrorView("TODO Failed to load subscription plans", caught);
|
||||
}
|
||||
|
||||
private void addIndividual(final EventBus eventBus, final SubscriptionView view) {
|
||||
final SubscriptionPlanDTO individualPlan = new SubscriptionPlanDTO(null /* id */,
|
||||
new StringMessagesKey("individual_subscription_plan_name"),
|
||||
new StringMessagesKey("individual_subscription_plan_description"),
|
||||
Collections.emptySet() /* features */,
|
||||
Collections.emptySet() /* prices */,
|
||||
null /* error */);
|
||||
view.addSubscriptionPlan(individualPlan, Type.INDIVIDUAL, eventBus);
|
||||
}
|
||||
|
||||
private void addFreePlan(final SubscriptionView view) {
|
||||
Set<StringMessagesKey> freeFeatures = new LinkedHashSet<StringMessagesKey>(
|
||||
Arrays.asList(new StringMessagesKey("free_feature_1"),
|
||||
new StringMessagesKey("free_feature_2"),
|
||||
@@ -52,35 +79,12 @@ public class SubscriptionActivity extends AbstractActivity {
|
||||
freeFeatures,
|
||||
Collections.emptySet() /* prices */,
|
||||
null /* error */);
|
||||
view.addSubscriptionPlan(freePlan, Type.FREE);
|
||||
result.forEach(plan -> {
|
||||
if (checkIfUserIsOwnerOfThePlan(plan)) {
|
||||
view.addSubscriptionPlan(plan, Type.OWNER);
|
||||
} else if (subscriptionsPlace.getPlansToHighlight().contains(plan.getId())) {
|
||||
view.addSubscriptionPlan(plan, Type.HIGHLIGHT);
|
||||
} else {
|
||||
view.addSubscriptionPlan(plan, Type.DEFAULT);
|
||||
}
|
||||
});
|
||||
final SubscriptionPlanDTO individualPlan = new SubscriptionPlanDTO(null /* id */,
|
||||
new StringMessagesKey("individual_subscription_plan_name"),
|
||||
new StringMessagesKey("individual_subscription_plan_description"),
|
||||
Collections.emptySet() /* features */,
|
||||
Collections.emptySet() /* prices */,
|
||||
null /* error */);
|
||||
view.addSubscriptionPlan(individualPlan, Type.INDIVIDUAL);
|
||||
view.addSubscriptionPlan(freePlan, Type.FREE, eventBus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(final Throwable caught) {
|
||||
clientFactory.createErrorView("TODO Failed to load subscription plans", caught);
|
||||
}
|
||||
|
||||
});
|
||||
} catch (final InvalidSubscriptionProviderException exc) {
|
||||
onInvalidSubscriptionProviderError(exc);
|
||||
}
|
||||
|
||||
panel.setWidget(view);
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -1,12 +1,13 @@
|
||||
package com.sap.sailing.gwt.home.shared.places.subscription;
|
||||
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.user.client.ui.IsWidget;
|
||||
import com.sap.sailing.gwt.home.desktop.partials.subscription.SubscriptionCard;
|
||||
import com.sap.sse.security.ui.shared.subscription.SubscriptionPlanDTO;
|
||||
|
||||
public interface SubscriptionView extends IsWidget {
|
||||
|
||||
void addSubscriptionPlan(SubscriptionPlanDTO plan, final SubscriptionCard.Type type);
|
||||
void addSubscriptionPlan(SubscriptionPlanDTO plan, final SubscriptionCard.Type type, final EventBus eventBus);
|
||||
|
||||
public interface Presenter {
|
||||
|
||||
@@ -14,6 +15,7 @@ public interface SubscriptionView extends IsWidget {
|
||||
|
||||
void manageSubscriptions();
|
||||
|
||||
void toggleAuthenticationFlyout();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-8
@@ -1,6 +1,6 @@
|
||||
package com.sap.sailing.gwt.home.shared.places.subscription;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.sap.sailing.gwt.home.desktop.partials.subscription.SubscriptionCard;
|
||||
@@ -18,36 +18,36 @@ public class SubscriptionViewImpl extends Composite implements SubscriptionView
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSubscriptionPlan(final SubscriptionPlanDTO plan, final SubscriptionCard.Type type) {
|
||||
public void addSubscriptionPlan(final SubscriptionPlanDTO plan, final SubscriptionCard.Type type, final EventBus eventBus) {
|
||||
switch (type) {
|
||||
case HIGHLIGHT:
|
||||
container.addSubscription(new SubscriptionCard(plan, type, (price) -> {
|
||||
if (price != null) {
|
||||
presenter.startSubscription(price.getPriceId());
|
||||
}
|
||||
}));
|
||||
}, eventBus));
|
||||
break;
|
||||
case DEFAULT:
|
||||
container.addSubscription(new SubscriptionCard(plan, type, (price) -> {
|
||||
if (price != null) {
|
||||
presenter.startSubscription(price.getPriceId());
|
||||
}
|
||||
}));
|
||||
}, eventBus));
|
||||
break;
|
||||
case OWNER:
|
||||
container.addSubscription(new SubscriptionCard(plan, type, (price) -> {
|
||||
presenter.manageSubscriptions();
|
||||
}));
|
||||
}, eventBus));
|
||||
break;
|
||||
case INDIVIDUAL:
|
||||
container.addSubscription(new SubscriptionCard(plan, type, (price) -> {
|
||||
Window.Location.assign("mailto:info@sapsailing.com");
|
||||
}));
|
||||
}, eventBus));
|
||||
break;
|
||||
case FREE:
|
||||
container.addSubscription(new SubscriptionCard(plan, type, (price) -> {
|
||||
GWT.log("TODO: sign up dialog");
|
||||
}));
|
||||
presenter.toggleAuthenticationFlyout();
|
||||
}, eventBus));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user