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