mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
- A VM's tags set while its host's list drops it: the VM is checked again under the ownership lock and the page says it was moved, instead of a 500 or a success that kept the old tags in its removed record. - A tag deleted right after another rename cleans the removed VMs' kept name it has now; a delete sent while a backup schedule uses the tag (saved after the page was shown) is refused with the schedules' names. - A rename to a name another tag took meanwhile is a form error, not a 500; "There is a tag with this name already" is translated. - Tom Select makes a typed name lower case and offers no new tag for one that is there in another case; the API's ?tag= is lower-cased too.
29 lines
1.3 KiB
JavaScript
29 lines
1.3 KiB
JavaScript
// A <select data-searchable> of many users or VMs gets a search box (Tom Select).
|
|
document.querySelectorAll("select[data-searchable]").forEach(function (select) {
|
|
new TomSelect(select, {
|
|
// the box leaves its focused, taller look at once: else the next tap's
|
|
// button moves away under the finger on a phone
|
|
onItemAdd: function () { this.blur(); },
|
|
});
|
|
});
|
|
|
|
// A <select multiple data-tags>: the tags there are, and a new one typed (the
|
|
// server checks it), in lower case as the tags are kept: "Prod" is "prod".
|
|
document.querySelectorAll("select[data-tags]").forEach(function (select) {
|
|
new TomSelect(select, {
|
|
create: function (input) {
|
|
return {value: input.toLowerCase(), text: input.toLowerCase()};
|
|
},
|
|
createFilter: function (input) {
|
|
return /^[A-Za-z0-9][A-Za-z0-9._-]{0,31}$/.test(input) && !this.options[input.toLowerCase()];
|
|
},
|
|
persist: false,
|
|
render: {
|
|
// the page's own words (data-add): the library's are English
|
|
option_create: function (data, escape) {
|
|
return '<div class="create">' + escape(select.dataset.add.replace("%(tag)s", data.input)) + "</div>";
|
|
},
|
|
no_results: null,
|
|
},
|
|
});
|
|
});
|