Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
boco-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
idatt2106_2022_02
boco-frontend
Commits
0e3a9aef
Commit
0e3a9aef
authored
3 years ago
by
Titus Netland
Browse files
Options
Downloads
Patches
Plain Diff
My communities
parent
25498281
No related branches found
No related tags found
No related merge requests found
Pipeline
#180535
passed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/views/CommunityViews/MyCommunitiesView.vue
+97
-13
97 additions, 13 deletions
src/views/CommunityViews/MyCommunitiesView.vue
with
97 additions
and
13 deletions
src/views/CommunityViews/MyCommunitiesView.vue
+
97
−
13
View file @
0e3a9aef
<
template
>
<
template
>
<div>
<!-- My communities, with pagination -->
<div
id=
"myGroups"
>
<div
v-if=
"loggedIn"
>
<div>
Mine grupper:
</div>
<div
class=
"flex flex-row p-4 relative"
>
<group-list
:groupList=
"myGroups"
/>
<div
class=
"text-xl md:text-2xl text-gray-600 font-medium w-full"
>
Mine grupper
</div>
<UserAddIcon
class=
"cursor-pointer max-h-6 max-w-6 float-right grow text-primary-dark"
@
click=
"$router.push('/newCommunity')"
alt=
"Opprett ny gruppe"
/>
</div>
<CommunityList
:communities=
"visibleMyCommunities"
:member=
"true"
/>
<!-- pagination my communities -->
<div
class=
"flex justify-center"
>
<PaginationTemplate
v-bind:items=
"myCommunities"
v-on:page:update=
"updatePageMyCommunities"
v-bind:currentPage=
"currentPageMyCommunities"
v-bind:pageSize=
"pageSizeMyCommunities"
class=
"mt-10 mb-5"
/>
</div>
</div>
</div>
</div>
<!-- Public communities, with search and pagination -->
<p
class=
"text-xl md:text-2xl text-gray-600 font-medium w-full p-4"
>
Offentlige grupper
</p>
<!-- Search field -->
<div
class=
"relative mt-1 mx-2"
id=
"searchComponent"
>
<span
class=
"absolute inset-y-0 left-0 flex items-center pl-3"
>
<div
class=
"w-5 h-5 text-gray-400"
>
<SearchIcon/>
</div>
</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>
<!-- Public communities list, two lists, one for when it's searched and one for pagination -->
<!-- pagination Public communities -->
</
template
>
</
template
>
<
script
>
<
script
>
import
GroupList
from
"
@/components/CommunityComponents/CommunityList.vue
"
;
import
CommunityList
from
"
@/components/CommunityComponents/CommunityList.vue
"
;
import
{
getMyGroups
}
from
"
@/utils/apiutil
"
;
import
{
UserAddIcon
,
SearchIcon
}
from
"
@heroicons/vue/outline
"
;
import
PaginationTemplate
from
"
@/components/BaseComponents/PaginationTemplate
"
;
import
CommunityService
from
"
@/services/community.service
"
;
export
default
{
export
default
{
name
:
"
HomeView
"
,
data
()
{
data
()
{
return
{
return
{
myGroups
:
[],
loggedIn
:
false
,
myCommunities
:
[],
search
:
""
,
showSearched
:
false
,
showPaginated
:
true
,
//Variables connected to pagination
currentPageMyCommunities
:
0
,
pageSizeMyCommunities
:
5
,
visibleMyCommunities
:
[],
};
};
},
},
components
:
{
components
:
{
GroupList
,
CommunityList
,
UserAddIcon
,
PaginationTemplate
,
SearchIcon
,
},
},
methods
:
{
methods
:
{
async
getMyGroups
()
{
//Pagination
this
.
myGroups
=
await
getMyGroups
();
updatePageMyCommunities
(
pageNumber
)
{
this
.
currentPageMyCommunities
=
pageNumber
;
this
.
updateVisibleCommunities
();
},
updateVisibleCommunities
()
{
this
.
visibleMyCommunities
=
this
.
myCommunities
.
slice
(
this
.
currentPageMyCommunities
*
this
.
pageSizeMyCommunities
,
this
.
currentPageMyCommunities
*
this
.
pageSizeMyCommunities
+
this
.
pageSizeMyCommunities
);
// if we have 0 visible communities, go back a page
if
(
this
.
visibleMyCommunities
.
length
===
0
&&
this
.
currentPageMyCommunities
>
0
)
{
this
.
updatePageMyCommunities
(
this
.
currentPageMyCommunities
-
1
);
}
},
searchWritten
()
{
//This method triggers when search input field is changed
this
.
showPaginated
=
this
.
search
.
length
<
1
;
this
.
showSearched
=
this
.
search
.
length
>
0
;
},
async
load
()
{
this
.
loggedIn
=
this
.
$store
.
state
.
user
.
token
!==
null
;
if
(
!
this
.
loggedIn
)
return
;
this
.
myCommunities
=
await
CommunityService
.
getUserCommunities
();
},
},
},
beforeMount
()
{
this
.
getMyGroups
();
},
},
};
};
</
script
>
</
script
>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment