Added mixins to capitalize/prettify text

This commit is contained in:
Fabio Manganiello 2022-04-10 01:50:13 +02:00
parent 655d56f4da
commit b2ff66aa62
Signed by: blacklight
GPG key ID: D90FBA7F76362774
2 changed files with 19 additions and 1 deletions

View file

@ -5,10 +5,11 @@ import DateTime from "@/utils/DateTime";
import Events from "@/utils/Events";
import Notification from "@/utils/Notification";
import Screen from "@/utils/Screen";
import Text from "@/utils/Text";
import Types from "@/utils/Types";
export default {
name: "Utils",
mixins: [Api, Cookies, Notification, Events, DateTime, Screen, Types],
mixins: [Api, Cookies, Notification, Events, DateTime, Screen, Text, Types],
}
</script>

View file

@ -0,0 +1,17 @@
<script>
export default {
name: "Text",
methods: {
capitalize(text) {
if (!text?.length)
return text
return text.charAt(0).toUpperCase() + text.slice(1)
},
prettify(text) {
return text.split('_').map((t) => this.capitalize(t)).join(' ')
},
},
}
</script>