minicard.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { Cookies } from 'meteor/ostrio:cookies';
  2. const cookies = new Cookies();
  3. // Template.cards.events({
  4. // 'click .member': Popup.open('cardMember')
  5. // });
  6. BlazeComponent.extendComponent({
  7. template() {
  8. return 'minicard';
  9. },
  10. formattedCurrencyCustomFieldValue(definition) {
  11. const customField = this.data()
  12. .customFieldsWD()
  13. .find(f => f._id === definition._id);
  14. const customFieldTrueValue =
  15. customField && customField.trueValue ? customField.trueValue : '';
  16. const locale = TAPi18n.getLanguage();
  17. return new Intl.NumberFormat(locale, {
  18. style: 'currency',
  19. currency: definition.settings.currencyCode,
  20. }).format(customFieldTrueValue);
  21. },
  22. events() {
  23. return [
  24. {
  25. 'click .js-linked-link'() {
  26. if (this.data().isLinkedCard()) Utils.goCardId(this.data().linkedId);
  27. else if (this.data().isLinkedBoard())
  28. Utils.goBoardId(this.data().linkedId);
  29. },
  30. },
  31. {
  32. 'click .js-toggle-minicard-label-text'() {
  33. if (cookies.has('hiddenMinicardLabelText')) {
  34. cookies.remove('hiddenMinicardLabelText'); //true
  35. } else {
  36. cookies.set('hiddenMinicardLabelText', 'true'); //true
  37. }
  38. },
  39. },
  40. ];
  41. },
  42. }).register('minicard');
  43. Template.minicard.helpers({
  44. showDesktopDragHandles() {
  45. currentUser = Meteor.user();
  46. if (currentUser) {
  47. return (currentUser.profile || {}).showDesktopDragHandles;
  48. } else if (cookies.has('showDesktopDragHandles')) {
  49. return true;
  50. } else {
  51. return false;
  52. }
  53. },
  54. hiddenMinicardLabelText() {
  55. currentUser = Meteor.user();
  56. if (currentUser) {
  57. return (currentUser.profile || {}).hiddenMinicardLabelText;
  58. } else if (cookies.has('hiddenMinicardLabelText')) {
  59. return true;
  60. } else {
  61. return false;
  62. }
  63. },
  64. });