mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-10-11 23:25:46 +00:00
Compare commits
1 Commits
master
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a62c47b8b |
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
name: Lint
|
name: Lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Install system dependencies
|
- name: Install system dependencies
|
||||||
run: sudo apt-get update && sudo apt-get install -y libcairo2-dev
|
run: sudo apt-get update && sudo apt-get install -y libcairo2-dev
|
||||||
@@ -45,7 +45,7 @@ jobs:
|
|||||||
DATABASE_ENGINE: sqlite3
|
DATABASE_ENGINE: sqlite3
|
||||||
DATABASE_NAME: db.sqlite3
|
DATABASE_NAME: db.sqlite3
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Install system dependencies
|
- name: Install system dependencies
|
||||||
run: sudo apt-get update && sudo apt-get install -y libcairo2-dev
|
run: sudo apt-get update && sudo apt-get install -y libcairo2-dev
|
||||||
@@ -94,7 +94,7 @@ jobs:
|
|||||||
- platform: linux/arm64
|
- platform: linux/arm64
|
||||||
runner: ubuntu-24.04-arm
|
runner: ubuntu-24.04-arm
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- uses: docker/setup-buildx-action@v4
|
- uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
// If there were errors, apply the previous Rig/not-Rig selection
|
// If there were errors, apply the previous Rig/not-Rig selection
|
||||||
{% if form.errors %}
|
{% if form.errors %}
|
||||||
all('.form-hws').forEach(function (el) { slideDown(el, 0); });
|
all('.form-hws').forEach(function (el) { slideDown(el, 0); });
|
||||||
if (document.getElementById('{{form.is_rig.auto_id}}').checked === false) {
|
if (document.getElementById('{{form.is_rig.auto_id}}').getAttribute('checked') !== 'checked') {
|
||||||
all('.form-is_rig').forEach(function (el) { el.style.display = 'none'; });
|
all('.form-is_rig').forEach(function (el) { el.style.display = 'none'; });
|
||||||
}
|
}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ function initPicker(select) {
|
|||||||
var noClear = 'noclear' in select.dataset;
|
var noClear = 'noclear' in select.dataset;
|
||||||
var multiple = select.multiple;
|
var multiple = select.multiple;
|
||||||
var url = select.dataset.sourceurl;
|
var url = select.dataset.sourceurl;
|
||||||
// input_autogrow keeps the search box on the same line as the selected value (otherwise it wraps and doubles the height)
|
var plugins = [];
|
||||||
var plugins = ['input_autogrow'];
|
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
plugins.push('remove_button');
|
plugins.push('remove_button');
|
||||||
} else if (!noClear) {
|
} else if (!noClear) {
|
||||||
@@ -71,28 +70,18 @@ function initPicker(select) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
// The server does the searching. Tom Select keeps every option it has ever loaded, so remember which
|
|
||||||
// ones the server returned for each query and only show those (otherwise results for "a" and "al"
|
|
||||||
// linger in the dropdown when searching for "ali hassan").
|
|
||||||
var results = {};
|
|
||||||
var normalise = function (query) { return query.trim().toLowerCase(); };
|
|
||||||
|
|
||||||
Object.assign(settings, {
|
Object.assign(settings, {
|
||||||
score: function (query) {
|
// Results come from the server so don't filter them locally
|
||||||
var ids = results[normalise(query)];
|
score: function () { return function () { return 1; }; },
|
||||||
return function (option) { return ids && ids.has(String(option.value)) ? 1 : 0; };
|
|
||||||
},
|
|
||||||
shouldLoad: function (query) { return query.length > 0; },
|
shouldLoad: function (query) { return query.length > 0; },
|
||||||
load: function (query, callback) {
|
load: function (query, callback) {
|
||||||
var separator = url.indexOf('?') === -1 ? '?' : '&';
|
var separator = url.indexOf('?') === -1 ? '?' : '&';
|
||||||
fetch(url + separator + 'q=' + encodeURIComponent(query), {credentials: 'same-origin'})
|
fetch(url + separator + 'q=' + encodeURIComponent(query), {credentials: 'same-origin'})
|
||||||
.then(function (response) { return response.json(); })
|
.then(function (response) { return response.json(); })
|
||||||
.then(function (data) {
|
.then(function (data) {
|
||||||
var options = data.map(function (item) {
|
callback(data.map(function (item) {
|
||||||
return {value: item.pk, text: item.text, update_url: item.update};
|
return {value: item.pk, text: item.text, update_url: item.update};
|
||||||
});
|
}));
|
||||||
results[normalise(query)] = new Set(options.map(function (option) { return String(option.value); }));
|
|
||||||
callback(options);
|
|
||||||
})
|
})
|
||||||
.catch(function () { callback(); });
|
.catch(function () { callback(); });
|
||||||
}
|
}
|
||||||
@@ -105,14 +94,6 @@ function initPicker(select) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var ts = new TomSelect(select, settings);
|
var ts = new TomSelect(select, settings);
|
||||||
if (url) {
|
|
||||||
// Emptying the search box shouldn't list everything loaded so far (selected options are kept)
|
|
||||||
ts.on('type', function (query) {
|
|
||||||
if (query === '') {
|
|
||||||
ts.clearOptions();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Object.keys(update_urls).forEach(function (value) {
|
Object.keys(update_urls).forEach(function (value) {
|
||||||
if (ts.options[value]) {
|
if (ts.options[value]) {
|
||||||
ts.options[value].update_url = update_urls[value];
|
ts.options[value].update_url = update_urls[value];
|
||||||
|
|||||||
Reference in New Issue
Block a user