質問編集履歴

1

                

2024/07/23 02:51

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,225 +1,3 @@
1
-
2
- $(document).ready(function() {
3
-
4
- const currentTicketNumber = ViewCustomize.context.issue.id;
5
-
6
- const newNumber = currentTicketNumber - 20;
7
-
8
- let prefix = '24-';
9
- const currentDate = new Date();
10
-
11
- if (currentDate.getMonth() === 3 && currentDate.getDate() === 1) {
12
- prefix = '25-';
13
- }
14
-
15
- const paddedNumber = ('000000' + newNumber).slice(-6);
16
-
17
- if ($('#issue_custom_field_values_1').val() === '') {
18
- $('#issue_custom_field_values_1').val(prefix + paddedNumber);
19
- }
20
-
21
- $('#issue_custom_field_values_1').prop('disabled', true);
22
- });
23
-
24
-
25
- -----------------------------------------------------------------------------
26
-
27
- <script src="https://cdnjs.cloudflare.com/ajax/libs/at.js/1.5.2/js/jquery.atwho.min.js" defer></script>
28
- <script src="https://cdnjs.cloudflare.com/ajax/libs/Caret.js/0.3.1/jquery.caret.min.js" defer></script>
29
- <style>
30
- .atwho-view {
31
- position:absolute;
32
- top: 0;
33
- left: 0;
34
- display: none;
35
- margin-top: 18px;
36
- background: white;
37
- color: black;
38
- border: 1px solid #DDD;
39
- border-radius: 3px;
40
- box-shadow: 0 0 5px rgba(0,0,0,0.1);
41
- min-width: 120px;
42
- z-index: 11110 !important;
43
- }
44
- .atwho-view .atwho-header {
45
- padding: 5px;
46
- margin: 5px;
47
- cursor: pointer;
48
- border-bottom: solid 1px #eaeff1;
49
- color: #6f8092;
50
- font-size: 11px;
51
- font-weight: bold;
52
- }
53
- .atwho-view .atwho-header .small {
54
- color: #6f8092;
55
- float: right;
56
- padding-top: 2px;
57
- margin-right: -5px;
58
- font-size: 12px;
59
- font-weight: normal;
60
- }
61
- .atwho-view .atwho-header:hover {
62
- cursor: default;
63
- }
64
- .atwho-view .cur {
65
- background: #3366FF;
66
- color: white;
67
- }
68
- .atwho-view .cur small {
69
- color: white;
70
- }
71
- .atwho-view strong {
72
- color: #3366FF;
73
- }
74
- .atwho-view .cur strong {
75
- color: white;
76
- font:bold;
77
- }
78
- .atwho-view ul {
79
- /* width: 100px; */
80
- list-style:none;
81
- padding:0;
82
- margin:auto;
83
- max-height: 200px;
84
- overflow-y: auto;
85
- }
86
- .atwho-view ul li {
87
- display: block;
88
- padding: 5px 10px;
89
- border-bottom: 1px solid #DDD;
90
- cursor: pointer;
91
- }
92
- .atwho-view small {
93
- font-size: smaller;
94
- color: #777;
95
- font-weight: normal;
96
- }
97
- </style>
98
- <script>
99
- $(document).ready(function() {
100
- const allowedUserIDs = [5, 7, 12, 1];
101
-
102
- const currentUserID = $('#loggedas a').attr('href').match(/(\d+)$/)[0];
103
-
104
- if (allowedUserIDs.includes(parseInt(currentUserID))) {
105
- const customFieldId = '2';
106
- const customFieldSelector = `#issue_custom_field_values_${customFieldId}`;
107
-
108
- const inputCandidates = [
109
- { name: '1', content: '1' },
110
- ];
111
-
112
- $(customFieldSelector).atwho({
113
- at: '@',
114
- data: inputCandidates,
115
- insertTpl: '${content}',
116
- suffix: ''
117
- });
118
-
119
- const buttonHtml = '<button id="showCandidatesButton">ANS</button>';
120
- $(customFieldSelector).after(buttonHtml);
121
-
122
- $('#showCandidatesButton').click(function(e) {
123
- e.preventDefault();
124
-
125
- const candidatesWindow = window.open('', 'title', 'width=400,height=300');
126
- const candidatesHtml = `
127
- <h2>title2</h2>
128
- <ul>
129
- ${inputCandidates.map(candidate => `<li data-content="${candidate.content}">${candidate.name}</li>`).join('')}
130
- </ul>
131
- `;
132
- candidatesWindow.document.write(candidatesHtml);
133
-
134
- candidatesWindow.document.querySelectorAll('li').forEach(li => {
135
- li.addEventListener('click', function() {
136
- const selectedContent = li.getAttribute('data-content');
137
- $(customFieldSelector).val(selectedContent);
138
- candidatesWindow.close();
139
- });
140
- });
141
- });
142
- }
143
- });
144
- </script>
145
-
146
-
147
- ----------------------------------------------------------------------------
148
-
149
- <script>
150
- $(document).ready(function() {
151
- const customFieldId2 = '2';
152
- const customFieldSelector2 = `#issue_custom_field_values_${customFieldId2}`;
153
- const customFieldId3 = '3';
154
- const customFieldSelector3 = `#issue_custom_field_values_${customFieldId3}`;
155
-
156
- const candidatesPerSelection = {
157
- '1': [
158
- { name: '12', content: '1' },
159
- ],
160
- '2': [
161
- { name: '15', content: '3' },
162
- ],
163
- '3': [
164
- { name: '20', content: '4' },
165
- ],
166
- '4': [
167
- { name: '27', content: '7' },
168
- ],
169
- };
170
-
171
- const updateCandidates = () => {
172
- const selectionValue = $(customFieldSelector3).val();
173
- const inputCandidates = candidatesPerSelection[selectionValue] || [];
174
-
175
- $(customFieldSelector3).atwho({
176
- at: '@',
177
- data: inputCandidates.map(candidate => candidate.name),
178
- insertTpl: '${content}',
179
- suffix: ''
180
- });
181
- };
182
-
183
- updateCandidates();
184
-
185
- $(customFieldSelector3).change(updateCandidates);
186
-
187
- const buttonHtml = '<button id="showCandidatesButton">ANS</button>';
188
- $(customFieldSelector3).parent().append(buttonHtml);
189
-
190
- $(document).on('click', '#showCandidatesButton', function(e) {
191
- e.preventDefault();
192
- const candidatesWindow = window.open('', 'title', 'width=400,height=300');
193
- const candidatesHtml = `
194
- <!DOCTYPE html>
195
- <html>
196
- <head>
197
- <title>title2</title>
198
- </head>
199
- <body>
200
- <h2>title3</h2>
201
- <ul>
202
- ${candidatesPerSelection[$(customFieldSelector3).val()].map(candidate => `<li data-content="${candidate.content}">${candidate.name}</li>`).join('')}
203
- </ul>
204
- </body>
205
- </html>
206
- `;
207
- candidatesWindow.document.write(candidatesHtml);
208
-
209
- candidatesWindow.document.querySelectorAll('li').forEach(li => {
210
- li.addEventListener('click', function() {
211
- const selectedContent = li.getAttribute('data-content');
212
- $(customFieldSelector2).val(selectedContent);
213
- candidatesWindow.close();
214
- });
215
- });
216
- });
217
- });
218
- </script>
219
-
220
-
221
- ------------------------------------------------------------------------------------
222
-
223
1
  $(document).ready(function() {
224
2
 
225
3
  $('#issue-form').submit(function(event) {