Vaahvue

Helpers

Introduction

VaahCms includes a variety of global "helper" Vue Functions and Components. Many of these Functions and Components are used in the Vue component; however, you are free to use them in your own applications if you find them convenient.

There are 2 file in Helpers directory.

  • GlobalComponents.js
  • VaahHelper.js

How to use Helpers?

First you have to check that your Module or Theme has helpers at VaahCms/Themes/BlogTheme/Vue/vaahvue/helpers.

If not found then download it from here.

GlobalComponents

In GlobalComponents.js, there are components that can be used anywhere in an application, including within other components.

Component NameDescription
LoaderComponent to create Placeholder/Table loading, like Facebook cards loading. Reference Url: Loader
ClickToCopyComponent to copy the content on click. Reference Url: Click to Copy
VueErrorsComponent to show Error messages in list.
VueMessagesComponent to show Success messages in list.
Loader

This component to create placeholder loading, like Facebook cards loading.

<Loader></Loader>
ClickToCopy

Click To Copy Vue.js component

<ClickToCopy text="ClickToCopy" :data="value"></ClickToCopy>
PropertiesDescriptionTypeDefault
textText to displayString
dataData to be copiedString
VueErrors

The component to display single error message or multiple error messages to user.

<VueErrors :list="list"></VueErrors>
"list":[
    'Error Message 1',
    'Error Message 2'
]
VueMessages

The component to display single message or multiple messages to user.

<VueMessages :list="list"></VueMessages>
"list":[
    'Message 1',
    'Message 2'
]

Vaah Helper

In VaahHelper.js, there are functions that can be used anywhere in Vue Components.

Example:

//---------------------------------------------------------------------
getList: function () {
    let url = this.ajax_url + '/list';
    let params = {
        q:'search'
    };
    // ajaxGet(url, params, callback)
    this.$vaah.ajaxGet(url, params, this.getListAfter);
},
//---------------------------------------------------------------------
getListAfter: function (data, res) {

},
//---------------------------------------------------------------------
Function NameParameterDescription
ajaxGeturl params callbackMethod is used to make an HTTP Get request
ajaxurl params callback queryMethod is used to make an HTTP Post request
processResponseresponseComponent to show Error messages in list.
processErrorerrorComponent to show Success messages in list.
updateRootStatestate_name state_valueComponent to show Success messages in list.
updateStateupdateComponent to show Success messages in list.
updateFiltersFromURLstate_name namespace routeComponent to show Success messages in list.
confirmCopiedDatadataComponent to show Success messages in list.
toastSuccessmessagesAccept messages in array format to show success notification.
toastErrorsmessagesAccept messages in array format to show error notification.
copydata confirm=trueCopy data with notification.
consoledata label='--->'Print data in console screen when debug is true.
updateCurrentURLquery routerComponent to show Success messages in list.
findAndReplaceStringfind_string replace_string full_stringFind and replace substring in string.
findAndReplacearr key dataFind and replace value in array.
updateArrayarray updatedElementComponent to show Success messages in list.
removeFromArrayarr elementRemove an element from Array.
removeEmptyobjComponent to show Success messages in list.
findInArrayByKeyarray key valueFind an element of array by key.
pluckFromObjectobj keyComponent to show Success messages in list.
toggleitemComponent to show Success messages in list.
testReturnComponent to show Success messages in list.
removeInArrayByKeyarray element keyRemove an element of array by key.
existInArrayarray elementCheck whether a given value exists in an array or not.
existInArrayByKeyarray element keyCheck whether a given value exists in specified key of array or not.
limitStringstring charactersComponent to show Success messages in list.
formatDatevalueConvert given date string in to YYYY-MM-DD format.
formatTimevalueConvert given date time string in to HH:mm format.
formatDateTimevalueConvert given date time string in to YYYY-MM-DD HH:mm format.
fromNowvalueComponent to show Success messages in list.
currentDateReturn Current Date in YYYY-MM-DD format.
currentDateTimeReturn Current Date Time in YYYY-MM-DD HH:mm:ss format.
dateForHumansvalueConvert given date time string in to ddd, MMM DD, YYYY format.
dateTimeForHumansvalueConvert given date time string in to YYYY-MM-DD hh:mm A format.
dateTimeForHumansWithDayvalueConvert given date time string in to YYYY MMM DD hh:mm A (dddd) format.
hasPermissionpermissions slugComponent to show Success messages in list.
paginateevent pageComponent to show Success messages in list.
makePaginationdataComponent to show Success messages in list.
paginateIsActivepageComponent to show Success messages in list.
toIndianFormatnStrComponent to show Success messages in list.
toLabelstrConvert string in to Title format.
toUpperCaseWordsstrConverts the first character of a string to uppercase..
currencyToSymbolcurrencyConvert currency code to symbol.
setCookiescookie_name value expiry_daysSet Cookie.
getCookiescookie_nameGet Cookie.
deleteCookiescookie_nameDelete Cookie of given name.
shiftToToparr key valueShift given key of array to Top.
timeDifferenceInSecondsstarted_at ended_atGet Two Time difference in Seconds.
secondsToHoursMinutsSecondssecondsConvert Seconds in Hours,Minutes and Seconds.
getTimeDifferenceInHHMMSSstarted_at ended_atGet Two Time difference in HHMMSS Format.
secondsToHourssecondsConvert Seconds in Hours.
getTimeDifferenceInDaysstarted_at ended_atGet Two Time difference in Days.
addTagToOneSignalUsertag_name tag_valueComponent to show Success messages in list.
deleteTagToOneSignalUsertag_nameComponent to show Success messages in list.
openUrlevent urlOpen url in new Tab.
remainingCharactersevent min_characters max_characters target_show_remainingComponent to show Success messages in list.
randomStringlength=6Generate random string of given length.
updateDocumentUrlTitletitle urlComponent to show Success messages in list.
strToSlugtitleGenerates a URL friendly slug from the given string.
isIntnDetermines whether the passed value is an Integer.
isFloatnDetermines whether the passed value is a Float.
fileNameFromUrlurlGet File name from URL.
fileExtensionFromUrlurlGet File extension from URL.
getClipboardValueComponent to show Success messages in list.
getNonReactiveObjectobjConvert Reactive Object to Non Reactive Object.
pluckarray keyReturn value of specified key from array object.
pusherAuthpusher_auth_url pusher_key pusher_cluster params=nullConvert Reactive Object to Non Reactive Object.
pusherSubscribepusher_instance channel_name callback=nullConvert Reactive Object to Non Reactive Object.
pusherListenEventchannel_instance event_name callback=nullConvert Reactive Object to Non Reactive Object.

Copyright © 2024