blob: 6514e300bb7efa70bf7251bc9ada6522d8f59e5c [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001[# arg0 is either "user" for user saved queries or "project" for canned queries]
2<style>
3 #queries th, #queries td { padding-bottom: 1em }
4</style>
5
6<table border="0" id="queries">
7 <tr>
8 <th></th>
9 <th style="text-align:left">Saved query name:</th>
10 [is arg0 "user"]
11 <th style="text-align:left">Project(s):</th>
12 [end]
13 <th colspan="2" style="text-align:left">Query:</th>
14 [is arg0 "user"]
15 <th style="text-align:left">Subscription options:</th>
16 [end]
17 <th></th>
18 </tr>
19
20 [for canned_queries]
21 <tr>
22 <td style="text-align:right" width="20">[canned_queries.idx].
23 <input type="hidden" name="savedquery_id_[canned_queries.idx]" value="[canned_queries.query_id]">
24 </td>
25 <td><input type="text" name="savedquery_name_[canned_queries.idx]" size="35" value="[canned_queries.name]" class="acob"></td>
26 [is arg0 "user"]
27 <td><input type="text" name="savedquery_projects_[canned_queries.idx]" size="35" value="[canned_queries.projects]"
28 class="acob" autocomplete="off" id="savedquery_projects_[canned_queries.idx]"></td>
29 [end]
30
31 <td>
32 <select name="savedquery_base_[canned_queries.idx]">
33 [define can][canned_queries.base_query_id][end]
34 [include "../tracker/issue-can-widget.ezt" "admin"]
35 </select>
36 </td>
37 <td>
38 <input type="text" name="savedquery_query_[canned_queries.idx]" size="50" value="[canned_queries.query]" autocomplete="off" id="query_existing_[canned_queries.idx]" class="acob">
39 </td>
40 [is arg0 "user"]
41 <td>
42 <select id="savedquery_sub_mode_[canned_queries.idx]" name="savedquery_sub_mode_[canned_queries.idx]">
43 <option [is canned_queries.subscription_mode "noemail"]selected="select"[end] value="noemail"
44 >No emails</option>
45 <option [is canned_queries.subscription_mode "immediate"]selected="select"[end] value="immediate">Notify Immediately</option>
46 [# TODO(jrobbins): <option disabled="disabled">Notify Daily</option>]
47 [# TODO(jrobbins): <option disabled="disabled">Notify Weekly on Monday</option>]
48 </select>
49 </td>
50 [end]
51 <td></td>
52 </tr>
53 [end]
54
55 [is arg0 "user"]
56 [define can]1[end][# All blank lines for user queries default to "All Issues" scope.]
57 [else]
58 [define can]2[end][# All blank lines for project queries default to "Open issues" scope.]
59 [end]
60 [for new_query_indexes]
61 <tr id="newquery[new_query_indexes]" [if-index new_query_indexes first][else]style="display:none"[end]>
62 <td style="text-align:right" width="20">[new_query_indexes].</td>
63 <td><input type="text" name="new_savedquery_name_[new_query_indexes]"
64 class="showNextQueryRow acob" data-index="[new_query_indexes]"
65 size="35" value="" placeholder="Required"></td>
66 [is arg0 "user"]
67 <td><input type="text" name="new_savedquery_projects_[new_query_indexes]" size="35" value="" class="acob"
68 autocomplete="off" id="new_savedquery_projects_[new_query_indexes]" placeholder="Optional"></td>
69 [end]
70 <td>
71 <select name="new_savedquery_base_[new_query_indexes]">
72 [include "../tracker/issue-can-widget.ezt" "admin"]
73 </select>
74 </td>
75 <td>
76 <input type="text" name="new_savedquery_query_[new_query_indexes]" size="50" value="" autocomplete="off" id="query_new_[new_query_indexes]" class="acob" placeholder="Optional. Example- &quot;label:Security owner:me&quot;">
77 </td>
78 [is arg0 "user"]
79 <td>
80 <select id="new_savedquery_sub_mode_[new_query_indexes]" name="new_savedquery_sub_mode_[new_query_indexes]">
81 <option selected="selected" value="noemail">No emails</option>
82 <option value="immediate">Notify Immediately</option>
83 [# TODO(jrobbins): <option disabled="disabled">Notify Daily</option>]
84 [# TODO(jrobbins): <option disabled="disabled">Notify Weekly</option>]
85 </select>
86 </td>
87 [end]
88 <td width="40px">
89 [if-index new_query_indexes last][else]
90 <span id="addquery[new_query_indexes]" class="fakelink" data-index="[new_query_indexes]">Add a row</span
91 [end]
92 </td>
93 </tr>
94 [end]
95
96</table>
97
98<script type="text/javascript" nonce="[nonce]">
99runOnLoad(function() {
100 function showNextQueryRow(i) {
101 if (i < [max_queries]) {
102 _showID('newquery' + (i + 1));
103 _hideID('addquery' + i);
104 }
105 }
106 _fetchUserProjects(true);
107
108 var addARowLinks = document.getElementsByClassName("fakelink");
109 for (var i = 0; i < addARowLinks.length; ++i) {
110 var link = addARowLinks[[]i];
111 link.addEventListener("click", function(event) {
112 var index = Number(event.target.getAttribute("data-index"));
113 showNextQueryRow(index);
114 });
115 }
116
117 var typeToAddARow = document.getElementsByClassName("showNextQueryRow");
118 for (var i = 0; i < typeToAddARow.length; ++i) {
119 var el = typeToAddARow[[]i];
120 el.addEventListener("keydown", function(event) {
121 var index = Number(event.target.getAttribute("data-index"));
122 showNextQueryRow(index);
123 });
124 }
125
126 var acobElements = document.getElementsByClassName("acob");
127 for (var i = 0; i < acobElements.length; ++i) {
128 var el = acobElements[[]i];
129 el.addEventListener("focus", function(event) {
130 _acrob(null);
131 _acof(event);
132 });
133 }
134});
135</script>