mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
improved tooltip in map, improved user-settings handling
This commit is contained in:
@@ -90,15 +90,25 @@ export function upsertSettings(settingsMapOrEntry, userId = null) {
|
|||||||
: Object.entries(settingsMapOrEntry || {});
|
: Object.entries(settingsMapOrEntry || {});
|
||||||
|
|
||||||
for (const [name, rawValue] of entries) {
|
for (const [name, rawValue] of entries) {
|
||||||
const id = nanoid();
|
if (rawValue === null) {
|
||||||
const create_date = Date.now();
|
SqliteConnection.execute(
|
||||||
const json = toJson(rawValue === null ? 'null' : rawValue);
|
`DELETE FROM settings WHERE name = @name AND (user_id = @userId OR (user_id IS NULL AND @userId IS NULL))`,
|
||||||
SqliteConnection.execute(
|
{
|
||||||
`INSERT INTO settings (id, create_date, name, value, user_id)
|
name,
|
||||||
|
userId,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const id = nanoid();
|
||||||
|
const create_date = Date.now();
|
||||||
|
const json = toJson(rawValue);
|
||||||
|
SqliteConnection.execute(
|
||||||
|
`INSERT INTO settings (id, create_date, name, value, user_id)
|
||||||
VALUES (@id, @create_date, @name, @value, @userId)
|
VALUES (@id, @create_date, @name, @value, @userId)
|
||||||
ON CONFLICT(name, IFNULL(user_id, 'GLOBAL_SETTING')) DO UPDATE SET value = excluded.value`,
|
ON CONFLICT(name, IFNULL(user_id, 'GLOBAL_SETTING')) DO UPDATE SET value = excluded.value`,
|
||||||
{ id, create_date, name, value: json, userId },
|
{ id, create_date, name, value: json, userId },
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// keep cache in sync (only for global settings)
|
// keep cache in sync (only for global settings)
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ function isOneOf(word, arr) {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
function nullOrEmpty(val) {
|
function nullOrEmpty(val) {
|
||||||
return val == null || val.length === 0 || val === 'null' || val === 'undefined';
|
return val == null || val.length === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import RangeSlider from 'react-range-slider-input';
|
|||||||
import 'react-range-slider-input/dist/style.css';
|
import 'react-range-slider-input/dist/style.css';
|
||||||
import './Map.less';
|
import './Map.less';
|
||||||
import { xhrDelete } from '../../services/xhr.js';
|
import { xhrDelete } from '../../services/xhr.js';
|
||||||
|
import { Link } from 'react-router';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
@@ -503,7 +504,12 @@ export default function MapView() {
|
|||||||
type="warning"
|
type="warning"
|
||||||
bordered
|
bordered
|
||||||
closeIcon={null}
|
closeIcon={null}
|
||||||
description="You have not set your home address yet. Please do so in the settings to use the distance filter."
|
description={
|
||||||
|
<span>
|
||||||
|
You have not set your home address yet. Please do so in the <Link to="/userSettings">user settings</Link>{' '}
|
||||||
|
to use the distance filter.
|
||||||
|
</span>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user