Lines 185-191
Link Here
|
185 |
<label for="aliases">Aliases: </label> |
185 |
<label for="aliases">Aliases: </label> |
186 |
<div id="aliases" style="padding-left: 11rem;"></div> |
186 |
<div id="aliases" style="padding-left: 11rem;"></div> |
187 |
</li> |
187 |
</li> |
188 |
|
|
|
189 |
</ol> |
188 |
</ol> |
190 |
</fieldset> |
189 |
</fieldset> |
191 |
<fieldset class="rows"> |
190 |
<fieldset class="rows"> |
Lines 203-208
Link Here
|
203 |
<button id="add-contact" class="btn btn-default"><i class="fa fa-plus"></i> Add another contact</button> |
202 |
<button id="add-contact" class="btn btn-default"><i class="fa fa-plus"></i> Add another contact</button> |
204 |
</fieldset> |
203 |
</fieldset> |
205 |
|
204 |
|
|
|
205 |
<fieldset class="rows"> |
206 |
<legend>Interfaces</legend> |
207 |
<div id="interfaces"></div> |
208 |
</fieldset> |
209 |
|
206 |
<fieldset class="rows"> |
210 |
<fieldset class="rows"> |
207 |
<legend>Ordering information</legend> |
211 |
<legend>Ordering information</legend> |
208 |
<ol><li><label for="activestatus">Vendor is:</label> |
212 |
<ol><li><label for="activestatus">Vendor is:</label> |
Lines 355-360
Link Here
|
355 |
<p><strong>Notes: </strong>[% notes | html %]</p> |
359 |
<p><strong>Notes: </strong>[% notes | html %]</p> |
356 |
[% END %] |
360 |
[% END %] |
357 |
</div> <!-- #supplier-ordering-information --> |
361 |
</div> <!-- #supplier-ordering-information --> |
|
|
362 |
|
363 |
[% IF vendor.interfaces.count %] |
364 |
<div id="supplier-interfaces" class="page-section"> |
365 |
<h2>Interfaces</h2> |
366 |
|
367 |
[% FOR interface IN vendor.interfaces %] |
368 |
<fieldset class="rows"> |
369 |
<legend>[% interface.name | html %]</legend> |
370 |
<ul> |
371 |
<li> |
372 |
<li>Type: [% interface.type | html %]</li> |
373 |
<li>URI: [% interface.uri | html %]</li> |
374 |
<li>Login: [% interface.login | html %]</li> |
375 |
<li>Password: [% interface.password | html %]</li> |
376 |
<li>Account email: [% interface.account_email | html %]</li> |
377 |
<li>Notes : [% interface.notes | html %]</li> |
378 |
</li> |
379 |
</ul> |
380 |
</fieldset> |
381 |
[% END %] |
382 |
</div> |
383 |
[% END %] |
384 |
|
358 |
</div> <!-- /.col-sm-6 --> |
385 |
</div> <!-- /.col-sm-6 --> |
359 |
|
386 |
|
360 |
<div class="col-sm-6"> |
387 |
<div class="col-sm-6"> |
Lines 492-497
Link Here
|
492 |
$("#aliases").html(nodes.html()); |
519 |
$("#aliases").html(nodes.html()); |
493 |
} |
520 |
} |
494 |
|
521 |
|
|
|
522 |
[% IF vendor %] |
523 |
let interfaces = [% To.json(vendor.interfaces.unblessed) | $raw %]; |
524 |
[% ELSE %] |
525 |
let interfaces = []; |
526 |
[% END %] |
527 |
function serialize_interface_form(){ |
528 |
interfaces = []; |
529 |
$("#interfaces > fieldset.supplier-interface > ol.interface-form").each( (index, interface_form )=> { |
530 |
let interface = {}; |
531 |
$(interface_form).find('input,textarea').serializeArray().map(attr => { |
532 |
let name = attr.name.replace(/interface_([\w_]+)_\d+/, "$1"); |
533 |
interface[name] = attr.value |
534 |
}) |
535 |
interfaces.push(interface); |
536 |
}); |
537 |
return interfaces; |
538 |
} |
539 |
function remove_interface(i){ |
540 |
interfaces = serialize_interface_form(); |
541 |
interfaces.splice(i, 1); |
542 |
refresh_interfaces(); |
543 |
} |
544 |
function add_interface(){ |
545 |
interfaces = serialize_interface_form(); |
546 |
interfaces.push({ |
547 |
type: "", |
548 |
name: "", |
549 |
uri: "", |
550 |
login: "", |
551 |
password: "", |
552 |
account_email: "", |
553 |
notes: "", |
554 |
}); |
555 |
refresh_interfaces(); |
556 |
} |
557 |
function refresh_interfaces(){ |
558 |
let nodes = $("<div id='interfaces'></div>"); |
559 |
interfaces.forEach((interface, i) => { |
560 |
let n = $("<fieldset class='supplier-interface'></fieldset>"); |
561 |
n.append("<legend>" + _("Interface details") + "</legend>"); |
562 |
n.append(`<input type="hidden" name="interface_counter" value="${i}" />`); |
563 |
let ol = $('<ol class="interface-form"></ol>'); |
564 |
ol.append(`<li><label for="interface_name_${i}">` + _("Name: ") + `</label><input type="text" size="40" id="interface_name_${i}" name="interface_name_${i}" value="${interface.name}" /></li>`); |
565 |
ol.append(`<li><label for="interface_type_${i}">` + _("Type: ") + `</label><input type="text" size="40" id="interface_type_${i}" name="interface_type_${i}" value="${interface.type}" /></li>`); |
566 |
ol.append(`<li><label for="interface_uri_${i}">` + _("URI: ") + `</label><input type="text" size="40" id="interface_uri_${i}" name="interface_uri_${i}" value="${interface.uri}" /></li>`); |
567 |
ol.append(`<li><label for="interface_login_${i}">` + _("Login: ") + `</label><input type="text" size="40" id="interface_login_${i}" name="interface_login_${i}" value="${interface.login}" /></li>`); |
568 |
ol.append(`<li><label for="interface_password_${i}">` + _("Password: ") + `</label><input type="text" size="40" id="interface_password_${i}" name="interface_password_${i}" value="${interface.password}" /></li>`); |
569 |
ol.append(`<li><label for="interface_account_email_${i}">` + _("Account email: ") + `</label><input type="text" size="40" id="interface_account_email_${i}" name="interface_account_email_${i}" value="${interface.account_email}" /></li>`); |
570 |
ol.append(`<li><label for="interface_notes_${i}">` + _("Notes: ") + `</label><textarea cols="40" rows="3" id="interface_notes_${i}" name="interface_notes_${i}">${interface.notes}</textarea></li>`); |
571 |
ol.append(`<li><button class="btn btn-default" onclick="remove_interface(${i});"><i class="fa fa-trash"></i> Delete interface</li>`); |
572 |
n.append(ol); |
573 |
nodes.append(n); |
574 |
}); |
575 |
nodes.append(`<button onclick="add_interface();" class="btn btn-default"><i class="fa fa-plus"></i> ` + _("Add another interface") + '</button>') |
576 |
$("#interfaces").replaceWith(nodes); |
577 |
} |
578 |
|
495 |
var Sticky; |
579 |
var Sticky; |
496 |
|
580 |
|
497 |
$(document).ready(function() { |
581 |
$(document).ready(function() { |
Lines 532-537
Link Here
|
532 |
}); |
616 |
}); |
533 |
|
617 |
|
534 |
refresh_aliases(); |
618 |
refresh_aliases(); |
|
|
619 |
refresh_interfaces(); |
535 |
|
620 |
|
536 |
Sticky = $("#toolbar"); |
621 |
Sticky = $("#toolbar"); |
537 |
Sticky.hcSticky({ |
622 |
Sticky.hcSticky({ |
538 |
- |
|
|