Merge branch 'fix-item-input' into add-recipe-page
This commit is contained in:
@@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.*;
|
||||
"readyInMinutes",
|
||||
"servings",
|
||||
"image",
|
||||
"sourceUrl",
|
||||
"spoonacularSourceUrl"
|
||||
})
|
||||
@Generated("jsonschema2pojo")
|
||||
@@ -44,6 +45,8 @@ public class Recipe {
|
||||
private Integer servings;
|
||||
@JsonProperty("image")
|
||||
private String image;
|
||||
@JsonProperty("sourceUrl")
|
||||
private String sourceUrl;
|
||||
@JsonProperty("spoonacularSourceUrl")
|
||||
private String spoonacularSourceUrl;
|
||||
|
||||
@@ -147,4 +150,14 @@ public class Recipe {
|
||||
this.spoonacularSourceUrl = spoonacularSourceUrl;
|
||||
}
|
||||
|
||||
@JsonProperty("sourceUrl")
|
||||
public String getSourceUrl() {
|
||||
return sourceUrl;
|
||||
}
|
||||
|
||||
@JsonProperty("sourceUrl")
|
||||
public void setSourceUrl(String sourceUrl) {
|
||||
this.sourceUrl = sourceUrl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package whattocook.models;
|
||||
|
||||
public enum Unit {
|
||||
GRAMMS,
|
||||
MILLILETERS
|
||||
g,
|
||||
ml,
|
||||
units
|
||||
}
|
||||
|
||||
@@ -29,14 +29,14 @@ final class ItemTests {
|
||||
|
||||
@Test
|
||||
public void saveTest() {
|
||||
Item item = new Item("kartoffel", Unit.GRAMMS, 5000);
|
||||
Item item = new Item("kartoffel", Unit.g, 5000);
|
||||
itemRepository.save(item);
|
||||
assertTrue(itemRepository.existsById(item.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findByIDTest() {
|
||||
Item item = new Item("tortillias", Unit.GRAMMS, 5000);
|
||||
Item item = new Item("tortillias", Unit.g, 5000);
|
||||
itemRepository.save(item);
|
||||
assertEquals(item, itemRepository.findById(item.getId()).get());
|
||||
}
|
||||
@@ -49,7 +49,7 @@ final class ItemTests {
|
||||
|
||||
@Test
|
||||
public void findByNameTest(){
|
||||
Item item = new Item("tortillias", Unit.GRAMMS, 5000);
|
||||
Item item = new Item("tortillas", Unit.g, 5000);
|
||||
itemRepository.save(item);
|
||||
assertEquals(item, itemRepository.findByName(item.getName()).get());
|
||||
}
|
||||
@@ -57,11 +57,11 @@ final class ItemTests {
|
||||
@Test
|
||||
public void findAllTest() {
|
||||
List<Item> savedItems = new ArrayList();
|
||||
savedItems.add( new Item("nachos", Unit.GRAMMS, 5000));
|
||||
savedItems.add( new Item("wurst", Unit.GRAMMS, 5000));
|
||||
savedItems.add( new Item("schinken", Unit.GRAMMS, 5000));
|
||||
savedItems.add( new Item("brokkoli", Unit.GRAMMS, 5000));
|
||||
savedItems.add( new Item("eiscreme", Unit.GRAMMS, 5000));
|
||||
savedItems.add( new Item("nachos", Unit.g, 5000));
|
||||
savedItems.add( new Item("wurst", Unit.g, 5000));
|
||||
savedItems.add( new Item("schinken", Unit.g, 5000));
|
||||
savedItems.add( new Item("brokkoli", Unit.g, 5000));
|
||||
savedItems.add( new Item("eiscreme", Unit.g, 5000));
|
||||
|
||||
itemRepository.saveAll(savedItems);
|
||||
|
||||
@@ -71,7 +71,7 @@ final class ItemTests {
|
||||
|
||||
@Test
|
||||
public void deleteTest() {
|
||||
Item item = new Item("elefantenfuß", Unit.GRAMMS, 5000);
|
||||
Item item = new Item("elefantenfuß", Unit.g, 5000);
|
||||
itemRepository.save(item);
|
||||
assertEquals(item, itemRepository.findById(item.getId()).get());
|
||||
itemRepository.delete(item);
|
||||
@@ -80,7 +80,7 @@ final class ItemTests {
|
||||
|
||||
@Test
|
||||
public void updateTest() {
|
||||
Item item = new Item("schokoküsse", Unit.GRAMMS, 5000);
|
||||
Item item = new Item("schokoküsse", Unit.g, 5000);
|
||||
itemRepository.save(item);
|
||||
long itemCount = itemRepository.count();
|
||||
item.setQuantity(4574);
|
||||
|
||||
@@ -95,6 +95,8 @@
|
||||
</v-row>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- response element -->
|
||||
|
||||
<div class="item-section" v-show="items.length" v-cloak>
|
||||
@@ -138,6 +140,8 @@ const Items = {
|
||||
return {
|
||||
items: [],
|
||||
newItem: '',
|
||||
newQuantity: 0,
|
||||
newUnit: '',
|
||||
editedItem: null,
|
||||
loading: true,
|
||||
error: null,
|
||||
@@ -163,29 +167,29 @@ const Items = {
|
||||
return this.activeUser ? this.activeUser.email : ''
|
||||
},
|
||||
inputPlaceholder: function () {
|
||||
return this.activeUser ? this.activeUser.given_name + ', what do you want to add?' : 'What needs to be added'
|
||||
return this.activeUser ? this.activeUser.given_name + ', What do you want to add?' : 'What needs to be added?'
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
addItem: function () {
|
||||
var value = this.newItem && this.newItem.trim()
|
||||
if (!value) {
|
||||
const addableItem = this.newItem && this.newItem.trim();
|
||||
const addableQuantity = parseInt(this.newQuantity);
|
||||
const addableUnit = this.newUnit;
|
||||
if (!addableItem) {
|
||||
return
|
||||
}
|
||||
|
||||
var components = value.split(' ')
|
||||
|
||||
api.createNew(components[0],
|
||||
parseInt(components[1].replace(/[^\d.]/g, '')),
|
||||
components[1].replace(/[0-9]/g, '') === 'ml' ? 'MILLILETERS' : "GRAMMS"
|
||||
api.createNew(addableItem,
|
||||
addableQuantity,
|
||||
addableUnit
|
||||
).then((response) => {
|
||||
this.$log.debug("New item created:", response);
|
||||
this.items.push({
|
||||
id: response.data.id,
|
||||
name: components[0],
|
||||
quantity: parseInt(components[1].replace(/[^\d.]/g, '')),
|
||||
unit: components[1].replace(/[0-9]/g, '') === 'MILLILETERS' ? 'ml' : 'g'
|
||||
name: addableItem,
|
||||
quantity: addableQuantity,
|
||||
unit: addableUnit
|
||||
})
|
||||
}).catch((error) => {
|
||||
this.$log.debug(error);
|
||||
@@ -218,10 +222,6 @@ export default Items
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200&display=swap');
|
||||
@@ -284,7 +284,7 @@ body{
|
||||
position: relative;
|
||||
z-index: 5;
|
||||
width: 20vh;
|
||||
height: 3vh;
|
||||
height: 2vh;
|
||||
}
|
||||
|
||||
.newItemName {
|
||||
|
||||
@@ -316,11 +316,11 @@ body{
|
||||
|
||||
/* Workaround for below WQHD resolution */
|
||||
|
||||
@media screen and (max-height: 1400px) {
|
||||
.formLabel{
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
//@media screen and (max-height: 1400px) {
|
||||
// .formLabel{
|
||||
// opacity: 0;
|
||||
// }
|
||||
//}
|
||||
|
||||
/* item section */
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
.menu-icon {
|
||||
position: relative;
|
||||
padding: 0.5vh 0.5vh;
|
||||
top: 2vh;
|
||||
cursor: pointer;
|
||||
z-index: 1;
|
||||
display: none;
|
||||
@@ -75,6 +76,7 @@
|
||||
.logo{
|
||||
position: relative;
|
||||
padding: 0.5vh 0.5vh;
|
||||
top: 2vh;
|
||||
}
|
||||
|
||||
.logo:hover {
|
||||
|
||||
Reference in New Issue
Block a user