Lines 186-192
Link Here
|
186 |
<label for="aliases">Aliases: </label> |
186 |
<label for="aliases">Aliases: </label> |
187 |
<div id="aliases" style="padding-left: 11rem;"></div> |
187 |
<div id="aliases" style="padding-left: 11rem;"></div> |
188 |
</li> |
188 |
</li> |
189 |
|
|
|
190 |
</ol> |
189 |
</ol> |
191 |
</fieldset> |
190 |
</fieldset> |
192 |
<fieldset class="rows"> |
191 |
<fieldset class="rows"> |
Lines 204-209
Link Here
|
204 |
<button id="add-contact" class="btn btn-default"><i class="fa fa-plus"></i> Add another contact</button> |
203 |
<button id="add-contact" class="btn btn-default"><i class="fa fa-plus"></i> Add another contact</button> |
205 |
</fieldset> |
204 |
</fieldset> |
206 |
|
205 |
|
|
|
206 |
<fieldset class="rows"> |
207 |
<legend>Interfaces</legend> |
208 |
<div id="interfaces"></div> |
209 |
</fieldset> |
210 |
|
207 |
<fieldset class="rows"> |
211 |
<fieldset class="rows"> |
208 |
<legend>Ordering information</legend> |
212 |
<legend>Ordering information</legend> |
209 |
<ol><li><label for="activestatus">Vendor is:</label> |
213 |
<ol><li><label for="activestatus">Vendor is:</label> |
Lines 359-364
Link Here
|
359 |
<p><strong>Notes: </strong>[% notes | html %]</p> |
363 |
<p><strong>Notes: </strong>[% notes | html %]</p> |
360 |
[% END %] |
364 |
[% END %] |
361 |
</div> <!-- #supplier-ordering-information --> |
365 |
</div> <!-- #supplier-ordering-information --> |
|
|
366 |
|
367 |
[% IF vendor.interfaces.count %] |
368 |
<div id="supplier-interfaces" class="page-section"> |
369 |
<h2>Interfaces</h2> |
370 |
|
371 |
[% FOR interface IN vendor.interfaces %] |
372 |
<fieldset class="rows"> |
373 |
<legend>[% interface.name | html %]</legend> |
374 |
<ul> |
375 |
<li> |
376 |
<li>Type: [% interface.type | html %]</li> |
377 |
<li>URI: [% interface.uri | html %]</li> |
378 |
<li>Login: [% interface.login | html %]</li> |
379 |
<li>Password: [% interface.password | html %]</li> |
380 |
<li>Account email: [% interface.account_email | html %]</li> |
381 |
<li>Notes : [% interface.notes | html %]</li> |
382 |
</li> |
383 |
</ul> |
384 |
</fieldset> |
385 |
[% END %] |
386 |
</div> |
387 |
[% END %] |
388 |
|
362 |
</div> <!-- /.col-sm-6 --> |
389 |
</div> <!-- /.col-sm-6 --> |
363 |
|
390 |
|
364 |
<div class="col-sm-6"> |
391 |
<div class="col-sm-6"> |
Lines 511-516
Link Here
|
511 |
$("#aliases").html(nodes.html()); |
538 |
$("#aliases").html(nodes.html()); |
512 |
} |
539 |
} |
513 |
|
540 |
|
|
|
541 |
[% IF vendor %] |
542 |
let interfaces = [% To.json(vendor.interfaces.unblessed) | $raw %]; |
543 |
[% ELSE %] |
544 |
let interfaces = []; |
545 |
[% END %] |
546 |
function serialize_interface_form(){ |
547 |
interfaces = []; |
548 |
$("#interfaces > fieldset.supplier-interface > ol.interface-form").each( (index, interface_form )=> { |
549 |
let interface = {}; |
550 |
$(interface_form).find('input,textarea').serializeArray().map(attr => { |
551 |
let name = attr.name.replace(/interface_([\w_]+)_\d+/, "$1"); |
552 |
interface[name] = attr.value |
553 |
}) |
554 |
interfaces.push(interface); |
555 |
}); |
556 |
return interfaces; |
557 |
} |
558 |
function remove_interface(i){ |
559 |
interfaces = serialize_interface_form(); |
560 |
interfaces.splice(i, 1); |
561 |
refresh_interfaces(); |
562 |
} |
563 |
function add_interface(){ |
564 |
interfaces = serialize_interface_form(); |
565 |
interfaces.push({ |
566 |
type: "", |
567 |
name: "", |
568 |
uri: "", |
569 |
login: "", |
570 |
password: "", |
571 |
account_email: "", |
572 |
notes: "", |
573 |
}); |
574 |
refresh_interfaces(); |
575 |
} |
576 |
function refresh_interfaces(){ |
577 |
let nodes = $("<div id='interfaces'></div>"); |
578 |
interfaces.forEach((interface, i) => { |
579 |
let n = $("<fieldset class='supplier-interface'></fieldset>"); |
580 |
n.append("<legend>" + _("Interface details") + "</legend>"); |
581 |
n.append(`<input type="hidden" name="interface_counter" value="${i}" />`); |
582 |
let ol = $('<ol class="interface-form"></ol>'); |
583 |
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>`); |
584 |
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>`); |
585 |
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>`); |
586 |
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>`); |
587 |
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>`); |
588 |
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>`); |
589 |
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>`); |
590 |
ol.append(`<li><button class="btn btn-default" onclick="remove_interface(${i});"><i class="fa fa-trash"></i> Delete interface</li>`); |
591 |
n.append(ol); |
592 |
nodes.append(n); |
593 |
}); |
594 |
nodes.append(`<button onclick="add_interface();" class="btn btn-default"><i class="fa fa-plus"></i> ` + _("Add another interface") + '</button>') |
595 |
$("#interfaces").replaceWith(nodes); |
596 |
} |
597 |
|
514 |
var Sticky; |
598 |
var Sticky; |
515 |
|
599 |
|
516 |
$(document).ready(function() { |
600 |
$(document).ready(function() { |
Lines 551-556
Link Here
|
551 |
}); |
635 |
}); |
552 |
|
636 |
|
553 |
refresh_aliases(); |
637 |
refresh_aliases(); |
|
|
638 |
refresh_interfaces(); |
554 |
|
639 |
|
555 |
Sticky = $("#toolbar"); |
640 |
Sticky = $("#toolbar"); |
556 |
Sticky.hcSticky({ |
641 |
Sticky.hcSticky({ |
557 |
- |
|
|