MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / createFieldCard

Function createFieldCard

src/settings/components/FieldManagerComponent.ts:105–264  ·  view source on GitHub ↗

* Creates a card for a single field using the CardComponent system

(
	container: HTMLElement,
	field: ModalFieldConfig,
	index: number,
	config: TaskModalFieldsConfig,
	plugin: TaskNotesPlugin,
	onUpdate: (config: TaskModalFieldsConfig) => void,
	app: App,
	groupId: FieldGroup
)

Source from the content-addressed store, hash-verified

103 * Creates a card for a single field using the CardComponent system
104 */
105function createFieldCard(
106 container: HTMLElement,
107 field: ModalFieldConfig,
108 index: number,
109 config: TaskModalFieldsConfig,
110 plugin: TaskNotesPlugin,
111 onUpdate: (config: TaskModalFieldsConfig) => void,
112 app: App,
113 groupId: FieldGroup
114): void {
115 // Create type badge
116 const typeBadge = activeDocument.createElement("span");
117 typeBadge.classList.add("field-card__type");
118 typeBadge.classList.add(`field-card__type--${field.fieldType}`);
119 typeBadge.textContent = field.fieldType;
120
121 // Create toggle switches with callbacks
122 const enabledToggle = createCardToggle(field.enabled, (value) => {
123 const fieldIndex = config.fields.findIndex((f) => f.id === field.id);
124 if (fieldIndex !== -1) {
125 config.fields[fieldIndex].enabled = value;
126 onUpdate(config);
127 // Re-render to update visibility
128 const activeTab = activeDocument.querySelector(
129 ".field-manager__tab--active"
130 ) as HTMLElement;
131 if (activeTab) {
132 const tabParent = activeTab.parentElement;
133 const contentParent = container.parentElement;
134 if (!tabParent || !contentParent) {
135 return;
136 }
137 const tabIndex = Array.from(tabParent.children).indexOf(activeTab);
138 const groups = [...config.groups].sort((a, b) => a.order - b.order);
139 const groupToRender = groups[tabIndex];
140 if (groupToRender) {
141 renderFieldGroup(
142 contentParent,
143 groupToRender.id,
144 config,
145 plugin,
146 onUpdate,
147 app
148 );
149 }
150 }
151 }
152 });
153
154 const creationToggle = createCardToggle(field.visibleInCreation, (value) => {
155 const fieldIndex = config.fields.findIndex((f) => f.id === field.id);
156 if (fieldIndex !== -1) {
157 config.fields[fieldIndex].visibleInCreation = value;
158 onUpdate(config);
159 }
160 });
161
162 const editToggle = createCardToggle(field.visibleInEdit, (value) => {

Callers 1

renderFieldGroupFunction · 0.85

Calls 6

createCardToggleFunction · 0.90
createCardSelectFunction · 0.90
createCardFunction · 0.90
setupCardDragAndDropFunction · 0.90
renderFieldGroupFunction · 0.85
getFieldSecondaryTextFunction · 0.85

Tested by

no test coverage detected