From 451b79d5f179eaed45bcd64f1062575b7837051a Mon Sep 17 00:00:00 2001 From: Erik Borgeteien Hansen <erik@erikbhan.no> Date: Tue, 3 May 2022 16:28:14 +0200 Subject: [PATCH] lint --- .../CommunityComponents/CommunityHome.vue | 2 +- .../UserProfileComponents/UserItems.vue | 123 +++++++++--------- .../UserProfileComponents/UserProfile.vue | 1 - src/router/index.js | 2 +- src/views/UserProfileViews/UserItemsView.vue | 17 +-- .../pagination-template.spec.js | 28 ++-- 6 files changed, 81 insertions(+), 92 deletions(-) diff --git a/src/components/CommunityComponents/CommunityHome.vue b/src/components/CommunityComponents/CommunityHome.vue index 0f0790d..53fb604 100644 --- a/src/components/CommunityComponents/CommunityHome.vue +++ b/src/components/CommunityComponents/CommunityHome.vue @@ -116,7 +116,7 @@ export default { title: "", pricePerDay: 0, }, - + communityID: -1, community: {}, diff --git a/src/components/UserProfileComponents/UserItems.vue b/src/components/UserProfileComponents/UserItems.vue index 73ae23b..7b9a503 100644 --- a/src/components/UserProfileComponents/UserItems.vue +++ b/src/components/UserProfileComponents/UserItems.vue @@ -1,69 +1,64 @@ <template> - <div id = "headline" class = "text-xl md:text-2xl text-gray-600 font-medium w-full"> - Dine gjenstander + <div + id="headline" + class="text-xl md:text-2xl text-gray-600 font-medium w-full" + > + Dine gjenstander </div> <!-- Search field --> - <div class="relative" id="searchComponent"> - <span class="absolute inset-y-0 left-0 flex items-center pl-3"> - <svg class="w-5 h-5 text-gray-400" viewBox="0 0 24 24" fill="none"> - <path - d="M21 21L15 15M17 10C17 13.866 13.866 17 10 17C6.13401 17 3 13.866 3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10Z" - stroke="currentColor" - stroke-width="2" - stroke-linecap="round" - stroke-linejoin="round" - ></path> - </svg> - </span> + <div class="relative" id="searchComponent"> + <span class="absolute inset-y-0 left-0 flex items-center pl-3"> + <svg class="w-5 h-5 text-gray-400" viewBox="0 0 24 24" fill="none"> + <path + d="M21 21L15 15M17 10C17 13.866 13.866 17 10 17C6.13401 17 3 13.866 3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10Z" + stroke="currentColor" + stroke-width="2" + stroke-linecap="round" + stroke-linejoin="round" + ></path> + </svg> + </span> - <input - type="text" - id="searchInput" - class="w-full py-3 pl-10 pr-4 text-gray-700 bg-white border rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-primary-medium dark:focus:border-primary-medium focus:outline-none focus:ring" - placeholder="Search" - v-model="search" - @change="searchWritten" - /> - </div> - - <div class="absolute inset-x-0 px-5 py-3"> - <!-- ItemCards --> - <div class="flex items-center justify-center w-screen"> - <!-- Shows items based on pagination --> - <div - class="grid grid-flow-row-dense grid-cols-2 md:grid-cols-4 lg:grid-cols-5 w-full" - v-if="showItems" - > - <ItemCard - v-for="item in visibleItems" - :key="item" - :item="item" - /> - </div> + <input + type="text" + id="searchInput" + class="w-full py-3 pl-10 pr-4 text-gray-700 bg-white border rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-primary-medium dark:focus:border-primary-medium focus:outline-none focus:ring" + placeholder="Search" + v-model="search" + @change="searchWritten" + /> + </div> - <!-- Shows items based on search field input --> - <div - class="grid grid-flow-row-dense grid-cols-2 md:grid-cols-4 lg:grid-cols-5 w-full place-items-center" - v-if="showSearchedItems" - > - <ItemCard - v-for="item in searchedItems" - :key="item" - :item="item" - /> - </div> + <div class="absolute inset-x-0 px-5 py-3"> + <!-- ItemCards --> + <div class="flex items-center justify-center w-screen"> + <!-- Shows items based on pagination --> + <div + class="grid grid-flow-row-dense grid-cols-2 md:grid-cols-4 lg:grid-cols-5 w-full" + v-if="showItems" + > + <ItemCard v-for="item in visibleItems" :key="item" :item="item" /> </div> - <!-- pagination --> - <div class="flex justify-center" v-if="showItems"> - <PaginationTemplate - v-bind:items="items" - v-on:page:update="updatePage" - v-bind:currentPage="currentPage" - v-bind:pageSize="pageSize" - class="mt-10" - /> + + <!-- Shows items based on search field input --> + <div + class="grid grid-flow-row-dense grid-cols-2 md:grid-cols-4 lg:grid-cols-5 w-full place-items-center" + v-if="showSearchedItems" + > + <ItemCard v-for="item in searchedItems" :key="item" :item="item" /> </div> </div> + <!-- pagination --> + <div class="flex justify-center" v-if="showItems"> + <PaginationTemplate + v-bind:items="items" + v-on:page:update="updatePage" + v-bind:currentPage="currentPage" + v-bind:pageSize="pageSize" + class="mt-10" + /> + </div> + </div> </template> <script> import { GetUserListings, getItemPictures } from "@/utils/apiutil"; @@ -74,7 +69,7 @@ export default { name: "UserItems", components: { ItemCard, - PaginationTemplate + PaginationTemplate, }, data() { return { @@ -88,7 +83,7 @@ export default { }, showItems: true, showSearchedItems: false, - search: "", + search: "", //Variables connected to pagination currentPage: 0, pageSize: 12, @@ -119,7 +114,7 @@ export default { } } }, - //Pagination + //Pagination updatePage(pageNumber) { this.currentPage = pageNumber; this.updateVisibleTodos(); @@ -149,7 +144,6 @@ export default { async beforeMount() { await this.getUserListingsFromAPI(); this.updateVisibleTodos(); - }, }; </script> @@ -158,7 +152,6 @@ export default { #headline { display: block; margin-top: 10px; - margin-bottom: 10px; - + margin-bottom: 10px; } -</style> \ No newline at end of file +</style> diff --git a/src/components/UserProfileComponents/UserProfile.vue b/src/components/UserProfileComponents/UserProfile.vue index aa280f2..ff50ea7 100644 --- a/src/components/UserProfileComponents/UserProfile.vue +++ b/src/components/UserProfileComponents/UserProfile.vue @@ -33,7 +33,6 @@ > <li> <router-link - to="/user/userItems" class="block py-2 px-4 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white" >Mine gjenstander</router-link diff --git a/src/router/index.js b/src/router/index.js index 1f12a1c..348a238 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -121,7 +121,7 @@ const routes = [ path: "/user/userItems", name: "UserItems", component: () => import("../views/UserProfileViews/UserItemsView.vue"), - } + }, ]; const router = createRouter({ diff --git a/src/views/UserProfileViews/UserItemsView.vue b/src/views/UserProfileViews/UserItemsView.vue index 68183fe..8ac137d 100644 --- a/src/views/UserProfileViews/UserItemsView.vue +++ b/src/views/UserProfileViews/UserItemsView.vue @@ -3,16 +3,13 @@ </template> <script> -import UserItems from "@/components/UserProfileComponents/UserItems.vue" +import UserItems from "@/components/UserProfileComponents/UserItems.vue"; export default { - name: "UserItemsView", - components:{ - UserItems - } - -} + name: "UserItemsView", + components: { + UserItems, + }, +}; </script> -<style> - -</style> +<style></style> diff --git a/tests/unit/component-tests/base-component-tests/pagination-template.spec.js b/tests/unit/component-tests/base-component-tests/pagination-template.spec.js index c074ce4..91a7495 100644 --- a/tests/unit/component-tests/base-component-tests/pagination-template.spec.js +++ b/tests/unit/component-tests/base-component-tests/pagination-template.spec.js @@ -1,21 +1,21 @@ -import {mount} from "@vue/test-utils"; +import { mount } from "@vue/test-utils"; import Pagination from "@/components/BaseComponents/PaginationTemplate.vue"; describe("PaginationTemplate", () => { - let wrapper; + let wrapper; - beforeEach(() => { - wrapper = mount(Pagination, { - //passing prop to component - props: { - items: [], - currentPage: 0, - pageSize: 4, - }, - }); + beforeEach(() => { + wrapper = mount(Pagination, { + //passing prop to component + props: { + items: [], + currentPage: 0, + pageSize: 4, + }, }); + }); - it("is instantiated", () => { - expect(wrapper.exists()).toBeTruthy(); - }); + it("is instantiated", () => { + expect(wrapper.exists()).toBeTruthy(); + }); }); -- GitLab