1 | activityStatusTranslation = new Array(); |
---|
2 | activityStatusTranslation['running'] = 'Em execução'; |
---|
3 | activityStatusTranslation['completed'] = 'Completada'; |
---|
4 | |
---|
5 | instanceStatusTranslation = new Array(); |
---|
6 | instanceStatusTranslation['completed'] = 'Completada'; |
---|
7 | instanceStatusTranslation['active'] = 'Ativa'; |
---|
8 | instanceStatusTranslation['aborted'] = 'Abortada'; |
---|
9 | instanceStatusTranslation['exception'] = 'Em exceção'; |
---|
10 | |
---|
11 | workflowInboxPriority = new Array(); |
---|
12 | workflowInboxPriority[0] = '<font color="#dedede"><b>•</b></font> '; |
---|
13 | workflowInboxPriority[1] = '<font color="#7ec65b"><b>•</b></font> '; |
---|
14 | workflowInboxPriority[2] = '<font color="#efea4e"><b>•</b></font> '; |
---|
15 | workflowInboxPriority[3] = '<font color="#fc9e34"><b>•</b></font> '; |
---|
16 | workflowInboxPriority[4] = '<font color="#e31b23"><b>•</b></font> '; |
---|
17 | |
---|
18 | var workflowCommonExpressoIndexPath = null; |
---|
19 | |
---|
20 | /* abre uma nova aba para mostrar os dados da instancia */ |
---|
21 | function drawViewInstance(data) |
---|
22 | { |
---|
23 | var borderID = create_border("Visualizar Instância"); |
---|
24 | |
---|
25 | var content = '<br/>'; |
---|
26 | content += '<table class="info_table" width="90%" align="center">'; |
---|
27 | content += '<tr class="info_tr_header"><td colspan="5">Instância de ' + data['wf_procname'] + '(v' + data['wf_version'] + ')</td></tr>'; |
---|
28 | content += '<tr class="info_tr_sub_header">'; |
---|
29 | content += '<td width="19%">Criado em</td>'; |
---|
30 | content += '<td width="19%">Finalizado em</td>'; |
---|
31 | content += '<td width="10%">Prioridade</td>'; |
---|
32 | content += '<td width="13%">Situação</td>'; |
---|
33 | content += '<td width="39%">Proprietário</td>'; |
---|
34 | content += '</tr>'; |
---|
35 | content += '<tr class="info_tr_simple">'; |
---|
36 | content += '<td>' + data['wf_started'] + '</td>'; |
---|
37 | content += '<td>' + data['wf_ended'] + '</td>'; |
---|
38 | content += '<td align="center">' + data['wf_priority'] + '</td>'; |
---|
39 | content += '<td>' + instanceStatusTranslation[data['wf_status']] + '</td>'; |
---|
40 | content += '<td>' + data['wf_owner'] + '</td>'; |
---|
41 | content += '</tr>'; |
---|
42 | content += '</table>'; |
---|
43 | |
---|
44 | content += '<br/>'; |
---|
45 | content += '<table class="info_table" width="90%" align="center">'; |
---|
46 | content += '<tr class="info_tr_header"><td colspan="4">Histórico</td></tr>'; |
---|
47 | content += '<tr class="info_tr_sub_header">'; |
---|
48 | content += '<td width="30%">Atividade</td>'; |
---|
49 | content += '<td width="20%">Iniciado em</td>'; |
---|
50 | content += '<td width="20%">Duração</td>'; |
---|
51 | content += '<td width="30%">Usuário</td>'; |
---|
52 | content += '</tr>'; |
---|
53 | |
---|
54 | var current; |
---|
55 | var workitemCount = data['wf_workitems'].length; |
---|
56 | for (var i = 0; i < workitemCount; i++) |
---|
57 | { |
---|
58 | current = data['wf_workitems'][i]; |
---|
59 | content += '<tr class="info_tr_simple">'; |
---|
60 | content += '<td>' + activity_icon(current['wf_type'], current['wf_is_interactive']) + " " + current['wf_name']; |
---|
61 | content += '<td>' + current['wf_started'] + '</td>'; |
---|
62 | content += '<td>' + current['wf_duration'] + '</td>'; |
---|
63 | content += '<td>' + current['wf_user'] + '</td>'; |
---|
64 | content += '</tr>'; |
---|
65 | } |
---|
66 | content += '</table>'; |
---|
67 | |
---|
68 | if ((data['wf_status'] == 'active') || (data['wf_status'] == 'exception')) |
---|
69 | { |
---|
70 | content += '<br/>'; |
---|
71 | content += '<table class="info_table" width="90%" align="center">'; |
---|
72 | content += '<tr class="info_tr_header"><td colspan="4">Atividades em Andamento</td></tr>'; |
---|
73 | content += '<tr class="info_tr_sub_header">'; |
---|
74 | content += '<td width="30%">Nome</td>'; |
---|
75 | content += '<td width="20%">Iniciado em</td>'; |
---|
76 | content += '<td width="20%">Situação</td>'; |
---|
77 | content += '<td width="30%">Usuário</td>'; |
---|
78 | content += '</tr>'; |
---|
79 | |
---|
80 | var current; |
---|
81 | var activityCount = data['wf_activities'].length; |
---|
82 | for (var i = 0; i < activityCount; i++) |
---|
83 | { |
---|
84 | current = data['wf_activities'][i]; |
---|
85 | content += '<tr class="info_tr_simple">'; |
---|
86 | content += '<td>' + activity_icon(current['wf_type'], current['wf_is_interactive']) + " " + current['wf_name']; |
---|
87 | content += '<td>' + current['wf_started'] + '</td>'; |
---|
88 | content += '<td>' + activityStatusTranslation[current['wf_status']] + '</td>'; |
---|
89 | content += '<td>' + ((current['wf_user']) ? current['wf_user'] : '*') + '</td>'; |
---|
90 | content += '</tr>'; |
---|
91 | } |
---|
92 | |
---|
93 | content += '</table>'; |
---|
94 | } |
---|
95 | |
---|
96 | if(data['wf_properties'] != null) |
---|
97 | { |
---|
98 | content += '<br/>'; |
---|
99 | content += '<table class="info_table" width="90%" align="center">'; |
---|
100 | content += '<tr class="info_tr_header"><td colspan="2">Propriedades</td></tr>'; |
---|
101 | content += '<tr class="info_tr_sub_header">'; |
---|
102 | content += '<td width="30%">Nome</td>'; |
---|
103 | content += '<td width="70%">Valor</td>'; |
---|
104 | content += '</tr>'; |
---|
105 | |
---|
106 | var propertiesCount = data['wf_properties']['keys'].length; |
---|
107 | for (var i = 0; i < propertiesCount; i++) |
---|
108 | { |
---|
109 | content += '<tr class="info_tr_simple">'; |
---|
110 | content += '<td>' + data['wf_properties']['keys'][i] + '</td>'; |
---|
111 | content += '<td>' + data['wf_properties']['values'][i] + '</td>'; |
---|
112 | content += '</tr>'; |
---|
113 | } |
---|
114 | content += '</table>'; |
---|
115 | } |
---|
116 | |
---|
117 | if (data['viewRunAction']) |
---|
118 | { |
---|
119 | var viewActivity = data['viewRunAction']; |
---|
120 | content += '<br/>'; |
---|
121 | content += '<table class="info_table" width="90%" align="center">'; |
---|
122 | content += '<tr class="info_tr_header"><td>Atividade View do Processo</td></tr>'; |
---|
123 | content += '<tr class="info_tr_simple">'; |
---|
124 | content += '<td width="100%"><iframe src="' + getInstanceURL(data['wf_instance_id'], viewActivity['viewActivityID'], viewActivity['useHTTPS']) + '" width="100%" ' + ((viewActivity['height'] > 0) ? ' height="' + viewActivity['height'] + '"' : '') + '></iframe></td>'; |
---|
125 | content += '</tr>'; |
---|
126 | content += '</table>'; |
---|
127 | } |
---|
128 | |
---|
129 | $('content_id_' + borderID).innerHTML = content; |
---|
130 | } |
---|
131 | |
---|
132 | /** |
---|
133 | * Constrói um iframe oculto para os processos que possuem sua própria atividade do tipo view |
---|
134 | * @param string preffix O prefixo usado para nomear o iframe oculto |
---|
135 | * @param int numberOfColumns A quantidade de colunas da tabela |
---|
136 | * @param int instanceID O ID da instância |
---|
137 | * @param int activityID O ID da atividade |
---|
138 | * @param int height A altura do iframe |
---|
139 | * @return string O código XHTML do iframe |
---|
140 | */ |
---|
141 | function constructHiddenView(preffix, numberOfColumns, instanceID, activityID, height) |
---|
142 | { |
---|
143 | var output = ''; |
---|
144 | output += '<tr class="table_elements_tr_line" id="' + preffix + '_hiddenView_' + instanceID + '_' + activityID + '" style="display: none;">'; |
---|
145 | output += '<td colspan="' + numberOfColumns + '" align="left"><iframe width="100%" ' + ((height > 0) ? ' height="' + height + '"' : '') + '></iframe>'; |
---|
146 | output += '</td></tr>'; |
---|
147 | return output; |
---|
148 | } |
---|
149 | |
---|
150 | /** |
---|
151 | * Exibe ou oculta o iframe da atividade View |
---|
152 | * @param string preffix O prefixo usado para nomear o iframe oculto |
---|
153 | * @param int instanceID O ID da instância |
---|
154 | * @param int activityID O ID da atividade |
---|
155 | * @param int viewActivityID O ID da atividade View |
---|
156 | * @return void |
---|
157 | */ |
---|
158 | function toggleHiddenView(preffix, instanceID, activityID, viewActivityID, useHTTPS) |
---|
159 | { |
---|
160 | var tr = $(preffix + '_hiddenView_' + instanceID + '_' + activityID); |
---|
161 | var iframe = tr.childNodes[0].childNodes[0]; |
---|
162 | |
---|
163 | function openView(obj) |
---|
164 | { |
---|
165 | workflowInboxOpenedViewActivities++; |
---|
166 | if (obj.element.src == '') |
---|
167 | obj.element.src = getInstanceURL(instanceID, viewActivityID, useHTTPS); |
---|
168 | } |
---|
169 | |
---|
170 | function closeView(obj) |
---|
171 | { |
---|
172 | workflowInboxOpenedViewActivities--; |
---|
173 | if (workflowInboxOpenedViewActivities < 0) |
---|
174 | workflowInboxOpenedViewActivities = 0; |
---|
175 | tr.hide(); |
---|
176 | } |
---|
177 | |
---|
178 | if (tr.visible()) |
---|
179 | { |
---|
180 | new Effect.BlindUp(iframe, {duration: 0.2, afterFinish: closeView}); |
---|
181 | } |
---|
182 | else |
---|
183 | { |
---|
184 | tr.show(); |
---|
185 | new Effect.BlindDown(iframe, {duration: 0.2, afterFinish: openView}); |
---|
186 | } |
---|
187 | } |
---|
188 | |
---|
189 | function getInstanceURL(instanceID, activityID, useHTTPS) |
---|
190 | { |
---|
191 | if (workflowCommonExpressoIndexPath == null) |
---|
192 | { |
---|
193 | workflowCommonExpressoIndexPath = $A(document.getElementsByTagName("script")).findAll( |
---|
194 | function(s) |
---|
195 | { |
---|
196 | return (s.src && s.src.match(/\/workflow\/js\/userinterface\/common_functions\.js(\?.*)?$/)); |
---|
197 | }).first().src; |
---|
198 | /* pega só até o /workflow/ */ |
---|
199 | workflowCommonExpressoIndexPath = workflowCommonExpressoIndexPath.replace(/\/workflow\/js\/userinterface\/common_functions\.js(\?.*)?$/, ''); |
---|
200 | |
---|
201 | /* se não possuir o endereço completo, tenta montá-lo utilizando a informação da página atual (IE MAGIC) */ |
---|
202 | if (workflowCommonExpressoIndexPath.match(/^https?:\/\//) == null) |
---|
203 | workflowCommonExpressoIndexPath = location.href.substr(0, location.href.indexOf('/', location.href.indexOf('//') + 2)) + workflowCommonExpressoIndexPath; |
---|
204 | } |
---|
205 | var output = instanceURL = workflowCommonExpressoIndexPath + '/index.php?menuaction=workflow.run_activity.go&iid=' + instanceID + '&activity_id=' + activityID; |
---|
206 | if (useHTTPS == 1) |
---|
207 | output = output.replace(/http:/, 'https:'); |
---|
208 | return output; |
---|
209 | } |
---|