moved time format local to config
This commit is contained in:
@@ -41,7 +41,6 @@ module.exports = {
|
|||||||
config: "",
|
config: "",
|
||||||
current_time: "",
|
current_time: "",
|
||||||
is_loading_time: false,
|
is_loading_time: false,
|
||||||
is_24_hr_format: false,
|
|
||||||
selected_date: null,
|
selected_date: null,
|
||||||
selected_hours: `${new Date().getHours()}`,
|
selected_hours: `${new Date().getHours()}`,
|
||||||
selected_minutes: `${new Date().getMinutes()}`,
|
selected_minutes: `${new Date().getMinutes()}`,
|
||||||
@@ -59,7 +58,7 @@ module.exports = {
|
|||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
get_current_time: function () {
|
get_current_time: function () {
|
||||||
if (this.is_24_hr_format == true) {
|
if (this.config.admin.time_format == true) {
|
||||||
return this.current_time;
|
return this.current_time;
|
||||||
} else {
|
} else {
|
||||||
const [hour, minutes, seconds] = this.current_time.split(":");
|
const [hour, minutes, seconds] = this.current_time.split(":");
|
||||||
@@ -187,6 +186,16 @@ module.exports = {
|
|||||||
this.$dispatch("config-changed");
|
this.$dispatch("config-changed");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
change_time_format: async function () {
|
||||||
|
try {
|
||||||
|
this.config.admin.time_format = !this.config.admin.time_format;
|
||||||
|
await api.put("config/save", this.config);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Update failed:", error);
|
||||||
|
alert("Update failed");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
change_date_time: async function () {
|
change_date_time: async function () {
|
||||||
if (!this.selected_date || !this.selected_hours === "" || !this.selected_minutes === "") {
|
if (!this.selected_date || !this.selected_hours === "" || !this.selected_minutes === "") {
|
||||||
alert("Please enter all required fields.");
|
alert("Please enter all required fields.");
|
||||||
@@ -196,7 +205,7 @@ module.exports = {
|
|||||||
let hours = parseInt(this.selected_hours, 10);
|
let hours = parseInt(this.selected_hours, 10);
|
||||||
const minutes = parseInt(this.selected_minutes, 10);
|
const minutes = parseInt(this.selected_minutes, 10);
|
||||||
|
|
||||||
if (this.is_24_hr_format) {
|
if (this.config.admin.time_format) {
|
||||||
if (hours < 0 || hours > 23 || minutes < 0 || minutes > 59) {
|
if (hours < 0 || hours > 23 || minutes < 0 || minutes > 59) {
|
||||||
return alert("Invalid Time");
|
return alert("Invalid Time");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ script#admin-general-view-template(type="text/x-template")
|
|||||||
span(v-else) {{ get_current_time }}
|
span(v-else) {{ get_current_time }}
|
||||||
|
|
||||||
label
|
label
|
||||||
input(type="checkbox" v-model="is_24_hr_format")
|
input(type="checkbox" v-model="config.admin.time_format" @change="change_time_format")
|
||||||
| Use 24-hour format
|
| Use 24-hour format
|
||||||
|
|
||||||
.pure-form
|
.pure-form
|
||||||
@@ -83,8 +83,8 @@ script#admin-general-view-template(type="text/x-template")
|
|||||||
v-model="selected_hours"
|
v-model="selected_hours"
|
||||||
placeholder="HH"
|
placeholder="HH"
|
||||||
maxlength="2"
|
maxlength="2"
|
||||||
:min="is_24_hr_format ? 0 : 1"
|
:min="config.admin.time_format ? 0 : 1"
|
||||||
:max="is_24_hr_format ? 23 : 12"
|
:max="config.admin.time_format ? 23 : 12"
|
||||||
style="width:45px"
|
style="width:45px"
|
||||||
required
|
required
|
||||||
)
|
)
|
||||||
@@ -101,7 +101,7 @@ script#admin-general-view-template(type="text/x-template")
|
|||||||
required
|
required
|
||||||
)
|
)
|
||||||
|
|
||||||
select(:disabled="is_24_hr_format" v-model="selected_meridiem" style="width:65px")
|
select(:disabled="config.admin.time_format" v-model="selected_meridiem" style="width:65px")
|
||||||
option(value="AM" selected) AM
|
option(value="AM" selected) AM
|
||||||
option(value="PM") PM
|
option(value="PM") PM
|
||||||
|
|
||||||
|
|||||||
@@ -673,7 +673,7 @@
|
|||||||
"type": "bool",
|
"type": "bool",
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
"time-format": {
|
"time_format": {
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"default": true
|
"default": true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user