Skip to content

Commit

Permalink
Merge pull request #46 from solidtime-io/feature/dashboard_empty_states
Browse files Browse the repository at this point in the history
Feature/dashboard empty states
  • Loading branch information
Onatcer authored Apr 20, 2024
2 parents db9c0de + b44e8ef commit c5a6608
Show file tree
Hide file tree
Showing 19 changed files with 342 additions and 104 deletions.
6 changes: 6 additions & 0 deletions e2e/projects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,9 @@ test('test that creating and deleting a new project via the modal works', async
// Test that project task count is displayed correctly

// Test that active / archive / all filter works (once implemented)

// Edit Project Modal Test

// Add Project with billable rate

// Edit Project with billable rate
15 changes: 10 additions & 5 deletions resources/js/Components/Common/Project/ProjectCreateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Badge from '@/Components/Common/Badge.vue';
import { useClientsStore } from '@/utils/useClients';
import { storeToRefs } from 'pinia';
import ProjectColorSelector from '@/Components/Common/Project/ProjectColorSelector.vue';
import BillableRateInput from '@/Components/Common/BillableRateInput.vue';
const { createProject } = useProjectsStore();
const { clients } = storeToRefs(useClientsStore());
Expand Down Expand Up @@ -59,10 +60,11 @@ const currentClientName = computed(() => {
</template>

<template #content>
<div class="flex items-center space-x-4">
<ProjectColorSelector
v-model="project.color"></ProjectColorSelector>
<div class="col-span-6 sm:col-span-4 flex-1">
<div
class="sm:flex items-center space-y-2 sm:space-y-0 sm:space-x-4">
<div class="flex-1 flex items-center">
<ProjectColorSelector
v-model="project.color"></ProjectColorSelector>
<TextInput
id="projectName"
ref="projectNameInput"
Expand All @@ -74,7 +76,10 @@ const currentClientName = computed(() => {
required
autocomplete="projectName" />
</div>
<div class="col-span-6 sm:col-span-4">
<div class="sm:max-w-[120px]">
<BillableRateInput v-model="project.billable_rate" />
</div>
<div>
<ClientDropdown v-model="project.client_id">
<template #trigger>
<Badge size="large">
Expand Down
114 changes: 114 additions & 0 deletions resources/js/Components/Common/Project/ProjectEditModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<script setup lang="ts">
import TextInput from '@/Components/TextInput.vue';
import SecondaryButton from '@/Components/SecondaryButton.vue';
import DialogModal from '@/Components/DialogModal.vue';
import { computed, ref } from 'vue';
import type { CreateProjectBody, Project } from '@/utils/api';
import PrimaryButton from '@/Components/PrimaryButton.vue';
import { useProjectsStore } from '@/utils/useProjects';
import { useFocus } from '@vueuse/core';
import ClientDropdown from '@/Components/Common/Client/ClientDropdown.vue';
import { twMerge } from 'tailwind-merge';
import Badge from '@/Components/Common/Badge.vue';
import { useClientsStore } from '@/utils/useClients';
import { storeToRefs } from 'pinia';
import BillableRateInput from '@/Components/Common/BillableRateInput.vue';
import ProjectColorSelector from '@/Components/Common/Project/ProjectColorSelector.vue';
const { updateProject } = useProjectsStore();
const { clients } = storeToRefs(useClientsStore());
const show = defineModel('show', { default: false });
const saving = ref(false);
const props = defineProps<{
originalProject: Project;
}>();
const project = ref<CreateProjectBody>({
name: props.originalProject.name,
color: props.originalProject.color,
client_id: props.originalProject.client_id,
billable_rate: props.originalProject.billable_rate,
});
async function submit() {
await updateProject(props.originalProject.id, project.value);
show.value = false;
}
const projectNameInput = ref<HTMLInputElement | null>(null);
useFocus(projectNameInput, { initialValue: true });
const currentClientName = computed(() => {
if (project.value.client_id) {
return clients.value.find(
(client) => client.id === project.value.client_id
)?.name;
}
return 'No Client';
});
</script>

<template>
<DialogModal closeable :show="show" @close="show = false">
<template #title>
<div class="flex space-x-2">
<span> Edit Project {{ props.originalProject.name }} </span>
</div>
</template>

<template #content>
<div
class="sm:flex items-center space-y-2 sm:space-y-0 sm:space-x-4">
<div class="flex-1 flex items-center">
<div class="px-3">
<ProjectColorSelector
v-model="project.color"></ProjectColorSelector>
</div>
<TextInput
id="projectName"
ref="projectNameInput"
v-model="project.name"
type="text"
placeholder="Project Name"
@keydown.enter="submit()"
class="mt-1 block w-full"
required
autocomplete="projectName" />
</div>
<div class="sm:max-w-[120px]">
<BillableRateInput v-model="project.billable_rate" />
</div>
<div class="">
<ClientDropdown v-model="project.client_id">
<template #trigger>
<Badge size="large">
<div
:class="
twMerge('inline-block rounded-full')
"></div>
<span>
{{ currentClientName }}
</span>
</Badge>
</template>
</ClientDropdown>
</div>
</div>
</template>
<template #footer>
<SecondaryButton @click="show = false"> Cancel</SecondaryButton>

<PrimaryButton
class="ms-3"
:class="{ 'opacity-25': saving }"
:disabled="saving"
@click="submit">
Update Project
</PrimaryButton>
</template>
</DialogModal>
</template>

<style scoped></style>
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script setup lang="ts">
import Dropdown from '@/Components/Dropdown.vue';
import { TrashIcon } from '@heroicons/vue/20/solid';
import { TrashIcon, PencilSquareIcon } from '@heroicons/vue/20/solid';
import type { Project } from '@/utils/api';
const emit = defineEmits<{
delete: [];
edit: [];
}>();
const props = defineProps<{
project: Project;
Expand Down Expand Up @@ -33,10 +34,19 @@ const props = defineProps<{
@click.prevent="emit('delete')"
:aria-label="'Delete Project ' + props.project.name"
data-testid="project_delete"
class="flex items-center space-x-3 w-full px-3 py-2.5 text-start text-sm font-medium leading-5 text-white hover:bg-card-background-active focus:outline-none focus:bg-card-background-active transition duration-150 ease-in-out">
class="border-b border-card-background-separator flex items-center space-x-3 w-full px-3 py-2.5 text-start text-sm font-medium leading-5 text-white hover:bg-card-background-active focus:outline-none focus:bg-card-background-active transition duration-150 ease-in-out">
<TrashIcon class="w-5 text-icon-active"></TrashIcon>
<span>Delete</span>
</button>
<button
@click.prevent="emit('edit')"
:aria-label="'Edit Project ' + props.project.name"
data-testid="project_edit"
class="flex items-center space-x-3 w-full px-3 py-2.5 text-start text-sm font-medium leading-5 text-white hover:bg-card-background-active focus:outline-none focus:bg-card-background-active transition duration-150 ease-in-out">
<PencilSquareIcon
class="w-5 text-icon-active"></PencilSquareIcon>
<span>Edit</span>
</button>
</template>
</Dropdown>
</template>
Expand Down
16 changes: 14 additions & 2 deletions resources/js/Components/Common/Project/ProjectTableRow.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<script setup lang="ts">
import ProjectMoreOptionsDropdown from '@/Components/Common/Project/ProjectMoreOptionsDropdown.vue';
import type { Project } from '@/utils/api';
import { computed } from 'vue';
import { computed, ref } from 'vue';
import { CheckCircleIcon } from '@heroicons/vue/20/solid';
import { useClientsStore } from '@/utils/useClients';
import { storeToRefs } from 'pinia';
import { useTasksStore } from '@/utils/useTasks';
import { useProjectsStore } from '@/utils/useProjects';
import TableRow from '@/Components/TableRow.vue';
import ProjectEditModal from '@/Components/Common/Project/ProjectEditModal.vue';
import { formatCents } from '@/utils/money';
const { clients } = storeToRefs(useClientsStore());
const { tasks } = storeToRefs(useTasksStore());
Expand All @@ -30,9 +32,14 @@ const projectTasksCount = computed(() => {
function deleteProject() {
useProjectsStore().deleteProject(props.project.id);
}
const showEditProjectModal = ref(false);
</script>

<template>
<ProjectEditModal
v-model:show="showEditProjectModal"
:original-project="project"></ProjectEditModal>
<TableRow :href="route('projects.show', { project: project.id })">
<div
class="whitespace-nowrap flex items-center space-x-5 3xl:pl-12 py-4 pr-3 text-sm font-medium text-white pl-4 sm:pl-6 lg:pl-8 3xl:pl-12">
Expand All @@ -54,7 +61,11 @@ function deleteProject() {
<div v-else>No client</div>
</div>
<div class="whitespace-nowrap px-3 py-4 text-sm text-muted">
{{ project.billable_rate ?? '--' }}
{{
project.billable_rate
? formatCents(project.billable_rate)
: '--'
}}
</div>
<div
class="whitespace-nowrap px-3 py-4 text-sm text-muted flex space-x-1 items-center font-medium">
Expand All @@ -65,6 +76,7 @@ function deleteProject() {
class="relative whitespace-nowrap flex items-center pl-3 text-right text-sm font-medium sm:pr-0 pr-4 sm:pr-6 lg:pr-8 3xl:pr-12">
<ProjectMoreOptionsDropdown
:project="project"
@edit="showEditProjectModal = true"
@delete="deleteProject"></ProjectMoreOptionsDropdown>
</div>
</TableRow>
Expand Down
3 changes: 1 addition & 2 deletions resources/js/Components/Dashboard/DashboardCard.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<template>
<section class="flex flex-col">
<CardTitle :title="title" :icon="icon"></CardTitle>

<div
class="rounded-lg bg-card-background border border-card-border flex-1 flex items-stretch">
<div

Check warning on line 6 in resources/js/Components/Dashboard/DashboardCard.vue

View workflow job for this annotation

GitHub Actions / build

Delete `⏎···············`
class="divide-y divide-card-background-separator w-full flex flex-col">
class="w-full flex flex-col">
<slot></slot>
</div>
</div>
Expand Down
77 changes: 77 additions & 0 deletions resources/js/Components/Dashboard/DayOverviewCardChart.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<script setup lang="ts">
import VChart from 'vue-echarts';
import { ref } from 'vue';
const props = defineProps<{
history: number[];
}>();
const seriesData = props.history.map((el) => {
return {
value: el,
...{
itemStyle: {
borderWidth: 1,
borderColor: 'rgba(125,156,188,1)',
borderRadius: [2, 2, 0, 0],
color: 'rgba(125,156,188,1)',
},
},
};
});
const option = ref({
grid: {
top: 0,
right: 0,
left: 0,
bottom: 0,
},
backgroundColor: 'transparent',
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
markLine: {
lineStyle: {
color: 'rgba(125,156,188,0.1)',
type: 'dashed',
},
},
axisLine: {
lineStyle: {
color: 'transparent', // Set desired color here
},
},
axisLabel: {
fontSize: 16,
fontWeight: 600,
margin: 24,
fontFamily: 'Outfit, sans-serif',
},
axisTick: {
lineStyle: {
color: 'transparent', // Set desired color here
},
},
},
yAxis: {
type: 'value',
splitLine: {
lineStyle: {
color: 'transparent', // Set desired color here
},
},
},
series: [
{
data: seriesData,
type: 'bar',
},
],
});
</script>

<template>
<v-chart style="height: 20px; width: 80px" class="chart" :option="option" />
</template>

<style scoped></style>
Loading

0 comments on commit c5a6608

Please sign in to comment.