Chore: Add code comments

This commit is contained in:
Nelson Chan 2022-05-31 16:24:39 +08:00
parent 43527f2f40
commit 179e3569b5
2 changed files with 45 additions and 5 deletions

View file

@ -15,28 +15,54 @@
</template> </template>
<script> <script>
/**
* Generic input field with a customizable action on the right.
* Action is passed in as a function.
*/
export default { export default {
props: { props: {
/**
* The value of the input field.
*/
modelValue: { modelValue: {
type: String, type: String,
default: "" default: ""
}, },
/**
* Whether the input field is enabled / disabled.
*/
enabled: { enabled: {
type: Boolean, type: Boolean,
default: true default: true
}, },
/**
* Placeholder text for the input field.
*/
placeholder: { placeholder: {
type: String, type: String,
default: "" default: ""
}, },
/**
* The icon displayed in the right button of the input field.
* Accepts a Font Awesome icon string identifier.
* @example "plus"
*/
icon: { icon: {
type: String, type: String,
required: true, required: true,
}, },
/**
* The input type of the input field.
* @example "email"
*/
type: { type: {
type: String, type: String,
default: "text", default: "text",
}, },
/**
* The action to be performed when the button is clicked.
* Action is passed in as a function.
*/
action: { action: {
type: Function, type: Function,
default: () => {}, default: () => {},
@ -44,6 +70,9 @@ export default {
}, },
emits: [ "update:modelValue" ], emits: [ "update:modelValue" ],
computed: { computed: {
/**
* Send value update to parent on change.
*/
model: { model: {
get() { get() {
return this.modelValue; return this.modelValue;
@ -53,10 +82,5 @@ export default {
} }
} }
}, },
created() {
},
methods: {
}
}; };
</script> </script>

View file

@ -57,6 +57,9 @@ export default {
data() { data() {
return { return {
/**
* Variable to store the input for new certificate expiry day.
*/
expiryNotifInput: null, expiryNotifInput: null,
}; };
}, },
@ -74,9 +77,22 @@ export default {
}, },
methods: { methods: {
/**
* Remove a day from expiry notification days.
* @param {number} day The day to remove.
*/
removeExpiryNotifDay(day) { removeExpiryNotifDay(day) {
this.settings.tlsExpiryNotifyDays = this.settings.tlsExpiryNotifyDays.filter(d => d !== day); this.settings.tlsExpiryNotifyDays = this.settings.tlsExpiryNotifyDays.filter(d => d !== day);
}, },
/**
* Add a new expiry notification day.
* Will verify:
* - day is not null or empty string.
* - day is a number.
* - day is > 0.
* - The day is not already in the list.
* @param {number} day The day number to add.
*/
addExpiryNotifDay(day) { addExpiryNotifDay(day) {
if (day != null && day !== "") { if (day != null && day !== "") {
const parsedDay = parseInt(day); const parsedDay = parseInt(day);