mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 12:39:04 +01:00
refactor(views/table): integrate parser into data
This commit is contained in:
parent
e66aef17df
commit
0b74de275c
@ -2,8 +2,7 @@ import froca from "../../services/froca.js";
|
||||
import ViewMode, { type ViewModeArgs } from "./view_mode.js";
|
||||
import { createGrid, AllCommunityModule, ModuleRegistry, GridOptions } from "ag-grid-community";
|
||||
import { setLabel } from "../../services/attributes.js";
|
||||
import getPromotedAttributeInformation from "./table_view/parser.js";
|
||||
import { buildData, TableData } from "./table_view/data.js";
|
||||
import getPromotedAttributeInformation, { buildData, TableData } from "./table_view/data.js";
|
||||
import applyHeaderCustomization from "./table_view/header-customization.js";
|
||||
import server from "../../services/server.js";
|
||||
import type { GridState } from "ag-grid-community";
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { GridOptions } from "ag-grid-community";
|
||||
import FNote from "../../../entities/fnote.js";
|
||||
import type { LabelType } from "../../../services/promoted_attribute_definition_parser.js";
|
||||
import { default as getPromotedAttributeInformation, type PromotedAttributeInformation } from "./parser.js";
|
||||
|
||||
export type TableData = {
|
||||
noteId: string;
|
||||
@ -9,6 +8,11 @@ export type TableData = {
|
||||
labels: Record<string, boolean | string | null>;
|
||||
};
|
||||
|
||||
export interface PromotedAttributeInformation {
|
||||
name: string;
|
||||
title?: string;
|
||||
type?: LabelType;
|
||||
}
|
||||
|
||||
type GridLabelType = 'text' | 'number' | 'boolean' | 'date' | 'dateString' | 'object';
|
||||
|
||||
@ -84,3 +88,26 @@ export function buildRowDefinitions(notes: FNote[], infos: PromotedAttributeInfo
|
||||
|
||||
return definitions;
|
||||
}
|
||||
|
||||
export default function getPromotedAttributeInformation(parentNote: FNote) {
|
||||
const info: PromotedAttributeInformation[] = [];
|
||||
for (const promotedAttribute of parentNote.getPromotedDefinitionAttributes()) {
|
||||
if (promotedAttribute.type !== "label") {
|
||||
console.warn("Relations are not supported for now");
|
||||
continue;
|
||||
}
|
||||
|
||||
const def = promotedAttribute.getDefinition();
|
||||
if (def.multiplicity !== "single") {
|
||||
console.warn("Multiple values are not supported for now");
|
||||
continue;
|
||||
}
|
||||
|
||||
info.push({
|
||||
name: promotedAttribute.name.split(":", 2)[1],
|
||||
title: def.promotedAlias,
|
||||
type: def.labelType
|
||||
})
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
import FNote from "../../../entities/fnote";
|
||||
import { LabelType } from "../../../services/promoted_attribute_definition_parser";
|
||||
|
||||
export interface PromotedAttributeInformation {
|
||||
name: string;
|
||||
title?: string;
|
||||
type?: LabelType;
|
||||
}
|
||||
|
||||
export default function getPromotedAttributeInformation(parentNote: FNote) {
|
||||
const info: PromotedAttributeInformation[] = [];
|
||||
for (const promotedAttribute of parentNote.getPromotedDefinitionAttributes()) {
|
||||
if (promotedAttribute.type !== "label") {
|
||||
console.warn("Relations are not supported for now");
|
||||
continue;
|
||||
}
|
||||
|
||||
const def = promotedAttribute.getDefinition();
|
||||
if (def.multiplicity !== "single") {
|
||||
console.warn("Multiple values are not supported for now");
|
||||
continue;
|
||||
}
|
||||
|
||||
info.push({
|
||||
name: promotedAttribute.name.split(":", 2)[1],
|
||||
title: def.promotedAlias,
|
||||
type: def.labelType
|
||||
})
|
||||
}
|
||||
return info;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user