UI Improvements
This commit is contained in:
parent
550c4aafaf
commit
e4bc1f9b7e
|
@ -25,13 +25,6 @@
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
|
||||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="test" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
|
11
pom.xml
11
pom.xml
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<groupId>com.mousetech.gourmet</groupId>
|
<groupId>com.mousetech.gourmet</groupId>
|
||||||
<artifactId>gourmetj</artifactId>
|
<artifactId>gourmetj</artifactId>
|
||||||
<version>2.0.4</version>
|
<version>2.0.18</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>GourmetJ</name>
|
<name>GourmetJ</name>
|
||||||
|
@ -172,6 +172,15 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.13.0</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.mousetech.gourmetj;
|
package com.mousetech.gourmetj;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -67,14 +66,6 @@ public class AdminMainBean implements Serializable {
|
||||||
return cookieBean;
|
return cookieBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param cookieBean the cookieBean to set.
|
|
||||||
* @deprecated Not invoked by @Inject
|
|
||||||
*/
|
|
||||||
public void setCookieBean(CookieBean cookieBean) {
|
|
||||||
this.cookieBean = cookieBean;
|
|
||||||
}
|
|
||||||
|
|
||||||
// **
|
// **
|
||||||
@Inject
|
@Inject
|
||||||
private UserSession userSession;
|
private UserSession userSession;
|
||||||
|
@ -248,6 +239,7 @@ public class AdminMainBean implements Serializable {
|
||||||
this.userSession.setLastEdit(null);
|
this.userSession.setLastEdit(null);
|
||||||
// Construct a blank recipe to be created.
|
// Construct a blank recipe to be created.
|
||||||
this.userSession.setRecipe(new Recipe());
|
this.userSession.setRecipe(new Recipe());
|
||||||
|
this.userSession.setDetailTab(0); // title tab
|
||||||
return "detailEdit?faces-redirect=true";
|
return "detailEdit?faces-redirect=true";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class CookieBean {
|
||||||
// **
|
// **
|
||||||
public Integer getDisplayListSize() {
|
public Integer getDisplayListSize() {
|
||||||
if (!cookieMap.containsKey(KEY_DISPLAY_ROWS)) {
|
if (!cookieMap.containsKey(KEY_DISPLAY_ROWS)) {
|
||||||
cookieMap.put(KEY_DISPLAY_ROWS, "30");
|
cookieMap.put(KEY_DISPLAY_ROWS, "0");
|
||||||
}
|
}
|
||||||
String st = cookieMap.get(KEY_DISPLAY_ROWS);
|
String st = cookieMap.get(KEY_DISPLAY_ROWS);
|
||||||
return Integer.valueOf(String.valueOf(st));
|
return Integer.valueOf(String.valueOf(st));
|
||||||
|
|
|
@ -243,7 +243,7 @@ public class RecipeDetailBean implements Serializable {
|
||||||
this.shop = this.getUserSession().getShoppingList()
|
this.shop = this.getUserSession().getShoppingList()
|
||||||
.contains(recipe);
|
.contains(recipe);
|
||||||
|
|
||||||
log.info("Set recipe: " + this.recipe);
|
log.debug("Set recipe: " + this.recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -358,8 +358,8 @@ public class RecipeDetailBean implements Serializable {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
String s = instructions.replace("\r\n", "<p/>")
|
String s = instructions.replace("\r\n", "<p/>")
|
||||||
.replace("\n\n", "<p/>");
|
.replace("\n\n", "<p/>")
|
||||||
s = s.replace("\n", "<br/>");
|
.replace("\n", "<br/>");
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ public class RecipeDetailBean implements Serializable {
|
||||||
* @see #addIngredientList(String)
|
* @see #addIngredientList(String)
|
||||||
*/
|
*/
|
||||||
public void addIngredient(String ingredientText) {
|
public void addIngredient(String ingredientText) {
|
||||||
log.info("Ingredient line: \"" + ingredientText + "\"");
|
log.debug("Ingredient line: \"" + ingredientText + "\"");
|
||||||
Ingredient ing =
|
Ingredient ing =
|
||||||
IngredientDigester.digest(ingredientText);
|
IngredientDigester.digest(ingredientText);
|
||||||
|
|
||||||
|
@ -977,7 +977,7 @@ public class RecipeDetailBean implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ajaxUpdateShopcat(IngredientUI item) {
|
public void ajaxUpdateShopcat(IngredientUI item) {
|
||||||
log.warn("SHOPCAT2 ");
|
log.debug("SHOPCAT2 ");
|
||||||
updateShopcat(item);
|
updateShopcat(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package com.mousetech.gourmetj;
|
package com.mousetech.gourmetj;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -144,6 +148,54 @@ public class UserSession implements Serializable {
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display source. If no "source" and there's a URL,
|
||||||
|
* use that.
|
||||||
|
*
|
||||||
|
* @param ltime
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String formatSource(Recipe r) {
|
||||||
|
String s = r.getSource();
|
||||||
|
if ( s != null && ! s.isBlank()) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
s = r.getLink();
|
||||||
|
return urlToSource(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take a URL and strip it of everything but
|
||||||
|
* the base domain name (including ".com")
|
||||||
|
* @param s URL string.
|
||||||
|
* @return Processed domain name.
|
||||||
|
* TestedBy: UserSessionTest
|
||||||
|
*/
|
||||||
|
String urlToSource(String s) {
|
||||||
|
if ( s == null || s.isBlank()) {
|
||||||
|
return ""; // no source, no URL
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if ( ! s.startsWith("http")) {
|
||||||
|
s = "http://" + s; // Convert to absolute URI
|
||||||
|
}
|
||||||
|
URL u = new URI(s).toURL();
|
||||||
|
String s1 = u.getHost();
|
||||||
|
if ( s1.startsWith("www.")) {
|
||||||
|
s1 = s1.substring("www.".length());
|
||||||
|
}
|
||||||
|
if ( s1.endsWith(".com")) {
|
||||||
|
// mousetech.com
|
||||||
|
s1 = s1.substring(0, s1.length() - ".com".length());
|
||||||
|
}
|
||||||
|
return s1;
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
return s;
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @Deprecated Using TimeConverter.
|
* @Deprecated Using TimeConverter.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -42,6 +42,10 @@
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
background-color: green;
|
background-color: green;
|
||||||
}
|
}
|
||||||
|
.noBorders .noBorders tr, .noBorders td {
|
||||||
|
background: none !important;
|
||||||
|
border: none !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<h:messages id="messages" />
|
<h:messages id="messages" />
|
||||||
<p:panel id="editorPanel"
|
<p:panel id="editorPanel"
|
||||||
|
@ -72,9 +76,16 @@
|
||||||
render="editorPanel"
|
render="editorPanel"
|
||||||
/>
|
/>
|
||||||
</p:inputText>
|
</p:inputText>
|
||||||
<p:outputLabel for="@next"
|
<!-- -->
|
||||||
|
<p:panel id="catPanel"
|
||||||
|
styleClass="noBorders"
|
||||||
|
style="display: flex; flex-direction: row; align-items: center;"
|
||||||
|
>
|
||||||
|
<p:outputLabel for="rcategory"
|
||||||
value="Category"
|
value="Category"
|
||||||
/>
|
/>
|
||||||
|
</p:panel>
|
||||||
|
<p:panel id="catEdit" styleClass="noBorders">
|
||||||
<p:inputText id="rcategory"
|
<p:inputText id="rcategory"
|
||||||
label="Category"
|
label="Category"
|
||||||
value="#{recipeDetailBean.category}"
|
value="#{recipeDetailBean.category}"
|
||||||
|
@ -97,6 +108,8 @@
|
||||||
value="#{recipeDetailBean.suggestCategory}"
|
value="#{recipeDetailBean.suggestCategory}"
|
||||||
/>
|
/>
|
||||||
</p:selectOneMenu>
|
</p:selectOneMenu>
|
||||||
|
</p:panel>
|
||||||
|
<!-- -->
|
||||||
<p:outputLabel for="@next"
|
<p:outputLabel for="@next"
|
||||||
value="Cuisine"
|
value="Cuisine"
|
||||||
/>
|
/>
|
||||||
|
@ -126,6 +139,13 @@
|
||||||
converterId="com.mousetech.gourmetj.utils.TimeConverter"
|
converterId="com.mousetech.gourmetj.utils.TimeConverter"
|
||||||
/>
|
/>
|
||||||
</p:inputText>
|
</p:inputText>
|
||||||
|
<p:outputLabel for="@next"
|
||||||
|
value="Servings"
|
||||||
|
/>
|
||||||
|
<p:inputText id="rserves"
|
||||||
|
max="10"
|
||||||
|
value="#{recipeDetailBean.recipe.servings}"
|
||||||
|
/>
|
||||||
<p:outputLabel for="@next"
|
<p:outputLabel for="@next"
|
||||||
value="Rating"
|
value="Rating"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -98,7 +98,7 @@
|
||||||
/>
|
/>
|
||||||
</p:column>
|
</p:column>
|
||||||
<p:column headerText="Source">
|
<p:column headerText="Source">
|
||||||
<h:outputText value="#{row.source}" />
|
<h:outputText value="#{userSession.formatSource(row)}" />
|
||||||
</p:column>
|
</p:column>
|
||||||
<p:column headerText="Prep Time">
|
<p:column headerText="Prep Time">
|
||||||
<h:outputText value="#{row.preptime}"
|
<h:outputText value="#{row.preptime}"
|
||||||
|
|
|
@ -45,9 +45,9 @@
|
||||||
columns="2" style="width: 220px;"
|
columns="2" style="width: 220px;"
|
||||||
>
|
>
|
||||||
<!-- TODO: ask if we should save -->
|
<!-- TODO: ask if we should save -->
|
||||||
<p:commandButton value="Back"
|
<p:commandButton value="Home"
|
||||||
ajax="false"
|
ajax="false"
|
||||||
icon="ui-icon-arrowthick-1-w"
|
icon="ui-icon-home"
|
||||||
action="home"
|
action="home"
|
||||||
immediate="true"
|
immediate="true"
|
||||||
/>
|
/>
|
||||||
|
@ -65,7 +65,11 @@
|
||||||
action="#{recipeDetailBean.doShop}"
|
action="#{recipeDetailBean.doShop}"
|
||||||
update="ctlShop"
|
update="ctlShop"
|
||||||
/>
|
/>
|
||||||
<h:outputText value="" />
|
<p:commandButton
|
||||||
|
icon="ui-icon-wrench"
|
||||||
|
value="Edit"
|
||||||
|
action="#{recipeDetailBean.editDescription}"
|
||||||
|
/>
|
||||||
<p:outputLabel for="@next"
|
<p:outputLabel for="@next"
|
||||||
value="Categories:"
|
value="Categories:"
|
||||||
/>
|
/>
|
||||||
|
@ -92,14 +96,23 @@
|
||||||
value="#{recipeDetailBean.recipe.cooktime}"
|
value="#{recipeDetailBean.recipe.cooktime}"
|
||||||
converter="com.mousetech.gourmetj.utils.TimeConverter"
|
converter="com.mousetech.gourmetj.utils.TimeConverter"
|
||||||
/>
|
/>
|
||||||
<h:outputText value="" />
|
<p:outputLabel for="@next"
|
||||||
<p:commandButton
|
value="Servings:"
|
||||||
icon="ui-icon-wrench"
|
/>
|
||||||
value="Edit"
|
<h:outputText
|
||||||
action="#{recipeDetailBean.editDescription}"
|
value="#{recipeDetailBean.recipe.servings}"
|
||||||
/>
|
/>
|
||||||
</p:panelGrid>
|
</p:panelGrid>
|
||||||
</p:panelGrid>
|
</p:panelGrid>
|
||||||
|
<p:panel id="sources">
|
||||||
|
<h:outputText value="#{recipeDetailBean.recipe.source}"/>
|
||||||
|
<br/>
|
||||||
|
<h:outputLink value="#{recipeDetailBean.recipe.link}"
|
||||||
|
rendered="#{not empty recipeDetailBean.recipe.link}"
|
||||||
|
>
|
||||||
|
#{recipeDetailBean.recipe.link}
|
||||||
|
</h:outputLink>
|
||||||
|
</p:panel>
|
||||||
</p:panelGrid>
|
</p:panelGrid>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<p:panel id="pnlInstr">
|
<p:panel id="pnlInstr">
|
||||||
|
|
25
src/test/java/com/mousetech/gourmetj/UserSessionTest.java
Normal file
25
src/test/java/com/mousetech/gourmetj/UserSessionTest.java
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package com.mousetech.gourmetj;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class UserSessionTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testformatSource() {
|
||||||
|
UserSession us = new UserSession();
|
||||||
|
|
||||||
|
assertEquals("mousetech",
|
||||||
|
us.urlToSource("www.mousetech.com"));
|
||||||
|
assertEquals("google",
|
||||||
|
us.urlToSource("google.com"));
|
||||||
|
assertEquals("foobar",
|
||||||
|
us.urlToSource("foobar"));
|
||||||
|
assertEquals("",
|
||||||
|
us.urlToSource("\t"));
|
||||||
|
assertEquals("",
|
||||||
|
us.urlToSource(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user