From ada7d27da93a1a59a4b2c54abeaa1e072a5793d5 Mon Sep 17 00:00:00 2001
From: Cristiano Magro <cristiano.magro@vola.it>
Date: Tue, 07 Jan 2025 18:19:48 +0100
Subject: [PATCH] processo di cancellazione di una resource

---
 10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/LearningResource.vue |    7 +++++--
 10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/StoredResource.vue   |    1 +
 10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/TheResources.vue     |    7 +++++++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/LearningResource.vue b/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/LearningResource.vue
index edfdd59..bb35ac2 100644
--- a/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/LearningResource.vue
+++ b/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/LearningResource.vue
@@ -3,7 +3,9 @@
     <base-card>
       <header>
         <h3>{{ title }}</h3>
-        <base-button mode="flat">Delete</base-button>
+        <base-button mode="flat" @click="deleteResource(id)"
+          >Delete</base-button
+        >
       </header>
       <p>{{ description }}</p>
       <nav>
@@ -15,7 +17,8 @@
 
 <script>
 export default {
-  props: ['title', 'description', 'link'],
+  props: ['id', 'title', 'description', 'link'],
+  inject: ['deleteResource'],
 };
 </script>
 
diff --git a/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/StoredResource.vue b/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/StoredResource.vue
index 27a564d..0a6af78 100644
--- a/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/StoredResource.vue
+++ b/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/StoredResource.vue
@@ -3,6 +3,7 @@
     <learning-resource
       v-for="res in resources"
       :key="res.id"
+      :id="res.id"
       :title="res.title"
       :description="res.description"
       :link="res.link"
diff --git a/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/TheResources.vue b/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/TheResources.vue
index f0e74fd..0e1aec5 100644
--- a/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/TheResources.vue
+++ b/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/TheResources.vue
@@ -56,6 +56,7 @@
     return {
       resources: this.storedResouces,
       addResource: this.addResource,
+      deleteResource: this.removeResource,
     };
   },
   methods: {
@@ -73,6 +74,12 @@
       this.storedResouces.unshift(newResource);
       this.selectedTab = 'stored-resources';
     },
+    removeResource(resId) {
+      this.storedResouces = this.storedResouces.filter(
+        (res) => res.id !== resId
+      );
+      console.log(this.storedResouces.length);
+    },
   },
 };
 </script>

--
Gitblit v1.8.0