mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-27 09:44:39 +00:00
feat(dueDate): replace removeTaskFromTodayTagList in favor of unschedule
This commit is contained in:
parent
9879fc5417
commit
0200e1eaee
9 changed files with 30 additions and 86 deletions
|
|
@ -53,7 +53,6 @@ import {
|
|||
import { MatSelect } from '@angular/material/select';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { MatInput } from '@angular/material/input';
|
||||
import { removeTaskFromTodayTagList } from '../../tag/store/tag.actions';
|
||||
|
||||
const DEFAULT_TIME = '09:00';
|
||||
|
||||
|
|
@ -305,7 +304,7 @@ export class DialogScheduleTaskComponent implements AfterViewInit {
|
|||
}
|
||||
}
|
||||
|
||||
async submit(isRemoveFromToday = false): Promise<void> {
|
||||
async submit(isUnschedule = false): Promise<void> {
|
||||
if (!this.selectedDate) {
|
||||
console.warn('no selected date');
|
||||
return;
|
||||
|
|
@ -317,8 +316,10 @@ export class DialogScheduleTaskComponent implements AfterViewInit {
|
|||
|
||||
this._handleReminderRemoval();
|
||||
|
||||
if (isRemoveFromToday) {
|
||||
this._removeFromToday();
|
||||
if (isUnschedule) {
|
||||
this._store.dispatch(
|
||||
unScheduleTask({ id: this.data.task.id, reminderId: this.data.task.reminderId }),
|
||||
);
|
||||
} else if (this.selectedTime) {
|
||||
this._scheduleWithTime();
|
||||
} else if (
|
||||
|
|
@ -354,10 +355,6 @@ export class DialogScheduleTaskComponent implements AfterViewInit {
|
|||
}
|
||||
}
|
||||
|
||||
private _removeFromToday(): void {
|
||||
this._store.dispatch(removeTaskFromTodayTagList({ taskId: this.data.task.id }));
|
||||
}
|
||||
|
||||
private _scheduleWithTime(): void {
|
||||
const task = this.data.task;
|
||||
const newDate = new Date(
|
||||
|
|
|
|||
|
|
@ -10,10 +10,7 @@ import { Store } from '@ngrx/store';
|
|||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { TaskService } from '../../tasks/task.service';
|
||||
import { ReminderService } from '../../reminder/reminder.service';
|
||||
import {
|
||||
moveTaskInTodayTagList,
|
||||
removeTaskFromTodayTagList,
|
||||
} from '../../tag/store/tag.actions';
|
||||
import { moveTaskInTodayTagList } from '../../tag/store/tag.actions';
|
||||
import { DateService } from '../../../core/date/date.service';
|
||||
import { DialogScheduleTaskComponent } from '../dialog-schedule-task/dialog-schedule-task.component';
|
||||
import { dateStrToUtcDate } from '../../../util/date-str-to-utc-date';
|
||||
|
|
@ -154,13 +151,6 @@ export class PlannerDayComponent {
|
|||
task.dueWithTime as number,
|
||||
reminder?.remindAt,
|
||||
);
|
||||
const isToday = new Date().toDateString() === newDate.toDateString();
|
||||
this._taskService.scheduleTask(task, newDate.getTime(), selectedReminderCfgId, false);
|
||||
if (isToday) {
|
||||
// not required any more
|
||||
// this._store.dispatch(planTaskForToday({ taskId: task.id }));
|
||||
} else {
|
||||
this._store.dispatch(removeTaskFromTodayTagList({ taskId: task.id }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,11 +29,6 @@ export const planTaskForToday = createAction(
|
|||
props<{ taskId: string }>(),
|
||||
);
|
||||
|
||||
export const removeTaskFromTodayTagList = createAction(
|
||||
'[Tag] Remove Task From Today',
|
||||
props<{ taskId: string }>(),
|
||||
);
|
||||
|
||||
export const updateAdvancedConfigForTag = createAction(
|
||||
'[Tag] Update Advanced Config',
|
||||
props<{ tagId: string; sectionKey: WorkContextAdvancedCfgKey; data: any }>(),
|
||||
|
|
|
|||
|
|
@ -33,11 +33,10 @@ import { MODEL_VERSION_KEY } from '../../../app.constants';
|
|||
import { MODEL_VERSION } from '../../../core/model-version';
|
||||
import {
|
||||
addTag,
|
||||
planTaskForToday,
|
||||
deleteTag,
|
||||
deleteTags,
|
||||
moveTaskInTodayTagList,
|
||||
removeTaskFromTodayTagList,
|
||||
planTaskForToday,
|
||||
updateAdvancedConfigForTag,
|
||||
updateTag,
|
||||
updateTagOrder,
|
||||
|
|
@ -559,19 +558,6 @@ export const tagReducer = createReducer<TagState>(
|
|||
state,
|
||||
);
|
||||
}),
|
||||
on(removeTaskFromTodayTagList, (state, { taskId }) => {
|
||||
return tagAdapter.updateOne(
|
||||
{
|
||||
id: TODAY_TAG.id,
|
||||
changes: {
|
||||
taskIds: (state.entities[TODAY_TAG.id] as Tag).taskIds.filter(
|
||||
(id) => id !== taskId,
|
||||
),
|
||||
},
|
||||
},
|
||||
state,
|
||||
);
|
||||
}),
|
||||
|
||||
on(moveTaskInTodayTagList, (state, { toTaskId, fromTaskId }) => {
|
||||
const todayTag = state.entities[TODAY_TAG.id] as Tag;
|
||||
|
|
|
|||
|
|
@ -69,10 +69,7 @@ import { TODAY_TAG } from '../../tag/tag.const';
|
|||
import { getWorklogStr } from '../../../util/get-work-log-str';
|
||||
import { deleteProject } from '../../project/store/project.actions';
|
||||
import { TimeTrackingActions } from '../../time-tracking/store/time-tracking.actions';
|
||||
import {
|
||||
planTaskForToday,
|
||||
removeTaskFromTodayTagList,
|
||||
} from '../../tag/store/tag.actions';
|
||||
import { planTaskForToday } from '../../tag/store/tag.actions';
|
||||
|
||||
export const TASK_FEATURE_NAME = 'tasks';
|
||||
|
||||
|
|
@ -718,22 +715,6 @@ export const taskReducer = createReducer<TaskState>(
|
|||
state,
|
||||
);
|
||||
}),
|
||||
on(removeTaskFromTodayTagList, (state, { taskId }) => {
|
||||
const targetTask = state.entities[taskId] as Task;
|
||||
if (targetTask.dueDay === getWorklogStr()) {
|
||||
return taskAdapter.updateOne(
|
||||
{
|
||||
id: taskId,
|
||||
changes: {
|
||||
dueDay: undefined,
|
||||
},
|
||||
},
|
||||
state,
|
||||
);
|
||||
}
|
||||
|
||||
return state;
|
||||
}),
|
||||
|
||||
// REMINDER STUFF
|
||||
// --------------
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@
|
|||
(task.projectId || task.tagIds.length > 1)
|
||||
) {
|
||||
<button
|
||||
(click)="removeFromMyDay()"
|
||||
(click)="unschedule()"
|
||||
mat-menu-item
|
||||
>
|
||||
<mat-icon svgIcon="remove_today"></mat-icon>
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ import { MatTooltip } from '@angular/material/tooltip';
|
|||
import { getWorklogStr } from '../../../../util/get-work-log-str';
|
||||
import { PlannerActions } from '../../../planner/store/planner.actions';
|
||||
import { combineDateAndTime } from '../../../../util/combine-date-and-time';
|
||||
import { isToday } from '../../../../util/is-today.util';
|
||||
import { DateAdapter } from '@angular/material/core';
|
||||
import { isShowAddToToday, isShowRemoveFromToday } from '../../util/is-task-today';
|
||||
import { ICAL_TYPE } from '../../../issue/issue.const';
|
||||
|
|
@ -70,11 +69,9 @@ import { toSignal } from '@angular/core/rxjs-interop';
|
|||
import { TagService } from '../../../tag/tag.service';
|
||||
import { DialogPromptComponent } from '../../../../ui/dialog-prompt/dialog-prompt.component';
|
||||
import { unScheduleTask } from '../../store/task.actions';
|
||||
import {
|
||||
planTaskForToday,
|
||||
removeTaskFromTodayTagList,
|
||||
} from '../../../tag/store/tag.actions';
|
||||
import { planTaskForToday } from '../../../tag/store/tag.actions';
|
||||
import { selectTodayTagTaskIds } from '../../../tag/store/tag.reducer';
|
||||
import { isToday } from '../../../../util/is-today.util';
|
||||
|
||||
@Component({
|
||||
selector: 'task-context-menu-inner',
|
||||
|
|
@ -344,8 +341,10 @@ export class TaskContextMenuInnerComponent implements AfterViewInit {
|
|||
this._store.dispatch(planTaskForToday({ taskId: this.task.id }));
|
||||
}
|
||||
|
||||
removeFromMyDay(): void {
|
||||
this._store.dispatch(removeTaskFromTodayTagList({ taskId: this.task.id }));
|
||||
unschedule(): void {
|
||||
this._store.dispatch(
|
||||
unScheduleTask({ id: this.task.id, reminderId: this.task.reminderId }),
|
||||
);
|
||||
}
|
||||
|
||||
convertToMainTask(): void {
|
||||
|
|
@ -482,8 +481,11 @@ export class TaskContextMenuInnerComponent implements AfterViewInit {
|
|||
moveToBacklog(): void {
|
||||
if (this.task.projectId && !this.task.parentId) {
|
||||
this._projectService.moveTaskToBacklog(this.task.id, this.task.projectId);
|
||||
if (this.task.dueDay === getWorklogStr()) {
|
||||
this.removeFromMyDay();
|
||||
if (
|
||||
this.task.dueDay === getWorklogStr() ||
|
||||
(this.task.dueWithTime && isToday(this.task.dueWithTime))
|
||||
) {
|
||||
this.unschedule();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -554,23 +556,16 @@ export class TaskContextMenuInnerComponent implements AfterViewInit {
|
|||
const formattedDate = this._datePipe.transform(newDay, 'shortDate') as string;
|
||||
|
||||
if (isRemoveFromToday) {
|
||||
this.removeFromMyDay();
|
||||
this.unschedule();
|
||||
} else if (this.task.dueWithTime) {
|
||||
const task = this.task;
|
||||
const newDate = combineDateAndTime(newDayDate, new Date(this.task.dueWithTime));
|
||||
const isTodayI = isToday(newDate);
|
||||
this._taskService.scheduleTask(
|
||||
task,
|
||||
newDate.getTime(),
|
||||
TaskReminderOptionId.AtStart,
|
||||
false,
|
||||
);
|
||||
if (isTodayI) {
|
||||
// not required any more
|
||||
// this._store.dispatch(planTaskForToday({ taskId: task.id }));
|
||||
} else {
|
||||
this._store.dispatch(removeTaskFromTodayTagList({ taskId: task.id }));
|
||||
}
|
||||
} else if (newDay === getWorklogStr()) {
|
||||
if (this.isShowAddToToday()) {
|
||||
this.addToMyDay();
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
}
|
||||
@if (isShowRemoveFromToday()) {
|
||||
<button
|
||||
(click)="parent.removeFromMyDay()"
|
||||
(click)="parent.unschedule()"
|
||||
[title]="T.F.TASK.CMP.REMOVE_FROM_MY_DAY | translate"
|
||||
class="ico-btn"
|
||||
color=""
|
||||
|
|
|
|||
|
|
@ -80,11 +80,9 @@ import { ShortDate2Pipe } from '../../../ui/pipes/short-date2.pipe';
|
|||
import { TagToggleMenuListComponent } from '../../tag/tag-toggle-menu-list/tag-toggle-menu-list.component';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { selectTodayTagTaskIds } from '../../tag/store/tag.reducer';
|
||||
import {
|
||||
planTaskForToday,
|
||||
removeTaskFromTodayTagList,
|
||||
} from '../../tag/store/tag.actions';
|
||||
import { planTaskForToday } from '../../tag/store/tag.actions';
|
||||
import { getWorklogStr } from '../../../util/get-work-log-str';
|
||||
import { unScheduleTask } from '../store/task.actions';
|
||||
|
||||
@Component({
|
||||
selector: 'task',
|
||||
|
|
@ -479,8 +477,10 @@ export class TaskComponent implements OnDestroy, AfterViewInit {
|
|||
this._store.dispatch(planTaskForToday({ taskId: this.task().id }));
|
||||
}
|
||||
|
||||
removeFromMyDay(): void {
|
||||
this._store.dispatch(removeTaskFromTodayTagList({ taskId: this.task().id }));
|
||||
unschedule(): void {
|
||||
this._store.dispatch(
|
||||
unScheduleTask({ id: this.task().id, reminderId: this.task().reminderId }),
|
||||
);
|
||||
}
|
||||
|
||||
focusPrevious(isFocusReverseIfNotPossible: boolean = false): void {
|
||||
|
|
@ -640,7 +640,7 @@ export class TaskComponent implements OnDestroy, AfterViewInit {
|
|||
// NOTHING
|
||||
} else {
|
||||
if (this.isOnTodayList()) {
|
||||
this.removeFromMyDay();
|
||||
this.unschedule();
|
||||
} else {
|
||||
this.addToMyDay();
|
||||
}
|
||||
|
|
@ -762,7 +762,7 @@ export class TaskComponent implements OnDestroy, AfterViewInit {
|
|||
if (t.projectId && !t.parentId) {
|
||||
this._projectService.moveTaskToBacklog(t.id, t.projectId);
|
||||
if (this.isOnTodayList()) {
|
||||
this.removeFromMyDay();
|
||||
this.unschedule();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue