package modules.admin.User.actions;

import modules.admin.domain.Contact;
import modules.admin.domain.Contact.ContactType;
import modules.admin.domain.User;
import modules.admin.domain.User.WizardState;

import org.skyve.metadata.controller.ServerSideAction;
import org.skyve.metadata.controller.ServerSideActionResult;
import org.skyve.web.WebContext;

public class New implements ServerSideAction<User> {
	/**
	 * For Serialization.
	 */
	private static final long serialVersionUID = 7776867319664519408L;

	@Override
	public ServerSideActionResult<User> execute(User adminUser, WebContext webContext) throws Exception {
	
		// Clear out old matches
		adminUser.getCandidateContacts().clear();
		
		Contact contact = Contact.newInstance();
		String searchContactName = adminUser.getSearchContactName(); 
		if (searchContactName == null) {
			searchContactName = "<New Person>";
		}
		contact.setName(searchContactName);
		contact.setEmail1(adminUser.getSearchEmail());
		contact.setContactType(ContactType.person);
		adminUser.setContact(contact);
		
		adminUser.setWizardState(WizardState.createContact);

		return new ServerSideActionResult<>(adminUser);
	}
}

@@ -30,16 +30,166 @@
 tions;%0A%0A
+import org.skyve.metadata.controller.ServerSideAction;%0Aimport org.skyve.metadata.controller.ServerSideActionResult;%0Aimport org.skyve.web.WebContext;%0A%0A
 import m
@@ -351,158 +351,8 @@
 e;%0A%0A
-import org.skyve.metadata.controller.ServerSideAction;%0Aimport org.skyve.metadata.controller.ServerSideActionResult;%0Aimport org.skyve.web.WebContext;%0A%0A
 publ
@@ -404,40 +404,8 @@
 %3E %7B%0A
-%09/**%0A%09 * For Serialization.%0A%09 */
 %0A%09pr
@@ -771,86 +771,8 @@
 ); %0A
-%09%09if (searchContactName == null) %7B%0A%09%09%09searchContactName = %22%3CNew Person%3E%22;%0A%09%09%7D%0A
 %09%09co

Remove confusing contact name placeholder value during new user creation.