forked from apa-it/4me-UI-Mods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ITRPuimods.user.js
125 lines (102 loc) · 4.48 KB
/
ITRPuimods.user.js
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// ==UserScript==
// @name ITRPuimods
// @version 0.4
// @description Tampermonkey script. Modifications for the 4me/ITRP user interface. Works in Firefox and Chrome.
// Use at your own risk.
// @author Thomas Volpini
// @grant none
//
// @updateURL https://github.com/apa-it/4me-UI-Mods/raw/master/ITRPuimods.user.js
// @downloadURL https://github.com/apa-it/4me-UI-Mods/raw/master/ITRPuimods.user.js
//
// @include https://*.itrp.at
// @include https://*.itrp.at
// @match https://*.itrp.at/*
// @match https://*.itrp.at/*
//
// @include https://*.itrp-qa.at
// @include https://*.itrp-qa.at
// @match https://*.itrp-qa.at/*
// @match https://*.itrp-qa.at/*
//
// @include https://*.itrp.com
// @include https://*.itrp.com
// @match https://*.itrp.com/*
// @match https://*.itrp.com/*
//
// @include https://*.4me.com
// @include https://*.4me.com
// @match https://*.4me.com/*
// @match https://*.4me.com/*
//
// @include https://*.4me-demo.com
// @include https://*.4me-demo.com
// @match https://*.4me-demo.com/*
// @match https://*.4me-demo.com/*
//
// ==/UserScript==
(function() {
'use strict';
var $ = window.$; // Prevent warning by Tampermonkey editor.
if(true) {
// Grey-out lines containing "Waiting..." Records.
$("tr.item.table-row").has("span.waiting-until").css("color","Gainsboro");
$("tr.item.table-row").has("span.to-do-status").filter(
function() { return new RegExp(
"Waiting|Warten|Wachtend|En Attente|Esperando|Aguardando|Aspettando"
).test($(this).text());
}
).css("color","Gainsboro");
// TODO Tickets are also "Waiting for Customer" when the current User is the customer. Tickets should not be greyed out then.
}
// Print lines bold where the current user is the assignee
var currentUser = $("div.avatar").attr("alt");
$("td.cell-assignment:contains('" + currentUser + "')").closest('tr').find("td").css("font-weight","bold");
// Highlight lines containing Top impact incidents
$("tr.item.table-row").has("div.icon-impact-top").css({"color":"red", "background-color" : "rgba(255,0,0, 0.08"});
// Highlight all Record Identifiers contained in a list.
// TODO Currently we don't differentiate problems, requests and tasks here. Fix this.
if (false) {
var highlightRecords = [1159, 1193, 173002, 179426];
$("span.record-identifier").filter(function() { return (highlightRecords.includes( parseInt( $(this).text() ))) }).css("color", "green");
}
// Gray background for internal comments.
// This makes it easier to see if a record didn't get a customer-visible comment for some time.
if (true) {
function FormatInternalComments() {
// Adding and checking apaIt_InternalComment is to prevent loops.
$("div.icon-locked-note").closest("li").find("div.note-content").not(".apaIt_InternalComment")
.addClass("apaIt_InternalComment")
.css({"background-color" : "LightGray",
"color": "black",
"border-bottom-left-radius" : "5px",
"border-bottom-right-radius" : "5px",
"border-top-left-radius" : "5px",
"border-top-right-radius" : "5px"
});
};
var ListenForDetailsModification = true;
// Sometimes comments only become visible after the DOM is loaded, e.g. when
// the user clicks a Request in the Request list and the Request is shown in the detail view on the right.
$("#details-container").on('DOMSubtreeModified', function() {
console.log("Details modified");
if (ListenForDetailsModification) {
ListenForDetailsModification = false; // prevent recursion
FormatInternalComments();
ListenForDetailsModification = true;
}
});
// This call is for internal comments that are immediately visible after the DOM is loaded.
FormatInternalComments();
}
// Hotkeys
if (true) {
$(document).bind('keypress', 'e', function() {
if($(".modal_panel").length > 0) return; // Don't click the edit button when modal panels are visible.
$("span.icon-edit").click();
});
$(document).keyup(function(e){
if(e.keyCode === 27) { $("div.btn.cancel").click(); } // Binding escape like above doesn't work.
});
}
})();