package org.orienteer.core.widget.command;

import java.util.Optional;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.model.IModel;
import org.orienteer.core.component.BootstrapSize;
import org.orienteer.core.component.BootstrapType;
import org.orienteer.core.component.FAIconType;
import org.orienteer.core.component.command.AjaxCommand;
import org.orienteer.core.component.property.DisplayMode;
import org.orienteer.core.widget.DashboardPanel;
import org.orienteer.core.widget.IDashboardContainer;

import com.orientechnologies.orient.core.record.impl.ODocument;

/**
 * Command to save silently current dashboard
 */
public class SilentSaveDashboardCommand extends AjaxCommand<ODocument> {
	private static final long serialVersionUID = 1L;

	public SilentSaveDashboardCommand(String id, IModel<ODocument> dashboardDocumentModel) {
		super(id, "command.save", dashboardDocumentModel);
		setIcon(FAIconType.save);
		setChangingDisplayMode(true);
	}
	
	@Override
	public void onClick(Optional<AjaxRequestTarget> targetOptional) {
		IDashboardContainer container = findParent(IDashboardContainer.class);
		DashboardPanel<?> dashboard = container.getCurrentDashboard().getSelfComponent();
		dashboard.storeDashboard();
		dashboard.getModeModel().setObject(DisplayMode.VIEW);
		targetOptional.ifPresent(target -> target.add(dashboard));
	}
}

@@ -48,28 +48,64 @@
 ort 
-java.util.Optional;%0A
+com.orientechnologies.orient.core.record.impl.ODocument;
 %0Aimp
@@ -193,110 +193,8 @@
 el;%0A
-import org.orienteer.core.component.BootstrapSize;%0Aimport org.orienteer.core.component.BootstrapType;%0A
 impo
@@ -467,63 +467,26 @@
 ort 
-com.orientechnologies.orient.core.record.impl.ODocument
+java.util.Optional
 ;%0A%0A/
@@ -1228,16 +1228,75 @@
 rget -%3E 
+%7B%0A%09%09%09target.add(container.getSelf().get(%22pageHeader%22));%0A%09%09%09
 target.a
@@ -1308,16 +1308,21 @@
 shboard)
+;%0A%09%09%7D
 );%0A%09%7D%0A%7D%0A

Update page header on click