actions.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. Actions = new Mongo.Collection('actions');
  2. Actions.allow({
  3. insert(userId, doc) {
  4. return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
  5. },
  6. update(userId, doc) {
  7. return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
  8. },
  9. remove(userId, doc) {
  10. return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
  11. }
  12. });
  13. Actions.helpers({
  14. description() {
  15. if(this.actionType == "moveCardToTop"){
  16. if(this.listTitle == "*"){
  17. return TAPi18n.__('r-d-move-to-top-gen');
  18. }else{
  19. return TAPi18n.__('r-d-move-to-top-spec') + " " + this.listTitle;
  20. }
  21. }
  22. if(this.actionType == "moveCardToBottom"){
  23. if(this.listTitle == "*"){
  24. return TAPi18n.__('r-d-move-to-bottom-gen');
  25. }else{
  26. return TAPi18n.__('r-d-move-to-bottom-spec') + " " + this.listTitle;
  27. }
  28. }
  29. if(this.actionType == "sendEmail"){
  30. const to = " " + TAPi18n.__('r-d-send-email-to') + ": " + this.emailTo + ", ";
  31. const subject = TAPi18n.__('r-d-send-email-subject') + ": " + this.emailSubject + ", ";
  32. const message = TAPi18n.__('r-d-send-email-message') + ": " + this.emailMsg;
  33. const total = TAPi18n.__('r-d-send-email') + to + subject + message;
  34. return total;
  35. }
  36. if(this.actionType == "archive"){
  37. return TAPi18n.__('r-d-archive');
  38. }
  39. if(this.actionType == "unarchive"){
  40. return TAPi18n.__('r-d-unarchive');
  41. }
  42. if(this.actionType == "addLabel"){
  43. const board = Boards.findOne(Session.get('currentBoard'));
  44. const label = board.getLabelById(this.labelId);
  45. let name;
  46. if(label.name == "" || label.name == undefined){
  47. name = label.color.toUpperCase();
  48. }else{
  49. name = label.name;
  50. }
  51. return TAPi18n.__('r-d-add-label') + ": "+name;
  52. }
  53. if(this.actionType == "removeLabel"){
  54. const board = Boards.findOne(Session.get('currentBoard'));
  55. const label = board.getLabelById(this.labelId);
  56. let name;
  57. if(label.name == "" || label.name == undefined){
  58. name = label.color.toUpperCase();
  59. }else{
  60. name = label.name;
  61. }
  62. return TAPi18n.__('r-d-remove-label') + ": " + name;
  63. }
  64. if(this.actionType == "addMember"){
  65. return TAPi18n.__('r-d-add-member') + ": " + this.memberName;
  66. }
  67. if(this.actionType == "removeMember"){
  68. if(this.memberName == "*"){
  69. return TAPi18n.__('r-d-remove-all-member');
  70. }
  71. return TAPi18n.__('r-d-remove-member') + ": "+ this.memberName;
  72. }
  73. if(this.actionType == "checkAll"){
  74. return TAPi18n.__('r-d-check-all') + ": " + this.checklistName;
  75. }
  76. if(this.actionType == "uncheckAll"){
  77. return TAPi18n.__('r-d-uncheck-all') + ": "+ this.checklistName;
  78. }
  79. if(this.actionType == "checkItem"){
  80. return TAPi18n.__('r-d-check-one') + ": "+ this.checkItemName + " " + TAPi18n.__('r-d-check-of-list') + ": " +this.checklistName;
  81. }
  82. if(this.actionType == "uncheckItem"){
  83. return TAPi18n.__('r-d-check-one') + ": "+ this.checkItemName + " " + TAPi18n.__('r-d-check-of-list') + ": " +this.checklistName;
  84. }
  85. if(this.actionType == "addChecklist"){
  86. return TAPi18n.__('r-d-add-checklist') + ": "+ this.checklistName;
  87. }
  88. if(this.actionType == "removeChecklist"){
  89. return TAPi18n.__('r-d-remove-checklist') + ": "+ this.checklistName;
  90. }
  91. return "Ops not trigger description";
  92. }
  93. });