Skip to content

Activity Directive Builder#1900

Open
JosephVolosin wants to merge 8 commits into
developfrom
feature/directive-creation-modal
Open

Activity Directive Builder#1900
JosephVolosin wants to merge 8 commits into
developfrom
feature/directive-creation-modal

Conversation

@JosephVolosin
Copy link
Copy Markdown
Contributor

@JosephVolosin JosephVolosin commented Mar 27, 2026

This PR introduces the activity directive builder, modeled from the activity filter builder for timeline editing, to build an activity directive prior to actual creation on the timeline.

The builder can be accessed 3 different ways:

  1. Dragging & dropping an activity on the timeline now brings up the builder prior to creation
  2. Hovering over an activity type on the Activity, Resource, Event Types menu allows the user to click the '+' button which brings up the builder
  3. Clicking the '+' button next to upload and filter underneath Activity, Resource, Event Types

The directive builder allows the user to fill in a name, start time, and parameter values for a directive prior to having it created on the timeline. Validation for parameter values and missing required parameters is included, but the user is still able to create an 'invalid' directive if they wish.

Screenshot 2026-05-08 at 1 04 46 PM

Testing

Create a plan and choose any of the 3 ways from above to access the directive builder. Then, fill out the information in the builder and click 'Create'. The activity directive with all the entered information should appear on the timeline.

@AaronPlave
Copy link
Copy Markdown
Contributor

Any reason not to use the activity form here embedded in a draggable window with a few extra components thrown in on top?

@JosephVolosin JosephVolosin force-pushed the feature/directive-creation-modal branch from d91262a to cd6b8e4 Compare April 23, 2026 18:41
@JosephVolosin JosephVolosin force-pushed the feature/directive-creation-modal branch from cd6b8e4 to 157b1cc Compare April 23, 2026 18:42
@JosephVolosin JosephVolosin force-pushed the feature/directive-creation-modal branch from 157b1cc to b060112 Compare April 23, 2026 20:24
@JosephVolosin JosephVolosin force-pushed the feature/directive-creation-modal branch from b060112 to 7e23e38 Compare April 23, 2026 20:25
@JosephVolosin JosephVolosin force-pushed the feature/directive-creation-modal branch from 7e23e38 to 4e9d584 Compare April 23, 2026 20:34
@JosephVolosin JosephVolosin force-pushed the feature/directive-creation-modal branch from 4e9d584 to 1f30961 Compare April 23, 2026 20:45
@JosephVolosin JosephVolosin force-pushed the feature/directive-creation-modal branch from 1f30961 to 38304f5 Compare April 23, 2026 20:46
@JosephVolosin
Copy link
Copy Markdown
Contributor Author

Any reason not to use the activity form here embedded in a draggable window with a few extra components thrown in on top?

It seemed like it would be a considerable rework to support it here since we want the validation and editing to happen on a directive that isn't created. The code for validation is more-or-less copy/paste though, so at least I think that can be pulled out to a common function.

@JosephVolosin JosephVolosin force-pushed the feature/directive-creation-modal branch from b05e206 to cb284a8 Compare May 8, 2026 16:35
@JosephVolosin JosephVolosin marked this pull request as ready for review May 8, 2026 16:38
@JosephVolosin JosephVolosin requested a review from a team as a code owner May 8, 2026 16:38
import Parameters from '../parameters/Parameters.svelte';
import Draggable from '../timeline/form/TimelineEditor/Draggable.svelte';

export let directiveWidth: number = 1000;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe just width? Know the other ones say "filterWidth" though hoping at some point we can merge #1828 and make that width more generic if it isn't already included in there,

}
const activityDirectiveTags: ActivityDirectiveTagsInsertInput[] = tagsToAdd.map(({ id: tag_id }) => ({
directive_id: activityDirective.id,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

whitespace change not needed

@@ -760,7 +761,7 @@

const createActivities = () => {
items.forEach(item => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Only one buildDirective can win here so all previous dispatches will be lost. This PR is centered around a single builder window for a single directive and I don't think we want to go near a multi-directive builder here but it does break the previous behavior where a user could drag all activity types on the timeline via the handle to the right of the "Activities (X)" header. I doubt anyone was actually using this feature, it's likely more for testing purposes and it is pretty hidden. Should either directly create all of those directives and skip the builder, open the builder with the first type, or get rid of the handle entirely.


function onCreateActivityDirective(directive: ActivityDirectiveInsertInput) {
if ($plan !== null && $plan.model) {
effects.createActivityDirectivePredefined(directive, $plan, user);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we await creation of the directive first in case it fails to create? I know a failure toast will appear, just means that if any sort of hiccup happens (unlikely) that user input from builder will be lost. Not sure if it is necessary though.

>
<UploadIcon />
</button>
<Button variant="ghost" size="icon-sm" aria-label="Add Activity" on:click={onShowDirectiveBuilder}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Button needs permission gating.

>
<UploadIcon />
</button>
<Button variant="ghost" size="icon-sm" aria-label="Add Activity" on:click={onShowDirectiveBuilder}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this be an outline button that matches the height of the neighboring buttons?

</div>
</div>
<div class="directive-section-content directive-section-content-bordered">
<DatePickerField
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would be nice to use plan start/end instead of today for the buttons here (think we do it in other places in the app) to make it easier for users to get back to a relevant time range.

{/if}
</div>
</div>
<!-- </CssGrid> -->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unused comment

let startTimeField: FieldStore<string>;
let startTime: string = $plan?.start_time_doy ?? '';

let currentActivityTypeFormParams: FormParameter[] = [];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you alphabetize your let declarations in this component?

}

.body {
/* background: var(--st-gray-15); */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can remove this comment

return result;
}

export async function validateArguments(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add unit tests for this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add some e2e tests (though I'm sure you're working on those) that use the builder via button and drag and drop?

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

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants