diff --git a/vue/src/apps/CookbookView/CookbookView.vue b/vue/src/apps/CookbookView/CookbookView.vue
index 737300564f..bb63db823d 100644
--- a/vue/src/apps/CookbookView/CookbookView.vue
+++ b/vue/src/apps/CookbookView/CookbookView.vue
@@ -18,6 +18,9 @@
manually
+
+ {{submitText}}
+
@@ -33,10 +36,10 @@
-
+
{{ book.name }}
-
+
{{ book.description }}
@@ -44,14 +47,13 @@
- ↑
- ↓
+ ↑
+ ↓
-
- swap
+
+ swap
-
@@ -118,7 +120,9 @@ export default {
showAlp: true,
showMan: true,
md: 12,
- inputValue: ""
+ inputValue: "",
+ submitManual: false,
+ submitText: "Edit"
}
},
computed: {
@@ -200,6 +204,7 @@ export default {
this.showNtO = true
this.showOtN = true
this.showMan = true
+ this.submitManual = false
this.md = 12
},
@@ -210,6 +215,7 @@ export default {
this.showAlp= true
this.showOtN = true
this.showMan = true
+ this.submitManual = false
this.md = 12
},
sortOldest: function(){
@@ -219,16 +225,22 @@ export default {
this.showAlp= true
this.showNtO = true
this.showMan = true
+ this.submitManual = false
this.md = 12
},
enableSortManually: function(){
+ console.log(1)
+ this.synchroniseLocalToDatabase();
+ console.log(2)
+ if (localStorage.getItem('cookbooks') ){
+ this.cookbooks = JSON.parse(localStorage.getItem('cookbooks'))
+ }
this.showOtN= true
this.showAlp= true
this.showNtO = true
this.showMan = false
- this.md = 8
this.dropdown_text = "Sort by: manually"
-
+
},
swapUpBooks: function(index){
const tempArray = this.cookbooks
@@ -250,7 +262,6 @@ export default {
const position = parseInt(this.inputValue)
this.inputValue = ""
if (!(/^\d+$/.test(position)) || position >= this.cookbooks.length || position < 0){
- console.log("catch")
this.inputValue = ""
} else {
const tempArray = this.cookbooks
@@ -261,6 +272,32 @@ export default {
this.cookbooks = tempArray
}
+ }, submitManualChanging: function(){
+ if (!this.submitManual){
+ this.submitText = "Submit"
+ this.submitManual = true
+ this.md = 8
+ } else {
+ localStorage.setItem('cookbooks',JSON.stringify(this.cookbooks))
+ this.submitText = "Edit"
+ this.submitManual = false
+ this.md = 12
+ }
+ }, synchroniseLocalToDatabase: function(){
+ const localStorageData = localStorage.getItem('cookbooks');
+ const localStorageArray = JSON.parse(localStorageData) || [];
+ const updatedLocalStorageArray = localStorageArray.filter(localStorageElement => {
+ // Assuming there's a unique identifier in your objects, replace 'id' with the actual property
+ const isElementInTargetArray = this.cookbooks.some(targetElement => targetElement.id === localStorageElement.id);
+ return isElementInTargetArray;
+ });
+ this.cookbooks.forEach(targetElement => {
+ const isNewElement = !updatedLocalStorageArray.some(localStorageElement => localStorageElement.id === targetElement.id);
+ if (isNewElement) {
+ updatedLocalStorageArray.push(targetElement);
+ }
+ });
+ localStorage.setItem('cookbooks', JSON.stringify(updatedLocalStorageArray));
}
},
directives: {