1 {% extends "base.html" %}
14 height: calc(100% - 170px);
18 background-color: #ffffff;
70 -webkit-box-shadow: inherit;
74 -webkit-box-shadow: inherit;
84 padding-bottom: 4px !important;
85 border-bottom: 4px solid #41ba78 !important;
106 .step_untouched::after
112 width: calc(100% - 450px);
114 height: calc(100vh - 155px);
121 height: calc(100vh - 155px);
126 background-color: inherit;
129 #breadcrumbs.breadcrumb > li {
130 border: 1px solid #cccccc;
133 #breadcrumbs.breadcrumb > li:first-child {
134 border-left: 1px solid #cccccc;
136 #breadcrumbs.breadcrumb > li + li:before {
144 <button id="gof" onclick="go('next')" class="btn go_btn go_forward">Go Forward</button>
145 <button id="gob" onclick="go('prev')" class="btn go_btn go_back">Go Back</button>
147 <div class="options">
148 <button id="cancel_btn" class="btn btn-primary" onclick="cancel_wf()">Cancel</button>
150 <div class="btn_wrapper">
151 <ol id="breadcrumbs" class="btn-group breadcrumb">
156 <script type="text/javascript">
162 var context_data = false;
170 function request_leave(to)
175 beforeSend: function(request) {
176 request.setRequestHeader("X-CSRFToken",
177 $('input[name="csrfmiddlewaretoken"]').val());
179 success: function (data) {
180 confirm_permission(to, data);
186 function confirm_permission(to, data)
188 if( errors_exist(data) )
196 var problem = function() {
197 alert("There was a problem");
199 //makes an asynch request
200 req = new XMLHttpRequest();
201 url = "/wf/workflow/?step=" + to;
202 req.open("GET", url, true);
203 req.onload = function(e) {
204 if(req.readyState === 4){
205 if(req.status < 300){
206 document.getElementById("viewport-iframe").srcdoc = this.responseText;
207 } else { problem(); }
208 } else { problem(); }
210 req.onerror = problem;
214 function step_on_leave()
216 document.getElementById("viewport-iframe").contentWindow.step_on_leave();
219 function errors_exist(data)
221 var stat = data['steps'][data['active']]['valid'];
222 if( stat >= 100 && stat < 200 )
232 function update_context() {
236 beforeSend: function(request) {
237 request.setRequestHeader("X-CSRFToken",
238 $('input[name="csrfmiddlewaretoken"]').val());
240 success: function (data) {
246 function update_page(data)
249 update_breadcrumbs(data);
250 if(data["workflow_count"] == 1)
252 document.getElementById("cancel_btn").innerText = "Exit Workflow";
256 document.getElementById("cancel_btn").innerText = "Return to Parent";
260 function update_breadcrumbs(meta_json) {
261 step = meta_json['active'];
262 page_count = meta_json['steps'].length;
265 var btn = document.getElementById("gob");
266 btn.classList.add("go_btn_disabled");
271 var btn = document.getElementById("gob");
272 btn.classList.remove("go_btn_disabled");
273 btn.disabled = false;
275 if( step == page_count - 1 )
277 var btn = document.getElementById("gof");
278 btn.classList.add("go_btn_disabled");
283 var btn = document.getElementById("gof");
284 btn.classList.remove("go_btn_disabled");
285 btn.disabled = false;
287 //remove all children of breadcrumbs so we can redraw
288 var container = document.getElementById("breadcrumbs");
289 while(container.firstChild){
290 container.removeChild(container.firstChild);
293 draw_steps(meta_json);
296 function draw_steps(meta_json){
297 for( var i = 0; i < meta_json["steps"].length; i++ )
299 meta_json["steps"][i]["index"] = i;
300 var step_btn = create_step(meta_json["steps"][i], i == meta_json["active"]);
301 document.getElementById("breadcrumbs").appendChild(step_btn);
305 function create_step(step_json, active){
306 var step_dom = document.createElement("li");
308 step_dom.className = "step_active";
311 step_dom.className = "step";
313 step_dom.appendChild(document.createTextNode(step_json['title']));
314 var code = step_json['valid'];
319 step_dom.classList.add("step_untouched");
324 else if( code < 200 )
326 step_dom.classList.add("step_invalid");
328 msg = step_json['message'];
330 else if( code < 300 )
332 step_dom.classList.add("step_valid");
334 msg = step_json['message'];
336 if( step_json['enabled'] == false )
338 step_dom.classList.add("step_hidden");
342 update_message(msg, stat);
344 step_dom.classList.add("btn");
346 var step_number = step_json['index'];
350 function cancel_wf(){
351 var form = $("#workflow_pop_form");
352 var formData = form.serialize();
353 var req = new XMLHttpRequest();
354 req.open("POST", "/wf/workflow/finish/", false);
355 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
356 req.onerror = function() { alert("problem occurred while trying to cancel current workflow"); }
357 req.onreadystatechange = function() { if(req.readyState === 4){
363 function refresh_iframe() {
364 req = new XMLHttpRequest();
365 url = "/wf/workflow/";
366 req.open("GET", url, true);
367 req.onload = function(e) {
368 var doc = document.getElementById("viewport-iframe").contentWindow.document;
369 doc.open(); doc.write(this.responseText); doc.close();
374 function write_iframe(contents)
376 document.getElementById("viewport-iframe").contentWindow.document.innerHTML= contents;
379 function redirect_root()
381 window.location.replace('/wf/');
384 function add_wf(type){
385 add_wf_internal(type, false);
388 function add_edit_wf(type, target){
389 add_wf_internal(type, target);
392 function add_wf_internal(type, itemid){
393 data = {"add": type};
395 data['target'] = itemid;
401 beforeSend: function(request) {
402 request.setRequestHeader("X-CSRFToken",
403 $('input[name="csrfmiddlewaretoken"]').val()
406 success: refresh_wf_iframe()
410 function refresh_wf_iframe() {
411 window.location=window.location;
414 <div id="iframe_header" class="row view-header">
415 <div class="col-lg-12 step_header">
416 <h1 class="step_title" id="view_title"></h1>
417 <p class="description" id="view_desc"></p>
418 <p class="step_message" id="view_message"></p>
444 border-bottom: 1px solid #eee;
445 border-top: 1px solid #eee;
447 width: calc(100% - 202px);
451 function update_description(title, desc){
452 document.getElementById("view_title").innerText = title;
453 document.getElementById("view_desc").innerText = desc;
455 function update_message(message, stepstatus){
456 document.getElementById("view_message").innerText = message;
457 document.getElementById("view_message").className = "step_message";
458 document.getElementById("view_message").classList.add("message_" + stepstatus);
464 <div style="display: none;" id="workflow_pop_form_div">
465 <form id="workflow_pop_form" action="/wf/workflow/finish/" method="post">
470 <div class="iframe_div">
471 <iframe src="/wf/workflow" class="iframe_elem" scrolling="yes" id="viewport-iframe"></iframe>
473 {% endblock content %}