sampler-textual.riot 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <sampler-textual>
  2. <div class="current-sample-wrapper">
  3. <div class="current-sample" style="visibility: { visibility }">
  4. <div class="current-sample-colour"></div>
  5. <p class="current-sample-label">{ props.textual.subject } { props.mouseOver ? (props.sampler.currentSample.id + 1) : (props.sampler.samples.length) }</p>
  6. <div class="current-sample-number" style="background-color: { props.colours[props.sampler.currentSample.cid] }">
  7. { props.sampler.calculatedYield }
  8. </div>
  9. <p class="current-sample-label">
  10. { props.sampler.currentSample.cid === 0 ?
  11. props.textual.failure + ' ' + props.investmentOutput + ' Euro' :
  12. props.textual.success + ' ' + props.investmentOutput + ' Euro' }
  13. </p>
  14. </div>
  15. </div>
  16. <script charset="utf-8">
  17. export default {
  18. // life cycle methods
  19. onBeforeMount(props, state) {
  20. state.mouseOver = false;
  21. Object.defineProperty(this, 'visibility', { get: this.visibility }); // define visibility as getter only when 'this.props' is defined
  22. Object.defineProperty(this, 'sampleLabel', { get: this.sampleLabel }); // define visibility as getter only when 'this.props' is defined
  23. },
  24. // evaluates if modal should be shown
  25. visibility() {
  26. let visibility = 'hidden';
  27. if ((this.props.sampler.samples.length > 0 && this.props.groupSizeId === 0) ||
  28. (this.props.sampler.samples.length > 0 && this.props.mouseOver === true)) {
  29. visibility = 'visible';
  30. }
  31. return visibility;
  32. },
  33. sampleLabel () {
  34. let label = '';
  35. if (this.props.sampler.currentSample.cid === 0) {
  36. label = this.props.textual.failure;
  37. } else {
  38. label = this.props.textual.success;
  39. }
  40. return label += ' ' + this.props.investmentOutput + ' ' + this.props.labels.currency;
  41. }
  42. }
  43. </script>
  44. </sampler-textual>