Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle layerswipe url param #1036

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package fi.nls.oskari.control.view.modifier.param;

import fi.nls.oskari.annotation.OskariViewModifier;
import fi.nls.oskari.log.LogFactory;
import fi.nls.oskari.log.Logger;
import fi.nls.oskari.util.ConversionHelper;
import fi.nls.oskari.view.modifier.ModifierException;
import fi.nls.oskari.view.modifier.ModifierParams;
import fi.nls.oskari.view.modifier.ParamHandler;
import org.json.JSONException;
import org.json.JSONObject;

@OskariViewModifier("layerSwipe")
ZakarFin marked this conversation as resolved.
Show resolved Hide resolved
public class LayerSwipeParamHandler extends ParamHandler {

@Override
public int getPriority() {
return 1;
}
private static final Logger log = LogFactory.getLogger(LayerSwipeParamHandler.class);

public boolean handleParam(final ModifierParams params) throws ModifierException {
if(params.getParamValue() == null) {
return false;
}

try {
final JSONObject state = getBundleState(params.getConfig(), BUNDLE_LAYERSWIPE);
boolean layerSwipe = ConversionHelper.getBoolean(params.getParamValue(), false);
state.put(KEY_LAYER_SWIPE, layerSwipe);
ZakarFin marked this conversation as resolved.
Show resolved Hide resolved
return true;
ZakarFin marked this conversation as resolved.
Show resolved Hide resolved
} catch (JSONException je) {
throw new ModifierException("Could not set layerSwipe from URL param.");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ public abstract class ViewModifier {
public static final String BUNDLE_METADATAFLYOUT = "metadataflyout";
public static final String BUNDLE_BACKEND_STATUS = "backendstatus";

public static final String BUNDLE_LAYERSWIPE = "layerswipe";

public static final String KEY_EAST = "east";
public static final String KEY_NORTH = "north";
public static final String KEY_ZOOM = "zoom";
public static final String KEY_LAYER_SWIPE = "layerSwipe";
ZakarFin marked this conversation as resolved.
Show resolved Hide resolved
public static final String KEY_SELECTEDLAYERS = "selectedLayers";

public void init() {
Expand Down
Loading