mirror of
https://github.com/zadam/trilium.git
synced 2025-10-28 01:59:04 +01:00
feat(views/geo): add combobox to adjust style
This commit is contained in:
parent
8c4ed2d4da
commit
f90bf1ce7c
@ -203,6 +203,33 @@ export default class BookPropertiesWidget extends NoteContextAwareWidget {
|
|||||||
.append(" ".repeat(2))
|
.append(" ".repeat(2))
|
||||||
.append($numberInput));
|
.append($numberInput));
|
||||||
break;
|
break;
|
||||||
|
case "combobox":
|
||||||
|
const $select = $("<select>", {
|
||||||
|
class: "form-select form-select-sm"
|
||||||
|
});
|
||||||
|
for (const option of property.options) {
|
||||||
|
const $option = $("<option>", {
|
||||||
|
value: option.value,
|
||||||
|
text: option.label
|
||||||
|
});
|
||||||
|
if (note.getLabelValue(property.bindToLabel) === option.value) {
|
||||||
|
$option.prop("selected", true);
|
||||||
|
}
|
||||||
|
$select.append($option);
|
||||||
|
}
|
||||||
|
$select.on("change", () => {
|
||||||
|
const value = $select.val();
|
||||||
|
if (value === null || value === "") {
|
||||||
|
attributes.removeOwnedLabelByName(note, property.bindToLabel);
|
||||||
|
} else {
|
||||||
|
attributes.setLabel(note.noteId, property.bindToLabel, String(value));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$container.append($("<label>")
|
||||||
|
.text(property.label)
|
||||||
|
.append(" ".repeat(2))
|
||||||
|
.append($select));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
|
|||||||
@ -30,7 +30,14 @@ interface NumberProperty {
|
|||||||
min?: number;
|
min?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BookProperty = CheckBoxProperty | ButtonProperty | NumberProperty;
|
interface ComboBoxProperty {
|
||||||
|
type: "combobox",
|
||||||
|
label: string;
|
||||||
|
bindToLabel: string;
|
||||||
|
options: { value: string; label: string }[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export type BookProperty = CheckBoxProperty | ButtonProperty | NumberProperty | ComboBoxProperty;
|
||||||
|
|
||||||
interface BookContext {
|
interface BookContext {
|
||||||
note: FNote;
|
note: FNote;
|
||||||
@ -90,7 +97,17 @@ export const bookPropertiesConfig: Record<ViewTypeOptions, BookConfig> = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
geoMap: {
|
geoMap: {
|
||||||
properties: []
|
properties: [
|
||||||
|
{
|
||||||
|
label: "Map style:",
|
||||||
|
type: "combobox",
|
||||||
|
bindToLabel: "mapStyle",
|
||||||
|
options: [
|
||||||
|
{ value: "openstreetmap", label: "OpenStreetMap" },
|
||||||
|
{ value: "versatiles-colorful", label: "Versatiles Colorful (vector)" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
table: {
|
table: {
|
||||||
properties: [
|
properties: [
|
||||||
|
|||||||
@ -141,7 +141,7 @@ export default class GeoView extends ViewMode<MapData> {
|
|||||||
worldCopyJump: true
|
worldCopyJump: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const layerName = this.parentNote.getLabelValue("mapLayer") ?? "openstreetmap";
|
const layerName = this.parentNote.getLabelValue("mapStyle") ?? "openstreetmap";
|
||||||
const layer = (await getMapLayer(layerName));
|
const layer = (await getMapLayer(layerName));
|
||||||
layer.addTo(map);
|
layer.addTo(map);
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ export default class GeoView extends ViewMode<MapData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Full reload if map layer is changed.
|
// Full reload if map layer is changed.
|
||||||
if (loadResults.getAttributeRows().some(attr => attr.name === "mapLayer" && attributes.isAffecting(attr, this.parentNote))) {
|
if (loadResults.getAttributeRows().some(attr => attr.name === "mapStyle" && attributes.isAffecting(attr, this.parentNote))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user