Skip to content

Commit d880717

Browse files
committed
add TimeEntryCreateModal and MoreOptionsDropdown to ui package
1 parent df0f3b2 commit d880717

File tree

6 files changed

+38
-26
lines changed

6 files changed

+38
-26
lines changed

resources/js/Pages/Time.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { useProjectsStore } from '@/utils/useProjects';
2424
import TimeEntryGroupedTable from '@/packages/ui/src/TimeEntry/TimeEntryGroupedTable.vue';
2525
import { useTagsStore } from '@/utils/useTags';
2626
import { useClientsStore } from '@/utils/useClients';
27-
import TimeEntryCreateModal from '@/Components/Common/TimeEntry/TimeEntryCreateModal.vue';
27+
import TimeEntryCreateModal from '@/packages/ui/src/TimeEntry/TimeEntryCreateModal.vue';
2828
import { getOrganizationCurrencyString } from '@/utils/money';
2929
import TimeEntryMassActionRow from '@/packages/ui/src/TimeEntry/TimeEntryMassActionRow.vue';
3030
import type { UpdateMultipleTimeEntriesChangeset } from '@/packages/api/src';
@@ -123,7 +123,12 @@ function deleteSelected() {
123123
:enableEstimatedTime="isAllowedToPerformPremiumAction()"
124124
:createProject="createProject"
125125
:createClient="createClient"
126+
:createTag="createTag"
126127
:createTimeEntry="createTimeEntry"
128+
:projects
129+
:tasks
130+
:tags
131+
:clients
127132
v-model:show="showManualTimeEntryModal"></TimeEntryCreateModal>
128133
<AppLayout title="Dashboard" data-testid="time_view">
129134
<MainContainer

resources/js/packages/ui/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/packages/ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solidtime/ui",
3-
"version": "0.0.9",
3+
"version": "0.0.10",
44
"description": "Package containing the solidtime ui components",
55
"main": "./dist/solidtime-ui-lib.umd.cjs",
66
"module": "./dist/solidtime-ui-lib.js",

resources/js/packages/ui/src/Input/TimePicker.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,12 @@ const emit = defineEmits(['changed']);
9090
9191
useFocus(timeInput, { initialValue: props.focus });
9292
93-
const getStartOptions = computed(() => {
93+
type TimeOption = {
94+
timestamp: string;
95+
name: string;
96+
};
97+
98+
const getStartOptions = computed<TimeOption[]>(() => {
9499
// options for the entire day in 15 minute intervals
95100
const options = [];
96101
for (let hour = 0; hour < 24; hour++) {
@@ -141,8 +146,8 @@ const closestValue = computed({
141146
:class="twMerge('mine-w-0 w-24', size === 'large' && 'w-28')"
142147
v-model="closestValue"
143148
v-model:open="open"
144-
:get-key-from-item="(item) => item.timestamp"
145-
:get-name-for-item="(item) => item.name"
149+
:get-key-from-item="(item: TimeOption) => item.timestamp"
150+
:get-name-for-item="(item: TimeOption) => item.name"
146151
:items="getStartOptions">
147152
<template #trigger>
148153
<TextInput

resources/js/Components/Common/TimeEntry/TimeEntryCreateModal.vue renamed to resources/js/packages/ui/src/TimeEntry/TimeEntryCreateModal.vue

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,31 @@ import DialogModal from '@/packages/ui/src/DialogModal.vue';
55
import { computed, nextTick, ref, watch } from 'vue';
66
import PrimaryButton from '@/packages/ui/src/Buttons/PrimaryButton.vue';
77
import TimeTrackerProjectTaskDropdown from '@/packages/ui/src/TimeTracker/TimeTrackerProjectTaskDropdown.vue';
8-
import { getCurrentUserId } from '@/utils/useUser';
98
import InputLabel from '@/packages/ui/src/Input/InputLabel.vue';
109
import { TagIcon } from '@heroicons/vue/20/solid';
1110
import {
1211
getDayJsInstance,
1312
getLocalizedDayJs,
1413
} from '@/packages/ui/src/utils/time';
15-
import { storeToRefs } from 'pinia';
16-
import { useTasksStore } from '@/utils/useTasks';
17-
import { useProjectsStore } from '@/utils/useProjects';
18-
import { useTagsStore } from '@/utils/useTags';
1914
import type {
2015
CreateClientBody,
2116
CreateProjectBody,
2217
Project,
2318
Client,
2419
CreateTimeEntryBody,
2520
} from '@/packages/api/src';
26-
import { useClientsStore } from '@/utils/useClients';
2721
import TimePicker from '@/packages/ui/src/Input/TimePicker.vue';
2822
import { getOrganizationCurrencyString } from '@/utils/money';
2923
import { canCreateProjects } from '@/utils/permissions';
3024
import TagDropdown from '@/packages/ui/src/Tag/TagDropdown.vue';
3125
import { Badge } from '@/packages/ui/src';
3226
import BillableIcon from '@/packages/ui/src/Icons/BillableIcon.vue';
33-
import SelectDropdown from '../../../packages/ui/src/Input/SelectDropdown.vue';
27+
import SelectDropdown from '@/packages/ui/src/Input/SelectDropdown.vue';
3428
import DatePicker from '@/packages/ui/src/Input/DatePicker.vue';
3529
import DurationHumanInput from '@/packages/ui/src/Input/DurationHumanInput.vue';
3630
3731
import { InformationCircleIcon } from '@heroicons/vue/20/solid';
38-
const projectStore = useProjectsStore();
39-
const { projects } = storeToRefs(projectStore);
40-
const taskStore = useTasksStore();
41-
const { tasks } = storeToRefs(taskStore);
42-
const clientStore = useClientsStore();
43-
const { clients } = storeToRefs(clientStore);
32+
import type { Tag, Task } from '@/packages/api';
4433
4534
const show = defineModel('show', { default: false });
4635
const saving = ref(false);
@@ -52,6 +41,11 @@ const props = defineProps<{
5241
) => Promise<void>;
5342
createClient: (client: CreateClientBody) => Promise<Client | undefined>;
5443
createProject: (project: CreateProjectBody) => Promise<Project | undefined>;
44+
createTag: (name: string) => Promise<Tag | undefined>;
45+
tags: Tag[];
46+
projects: Project[];
47+
tasks: Task[];
48+
clients: Client[];
5549
}>();
5650
5751
const description = ref<HTMLInputElement | null>(null);
@@ -72,7 +66,6 @@ const timeEntryDefaultValues = {
7266
billable: false,
7367
start: getDayJsInstance().utc().subtract(1, 'h').format(),
7468
end: getDayJsInstance().utc().format(),
75-
user_id: getCurrentUserId(),
7669
};
7770
7871
const timeEntry = ref({ ...timeEntryDefaultValues });
@@ -101,17 +94,18 @@ async function submit() {
10194
localEnd.value = getLocalizedDayJs(timeEntryDefaultValues.end).format();
10295
show.value = false;
10396
}
104-
const { tags } = storeToRefs(useTagsStore());
105-
async function createTag(tag: string) {
106-
return await useTagsStore().createTag(tag);
107-
}
10897
10998
const billableProxy = computed({
11099
get: () => (timeEntry.value.billable ? 'true' : 'false'),
111100
set: (value: string) => {
112101
timeEntry.value.billable = value === 'true';
113102
},
114103
});
104+
105+
type BillableOption = {
106+
label: string;
107+
value: string;
108+
};
115109
</script>
116110

117111
<template>
@@ -183,8 +177,12 @@ const billableProxy = computed({
183177
<div class="flex-col">
184178
<SelectDropdown
185179
v-model="billableProxy"
186-
:get-key-from-item="(item) => item.value"
187-
:get-name-for-item="(item) => item.label"
180+
:get-key-from-item="
181+
(item: BillableOption) => item.value
182+
"
183+
:get-name-for-item="
184+
(item: BillableOption) => item.label
185+
"
188186
:items="[
189187
{
190188
label: 'Billable',

resources/js/packages/ui/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import Badge from './Badge.vue';
2626
import Checkbox from './Input/Checkbox.vue';
2727
import TimeEntryGroupedTable from './TimeEntry/TimeEntryGroupedTable.vue';
2828
import TimeEntryMassActionRow from './TimeEntry/TimeEntryMassActionRow.vue';
29+
import TimeEntryCreateModal from './TimeEntry/TimeEntryCreateModal.vue';
30+
import MoreOptionsDropdown from './MoreOptionsDropdown.vue';
2931

3032
export {
3133
money,
@@ -48,4 +50,6 @@ export {
4850
Checkbox,
4951
TimeEntryGroupedTable,
5052
TimeEntryMassActionRow,
53+
MoreOptionsDropdown,
54+
TimeEntryCreateModal,
5155
};

0 commit comments

Comments
 (0)