2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-12-05 16:39:03 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
<template>
|
2019-02-15 13:19:17 +00:00
|
|
|
<div class="team-area">
|
2019-08-29 11:05:22 +01:00
|
|
|
<div class="team-area__header">
|
2019-09-26 14:36:12 +01:00
|
|
|
<HeaderArea
|
|
|
|
:header-state="headerState"
|
2019-10-15 14:22:41 +01:00
|
|
|
:selected-project-members-count="selectedProjectMembersLength"
|
|
|
|
@onSuccessAction="resetPaginator"
|
2019-10-02 10:42:12 +01:00
|
|
|
/>
|
2018-12-05 16:39:03 +00:00
|
|
|
</div>
|
2019-10-02 10:42:12 +01:00
|
|
|
<div class="team-area__container" id="team-container" v-if="isTeamAreaShown">
|
2019-09-23 12:31:42 +01:00
|
|
|
<SortingListHeader :on-header-click-callback="onHeaderSectionClickCallback"/>
|
2019-08-29 11:05:22 +01:00
|
|
|
<div class="team-area__container__content">
|
2019-09-26 14:36:12 +01:00
|
|
|
<VList
|
2019-09-23 12:31:42 +01:00
|
|
|
:data-set="projectMembers"
|
|
|
|
:item-component="getItemComponent"
|
2019-10-02 10:42:12 +01:00
|
|
|
:on-item-click="onMemberClick"
|
|
|
|
/>
|
2018-12-12 16:19:20 +00:00
|
|
|
</div>
|
2019-09-26 14:36:12 +01:00
|
|
|
<VPagination
|
|
|
|
v-if="totalPageCount > 1"
|
2019-08-19 12:20:38 +01:00
|
|
|
class="pagination-area"
|
|
|
|
ref="pagination"
|
2019-09-23 12:31:42 +01:00
|
|
|
:total-page-count="totalPageCount"
|
2019-10-02 10:42:12 +01:00
|
|
|
:on-page-click-callback="onPageClick"
|
|
|
|
/>
|
2018-12-05 16:39:03 +00:00
|
|
|
</div>
|
2019-10-02 10:42:12 +01:00
|
|
|
<div class="team-area__empty-search-result-area" v-if="isEmptySearchResultShown">
|
2019-09-26 14:36:12 +01:00
|
|
|
<h1 class="team-area__empty-search-result-area__title">No results found</h1>
|
2019-10-23 13:26:39 +01:00
|
|
|
<EmptySearchResultIcon class="team-area__empty-search-result-area__image"/>
|
2019-02-15 13:19:17 +00:00
|
|
|
</div>
|
2018-12-05 16:39:03 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2019-09-09 11:33:39 +01:00
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
|
|
|
|
2019-09-26 14:36:12 +01:00
|
|
|
import VList from '@/components/common/VList.vue';
|
|
|
|
import VPagination from '@/components/common/VPagination.vue';
|
2019-09-09 11:33:39 +01:00
|
|
|
import HeaderArea from '@/components/team/HeaderArea.vue';
|
|
|
|
import ProjectMemberListItem from '@/components/team/ProjectMemberListItem.vue';
|
|
|
|
import SortingListHeader from '@/components/team/SortingListHeader.vue';
|
|
|
|
|
2019-10-23 13:26:39 +01:00
|
|
|
import EmptySearchResultIcon from '@/../static/images/common/emptySearchResult.svg';
|
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
import { SortDirection } from '@/types/common';
|
|
|
|
import { ProjectMember, ProjectMemberHeaderState, ProjectMemberOrderBy } from '@/types/projectMembers';
|
|
|
|
import { NOTIFICATION_ACTIONS, PM_ACTIONS } from '@/utils/constants/actionNames';
|
|
|
|
|
2019-10-17 11:34:45 +01:00
|
|
|
const {
|
|
|
|
FETCH,
|
|
|
|
DELETE,
|
|
|
|
TOGGLE_SELECTION,
|
|
|
|
CLEAR,
|
|
|
|
CLEAR_SELECTION,
|
|
|
|
SET_SEARCH_QUERY,
|
|
|
|
SET_SORT_BY,
|
|
|
|
SET_SORT_DIRECTION,
|
|
|
|
} = PM_ACTIONS;
|
|
|
|
|
2019-10-02 10:42:12 +01:00
|
|
|
declare interface ResetPagination {
|
|
|
|
resetPageIndex(): void;
|
|
|
|
}
|
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
@Component({
|
|
|
|
components: {
|
|
|
|
HeaderArea,
|
2019-09-26 14:36:12 +01:00
|
|
|
VList,
|
|
|
|
VPagination,
|
2019-09-09 11:33:39 +01:00
|
|
|
SortingListHeader,
|
2019-10-23 13:26:39 +01:00
|
|
|
EmptySearchResultIcon,
|
2019-09-13 15:58:18 +01:00
|
|
|
},
|
2019-09-09 11:33:39 +01:00
|
|
|
})
|
|
|
|
export default class ProjectMembersArea extends Vue {
|
|
|
|
private FIRST_PAGE = 1;
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-10-02 10:42:12 +01:00
|
|
|
public $refs!: {
|
|
|
|
pagination: HTMLElement & ResetPagination;
|
|
|
|
};
|
|
|
|
|
2019-10-17 11:34:45 +01:00
|
|
|
public async mounted(): Promise<void> {
|
|
|
|
await this.$store.dispatch(FETCH, 1);
|
|
|
|
}
|
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
public async beforeDestroy(): Promise<void> {
|
2019-10-17 11:34:45 +01:00
|
|
|
await this.$store.dispatch(CLEAR);
|
2019-09-09 11:33:39 +01:00
|
|
|
}
|
2019-09-04 16:02:39 +01:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
public onMemberClick(member: ProjectMember): void {
|
2019-10-25 11:01:03 +01:00
|
|
|
if (this.$store.getters.selectedProject.ownerId !== member.user.id) {
|
|
|
|
this.$store.dispatch(TOGGLE_SELECTION, member);
|
|
|
|
}
|
2019-09-09 11:33:39 +01:00
|
|
|
}
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
public get projectMembers(): ProjectMember[] {
|
|
|
|
return this.$store.state.projectMembersModule.page.projectMembers;
|
|
|
|
}
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
public get getItemComponent() {
|
|
|
|
return ProjectMemberListItem;
|
|
|
|
}
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
public get projectMembersTotalCount(): number {
|
|
|
|
return this.$store.state.projectMembersModule.page.totalCount;
|
|
|
|
}
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
public get projectMembersCount(): number {
|
|
|
|
return this.$store.state.projectMembersModule.page.projectMembers.length;
|
|
|
|
}
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
public get totalPageCount(): number {
|
|
|
|
return this.$store.state.projectMembersModule.page.pageCount;
|
|
|
|
}
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-10-15 14:22:41 +01:00
|
|
|
public get selectedProjectMembersLength(): number {
|
|
|
|
return this.$store.state.projectMembersModule.selectedProjectMembersEmails.length;
|
2019-09-09 11:33:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public get headerState(): number {
|
2019-10-15 14:22:41 +01:00
|
|
|
if (this.selectedProjectMembersLength > 0) {
|
2019-09-09 11:33:39 +01:00
|
|
|
return ProjectMemberHeaderState.ON_SELECT;
|
2019-07-18 14:39:39 +01:00
|
|
|
}
|
2019-08-09 12:19:49 +01:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
return ProjectMemberHeaderState.DEFAULT;
|
|
|
|
}
|
2019-08-09 12:19:49 +01:00
|
|
|
|
2019-10-02 10:42:12 +01:00
|
|
|
public get isTeamAreaShown(): boolean {
|
|
|
|
return this.projectMembersCount > 0 || this.projectMembersTotalCount > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get isEmptySearchResultShown(): boolean {
|
|
|
|
return this.projectMembersCount === 0 && this.projectMembersTotalCount === 0;
|
|
|
|
}
|
|
|
|
|
2019-09-13 10:48:27 +01:00
|
|
|
public async onPageClick(index: number): Promise<void> {
|
2019-09-09 11:33:39 +01:00
|
|
|
try {
|
2019-10-17 11:34:45 +01:00
|
|
|
await this.$store.dispatch(FETCH, index);
|
2019-09-26 14:36:12 +01:00
|
|
|
} catch (error) {
|
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, `Unable to fetch project members. ${error.message}`);
|
2019-08-09 12:19:49 +01:00
|
|
|
}
|
2019-09-09 11:33:39 +01:00
|
|
|
}
|
2019-08-19 12:20:38 +01:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
public async onHeaderSectionClickCallback(sortBy: ProjectMemberOrderBy, sortDirection: SortDirection): Promise<void> {
|
2019-10-17 11:34:45 +01:00
|
|
|
await this.$store.dispatch(SET_SORT_BY, sortBy);
|
|
|
|
await this.$store.dispatch(SET_SORT_DIRECTION, sortDirection);
|
2019-09-09 11:33:39 +01:00
|
|
|
try {
|
2019-10-17 11:34:45 +01:00
|
|
|
await this.$store.dispatch(FETCH, this.FIRST_PAGE);
|
2019-09-09 11:33:39 +01:00
|
|
|
} catch (error) {
|
2019-10-15 13:24:53 +01:00
|
|
|
await this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, `Unable to fetch project members. ${error.message}`);
|
2019-08-19 12:20:38 +01:00
|
|
|
}
|
|
|
|
|
2019-10-15 14:22:41 +01:00
|
|
|
this.resetPaginator();
|
|
|
|
}
|
|
|
|
|
|
|
|
public resetPaginator(): void {
|
2019-10-02 10:42:12 +01:00
|
|
|
if (this.totalPageCount > 1) {
|
|
|
|
this.$refs.pagination.resetPageIndex();
|
|
|
|
}
|
2019-07-08 14:45:25 +01:00
|
|
|
}
|
2019-09-09 11:33:39 +01:00
|
|
|
}
|
2018-12-05 16:39:03 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2019-02-15 13:19:17 +00:00
|
|
|
.team-area {
|
2019-08-29 11:05:22 +01:00
|
|
|
padding: 40px 65px 55px 64px;
|
2019-09-26 14:36:12 +01:00
|
|
|
font-family: 'font_regular';
|
2019-08-29 11:05:22 +01:00
|
|
|
|
|
|
|
&__header {
|
|
|
|
width: 100%;
|
|
|
|
background-color: #F5F6FA;
|
|
|
|
top: auto;
|
|
|
|
}
|
2019-08-19 12:20:38 +01:00
|
|
|
|
2019-08-29 11:05:22 +01:00
|
|
|
&__container {
|
|
|
|
max-height: 84vh;
|
|
|
|
|
|
|
|
&__content {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
margin-bottom: 20px;
|
|
|
|
flex-direction: column;
|
2019-09-26 14:36:12 +01:00
|
|
|
height: 49.4vh;
|
2019-08-29 11:05:22 +01:00
|
|
|
}
|
|
|
|
}
|
2019-08-19 12:20:38 +01:00
|
|
|
|
2019-08-29 11:05:22 +01:00
|
|
|
&__empty-search-result-area {
|
2019-09-26 14:36:12 +01:00
|
|
|
height: 100%;
|
2019-08-19 12:20:38 +01:00
|
|
|
display: flex;
|
2019-08-29 11:05:22 +01:00
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2019-08-19 12:20:38 +01:00
|
|
|
flex-direction: column;
|
|
|
|
|
2019-09-26 14:36:12 +01:00
|
|
|
&__title {
|
2019-08-29 11:05:22 +01:00
|
|
|
font-family: 'font_bold';
|
|
|
|
font-size: 32px;
|
|
|
|
line-height: 39px;
|
|
|
|
margin-top: 100px;
|
|
|
|
}
|
|
|
|
|
2019-09-26 14:36:12 +01:00
|
|
|
&__image {
|
2019-08-29 11:05:22 +01:00
|
|
|
margin-top: 40px;
|
|
|
|
}
|
|
|
|
}
|
2019-01-30 13:18:07 +00:00
|
|
|
}
|
2019-08-19 12:20:38 +01:00
|
|
|
|
|
|
|
.pagination-area {
|
|
|
|
margin-left: -25px;
|
|
|
|
}
|
|
|
|
|
2019-09-20 11:21:22 +01:00
|
|
|
@media screen and (max-width: 1024px) {
|
|
|
|
.team-area {
|
|
|
|
padding: 40px 40px 55px 40px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-29 11:05:22 +01:00
|
|
|
@media screen and (max-height: 800px) {
|
|
|
|
.team-area {
|
2019-08-19 12:20:38 +01:00
|
|
|
|
2019-08-29 11:05:22 +01:00
|
|
|
&__container {
|
|
|
|
|
|
|
|
&__content {
|
|
|
|
height: 41.5vh !important;
|
|
|
|
}
|
2018-12-05 16:39:03 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-10 10:55:40 +01:00
|
|
|
}
|
2019-04-08 23:34:28 +01:00
|
|
|
</style>
|