Sort by field/column of Vue JS data for Laravel Nova

<template> <divv-on:click=”$emit(‘sort-list’, 0.1)”role=”button”class=”sortable-title”> <spanclass=”title”v-html=”title”></span> <spanv-if=”order_type==’desc'”><iclass=”fa fa-arrow-circle-down”aria-hidden=”true”></i></span> <spanv-if=”order_type==’asc'”><iclass=”fa fa-arrow-circle-up”aria-hidden=”true”></i></span> <spanv-if=”order_type==null”><iclass=”fa fa-sort”aria-hidden=”true”></i></span> </div> </template> <script> export default { props: [ ‘title’, ‘order_type’, ], data() { return { // } }, mounted() { // }, methods: { // }, } </script>   Use it in the parent component: import SortableField from “./SortableField” export default { components :{ SortableField …

How to set variable in .map() in ReactJS

render() { this.yearTransactionNum=0; return ( …. {this.props.transactions.length > 0 && this.props.transactions.map((transaction,index) => { if ( this.props.invoiceYear == ‘All’ || transaction.date_formated.indexOf(this.props.invoiceYear) != -1 ) { this.yearTransactionNum++; return ( <React.Fragment> ….. ) else { … } {(this.props.transactions.length > 0 && this.yearTransactionNum == 0) && <div className=’text-center col-md-12 p-5′><i class=”fa fa-exclamation-triangle mr-2″aria-hidden=”true”></i>No Transaction for Year {this.props.invoiceYear}</div> }

How to automatically scroll to the top of the page after render() in React JS

Assume we have a long list page, click a link after scroll down few screens and the new page scroll bar stay at the middle !! How to automatically scroll to the top of the page after render() in React JS componentDidUpdate() { // ReactDOM.findDOMNode(this).scrollTop = 0 // ReactDom.findDOMNode(this).scrollIntoView(); window.scrollTo(0, 0) } Tested and on window.scrollTo(0, 0) works …

Sort array by custom string value and number

        // sort function         function wpd_last_name_sort( $a, $b ) {          $a_last = end(explode(‘ ‘, $a->post_title));          $b_last = end(explode(‘ ‘, $b->post_title));              return strcasecmp( $a_last, $b_last );         }         function wpd_menu_order_sort( $a, $b ) {             $a_last = $a->menu_order;          $b_last = $b->menu_order;          return $a_last > $b_last;         }                     // sort posts         $menu_order_tags = [             ‘cardiothoracic-surgery’, …

Silverstripe RESTful service API cross origin Access-Control-Allow-Origin issue

Add below to index.php for test if ( strpos($_SERVER[‘REQUEST_URI’], ‘/api/v1/’ ) !== false ){ // only allow GET, OPTIONS for all api header(‘Access-Control-Allow-Origin: *’); header(‘Access-Control-Allow-Methods: GET, OPTIONS’); header(‘Access-Control-Allow-Credentials: true’); header(‘Access-Control-Allow-Headers: Authorization, Content-Type, x-xsrf-token, x_csrftoken, x-csrf-token, x-requested-with, Cache-Control, X-Requested-With, Origin, Accept’); header(‘Content-Type: application/json’); if ($_SERVER[‘REQUEST_METHOD’] === ‘OPTIONS’) { echojson_encode($_SERVER[‘REQUEST_URI’]); exit(); } } // Build request and …

HTML code for the middle dot

There’s actually six variants of this HTML code for the middle dot: char description unicode html html entity utf-8 · Middle Dot U+00B7 &#183; &middot; C2 B7 • Bullet U+2022 &#8226; &bull; E2 80 A2 ‧ Hyphenation Point U+2027 &#8321; E2 80 A7 ∙ Bullet Operator U+2219 &#8729; E2 88 99 ● Black Circle U+25CF …

Install silverstripe4 on mac via composer

composer create–project silverstripe/installer ./my/website/folder Got error: need to install php-intl Solution: change default php7.1 to php7.3 by vi ~/.bash_profile … export PATH=/usr/local/opt/[email protected]/bin:$PATH source ~/.bash_profile now, php -v shows php7.3 php -i | grep intl run composer create–project silverstripe/installer ./my/website/folder again and looks fine Go to http://localhost/install.php shows error says need to set timezone vi php.ini set date.timezone …