1 {% extends "base.html" %}
14 height: calc(100% - 170px);
18 background-color: #ffffff;
89 width: calc(100% - 450px);
91 height: calc(100vh - 155px);
97 height: calc(100vh - 155px);
102 <button id="gof" onclick="go(step+1)" class="btn go_btn go_forward">Go Forward</button>
103 <button id="gob" onclick="go(step-1)" class="btn go_btn go_back">Go Back</button>
105 <div class="options">
106 <button id="cancel_btn" class="btn btn-primary" onclick="cancel_wf()">Cancel</button>
108 <div class="btn_wrapper">
109 <div id="breadcrumbs" class="btn-group">
110 <div class="btn-group" id="breadcrumb-wrapper">
116 <script type="text/javascript">
122 var context_data = false;
130 function request_leave(to)
135 beforeSend: function(request) {
136 request.setRequestHeader("X-CSRFToken",
137 $('input[name="csrfmiddlewaretoken"]').val());
139 success: function (data) {
140 confirm_permission(to, data);
146 function confirm_permission(to, data)
148 if( errors_exist(data) )
150 var continueanyway = confirm("The current step has errors that will prevent it from saving. Continue anyway?");
151 if( !continueanyway )
156 if( to >= page_count )
164 var problem = function() {
165 alert("There was a problem");
167 //makes an asynch request
168 req = new XMLHttpRequest();
169 url = "/wf/workflow/?step=" + to;
170 req.open("GET", url, true);
171 req.onload = function(e) {
172 if(req.readyState === 4){
173 if(req.status < 300){
174 document.getElementById("viewport-iframe").srcdoc = this.responseText;
175 } else { problem(); }
176 } else { problem(); }
178 req.onerror = problem;
182 function step_on_leave()
184 document.getElementById("viewport-iframe").contentWindow.step_on_leave();
187 function errors_exist(data)
189 var stat = data['steps'][data['active']]['valid'];
190 if( stat >= 100 && stat < 200 )
200 function update_context() {
204 beforeSend: function(request) {
205 request.setRequestHeader("X-CSRFToken",
206 $('input[name="csrfmiddlewaretoken"]').val());
208 success: function (data) {
214 function update_page(data)
217 update_breadcrumbs(data);
218 if(data["workflow_count"] == 1)
220 document.getElementById("cancel_btn").innerText = "Exit Workflow";
224 document.getElementById("cancel_btn").innerText = "Return to Parent";
228 function update_breadcrumbs(meta_json) {
229 step = meta_json['active'];
230 page_count = meta_json['steps'].length;
233 var btn = document.getElementById("gob");
234 btn.classList.add("go_btn_disabled");
239 var btn = document.getElementById("gob");
240 btn.classList.remove("go_btn_disabled");
241 btn.disabled = false;
243 if( step == page_count - 1 )
245 var btn = document.getElementById("gof");
246 btn.classList.add("go_btn_disabled");
251 var btn = document.getElementById("gof");
252 btn.classList.remove("go_btn_disabled");
253 btn.disabled = false;
255 //remove all children of breadcrumbs so we can redraw
256 var container = document.getElementById("breadcrumbs");
257 while(container.firstChild){
258 container.removeChild(container.firstChild);
261 draw_steps(meta_json);
264 function draw_steps(meta_json){
265 for( var i = 0; i < meta_json["steps"].length; i++ )
267 meta_json["steps"][i]["index"] = i;
268 var step_btn = create_step(meta_json["steps"][i], i == meta_json["active"]);
269 document.getElementById("breadcrumbs").appendChild(step_btn);
273 function create_step(step_json, active){
274 var step_dom = document.createElement("DIV");
276 step_dom.className = "step_active";
279 step_dom.className = "step";
281 step_dom.appendChild(document.createTextNode(step_json['title']));
282 var code = step_json['valid'];
287 step_dom.classList.add("step_untouched");
292 else if( code < 200 )
294 step_dom.classList.add("step_invalid");
296 msg = step_json['message'];
298 else if( code < 300 )
300 step_dom.classList.add("step_valid");
302 msg = step_json['message'];
306 update_message(msg, stat);
308 step_dom.classList.add("btn");
310 var step_number = step_json['index'];
311 step_dom.onclick = function(){ go(step_number); }
315 function cancel_wf(){
316 var form = $("#workflow_pop_form");
317 var formData = form.serialize();
318 var req = new XMLHttpRequest();
319 req.open("POST", "/wf/workflow/finish/", false);
320 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
321 req.onerror = function() { alert("problem occurred while trying to cancel current workflow"); }
322 req.onreadystatechange = function() { if(req.readyState === 4){
328 function refresh_iframe() {
329 req = new XMLHttpRequest();
330 url = "/wf/workflow/";
331 req.open("GET", url, true);
332 req.onload = function(e) {
333 var doc = document.getElementById("viewport-iframe").contentWindow.document;
334 doc.open(); doc.write(this.responseText); doc.close();
339 function write_iframe(contents)
341 document.getElementById("viewport-iframe").contentWindow.document.innerHTML= contents;
344 function redirect_root()
346 window.location.replace('/wf/');
349 function add_wf(type){
350 add_wf_internal(type, false);
353 function add_edit_wf(type, target){
354 add_wf_internal(type, target);
357 function add_wf_internal(type, itemid){
358 data = {"add": type};
360 data['target'] = itemid;
366 beforeSend: function(request) {
367 request.setRequestHeader("X-CSRFToken",
368 $('input[name="csrfmiddlewaretoken"]').val()
371 success: refresh_wf_iframe()
375 function refresh_wf_iframe() {
376 window.location=window.location;
379 <div id="iframe_header" class="row view-header">
380 <div class="col-lg-12 step_header">
381 <h1 class="step_title" id="view_title"></h1>
382 <p class="description" id="view_desc"></p>
383 <p class="step_message" id="view_message"></p>
409 border-bottom: 1px solid #eee;
410 border-top: 1px solid #eee;
412 width: calc(100% - 202px);
416 function update_description(title, desc){
417 document.getElementById("view_title").innerText = title;
418 document.getElementById("view_desc").innerText = desc;
420 function update_message(message, stepstatus){
421 document.getElementById("view_message").innerText = message;
422 document.getElementById("view_message").className = "step_message";
423 document.getElementById("view_message").classList.add("message_" + stepstatus);
429 <div style="display: none;" id="workflow_pop_form_div">
430 <form id="workflow_pop_form" action="/wf/workflow/finish/" method="post">
435 <div class="iframe_div">
436 <iframe src="/wf/workflow" class="iframe_elem" scrolling="yes" id="viewport-iframe"></iframe>
438 {% endblock content %}