mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-28 18:20:42 +00:00
feat: adjust context menu for planner and schedule
This commit is contained in:
parent
c55daa67fd
commit
77e4d8b0cf
6 changed files with 31 additions and 14 deletions
|
|
@ -13,7 +13,7 @@ import {
|
|||
} from '@angular/core';
|
||||
import { ScheduleEvent, ScheduleFromCalendarEvent } from '../schedule.model';
|
||||
import { MatIcon } from '@angular/material/icon';
|
||||
import { delay, first } from 'rxjs/operators';
|
||||
import { delay, first, switchMap } from 'rxjs/operators';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { selectProjectById } from '../../project/store/project.selectors';
|
||||
import { MatMiniFabButton } from '@angular/material/button';
|
||||
|
|
@ -47,6 +47,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|||
import { DialogTaskDetailPanelComponent } from '../../tasks/dialog-task-additional-info-panel/dialog-task-detail-panel.component';
|
||||
import { CalendarIntegrationService } from '../../calendar-integration/calendar-integration.service';
|
||||
import { TaskContextMenuComponent } from '../../tasks/task-context-menu/task-context-menu.component';
|
||||
import { BehaviorSubject, of } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'schedule-event',
|
||||
|
|
@ -97,6 +98,7 @@ export class ScheduleEventComponent implements OnInit {
|
|||
protected readonly SVEType = SVEType;
|
||||
destroyRef = inject(DestroyRef);
|
||||
private _isBeingSubmitted: boolean = false;
|
||||
private _projectId$ = new BehaviorSubject<string | null>(null);
|
||||
|
||||
@Input({ required: true })
|
||||
set event(event: ScheduleEvent) {
|
||||
|
|
@ -127,6 +129,7 @@ export class ScheduleEventComponent implements OnInit {
|
|||
this.se.type === SVEType.ScheduledTask
|
||||
) {
|
||||
this.task = this.se.data as TaskCopy;
|
||||
this._projectId$.next(this.task.projectId);
|
||||
|
||||
if (
|
||||
(this.se.type === SVEType.Task || this.se.type === SVEType.TaskPlannedForDay) &&
|
||||
|
|
@ -246,13 +249,21 @@ export class ScheduleEventComponent implements OnInit {
|
|||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
const pid = (this.se?.data as any)?.projectId;
|
||||
if (pid) {
|
||||
this._store
|
||||
.select(selectProjectById, { id: pid })
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
if (this.task) {
|
||||
this._projectId$
|
||||
.pipe(
|
||||
switchMap((projectId) =>
|
||||
projectId
|
||||
? this._store.select(selectProjectById, { id: projectId })
|
||||
: of(null),
|
||||
),
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
)
|
||||
.subscribe((p) => {
|
||||
this._elRef.nativeElement.style.setProperty('--project-color', p.theme.primary);
|
||||
this._elRef.nativeElement.style.setProperty(
|
||||
'--project-color',
|
||||
p ? p.theme.primary : '',
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<ng-template matMenuContent>
|
||||
<button
|
||||
(click)="startTask()"
|
||||
*ngIf="IS_TOUCH_PRIMARY && !task.isDone && !isCurrent && !task.subTasks?.length"
|
||||
*ngIf="isAdvancedControls() && IS_TOUCH_PRIMARY && !task.isDone && !isCurrent && !task.subTasks?.length"
|
||||
mat-menu-item
|
||||
>
|
||||
<span class="menuItemLeft">
|
||||
|
|
@ -25,9 +25,10 @@
|
|||
</span>
|
||||
<span class="key-i">{{ kb.togglePlay }}</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
(click)="pauseTask()"
|
||||
*ngIf="IS_TOUCH_PRIMARY && !task.isDone && isCurrent && !task.subTasks?.length"
|
||||
*ngIf="isAdvancedControls() &&IS_TOUCH_PRIMARY && !task.isDone && isCurrent && !task.subTasks?.length"
|
||||
mat-menu-item
|
||||
>
|
||||
<span class="menuItemLeft">
|
||||
|
|
@ -54,7 +55,7 @@
|
|||
|
||||
<button
|
||||
(click)="removeFromMyDay()"
|
||||
*ngIf="IS_TOUCH_PRIMARY && !task.parentId && !task.isDone && isTodayTag && (task.projectId || task.tagIds?.length > 1)"
|
||||
*ngIf="isAdvancedControls() &&IS_TOUCH_PRIMARY && !task.parentId && !task.isDone && isTodayTag && (task.projectId || task.tagIds?.length > 1)"
|
||||
mat-menu-item
|
||||
>
|
||||
<mat-icon svgIcon="remove_today"></mat-icon>
|
||||
|
|
@ -96,7 +97,7 @@
|
|||
|
||||
<button
|
||||
(click)="addSubTask();"
|
||||
*ngIf="!task.parentId&&!task.isDone"
|
||||
*ngIf="isAdvancedControls() && !task.parentId&&!task.isDone"
|
||||
mat-menu-item
|
||||
>
|
||||
<span class="menuItemLeft">
|
||||
|
|
@ -141,7 +142,7 @@
|
|||
|
||||
<button
|
||||
(click)="moveToBacklog();"
|
||||
*ngIf="!task.parentId && !isBacklog && task.projectId && (isShowMoveFromAndToBacklogBtns$|async)"
|
||||
*ngIf="isAdvancedControls() && !task.parentId && !isBacklog && task.projectId && (isShowMoveFromAndToBacklogBtns$|async)"
|
||||
mat-menu-item
|
||||
>
|
||||
<span class="menuItemLeft">
|
||||
|
|
@ -153,7 +154,7 @@
|
|||
|
||||
<button
|
||||
(click)="moveToToday();"
|
||||
*ngIf="!task.parentId && isBacklog && task.projectId && (isShowMoveFromAndToBacklogBtns$|async)"
|
||||
*ngIf="isAdvancedControls() && !task.parentId && isBacklog && task.projectId && (isShowMoveFromAndToBacklogBtns$|async)"
|
||||
mat-menu-item
|
||||
>
|
||||
<span class="menuItemLeft">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
AfterViewInit,
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
ElementRef,
|
||||
input,
|
||||
|
|
@ -136,6 +137,7 @@ export class TaskContextMenuInnerComponent implements AfterViewInit {
|
|||
private readonly _projectService: ProjectService,
|
||||
public readonly workContextService: WorkContextService,
|
||||
private readonly _globalConfigService: GlobalConfigService,
|
||||
private readonly _cd: ChangeDetectorRef,
|
||||
private readonly _store: Store,
|
||||
) {}
|
||||
|
||||
|
|
@ -159,7 +161,7 @@ export class TaskContextMenuInnerComponent implements AfterViewInit {
|
|||
}
|
||||
|
||||
get kb(): KeyboardConfig {
|
||||
if (IS_TOUCH_PRIMARY) {
|
||||
if (IS_TOUCH_PRIMARY || !this.isAdvancedControls()) {
|
||||
return {} as any;
|
||||
}
|
||||
return (this._globalConfigService.cfg?.keyboard as KeyboardConfig) || {};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
@if (isShowInner) {
|
||||
<task-context-menu-inner
|
||||
#taskContextMenuInner
|
||||
[isAdvancedControls]="isAdvancedControls()"
|
||||
[task]="task()"
|
||||
></task-context-menu-inner>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import { TaskContextMenuInnerComponent } from './task-context-menu-inner/task-co
|
|||
})
|
||||
export class TaskContextMenuComponent {
|
||||
task = input.required<TaskWithSubTasks | Task>();
|
||||
isAdvancedControls = input<boolean>(false);
|
||||
isShowInner: boolean = true;
|
||||
|
||||
@ViewChild('taskContextMenuInner', {
|
||||
|
|
|
|||
|
|
@ -382,6 +382,7 @@
|
|||
<!--*ngIf="isShowContextMenu"-->
|
||||
|
||||
<task-context-menu
|
||||
[isAdvancedControls]="true"
|
||||
#taskContextMenu
|
||||
[task]="task"
|
||||
></task-context-menu>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue