Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | import Lng from 'src/classes/Lng'; import { ILogger_ } from 'src/interfaces/ILogger'; import { IPrj } from 'src/interfaces/IPrj'; import { Field, FormConfiguration } from 'src/types/ModalFormType'; import CreateNewTaskManagementModal from './CreateNewTaskManagementModal'; import { Resolve } from '../DependencyInjection/functions/Resolve'; import { HelperObsidian } from '../Helper/Obsidian'; /** * Represents a modal to create a new project. */ export default class CreateNewProjectModal extends CreateNewTaskManagementModal { /** * Create a new `FormConfiguration` for the modal * @returns The form configuration */ protected override constructForm(): FormConfiguration { const form = super.constructForm(); form.title = `${Lng.gt('New')} ${Lng.gt('Project')}`; const typeFieldIndex = form.fields.findIndex( (field) => field.name === 'type', ); Iif ( typeFieldIndex !== -1 && form.fields[typeFieldIndex].input.type === 'select' ) { const selectInput = form.fields[typeFieldIndex].input as { type: 'select'; options: { value: string; label: string }[]; }; selectInput.options = [ { value: 'Project', label: Lng.gt('Project') }, ]; } // SubType const subType: Field = { name: 'subtype', label: Lng.gt('SubType'), description: Lng.gt('SubTypeDescription'), isRequired: false, input: { type: 'select', source: 'fixed', options: [], }, }; const taskSubTypes = this._IPrjSettings.prjSettings.subProjectTemplates?.map( (value) => ({ value: value.template, label: value.label }), ); Iif (taskSubTypes && subType.input.type === 'select') { subType.input.options.push({ value: '', label: Lng.gt('None') }); subType.input.options.push(...taskSubTypes); } // Fügen Sie das subType-Feld direkt nach dem typeField ein Iif (typeFieldIndex !== -1) { form.fields.splice(typeFieldIndex + 1, 0, subType); } return form; } /** * Registers the command to open the modal * @remarks No cleanup needed */ public static registerCommand(): void { const plugin = Resolve<IPrj>('IPrj'); const logger = Resolve<ILogger_>('ILogger_').getLogger( 'CreateNewProjectModal', ); logger.trace("Registering 'CreateNewProjectModal' commands"); plugin.addCommand({ id: 'create-new-project-file', name: `${Lng.gt('New project')}`, /** * */ callback: async () => { const modal = new CreateNewProjectModal(); const result = await modal.openForm(); Iif (result) { const prj = await modal.evaluateForm(result); Iif (prj) await HelperObsidian.openFile(prj.file); } }, }); } } |