2020-03-18 17:07:29 +00:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
2019-05-15 16:01:41 +01:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
<template>
|
2020-03-18 17:07:29 +00:00
|
|
|
<div class="project-details">
|
2020-05-06 13:47:39 +01:00
|
|
|
<div class="project-details__title-area">
|
|
|
|
<h1 class="project-details__title-area__title">{{ name }}</h1>
|
|
|
|
<span class="project-details__title-area__edit" v-if="!isEditing" @click="toggleEditing">
|
|
|
|
Edit Description
|
|
|
|
</span>
|
2020-03-18 17:07:29 +00:00
|
|
|
</div>
|
2020-05-06 13:47:39 +01:00
|
|
|
<p class="project-details__description" v-if="!isEditing">{{ displayedDescription }}</p>
|
|
|
|
<div class="project-details__editing" v-else>
|
|
|
|
<input
|
|
|
|
class="project-details__editing__input"
|
|
|
|
placeholder="Enter a description for your project. Descriptions are limited to 100 characters."
|
|
|
|
@input="onInput"
|
|
|
|
@change="onInput"
|
|
|
|
v-model="value"
|
2020-03-18 17:07:29 +00:00
|
|
|
/>
|
2020-05-06 13:47:39 +01:00
|
|
|
<span class="project-details__editing__limit">{{value.length}}/{{MAX_SYMBOLS}}</span>
|
|
|
|
<VButton
|
|
|
|
class="project-details__editing__cancel-button"
|
|
|
|
label="Cancel"
|
|
|
|
width="73px"
|
|
|
|
height="33px"
|
|
|
|
:on-press="toggleEditing"
|
|
|
|
is-white="true"
|
|
|
|
/>
|
|
|
|
<VButton
|
|
|
|
class="project-details__editing__save-button"
|
|
|
|
label="Save"
|
|
|
|
width="75px"
|
|
|
|
height="35px"
|
|
|
|
:on-press="onSaveButtonClick"
|
2020-03-18 17:07:29 +00:00
|
|
|
/>
|
2019-07-09 16:04:51 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-05-15 16:01:41 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2019-09-09 11:33:39 +01:00
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
import HeaderedInput from '@/components/common/HeaderedInput.vue';
|
2019-09-26 14:36:12 +01:00
|
|
|
import VButton from '@/components/common/VButton.vue';
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
import { PROJECTS_ACTIONS } from '@/store/modules/projects';
|
|
|
|
import { UpdateProjectModel } from '@/types/projects';
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
@Component({
|
|
|
|
components: {
|
2019-09-26 14:36:12 +01:00
|
|
|
VButton,
|
2019-09-09 11:33:39 +01:00
|
|
|
HeaderedInput,
|
2019-09-13 15:58:18 +01:00
|
|
|
},
|
2019-09-09 11:33:39 +01:00
|
|
|
})
|
2020-03-18 17:07:29 +00:00
|
|
|
export default class ProjectDetails extends Vue {
|
2020-05-06 13:47:39 +01:00
|
|
|
public readonly MAX_SYMBOLS: number = 100;
|
|
|
|
|
2020-03-18 17:07:29 +00:00
|
|
|
public isEditing: boolean = false;
|
2020-05-06 13:47:39 +01:00
|
|
|
public value: string = '';
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2020-02-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
* Returns selected project name.
|
|
|
|
*/
|
2019-09-09 11:33:39 +01:00
|
|
|
public get name(): string {
|
|
|
|
return this.$store.getters.selectedProject.name;
|
|
|
|
}
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2020-02-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
* Returns selected project description from store.
|
|
|
|
*/
|
2019-10-01 11:10:18 +01:00
|
|
|
public get storedDescription(): string {
|
|
|
|
return this.$store.getters.selectedProject.description;
|
|
|
|
}
|
|
|
|
|
2020-03-18 17:07:29 +00:00
|
|
|
/**
|
|
|
|
* Returns displayed project description on UI.
|
|
|
|
*/
|
2019-10-01 11:10:18 +01:00
|
|
|
public get displayedDescription(): string {
|
2020-02-14 15:35:10 +00:00
|
|
|
return this.storedDescription ?
|
|
|
|
this.storedDescription :
|
2019-09-09 11:33:39 +01:00
|
|
|
'No description yet. Please enter some information about the project if any.';
|
|
|
|
}
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2020-02-14 15:35:10 +00:00
|
|
|
/**
|
2020-05-06 13:47:39 +01:00
|
|
|
* Triggers on input.
|
2020-02-14 15:35:10 +00:00
|
|
|
*/
|
2020-05-06 13:47:39 +01:00
|
|
|
public onInput({ target }): void {
|
|
|
|
if (target.value.length < this.MAX_SYMBOLS) {
|
|
|
|
this.value = target.value;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.value = target.value.slice(0, this.MAX_SYMBOLS);
|
2019-09-09 11:33:39 +01:00
|
|
|
}
|
2019-07-18 14:39:39 +01:00
|
|
|
|
2020-02-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
* Updates project description.
|
|
|
|
*/
|
2019-09-09 11:33:39 +01:00
|
|
|
public async onSaveButtonClick(): Promise<void> {
|
|
|
|
try {
|
2020-05-06 13:47:39 +01:00
|
|
|
const updatedProject = new UpdateProjectModel(this.$store.getters.selectedProject.id, this.value);
|
2020-03-18 17:07:29 +00:00
|
|
|
await this.$store.dispatch(PROJECTS_ACTIONS.UPDATE, updatedProject);
|
2019-09-26 14:36:12 +01:00
|
|
|
} catch (error) {
|
2019-10-28 17:33:06 +00:00
|
|
|
await this.$notify.error(`Unable to update project description. ${error.message}`);
|
2019-10-07 15:51:33 +01:00
|
|
|
|
|
|
|
return;
|
2019-07-18 14:39:39 +01:00
|
|
|
}
|
2019-09-09 11:33:39 +01:00
|
|
|
|
|
|
|
this.toggleEditing();
|
2019-10-28 17:33:06 +00:00
|
|
|
await this.$notify.success('Project updated successfully!');
|
2019-09-09 11:33:39 +01:00
|
|
|
}
|
|
|
|
|
2020-02-14 15:35:10 +00:00
|
|
|
/**
|
2020-03-18 17:07:29 +00:00
|
|
|
* Toggles project description editing state.
|
2020-02-14 15:35:10 +00:00
|
|
|
*/
|
2019-10-01 11:10:18 +01:00
|
|
|
public toggleEditing(): void {
|
2019-09-09 11:33:39 +01:00
|
|
|
this.isEditing = !this.isEditing;
|
2020-05-06 13:47:39 +01:00
|
|
|
this.value = this.storedDescription;
|
2019-07-18 14:39:39 +01:00
|
|
|
}
|
2019-09-09 11:33:39 +01:00
|
|
|
}
|
2019-05-15 16:01:41 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2019-09-26 14:36:12 +01:00
|
|
|
h1,
|
2020-03-18 17:07:29 +00:00
|
|
|
p {
|
|
|
|
margin: 0;
|
2019-09-26 14:36:12 +01:00
|
|
|
}
|
|
|
|
|
2019-07-10 10:55:40 +01:00
|
|
|
.project-details {
|
2020-05-06 13:47:39 +01:00
|
|
|
padding: 35px;
|
|
|
|
width: calc(100% - 70px);
|
2019-10-28 15:59:19 +00:00
|
|
|
font-family: 'font_regular', sans-serif;
|
2020-03-18 17:07:29 +00:00
|
|
|
background-color: #fff;
|
|
|
|
border-radius: 6px;
|
2020-05-06 13:47:39 +01:00
|
|
|
margin-bottom: 36px;
|
2019-10-28 15:59:19 +00:00
|
|
|
|
2020-05-06 13:47:39 +01:00
|
|
|
&__title-area {
|
2019-10-28 15:59:19 +00:00
|
|
|
display: flex;
|
2019-07-10 10:55:40 +01:00
|
|
|
align-items: center;
|
2020-03-18 17:07:29 +00:00
|
|
|
justify-content: space-between;
|
2019-09-26 14:36:12 +01:00
|
|
|
|
2020-05-06 13:47:39 +01:00
|
|
|
&__title {
|
|
|
|
font-size: 22px;
|
|
|
|
line-height: 27px;
|
|
|
|
color: #000;
|
|
|
|
word-break: break-all;
|
2019-07-10 10:55:40 +01:00
|
|
|
}
|
2019-10-28 15:59:19 +00:00
|
|
|
|
2020-05-06 13:47:39 +01:00
|
|
|
&__edit {
|
|
|
|
font-size: 14px;
|
|
|
|
line-height: 14px;
|
|
|
|
color: #909ba8;
|
|
|
|
cursor: pointer;
|
2019-10-28 15:59:19 +00:00
|
|
|
|
2020-05-06 13:47:39 +01:00
|
|
|
&:hover {
|
|
|
|
color: #2683ff;
|
2019-07-10 10:55:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-28 15:59:19 +00:00
|
|
|
|
2020-05-06 13:47:39 +01:00
|
|
|
&__description {
|
|
|
|
margin-top: 30px;
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 24px;
|
|
|
|
color: #354049;
|
|
|
|
width: available;
|
|
|
|
overflow-y: scroll;
|
|
|
|
word-break: break-word;
|
|
|
|
max-height: 100px;
|
|
|
|
}
|
2019-10-28 15:59:19 +00:00
|
|
|
|
2020-05-06 13:47:39 +01:00
|
|
|
&__editing {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
margin-top: 20px;
|
|
|
|
width: calc(100% - 7px);
|
|
|
|
border-radius: 6px;
|
|
|
|
background-color: #f5f6fa;
|
|
|
|
padding-right: 7px;
|
|
|
|
|
|
|
|
&__input {
|
|
|
|
font-weight: normal;
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 21px;
|
|
|
|
flex: 1;
|
|
|
|
height: 48px;
|
|
|
|
width: available;
|
|
|
|
text-indent: 20px;
|
|
|
|
background-color: #f5f6fa;
|
|
|
|
border-color: #f5f6fa;
|
|
|
|
border-radius: 6px;
|
|
|
|
}
|
2019-10-28 15:59:19 +00:00
|
|
|
|
2020-05-06 13:47:39 +01:00
|
|
|
&__limit {
|
|
|
|
font-size: 14px;
|
|
|
|
line-height: 21px;
|
|
|
|
color: rgba(0, 0, 0, 0.3);
|
|
|
|
margin: 0 15px;
|
2019-07-10 10:55:40 +01:00
|
|
|
}
|
2019-10-28 15:59:19 +00:00
|
|
|
|
2020-05-06 13:47:39 +01:00
|
|
|
&__save-button {
|
|
|
|
margin-left: 10px;
|
2019-07-10 10:55:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-15 16:01:41 +01:00
|
|
|
</style>
|