summaryrefslogtreecommitdiffstats
path: root/models/actions.js
blob: fd1d03e0f7e9c8fe2e82d8fc68e582679c761fa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
Actions = new Mongo.Collection('actions');


Actions.allow({
	insert(userId, doc) {
		return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
	},
	update(userId, doc) {
		return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
	},
	remove(userId, doc) {
		return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
	}
});


Actions.helpers({
	description() {
		if(this.actionType == "moveCardToTop"){
			if(this.listTitle == "*"){
				return TAPi18n.__('r-d-move-to-top-gen');
			}else{
				return TAPi18n.__('r-d-move-to-top-spec') + " " + this.listTitle;
			}
		}
		if(this.actionType == "moveCardToBottom"){
			if(this.listTitle == "*"){
				return TAPi18n.__('r-d-move-to-bottom-gen');
			}else{
				return TAPi18n.__('r-d-move-to-bottom-spec') + " " + this.listTitle;
			}
		}
		if(this.actionType == "sendEmail"){
			const to = " " + TAPi18n.__('r-d-send-email-to') + ": " + this.emailTo + ", ";
			const subject = TAPi18n.__('r-d-send-email-subject') + ": " + this.emailSubject + ", ";
			const message = TAPi18n.__('r-d-send-email-message') + ": " + this.emailMsg;
			const total = TAPi18n.__('r-d-send-email') + to + subject + message;
			return total;
		}
		if(this.actionType == "archive"){
			return TAPi18n.__('r-d-archive');
		}
		if(this.actionType == "unarchive"){
			return TAPi18n.__('r-d-unarchive');
		}
		if(this.actionType == "addLabel"){
			const board = Boards.findOne(Session.get('currentBoard'));
			const label = board.getLabelById(this.labelId);
			let name;
			if(label.name == "" || label.name == undefined){
        		name = label.color.toUpperCase();
      		}else{
      			name = label.name;
      		}
    		
			return TAPi18n.__('r-d-add-label') + ": "+name;
		}
		if(this.actionType == "removeLabel"){
			const board = Boards.findOne(Session.get('currentBoard'));
			const label = board.getLabelById(this.labelId);
			let name;
			if(label.name == "" || label.name == undefined){
        		name = label.color.toUpperCase();
      		}else{
      			name = label.name;
      		}
			return TAPi18n.__('r-d-remove-label') + ": " + name;
		}
		if(this.actionType == "addMember"){
			return TAPi18n.__('r-d-add-member') + ": " + this.memberName;
		}
		if(this.actionType == "removeMember"){
			if(this.memberName == "*"){
				return TAPi18n.__('r-d-remove-all-member');
			}
			return TAPi18n.__('r-d-remove-member') + ": "+ this.memberName;
		}
		if(this.actionType == "checkAll"){
			return TAPi18n.__('r-d-check-all') + ": " + this.checklistName;
		}
		if(this.actionType == "uncheckAll"){
			return TAPi18n.__('r-d-uncheck-all') + ": "+ this.checklistName;
		}
		if(this.actionType == "checkItem"){
			return TAPi18n.__('r-d-check-one') + ": "+ this.checkItemName + " " + TAPi18n.__('r-d-check-of-list') + ": " +this.checklistName;
		}
		if(this.actionType == "uncheckItem"){
			return TAPi18n.__('r-d-check-one') + ": "+ this.checkItemName + " " + TAPi18n.__('r-d-check-of-list') + ": " +this.checklistName;
		}
		if(this.actionType == "addChecklist"){
			return TAPi18n.__('r-d-add-checklist') + ": "+ this.checklistName;
		}
		if(this.actionType == "removeChecklist"){
			return TAPi18n.__('r-d-remove-checklist') + ": "+ this.checklistName;
		}

	 return "Ops not trigger description";
	}
});