Skip to content

Commit

Permalink
add employees_can_see_billable_rates setting to organization settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Onatcer committed Oct 1, 2024
1 parent b013e89 commit efc89cf
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
33 changes: 32 additions & 1 deletion resources/js/Pages/Teams/Partials/OrganizationBillableRate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useOrganizationStore } from '@/utils/useOrganization';
import { storeToRefs } from 'pinia';
import OrganizationBillableRateModal from '@/Components/Common/Organization/OrganizationBillableRateModal.vue';
import { getOrganizationCurrencyString } from '@/utils/money';
import { Checkbox } from '@/packages/ui/src';
const store = useOrganizationStore();
const { fetchOrganization, updateOrganization } = store;
Expand All @@ -17,13 +18,16 @@ const saving = ref(false);
const organizationBody = ref<UpdateOrganizationBody>({
name: '',
billable_rate: null as number | null,
employees_can_see_billable_rates: false,
});
onMounted(async () => {
await fetchOrganization();
organizationBody.value = {
name: organization.value?.name ?? '',
billable_rate: organization.value?.billable_rate,
employees_can_see_billable_rates:
organization.value?.employees_can_see_billable_rates ?? false,
};
});
const showConfirmationModal = ref(false);
Expand All @@ -34,6 +38,17 @@ async function submit() {
saving.value = false;
showConfirmationModal.value = false;
}
function checkForConfirmationModal() {
if (
organizationBody.value.billable_rate ===
organization.value?.billable_rate
) {
submit();
} else {
showConfirmationModal.value = true;
}
}
</script>

<template>
Expand Down Expand Up @@ -64,9 +79,25 @@ async function submit() {
name="organizationBillableRate"></BillableRateInput>
</div>
</div>

<div class="col-span-6">
<div class="col-span-6 sm:col-span-4">
<div class="flex items-center space-x-2">
<Checkbox
v-if="organization"
v-model:checked="
organizationBody.employees_can_see_billable_rates
"
id="organizationShowBillableRatesToEmployees"></Checkbox>
<InputLabel
for="organizationShowBillableRatesToEmployees"
value="Show Billable Rates to Employees" />
</div>
</div>
</div>
</template>
<template #actions>
<PrimaryButton @click="showConfirmationModal = true"
<PrimaryButton @click="checkForConfirmationModal"
>Save</PrimaryButton
>
</template>
Expand Down
2 changes: 2 additions & 0 deletions resources/js/packages/api/src/openapi.json.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ const OrganizationResource = z
name: z.string(),
is_personal: z.boolean(),
billable_rate: z.union([z.number(), z.null()]),
employees_can_see_billable_rates: z.boolean(),
})
.passthrough();
const OrganizationUpdateRequest = z
.object({
name: z.string().max(255),
billable_rate: z.union([z.number(), z.null()]).optional(),
employees_can_see_billable_rates: z.boolean().optional(),
})
.passthrough();
const ProjectResource = z
Expand Down
5 changes: 5 additions & 0 deletions resources/js/packages/ui/src/Input/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const props = defineProps({
type: String,
default: null,
},
id: {
type: String,
default: null,
},
});
const proxyChecked = computed({
Expand All @@ -29,6 +33,7 @@ const proxyChecked = computed({
<input
v-model="proxyChecked"
type="checkbox"
:id="id"
:value="value"
class="rounded bg-input-background border-input-border text-indigo-600 shadow-sm focus:ring-indigo-500" />
</template>

0 comments on commit efc89cf

Please sign in to comment.