mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-12 18:08:47 +00:00
[Core] allow more dynamic options
This commit is contained in:
parent
60874b093a
commit
4ae6f847e6
@ -260,16 +260,17 @@ final class BridgeCard
|
|||||||
}
|
}
|
||||||
|
|
||||||
$fieldsValueString = '';
|
$fieldsValueString = '';
|
||||||
|
$fieldsNameUsedAsValueSeparator = isset($entry['fields_name_used_as_value_separator']) ? $entry['fields_name_used_as_value_separator'] : '-';
|
||||||
foreach ($entry['fields_name_used_as_value'] as $index => $field) {
|
foreach ($entry['fields_name_used_as_value'] as $index => $field) {
|
||||||
if ($index === 0) {
|
if ($index === 0) {
|
||||||
$fieldsValueString = 'option.' . $field;
|
$fieldsValueString = 'option.' . $field;
|
||||||
} else {
|
} else {
|
||||||
$fieldsValueString .= ' + \'-\' + option.' . $field;
|
$fieldsValueString .= ' + \'' . $fieldsNameUsedAsValueSeparator . '\' + option.' . $field;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = sprintf(
|
$list = sprintf(
|
||||||
'<input %s id="input-%s" name="%s" type="text" list="options-%s" onmousedown="
|
'<input %s id="input-%s" name="%s" autocomplete="off" type="text" list="options-%s" onmousedown="
|
||||||
const id = \'%s\';
|
const id = \'%s\';
|
||||||
const inputElement = document.getElementById(\'input-\' + id);
|
const inputElement = document.getElementById(\'input-\' + id);
|
||||||
const errorElement = document.getElementById(\'error-\' + id);
|
const errorElement = document.getElementById(\'error-\' + id);
|
||||||
@ -298,7 +299,10 @@ final class BridgeCard
|
|||||||
if (xhr.status === 200) {
|
if (xhr.status === 200) {
|
||||||
// Parse the response and update the datalist
|
// Parse the response and update the datalist
|
||||||
datalist.innerHTML = \'\'; // Clear existing options
|
datalist.innerHTML = \'\'; // Clear existing options
|
||||||
const options = JSON.parse(xhr.responseText); // Assuming JSON response
|
let options = JSON.parse(xhr.responseText); // Assuming JSON response
|
||||||
|
if (%s) {
|
||||||
|
options = options[\'%s\'];
|
||||||
|
}
|
||||||
options.forEach(option => {
|
options.forEach(option => {
|
||||||
const opt = document.createElement(\'option\');
|
const opt = document.createElement(\'option\');
|
||||||
|
|
||||||
@ -325,6 +329,8 @@ final class BridgeCard
|
|||||||
$id,
|
$id,
|
||||||
Configuration::getConfig('proxy', 'url') ?: 'https://cors-anywhere.herokuapp.com/',
|
Configuration::getConfig('proxy', 'url') ?: 'https://cors-anywhere.herokuapp.com/',
|
||||||
$entry['ajax_route'],
|
$entry['ajax_route'],
|
||||||
|
isset($entry['field_for_options']) ? 'true' : 'false',
|
||||||
|
isset($entry['field_for_options']) ? $entry['field_for_options'] : null,
|
||||||
$fieldsDisplayString,
|
$fieldsDisplayString,
|
||||||
$fieldsValueString,
|
$fieldsValueString,
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user