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) )
190 var continueanyway = confirm("The current step has errors that will prevent it from saving. Continue anyway?");
191 if( !continueanyway )
197 var problem = function() {
198 alert("There was a problem");
200 //makes an asynch request
201 req = new XMLHttpRequest();
202 url = "/wf/workflow/?step=" + to;
203 req.open("GET", url, true);
204 req.onload = function(e) {
205 if(req.readyState === 4){
206 if(req.status < 300){
207 document.getElementById("viewport-iframe").srcdoc = this.responseText;
208 } else { problem(); }
209 } else { problem(); }
211 req.onerror = problem;
215 function step_on_leave()
217 document.getElementById("viewport-iframe").contentWindow.step_on_leave();
220 function errors_exist(data)
222 var stat = data['steps'][data['active']]['valid'];
223 if( stat >= 100 && stat < 200 )
233 function update_context() {
237 beforeSend: function(request) {
238 request.setRequestHeader("X-CSRFToken",
239 $('input[name="csrfmiddlewaretoken"]').val());
241 success: function (data) {
247 function update_page(data)
250 update_breadcrumbs(data);
251 if(data["workflow_count"] == 1)
253 document.getElementById("cancel_btn").innerText = "Exit Workflow";
257 document.getElementById("cancel_btn").innerText = "Return to Parent";
261 function update_breadcrumbs(meta_json) {
262 step = meta_json['active'];
263 page_count = meta_json['steps'].length;
266 var btn = document.getElementById("gob");
267 btn.classList.add("go_btn_disabled");
272 var btn = document.getElementById("gob");
273 btn.classList.remove("go_btn_disabled");
274 btn.disabled = false;
276 if( step == page_count - 1 )
278 var btn = document.getElementById("gof");
279 btn.classList.add("go_btn_disabled");
284 var btn = document.getElementById("gof");
285 btn.classList.remove("go_btn_disabled");
286 btn.disabled = false;
288 //remove all children of breadcrumbs so we can redraw
289 var container = document.getElementById("breadcrumbs");
290 while(container.firstChild){
291 container.removeChild(container.firstChild);
294 draw_steps(meta_json);
297 function draw_steps(meta_json){
298 for( var i = 0; i < meta_json["steps"].length; i++ )
300 meta_json["steps"][i]["index"] = i;
301 var step_btn = create_step(meta_json["steps"][i], i == meta_json["active"]);
302 document.getElementById("breadcrumbs").appendChild(step_btn);
306 function create_step(step_json, active){
307 var step_dom = document.createElement("li");
309 step_dom.className = "step_active";
312 step_dom.className = "step";
314 step_dom.appendChild(document.createTextNode(step_json['title']));
315 var code = step_json['valid'];
320 step_dom.classList.add("step_untouched");
325 else if( code < 200 )
327 step_dom.classList.add("step_invalid");
329 msg = step_json['message'];
331 else if( code < 300 )
333 step_dom.classList.add("step_valid");
335 msg = step_json['message'];
337 if( step_json['enabled'] == false )
339 step_dom.classList.add("step_hidden");
343 update_message(msg, stat);
345 step_dom.classList.add("btn");
347 var step_number = step_json['index'];
351 function cancel_wf(){
352 var form = $("#workflow_pop_form");
353 var formData = form.serialize();
354 var req = new XMLHttpRequest();
355 req.open("POST", "/wf/workflow/finish/", false);
356 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
357 req.onerror = function() { alert("problem occurred while trying to cancel current workflow"); }
358 req.onreadystatechange = function() { if(req.readyState === 4){
364 function refresh_iframe() {
365 req = new XMLHttpRequest();
366 url = "/wf/workflow/";
367 req.open("GET", url, true);
368 req.onload = function(e) {
369 var doc = document.getElementById("viewport-iframe").contentWindow.document;
370 doc.open(); doc.write(this.responseText); doc.close();
375 function write_iframe(contents)
377 document.getElementById("viewport-iframe").contentWindow.document.innerHTML= contents;
380 function redirect_root()
382 window.location.replace('/wf/');
385 function add_wf(type){
386 add_wf_internal(type, false);
389 function add_edit_wf(type, target){
390 add_wf_internal(type, target);
393 function add_wf_internal(type, itemid){
394 data = {"add": type};
396 data['target'] = itemid;
402 beforeSend: function(request) {
403 request.setRequestHeader("X-CSRFToken",
404 $('input[name="csrfmiddlewaretoken"]').val()
407 success: refresh_wf_iframe()
411 function refresh_wf_iframe() {
412 window.location=window.location;
415 <div id="iframe_header" class="row view-header">
416 <div class="col-lg-12 step_header">
417 <h1 class="step_title" id="view_title"></h1>
418 <p class="description" id="view_desc"></p>
419 <p class="step_message" id="view_message"></p>
445 border-bottom: 1px solid #eee;
446 border-top: 1px solid #eee;
448 width: calc(100% - 202px);
452 function update_description(title, desc){
453 document.getElementById("view_title").innerText = title;
454 document.getElementById("view_desc").innerText = desc;
456 function update_message(message, stepstatus){
457 document.getElementById("view_message").innerText = message;
458 document.getElementById("view_message").className = "step_message";
459 document.getElementById("view_message").classList.add("message_" + stepstatus);
465 <div style="display: none;" id="workflow_pop_form_div">
466 <form id="workflow_pop_form" action="/wf/workflow/finish/" method="post">
471 <div class="iframe_div">
472 <iframe src="/wf/workflow" class="iframe_elem" scrolling="yes" id="viewport-iframe"></iframe>
474 {% endblock content %}