Inline activity creation - #5950
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enables inline creation of Activities from UI select fields (primarily the timesheet form), makes the feature enabled by default, and exposes a Superadmin system configuration toggle for it.
Changes:
- Enable inline Activity creation in the timesheet edit form and wire the create endpoint into the select widget.
- Add
activity.allow_inline_createto system configuration UI and flip its default totrue. - Update frontend select handling and rebuild compiled assets (manifest/entrypoints/build outputs).
Reviewed changes
Copilot reviewed 10 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Form/TimesheetEditForm.php | Enables inline activity creation in the timesheet form; adds a form option default driven by system config. |
| src/Form/FormTrait.php | Adjusts activity field recreation on PRE_SUBMIT (intended to preserve options). |
| src/DependencyInjection/Configuration.php | Changes default for activity.allow_inline_create to true. |
| src/Controller/SystemConfigurationController.php | Exposes activity.allow_inline_create in the system configuration UI. |
| assets/js/forms/KimaiTimesheetForm.js | Implements client-side “create activity” flow and replaces temporary TomSelect option with DB id. |
| assets/js/forms/KimaiFormSelect.js | Fixes TomSelect callback wiring for option-add/create handling. |
| public/build/manifest.json | Updates built asset hashes. |
| public/build/entrypoints.json | Updates built entrypoints and integrity hashes. |
| public/build/app.77ee706f.js.LICENSE.txt | Updates third-party license metadata in build output (DOMPurify version line). |
| public/build/app-rtl.7a875ca7.js | Adds updated RTL build chunk. |
| public/build/app-rtl.15853b82.js | Removes old RTL build chunk. |
Files not reviewed (1)
- public/build/app-rtl.7a875ca7.js: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Preserve api_data option when recreating activity field | ||
| $optionsForAdd = $options; | ||
| if (!isset($optionsForAdd['api_data'])) { | ||
| $optionsForAdd['api_data'] = []; | ||
| } | ||
|
|
||
| $event->getForm()->add('activity', ActivityType::class, $optionsForAdd); |
| this._activityListener = (event) => { | ||
| const project = this._project.value; | ||
| const tempName = event.detail.value; | ||
| /** @type {KimaiAPI} API */ | ||
| const API = this.getContainer().getPlugin('api'); | ||
| API.post(this._activity.dataset['create'], { | ||
| name: event.detail.value, | ||
| name: tempName, | ||
| project: (project === '' ? null : project), | ||
| visible: true, | ||
| }, () => { | ||
| }, (newActivity) => { | ||
| // TomSelect created an option with value=name (temp). Replace it | ||
| // with the real DB id so Symfony's EntityType validation accepts it. | ||
| const ts = this._activity.tomselect; | ||
| if (ts && newActivity && newActivity.id !== undefined) { | ||
| const realId = String(newActivity.id); | ||
| // Remove the temporary option (value=name) and add the real one | ||
| ts.removeOption(tempName); | ||
| ts.addOption({ value: realId, text: newActivity.name }); | ||
| ts.addItem(realId, true); // silent=true to avoid re-firing create | ||
| } | ||
| this._project.dispatchEvent(new Event('change')); | ||
| }); |
|
I am not sure of we really still need the option to disable this feature, what do you think? |
kevinpapst
left a comment
There was a problem hiding this comment.
Thanks for taking the time to contribute 👍
Can you please address the issues and remove all rebuild assets from public/build/.
I wil rebuild them later on.
dce2402 to
9f2f6e7
Compare
|
Ah, you found some very old test code with the allow_inline_create option. This can be completely removed. |
- enable by default - expose configuration option in Superadmin system-config UI - Uncomment activity.allow_inline_create configuration in SystemConfigurationController - Change default value from false to true in DependencyInjection/Configuration
…m SystemConfigurationController - Remove activity.allow_inline_create boolean node from DependencyInjection/Configuration - Remove activity.allow_inline_create translation entries from all language files
… creation - Remove unused `render` variable from KimaiFormSelect.js - Replace system configuration check with proper permission check for inline activity creation - Inject AuthorizationCheckerInterface into TimesheetEditForm - Only enable inline activity creation when user has 'create_activity' permission
9f2f6e7 to
9064024
Compare
|
It would be reaelly cool to have this added. At the moment it is quite a hazzle to start a new activity (I always first have to add it in the admin panel before you can book on it) |
Sure. Do you plan to address the Copilot comments? |
|
I didn't quite understand the problems, Cobpilot addressed and since I refatored it anyway I am not sure if this is still an issue. maybe you can take over from here, since you know the code base much better. what do you think? |
Description
Enable inline activity creation in UI-forms
Types of changes
Checklist
composer code-check)(there is no documentation there!)