Skip to content

Commit

Permalink
move multiselect components, week start and timezon functions to ui p…
Browse files Browse the repository at this point in the history
…ackage
  • Loading branch information
Onatcer committed Aug 21, 2024
1 parent 2fa2590 commit 248cdbc
Show file tree
Hide file tree
Showing 15 changed files with 2,009 additions and 144 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import MultiselectDropdown from '@/Components/Common/MultiselectDropdown.vue';
import MultiselectDropdown from '@/packages/ui/src/Input/MultiselectDropdown.vue';
import { storeToRefs } from 'pinia';
import type { Client } from '@/packages/api/src';
import { useClientsStore } from '@/utils/useClients';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import MultiselectDropdown from '@/Components/Common/MultiselectDropdown.vue';
import MultiselectDropdown from '@/packages/ui/src/Input/MultiselectDropdown.vue';
import { useMembersStore } from '@/utils/useMembers';
import { storeToRefs } from 'pinia';
import type { Member } from '@/packages/api/src';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import MultiselectDropdown from '@/Components/Common/MultiselectDropdown.vue';
import MultiselectDropdown from '@/packages/ui/src/Input/MultiselectDropdown.vue';
import { storeToRefs } from 'pinia';
import { useProjectsStore } from '@/utils/useProjects';
import type { Project } from '@/packages/api/src';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import MultiselectDropdown from '@/Components/Common/MultiselectDropdown.vue';
import MultiselectDropdown from '@/packages/ui/src/Input/MultiselectDropdown.vue';
import { storeToRefs } from 'pinia';
import type { Task } from '@/packages/api/src';
import { useTasksStore } from '@/utils/useTasks';
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Components/Dashboard/ThisWeekOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import LinearGradient from 'zrender/lib/graphic/LinearGradient';
import ProjectsChartCard from '@/Components/Dashboard/ProjectsChartCard.vue';
import { formatHumanReadableDuration } from '@/packages/ui/src/utils/time';
import { formatCents } from '@/packages/ui/src/utils/money';
import { getWeekStart } from '@/utils/useUser';
import { getWeekStart } from '@/packages/ui/src/utils/settings';
import { useCssVar } from '@vueuse/core';
import { getOrganizationCurrencyString } from '@/utils/money';
Expand Down
2,060 changes: 1,954 additions & 106 deletions resources/js/packages/ui/package-lock.json

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions resources/js/packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,27 @@
"type": "module",
"author": "solidtime",
"license": "AGPL-3.0",
"devDependencies": {
"@vitejs/plugin-vue": "^5.1.2",
"@vue/tsconfig": "^0.5.1",
"autoprefixer": "^10.4.20",
"postcss-import": "^15.1.0"
},
"peerDependencies": {
"@floating-ui/vue": "^1.1.4",
"tailwind-merge": "^2.5.2",
"@heroicons/vue": "^2.1.5",
"@types/node": "^22.4.1",
"@vitejs/plugin-vue": "^5.1.2",
"@vue/tsconfig": "^0.5.1",
"@vueuse/core": "^10.11.0",
"dayjs": "^1.11.13",
"parse-duration": "^1.1.0",
"postcss": "^8.4.14",
"postcss-nesting": "^12.1.0",
"tailwind-merge": "^2.5.2",
"tailwindcss": "^3.1.0",
"typescript": "^5.5.4",
"vite": "^5.4.1",
"vue": "^3.4.38",
"vue-tsc": "^2.0.29"
"vue-tsc": "^2.0.29",
"@zodios/core": "^10.9.6"
}
}
8 changes: 8 additions & 0 deletions resources/js/packages/ui/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
plugins: {
'postcss-import': {},
'tailwindcss/nesting': {},
tailwindcss: {},
autoprefixer: {},
},
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts" generic="T">
import Dropdown from '@/packages/ui/src/Input/Dropdown.vue';
import { type Component, computed, nextTick, ref, watch } from 'vue';
import MultiselectDropdownItem from '@/Components/Common/MultiselectDropdownItem.vue';
import MultiselectDropdownItem from '@/packages/ui/src/Input/MultiselectDropdownItem.vue';
const model = defineModel<string[]>({
default: [],
Expand Down
4 changes: 2 additions & 2 deletions resources/js/packages/ui/src/Tag/TagDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PlusCircleIcon } from '@heroicons/vue/20/solid';
import Dropdown from '@/packages/ui/src/Input/Dropdown.vue';
import { type Component, computed, nextTick, ref, watch } from 'vue';
import TagCreateModal from '@/packages/ui/src/Tag/TagCreateModal.vue';
import MultiselectDropdownItem from '@/Components/Common/MultiselectDropdownItem.vue';
import MultiselectDropdownItem from '@/packages/ui/src/Input/MultiselectDropdownItem.vue';
import type { Tag } from '@/packages/api/src';
import type { Placement } from '@floating-ui/vue';
Expand Down Expand Up @@ -67,7 +67,7 @@ watch(open, (isOpen) => {
});
const filteredTags = computed(() => {
return sortedTags.value.filter((tag) => {
return sortedTags.value.filter((tag: Tag) => {
return tag.name
.toLowerCase()
.includes(searchValue.value?.toLowerCase()?.trim() || '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,28 @@ const props = defineProps<{
}>();
function updateTimeEntryDescription(description: string) {
const updatedTimeEntries = props.timeEntry.timeEntries.map((entry) => {
const updatedTimeEntries = props.timeEntry.timeEntries.map((entry: TimeEntry) => {

Check warning on line 43 in resources/js/packages/ui/src/TimeEntry/TimeEntryAggregateRow.vue

View workflow job for this annotation

GitHub Actions / build

Insert `⏎········`
return { ...entry, description };

Check warning on line 44 in resources/js/packages/ui/src/TimeEntry/TimeEntryAggregateRow.vue

View workflow job for this annotation

GitHub Actions / build

Replace `········` with `············`
});

Check warning on line 45 in resources/js/packages/ui/src/TimeEntry/TimeEntryAggregateRow.vue

View workflow job for this annotation

GitHub Actions / build

Replace `}` with `····}⏎····`
props.updateTimeEntries(updatedTimeEntries);
}
function updateTimeEntryTags(tags: string[]) {
const updatedTimeEntries = props.timeEntry.timeEntries.map((entry) => {
const updatedTimeEntries = props.timeEntry.timeEntries.map((entry: TimeEntry) => {

Check warning on line 50 in resources/js/packages/ui/src/TimeEntry/TimeEntryAggregateRow.vue

View workflow job for this annotation

GitHub Actions / build

Insert `⏎········`
return { ...entry, tags };

Check warning on line 51 in resources/js/packages/ui/src/TimeEntry/TimeEntryAggregateRow.vue

View workflow job for this annotation

GitHub Actions / build

Replace `········` with `············`
});

Check warning on line 52 in resources/js/packages/ui/src/TimeEntry/TimeEntryAggregateRow.vue

View workflow job for this annotation

GitHub Actions / build

Replace `}` with `····}⏎····`
props.updateTimeEntries(updatedTimeEntries);
}
function updateTimeEntryBillable(billable: boolean) {
const updatedTimeEntries = props.timeEntry.timeEntries.map((entry) => {
const updatedTimeEntries = props.timeEntry.timeEntries.map((entry: TimeEntry) => {

Check warning on line 57 in resources/js/packages/ui/src/TimeEntry/TimeEntryAggregateRow.vue

View workflow job for this annotation

GitHub Actions / build

Insert `⏎········`
return { ...entry, billable };

Check warning on line 58 in resources/js/packages/ui/src/TimeEntry/TimeEntryAggregateRow.vue

View workflow job for this annotation

GitHub Actions / build

Replace `········` with `············`
});

Check warning on line 59 in resources/js/packages/ui/src/TimeEntry/TimeEntryAggregateRow.vue

View workflow job for this annotation

GitHub Actions / build

Replace `}` with `····}⏎····`
props.updateTimeEntries(updatedTimeEntries);
}
function updateProjectAndTask(projectId: string, taskId: string) {
const updatedTimeEntries = props.timeEntry.timeEntries.map((entry) => {
const updatedTimeEntries = props.timeEntry.timeEntries.map((entry: TimeEntry) => {

Check warning on line 64 in resources/js/packages/ui/src/TimeEntry/TimeEntryAggregateRow.vue

View workflow job for this annotation

GitHub Actions / build

Insert `⏎········`
return { ...entry, project_id: projectId, task_id: taskId };
});
props.updateTimeEntries(updatedTimeEntries);
Expand Down
19 changes: 19 additions & 0 deletions resources/js/packages/ui/src/utils/settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export function getWeekStart() {
const weekStart = window?.getWeekStartSetting() as string;

if (!weekStart) {
throw new Error(
'Please make sure to provide the current user week start setting as a vue inject (week_start)'
);
}
return weekStart;
}
export function getUserTimezone() {
const timezone = window?.getTimezoneSetting() as string;
if (!timezone) {
throw new Error(
'Please make sure to provide the current user timezone as a vue inject (timezone)'
);
}
return timezone;
}
2 changes: 1 addition & 1 deletion resources/js/packages/ui/src/utils/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import isYesterday from 'dayjs/plugin/isYesterday';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
import weekOfYear from 'dayjs/plugin/weekOfYear';
import { getUserTimezone, getWeekStart } from '@/utils/useUser';
import { getUserTimezone, getWeekStart } from './settings';
import updateLocale from 'dayjs/plugin/updateLocale';
import { computed } from 'vue';

Expand Down
22 changes: 1 addition & 21 deletions resources/js/utils/useUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ function getCurrentUserId() {
return page.props.auth.user.id;
}

function getWeekStart() {
const weekStart = window?.getWeekStartSetting() as string;

if (!weekStart) {
throw new Error(
'Please make sure to provide the current user week start setting as a vue inject (week_start)'
);
}
return weekStart;
}

function getCurrentOrganizationId() {
return page.props.auth.user.current_team_id;
Expand All @@ -37,21 +27,11 @@ function getCurrentRole() {
)?.membership.role;
}

function getUserTimezone() {
const timezone = window?.getTimezoneSetting() as string;
if (!timezone) {
throw new Error(
'Please make sure to provide the current user timezone as a vue inject (timezone)'
);
}
return timezone;
}


export {
getCurrentOrganizationId,
getCurrentUserId,
getUserTimezone,
getWeekStart,
getCurrentMembershipId,
getCurrentRole,
};

0 comments on commit 248cdbc

Please sign in to comment.