Changeset 7976
- Timestamp:
- 12/17/2018 07:34:12 AM (6 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/javascript/tracker/source/components/filterable-table/filterable-table.jsx
r3814 r7976 10 10 initialSortField : PropTypes.string.isRequired, 11 11 columns : PropTypes.object, 12 customRender : PropTypes.object, 12 13 }, 13 14 … … 63 64 'sortOrder' : this.state.sortOrder, 64 65 'sortField' : this.state.sortField, 66 'sortFunction': this.props.sortFunction 65 67 } ); 66 68 … … 78 80 sortOrder = { this.state.sortOrder } 79 81 handleSortEvent = { this.handleSortEvent } 82 customRender = { this.props.customRender } 80 83 /> 81 84 </div> -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/javascript/tracker/source/components/filterable-table/row.jsx
r3814 r7976 3 3 export default React.createClass( { 4 4 propTypes : { 5 columns : PropTypes.object, 6 row : PropTypes.object, 5 columns : PropTypes.object, 6 row : PropTypes.object, 7 customRender : PropTypes.object, 7 8 }, 8 9 9 10 getDefaultProps : function() { 10 11 return { 11 columns : {}, 12 row : {}, 12 columns : {}, 13 row : {}, 14 customRender : {}, 13 15 }; 14 16 }, … … 21 23 * shouldn't be displayed, like URLs. 22 24 */ 23 for ( let iin this.props.columns ) {25 for ( let columnName in this.props.columns ) { 24 26 let cellContent = ''; 25 27 26 if ( ! this.props.columns.hasOwnProperty( i) ) {28 if ( ! this.props.columns.hasOwnProperty( columnName ) ) { 27 29 continue; 28 30 } 29 31 30 if ( this.props.row[ i + 'Url' ] ) { 31 cellContent = <a href={ this.props.row[ i + 'Url' ] }>{ this.props.row[ i ] }</a>; 32 if ( this.props.row[ columnName + 'Url' ] ) { 33 cellContent = <a href={ this.props.row[ columnName + 'Url' ] }>{ this.props.row[ columnName ] }</a>; 34 } else if ( this.props.customRender[ columnName ] ) { 35 cellContent = this.props.customRender[ columnName ]( this.props.row[ columnName ] ); 32 36 } else { 33 cellContent = this.props.row[ i];37 cellContent = this.props.row[ columnName ]; 34 38 } 35 39 40 36 41 cells.push( 37 <td className={ i } key={ i}>42 <td className={ columnName } key={ columnName }> 38 43 { cellContent } 39 44 </td> -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/javascript/tracker/source/components/filterable-table/table.jsx
r3814 r7976 10 10 sortOrder : PropTypes.oneOf( [ 'asc', 'desc' ] ), 11 11 handleSortEvent : PropTypes.func.isRequired, 12 customRender : PropTypes.object, 12 13 }, 13 14 … … 22 23 render : function() { 23 24 const rows = this.props.rows.map( function( row, index ) { 24 return <TableRow columns={ this.props.columns } row={ row } key={ index } />; 25 return ( 26 <TableRow 27 columns = { this.props.columns } 28 row = { row } 29 key = { index } 30 customRender = { this.props.customRender } 31 /> 32 ); 25 33 }.bind( this ) ); 26 34 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/javascript/tracker/source/stores/table-store.js
r7975 r7976 65 65 * @returns {number} 66 66 */ 67 _sortRows : function( a, b ) {68 a = a[ filters.sortField ].to LowerCase();69 b = b[ filters.sortField ].to LowerCase();67 _sortRows : function( a, b ) { 68 a = a[ filters.sortField ].toString().toLowerCase(); 69 b = b[ filters.sortField ].toString().toLowerCase(); 70 70 71 71 if ( a > b ) { -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/javascript/tracker/source/tracker.jsx
r3814 r7976 7 7 require( './style.scss' ); 8 8 9 /** 10 * Courtesy: https://stackoverflow.com/a/3177838/1845153 11 * 12 * Converts unix seconds into human readable time. 13 * Looks like exact javascript convert of WordPress's human_time_diff, except this always compares from current time, instead of getting two arguments. 14 * 15 * @param {int} date Unix timestamp date to compare from 16 * 17 * @returns {string} Human readable time ago 18 */ 19 const timeSince = ( date ) => { 20 21 const seconds = Math.floor( (new Date() / 1000 ) - date ); 22 23 let interval = Math.floor(seconds / 31536000); 24 25 if (interval > 1) { 26 return interval + " years"; 27 } 28 interval = Math.floor(seconds / 2592000); 29 if (interval > 1) { 30 return interval + " months"; 31 } 32 interval = Math.floor(seconds / 86400); 33 if (interval > 1) { 34 return interval + " days"; 35 } 36 interval = Math.floor(seconds / 3600); 37 if (interval > 1) { 38 return interval + " hours"; 39 } 40 interval = Math.floor(seconds / 60); 41 if (interval > 1) { 42 return interval + " minutes"; 43 } 44 return Math.floor(seconds) + " seconds"; 45 }; 46 47 /** 48 * Custom render function for lastUpdatedColumn. Will display X time ago instead of unix timestamp 49 */ 50 const renderHumanizeTime = ( time ) => { 51 return timeSince( time ) + " ago"; 52 }; 53 54 9 55 ReactDOM.render( 10 56 <FilterableTable 11 57 initialSortField = { wpcApplicationTracker.initialSortField } 12 58 columns = { wpcApplicationTracker.displayColumns } 59 customRender = { 60 { 61 lastUpdate: renderHumanizeTime 62 } 63 } 13 64 />, 14 65 document.getElementById( 'wpc-application-tracker' ) -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/tracker.php
r7841 r7976 15 15 */ 16 16 function render_status_shortcode() { 17 return '<div id="wpc-application-tracker">Loading Application Tracker...</div>';17 return '<div id="wpc-application-tracker">Loading WordCamp Application Tracker...</div>'; 18 18 } 19 19 … … 70 70 'milestone' => $milestones[ $post->post_status ], 71 71 'status' => $statuses[ $post->post_status ], 72 'lastUpdate' => human_time_diff( time(), $last_update_timestamp ) . ' ago',72 'lastUpdate' => $last_update_timestamp, 73 73 ); 74 74 }
Note: See TracChangeset
for help on using the changeset viewer.