Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Inline activity creation - #5950

Open
rubo77 wants to merge 4 commits into
kimai:mainfrom
rubo77:inline_activity_creation
Open

Inline activity creation#5950
rubo77 wants to merge 4 commits into
kimai:mainfrom
rubo77:inline_activity_creation

Conversation

@rubo77

@rubo77 rubo77 commented May 15, 2026

Copy link
Copy Markdown

Description

Enable inline activity creation in UI-forms

  • 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

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist

  • I verified that my code applies to the guidelines (composer code-check)
  • I updated the documentation (see here)
    (there is no documentation there!)
  • I agree that this code is used in Kimai (see license)

Copilot AI review requested due to automatic review settings May 15, 2026 00:09
@CLAassistant

CLAassistant commented May 15, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_create to system configuration UI and flip its default to true.
  • 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.

Comment thread src/Form/TimesheetEditForm.php Outdated
Comment thread src/Form/FormTrait.php
Comment on lines +127 to +133
// 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);
Comment on lines 96 to 117
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'));
});
@rubo77

rubo77 commented May 15, 2026

Copy link
Copy Markdown
Author

I am not sure of we really still need the option to disable this feature, what do you think?

@kevinpapst kevinpapst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rubo77
rubo77 force-pushed the inline_activity_creation branch from dce2402 to 9f2f6e7 Compare May 19, 2026 04:32
@kevinpapst

Copy link
Copy Markdown
Member

Ah, you found some very old test code with the allow_inline_create option. This can be completely removed.
But what we need is a guard and activate the feature only for the users with isGranted('create_activity')

rubo77 added 3 commits May 29, 2026 12:38
- 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
@rubo77
rubo77 force-pushed the inline_activity_creation branch from 9f2f6e7 to 9064024 Compare May 29, 2026 11:13
@rubo77

rubo77 commented May 29, 2026

Copy link
Copy Markdown
Author

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)

@kevinpapst

Copy link
Copy Markdown
Member

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?

@rubo77

rubo77 commented Jun 3, 2026

Copy link
Copy Markdown
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants