mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-18 08:56:41 +00:00
feat(weekPlanner): make super basic add task work for planner
This commit is contained in:
parent
6c24d0250f
commit
666cbb5dc4
7 changed files with 93 additions and 7 deletions
|
|
@ -0,0 +1,17 @@
|
|||
<div
|
||||
style="text-align: center"
|
||||
*ngIf="!isShowAddTask"
|
||||
(click)="isShowAddTask = true"
|
||||
>
|
||||
<button mat-button>
|
||||
<mat-icon>add</mat-icon>
|
||||
Add new
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<add-task-bar
|
||||
*ngIf="isShowAddTask"
|
||||
(blurred)="isShowAddTask = false"
|
||||
(done)="isShowAddTask = false"
|
||||
[planForDay]="planForDay"
|
||||
></add-task-bar>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
// import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
//
|
||||
// import { AddTaskInlineComponent } from './add-task-inline.component';
|
||||
//
|
||||
// describe('AddTaskInlineComponent', () => {
|
||||
// let component: AddTaskInlineComponent;
|
||||
// let fixture: ComponentFixture<AddTaskInlineComponent>;
|
||||
//
|
||||
// beforeEach(async () => {
|
||||
// await TestBed.configureTestingModule({
|
||||
// imports: [AddTaskInlineComponent]
|
||||
// })
|
||||
// .compileComponents();
|
||||
//
|
||||
// fixture = TestBed.createComponent(AddTaskInlineComponent);
|
||||
// component = fixture.componentInstance;
|
||||
// fixture.detectChanges();
|
||||
// });
|
||||
//
|
||||
// it('should create', () => {
|
||||
// expect(component).toBeTruthy();
|
||||
// });
|
||||
// });
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||
import { TasksModule } from '../../tasks/tasks.module';
|
||||
import { UiModule } from '../../../ui/ui.module';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'add-task-inline',
|
||||
standalone: true,
|
||||
imports: [TasksModule, UiModule, CommonModule],
|
||||
templateUrl: './add-task-inline.component.html',
|
||||
styleUrl: './add-task-inline.component.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class AddTaskInlineComponent {
|
||||
@Input() planForDay?: string;
|
||||
|
||||
isShowAddTask = false;
|
||||
}
|
||||
|
|
@ -48,12 +48,7 @@
|
|||
}
|
||||
</div>
|
||||
|
||||
<div style="text-align: center">
|
||||
<button mat-button>
|
||||
<mat-icon>add</mat-icon>
|
||||
Add new
|
||||
</button>
|
||||
</div>
|
||||
<add-task-inline [planForDay]="day.dayDate"></add-task-inline>
|
||||
</div>
|
||||
|
||||
<div class="scheduled">
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import { plannerFeature } from './store/planner.reducer';
|
|||
import { PlannerEffects } from './store/planner.effects';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { DialogAddPlannedTasksComponent } from './dialog-add-planned-tasks/dialog-add-planned-tasks.component';
|
||||
import { AddTaskInlineComponent } from './add-task-inline/add-task-inline.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
|
@ -53,6 +54,7 @@ import { DialogAddPlannedTasksComponent } from './dialog-add-planned-tasks/dialo
|
|||
TagModule,
|
||||
CdkDragPlaceholder,
|
||||
IssueModule,
|
||||
AddTaskInlineComponent,
|
||||
],
|
||||
})
|
||||
export class PlannerModule {}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ import { blendInOutAnimation } from 'src/app/ui/animations/blend-in-out.ani';
|
|||
import { fadeAnimation } from '../../../ui/animations/fade.ani';
|
||||
import { SS } from '../../../core/persistence/storage-keys.const';
|
||||
import { IS_ANDROID_WEB_VIEW } from '../../../util/is-android-web-view';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { PlannerActions } from '../../planner/store/planner.actions';
|
||||
import { getWorklogStr } from '../../../util/get-work-log-str';
|
||||
|
||||
@Component({
|
||||
selector: 'add-task-bar',
|
||||
|
|
@ -59,6 +62,7 @@ export class AddTaskBarComponent implements AfterViewInit, OnDestroy {
|
|||
@Input() isDoubleEnterMode: boolean = false;
|
||||
@Input() isElevated: boolean = false;
|
||||
@Input() isDisableAutoFocus: boolean = false;
|
||||
@Input() planForDay?: string;
|
||||
@Output() blurred: EventEmitter<any> = new EventEmitter();
|
||||
@Output() done: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
|
|
@ -166,6 +170,7 @@ export class AddTaskBarComponent implements AfterViewInit, OnDestroy {
|
|||
private _projectService: ProjectService,
|
||||
private _tagService: TagService,
|
||||
private _cd: ChangeDetectorRef,
|
||||
private _store: Store,
|
||||
) {
|
||||
this._subs.add(
|
||||
this.activatedIssueTask$.subscribe((v) => (this.activatedIssueTask = v)),
|
||||
|
|
@ -239,6 +244,7 @@ export class AddTaskBarComponent implements AfterViewInit, OnDestroy {
|
|||
onBlur(ev: FocusEvent): void {
|
||||
const relatedTarget: HTMLElement = ev.relatedTarget as HTMLElement;
|
||||
let isUIelement = false;
|
||||
|
||||
if (relatedTarget) {
|
||||
const { className } = relatedTarget;
|
||||
isUIelement =
|
||||
|
|
@ -253,6 +259,7 @@ export class AddTaskBarComponent implements AfterViewInit, OnDestroy {
|
|||
(this.inputEl as ElementRef).nativeElement.value,
|
||||
);
|
||||
}
|
||||
|
||||
if (relatedTarget && isUIelement) {
|
||||
(this.inputEl as ElementRef).nativeElement.focus();
|
||||
} else {
|
||||
|
|
@ -262,6 +269,8 @@ export class AddTaskBarComponent implements AfterViewInit, OnDestroy {
|
|||
this._blurTimeout = window.setTimeout(() => {
|
||||
this.blurred.emit(ev);
|
||||
}, 300);
|
||||
} else {
|
||||
this.blurred.emit(ev);
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
|
|
@ -369,7 +378,29 @@ export class AddTaskBarComponent implements AfterViewInit, OnDestroy {
|
|||
|
||||
this.taskSuggestionsCtrl.setValue('');
|
||||
this._isAddInProgress = false;
|
||||
this._focusInput();
|
||||
|
||||
if (this._lastAddedTaskId) {
|
||||
this._planForDayAfterAddTaskIfConfigured(this._lastAddedTaskId);
|
||||
}
|
||||
|
||||
if (this.planForDay) {
|
||||
this.blurred.emit();
|
||||
} else {
|
||||
this._focusInput();
|
||||
}
|
||||
}
|
||||
|
||||
private _planForDayAfterAddTaskIfConfigured(taskId: string): void {
|
||||
const planForDay = this.planForDay;
|
||||
if (planForDay) {
|
||||
this._taskService.getByIdOnce$(taskId).subscribe((task) => {
|
||||
if (getWorklogStr() !== planForDay) {
|
||||
this._store.dispatch(
|
||||
PlannerActions.planTaskForDay({ task: task, day: planForDay }),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async _getCtxForTaskSuggestion({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue