From b2f2a4a477b43fd3b8d9f1f567faf0a21eda4712 Mon Sep 17 00:00:00 2001 From: mv88 Date: Sun, 21 Nov 2021 17:43:32 +0100 Subject: [PATCH] feat: refactor form for routes, ropes and attempts --- assets/main.less | 27 +++++ components/attempts/AttemptsAddForm.vue | 24 ++-- components/attempts/AttemptsCards.vue | 31 +---- .../climbingRoutes/ClimbingRoutesAddForm.vue | 14 ++- .../climbingRoutes/ClimbingRoutesEditForm.vue | 5 +- components/climbingRoutes/RouteTable.vue | 3 - components/ropes/Empty.vue | 27 +++++ components/ropes/RopeAddForm.vue | 5 +- components/ropes/RopeEditForm.vue | 8 +- components/ropes/RopesCards.vue | 110 ++++++++++++++++++ components/ropes/RopesTable.vue | 97 +++++++++++++++ pages/attempts.vue | 4 +- pages/ropes.vue | 95 +++++---------- pages/routes.vue | 70 +++++------ store/index.js | 2 +- 15 files changed, 354 insertions(+), 168 deletions(-) create mode 100644 components/ropes/Empty.vue create mode 100644 components/ropes/RopesCards.vue create mode 100644 components/ropes/RopesTable.vue diff --git a/assets/main.less b/assets/main.less index 3402821..d7b6517 100644 --- a/assets/main.less +++ b/assets/main.less @@ -120,6 +120,33 @@ body, height: ~"-webkit-calc(100% - 60px)"; overflow: auto; width: 100%; + + .item-card { + width: 100%; + margin-bottom: 16px; + border: 1px solid yellowgreen; + } + .item-card .info { + width: 124px; + text-align: left; + margin-right: 8px; + } + .item-card .info-block { + display: flex; + } + .spaced { + justify-content: space-evenly; + } + @media only screen and (min-width: 600px) { + .item-card { + width: 330px; + margin: 0px; + } + } + .item-row { + display: flex; + flex-wrap: wrap; + } } @media (min-width: 1025px) { .filterItem { diff --git a/components/attempts/AttemptsAddForm.vue b/components/attempts/AttemptsAddForm.vue index 9ac93e1..391b9e2 100644 --- a/components/attempts/AttemptsAddForm.vue +++ b/components/attempts/AttemptsAddForm.vue @@ -158,6 +158,13 @@ - + diff --git a/components/climbingRoutes/ClimbingRoutesAddForm.vue b/components/climbingRoutes/ClimbingRoutesAddForm.vue index f7fcfb4..5e229bd 100644 --- a/components/climbingRoutes/ClimbingRoutesAddForm.vue +++ b/components/climbingRoutes/ClimbingRoutesAddForm.vue @@ -161,11 +161,15 @@ export default { }, }) .then((data) => { - this.$emit("updateListItem", { - ...data.result, - hasGrade: { french: this.form.french }, - }); + this.$emit("updateListItem"); }); + this.form = { + name: "", + sector: "", + french: "", + link: "", + city: "", + }; this.$bvModal.hide("climbingRouteAddForm"); }, onReset(event) { @@ -174,7 +178,7 @@ export default { this.form = { name: "", sector: "", - grade: "", + french: "", link: "", city: "", }; diff --git a/components/climbingRoutes/ClimbingRoutesEditForm.vue b/components/climbingRoutes/ClimbingRoutesEditForm.vue index b1688f7..f7e9ffb 100644 --- a/components/climbingRoutes/ClimbingRoutesEditForm.vue +++ b/components/climbingRoutes/ClimbingRoutesEditForm.vue @@ -178,10 +178,7 @@ export default { }, }) .then((data) => { - this.$emit("updateItemById", this.form.id, { - ...data.result, - hasGrade: { french: this.form.hasGrade.french }, - }); + this.$emit("updateListItem"); }) .catch((e) => { console.error(e); diff --git a/components/climbingRoutes/RouteTable.vue b/components/climbingRoutes/RouteTable.vue index e470425..88d2b17 100644 --- a/components/climbingRoutes/RouteTable.vue +++ b/components/climbingRoutes/RouteTable.vue @@ -82,9 +82,6 @@ export default { editItem(route) { this.$emit("editItem", route); }, - updateItemById(id) { - this.$emit("updateItemById", id); - }, deleteItemById(id) { this.$emit("deleteItemById", id); }, diff --git a/components/ropes/Empty.vue b/components/ropes/Empty.vue new file mode 100644 index 0000000..7ad829b --- /dev/null +++ b/components/ropes/Empty.vue @@ -0,0 +1,27 @@ + + + + + diff --git a/components/ropes/RopeAddForm.vue b/components/ropes/RopeAddForm.vue index 00300b7..b58ed92 100644 --- a/components/ropes/RopeAddForm.vue +++ b/components/ropes/RopeAddForm.vue @@ -174,7 +174,7 @@ export default { data() { return { previewImageSrc: "", - form: defaultValues, + form: { ...defaultValues }, }; }, methods: { @@ -206,8 +206,9 @@ export default { }, }) .then((data) => { - this.$emit("updateListItem", data.result.rope); + this.$emit("updateListItem"); }); + this.form = { ...defaultValues }; this.$bvModal.hide("addRopeForm"); }, onReset(event) { diff --git a/components/ropes/RopeEditForm.vue b/components/ropes/RopeEditForm.vue index 1885659..1a6d2ce 100644 --- a/components/ropes/RopeEditForm.vue +++ b/components/ropes/RopeEditForm.vue @@ -1,6 +1,6 @@