mirror of
https://github.com/zadam/trilium.git
synced 2025-11-13 16:55:50 +01:00
chore(react/promoted_attributes): multiplicity
This commit is contained in:
@@ -5,6 +5,7 @@ import { Attribute } from "../services/attribute_parser";
|
||||
import { ComponentChild } from "preact";
|
||||
import FAttribute from "../entities/fattribute";
|
||||
import { t } from "../services/i18n";
|
||||
import ActionButton from "./react/ActionButton";
|
||||
|
||||
export default function PromotedAttributes() {
|
||||
const { note } = useNoteContext();
|
||||
@@ -94,6 +95,26 @@ function PromotedAttributeCell({ noteId, definitionAttr, valueAttr, valueName }:
|
||||
placeholder={t("promoted_attributes.unset-field-placeholder")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div />
|
||||
|
||||
{definition.multiplicity === "multi" && (
|
||||
<td className="multiplicity">
|
||||
<ActionButton
|
||||
icon="bx bx-plus"
|
||||
className="pointer tn-tool-button"
|
||||
text={t("promoted_attributes.add_new_attribute")}
|
||||
noIconActionClass
|
||||
/>
|
||||
|
||||
<ActionButton
|
||||
icon="bx bx-trash"
|
||||
className="pointer tn-tool-button"
|
||||
text={t("promoted_attributes.remove_this_attribute")}
|
||||
noIconActionClass
|
||||
/>
|
||||
</td>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -30,13 +30,8 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
|
||||
async createPromotedAttributeCell(definitionAttr: FAttribute, valueAttr: Attribute, valueName: string) {
|
||||
// .on("change", (event) => this.promotedAttributeChanged(event));
|
||||
|
||||
const $actionCell = $("<div>");
|
||||
const $multiplicityCell = $("<td>").addClass("multiplicity").attr("nowrap", "true");
|
||||
|
||||
const $wrapper = $('<div class="promoted-attribute-cell">')
|
||||
.append($actionCell)
|
||||
.append($multiplicityCell);
|
||||
|
||||
if (valueAttr.type === "label") {
|
||||
$wrapper.addClass(`promoted-attribute-label-${definition.labelType}`);
|
||||
if (definition.labelType === "text") {
|
||||
@@ -170,8 +165,6 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
|
||||
|
||||
if (definition.multiplicity === "multi") {
|
||||
const $addButton = $("<span>")
|
||||
.addClass("bx bx-plus pointer tn-tool-button")
|
||||
.prop("title", t("promoted_attributes.add_new_attribute"))
|
||||
.on("click", async () => {
|
||||
const $new = await this.createPromotedAttributeCell(
|
||||
definitionAttr,
|
||||
|
||||
Reference in New Issue
Block a user