Skip to content

Commit

Permalink
use mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
NRayya committed Aug 1, 2024
1 parent 09b5ec4 commit bbbee16
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 69 deletions.
9 changes: 9 additions & 0 deletions resources/js/Mixins/Global.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,15 @@ export default {
}
return query.trim();
},
customDateFormat(date) {
if (!date) return "";
const day = String(date.getDate()).padStart(2, "0");
const month = String(date.getMonth() + 1).padStart(2, "0");
const year = date.getFullYear();
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
return `${day}/${month}/${year}, ${hours}:${minutes}`;
},
},

computed: {
Expand Down
25 changes: 4 additions & 21 deletions resources/js/Pages/Announcement/Partials/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
<Datepicker
v-model="createAnnouncementForm.start_time"
:min-date="new Date()"
:format="customFormat"
:preview-format="customFormat"
:format="customDateFormat"
:preview-format="customDateFormat"
></Datepicker>
<jet-input-error
:message="createAnnouncementForm.errors.start_time"
Expand All @@ -92,8 +92,8 @@
</label>
<Datepicker
v-model="createAnnouncementForm.end_time"
:format="customFormat"
:preview-format="customFormat"
:format="customDateFormat"
:preview-format="customDateFormat"
></Datepicker>
<jet-input-error
:message="createAnnouncementForm.errors.end_time"
Expand Down Expand Up @@ -166,23 +166,6 @@ export default {
props: [],
setup() {
// Custom format function
const customFormat = (date) => {
if (!date) return "";
const day = String(date.getDate()).padStart(2, "0");
const month = String(date.getMonth() + 1).padStart(2, "0");
const year = date.getFullYear();
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
return `${day}/${month}/${year}, ${hours}:${minutes}`;
};
return {
customFormat,
};
},
data() {
return {
createAnnouncementForm: this.$inertia.form({
Expand Down
24 changes: 4 additions & 20 deletions resources/js/Pages/Announcement/Partials/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
<Datepicker
v-model="editAnnouncementForm.start_time"
:min-date="new Date()"
:format="customFormat"
:preview-format="customFormat"
:format="customDateFormat"
:preview-format="customDateFormat"
></Datepicker>
<jet-input-error
:message="editAnnouncementForm.errors.start_time"
Expand All @@ -89,8 +89,8 @@
</label>
<Datepicker
v-model="editAnnouncementForm.end_time"
:format="customFormat"
:preview-format="customFormat"
:format="customDateFormat"
:preview-format="customDateFormat"
></Datepicker>
<jet-input-error
:message="editAnnouncementForm.errors.end_time"
Expand Down Expand Up @@ -161,22 +161,6 @@ export default {
},
props: [],
setup() {
// Custom format function
const customFormat = (date) => {
if (!date) return "";
const day = String(date.getDate()).padStart(2, "0");
const month = String(date.getMonth() + 1).padStart(2, "0");
const year = date.getFullYear();
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
return `${day}/${month}/${year}, ${hours}:${minutes}`;
};
return {
customFormat,
};
},
data() {
return {
Expand Down
15 changes: 2 additions & 13 deletions resources/js/Pages/Project/Show.vue
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,9 @@
v-model="
project.release_date
"
:format="customFormat"
:format="customDateFormat"
:preview-format="
customFormat
customDateFormat
"
></Datepicker>
<p
Expand Down Expand Up @@ -1102,21 +1102,10 @@ export default {
const manageAuthorElement = ref(null);
const manageCitationElement = ref(null);
// Custom format function
const customFormat = (date) => {
if (!date) return "";
const day = String(date.getDate()).padStart(2, "0");
const month = String(date.getMonth() + 1).padStart(2, "0");
const year = date.getFullYear();
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
return `${day}/${month}/${year}, ${hours}:${minutes}`;
};
return {
projectDetailsElement,
manageAuthorElement,
manageCitationElement,
customFormat,
};
},
data() {
Expand Down
17 changes: 2 additions & 15 deletions resources/js/Pages/Publish.vue
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@
v-model="publishForm.release_date"
@update:modelValue="updateProject"
:min-date="new Date()"
:format="customFormat"
:preview-format="customFormat"
:format="customDateFormat"
:preview-format="customDateFormat"
></Datepicker>
<p class="mt-1 text-sm text-gray-500">
Publish your data now immediately or set a
Expand Down Expand Up @@ -862,22 +862,9 @@ export default {
setup() {
const manageAuthorElement = ref(null);
const manageCitationElement = ref(null);
// Custom format function
const customFormat = (date) => {
if (!date) return "";
const day = String(date.getDate()).padStart(2, "0");
const month = String(date.getMonth() + 1).padStart(2, "0");
const year = date.getFullYear();
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
return `${day}/${month}/${year}, ${hours}:${minutes}`;
};
return {
manageAuthorElement,
manageCitationElement,
customFormat,
};
},
Expand Down

0 comments on commit bbbee16

Please sign in to comment.