You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
5.0 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: components/GridActionButton.component.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: components/GridActionButton.component.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>import {Component} from '../../lib/vues6.js'
const template = `
&lt;div class="component-action-button">
&lt;button
v-if="!hidden"
v-bind:style="{border: '2px solid lightgrey', borderRadius: '3px', backgroundColor: color, color: 'white'}"
@click="on_click($event)"
>{{ text }}&lt;/button>
&lt;/div>
`
/**
* Component representing an action button that can be embedded in the shared grid.
* @extends Component
*/
class GridActionButtonComponent extends Component {
static get selector() { return 'app-action-button' }
static get template() { return template }
static get props() { return ['row', 'col'] }
/**
* The text shown on the action button.
* @type {string}
*/
text = ''
/**
* The CSS color of the action button.
* @type {string}
*/
color = 'white'
/**
* If true, the action button will be hidden.
* @type {boolean}
*/
hidden = false
/**
* Called when the component is instantiated. Updates the text, color, and hide status.
* @return {Promise&lt;void>}
*/
async vue_on_create() {
this.update_text()
this.update_color()
this.update_hidden()
}
/**
* Called when the row value changes. Updates the text, color, and hide status.
*/
watch_row() {
this.update_text()
this.update_color()
this.update_hidden()
}
/**
* Called when the column value changes. Updates the text, color, and hide status.
*/
watch_col() {
this.update_text()
this.update_color()
this.update_hidden()
}
/**
* Determine the text to show on the button based on the column definition.
*/
update_text() {
if ( typeof this.col.button_text === 'function' ) {
this.text = this.col.button_text(this.row, this.col)
} else {
this.text = this.col.button_text || ''
}
}
/**
* Determine the color to show on the button based on the column definition.
*/
update_color() {
if ( typeof this.col.button_color === 'function' ) {
this.color = this.col.button_color(this.row, this.col)
} else {
this.color = this.col.button_color || 'white'
}
}
/**
* Determine whether the button should be shown or not, based on the column definition.
*/
update_hidden() {
if ( !('button_hidden' in this.col) ) {
this.hidden = false;
} else if ( typeof this.col.button_hidden === 'function' ) {
this.hidden = this.col.button_hidden(this.row, this.col)
} else {
this.hidden = this.col.button_hidden
}
}
/**
* Called when the button is clicked. Emits a click event and updates the text, color, and hide status.
* @param {MouseEvent} $event
*/
on_click($event) {
this.$emit('click', [this.row, this.col])
this.update_text()
this.update_color()
this.update_hidden()
}
}
export default GridActionButtonComponent
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-routing.html">routing</a></li><li><a href="module-util.html">util</a></li></ul><h3>Classes</h3><ul><li><a href="AddPlayersComponent.html">AddPlayersComponent</a></li><li><a href="DraftBoardComponent.html">DraftBoardComponent</a></li><li><a href="GridActionButtonComponent.html">GridActionButtonComponent</a></li><li><a href="GridComponent.html">GridComponent</a></li><li><a href="LeagueComponent.html">LeagueComponent</a></li><li><a href="LinkComponent.html">LinkComponent</a></li><li><a href="module-routing-Router.html">Router</a></li><li><a href="MyTeamComponent.html">MyTeamComponent</a></li><li><a href="ScoresComponent.html">ScoresComponent</a></li><li><a href="TopLevelComponent.html">TopLevelComponent</a></li></ul><h3>Global</h3><ul><li><a href="global.html#GridCellRenderType">GridCellRenderType</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.5</a> on Sun Oct 25 2020 12:32:18 GMT-0500 (Central Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>