Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/make short syntax configurable #3571

Merged
merged 5 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ There is another older – the app looks and feels much better now ;) – [artic

### Short-Syntax

Can be used when adding a task.
Can be used when adding a task. <strong>(Each of these can be disabled in settings->short syntax)</strong>

- `# <tag-name>`: add a tag to the task
(`"task-description #tag1"`)
- `<number>m` or `<number>h`: set time-estimate for the task
(`"task-description 10m"` or `"task-description 5h"`)
- `@<time>`: add due time to the task
(`"task-description @fri 10pm"`)
- `+ <project-name>`: add the task to an existing project
(`"task-description +Important Project"`)
- `Ctr + 2`: toggle between moving the new task to the bottom and top of the list
Expand Down Expand Up @@ -315,13 +317,12 @@ Packaging the app is done via [electron-builder](https://github.com/electron-use

### Building for Android

*This feature was added on October 7, 2024. See [Pull Request #57](https://github.com/johannesjo/super-productivity-android/pull/57).*
_This feature was added on October 7, 2024. See [Pull Request #57](https://github.com/johannesjo/super-productivity-android/pull/57)._

To build the Android version of Super Productivity, please refer to the [Android Build Documentation](./android/offline.md), which includes instructions on configuring **Connectivity-Free Mode** and **Online-Only Mode (Compatibility Mode)**.

Ensure you follow the setup steps properly to configure the environment for building the app.


## Run as Docker Container

```bash
Expand Down
5 changes: 5 additions & 0 deletions src/app/features/config/default-global-config.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export const DEFAULT_GLOBAL_CONFIG: GlobalConfigState = {
**Why do I want it?**
`,
},
shortSyntax: {
isEnableProject: true,
isEnableDue: true,
isEnableTag: true,
},
evaluation: {
isHideEvaluationSheet: false,
},
Expand Down
31 changes: 31 additions & 0 deletions src/app/features/config/form-cfgs/short-syntax-form.const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { T } from '../../../t.const';
import { ConfigFormSection, ShortSyntaxConfig } from '../global-config.model';

export const SHORT_SYNTAX_FORM_CFG: ConfigFormSection<ShortSyntaxConfig> = {
title: T.GCF.SHORT_SYNTAX.TITLE,
key: 'shortSyntax',
help: T.GCF.SHORT_SYNTAX.HELP,
items: [
{
key: 'isEnableProject',
type: 'checkbox',
templateOptions: {
label: T.GCF.SHORT_SYNTAX.IS_ENABLE_PROJECT,
},
},
{
key: 'isEnableTag',
type: 'checkbox',
templateOptions: {
label: T.GCF.SHORT_SYNTAX.IS_ENABLE_TAG,
},
},
{
key: 'isEnableDue',
type: 'checkbox',
templateOptions: {
label: T.GCF.SHORT_SYNTAX.IS_ENABLE_DUE,
},
},
],
};
2 changes: 2 additions & 0 deletions src/app/features/config/global-config-form-config.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { FOCUS_MODE_FORM_CFG } from './form-cfgs/focus-mode-form.const';
import { IS_FIREFOX } from '../../util/is-firefox';
import { CALENDAR_FORM_CFG } from './form-cfgs/calendar-form.const';
import { REMINDER_FORM_CFG } from './form-cfgs/reminder-form.const';
import { SHORT_SYNTAX_FORM_CFG } from './form-cfgs/short-syntax-form.const';

const filterGlobalConfigForm = (cfg: ConfigFormSection<any>): boolean => {
return (
Expand All @@ -29,6 +30,7 @@ const filterGlobalConfigForm = (cfg: ConfigFormSection<any>): boolean => {
export const GLOBAL_CONFIG_FORM_CONFIG: ConfigFormConfig = [
LANGUAGE_SELECTION_FORM_FORM,
MISC_SETTINGS_FORM_CFG,
SHORT_SYNTAX_FORM_CFG,
IDLE_FORM_CFG,
KEYBOARD_SETTINGS_FORM_CFG,
TIME_TRACKING_FORM_CFG,
Expand Down
7 changes: 7 additions & 0 deletions src/app/features/config/global-config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export type MiscConfig = Readonly<{
isDisableAnimations: boolean;
}>;

export type ShortSyntaxConfig = Readonly<{
isEnableProject: boolean;
isEnableDue: boolean;
isEnableTag: boolean;
}>;

export type TimeTrackingConfig = Readonly<{
trackingInterval: number;
defaultEstimate: number;
Expand Down Expand Up @@ -170,6 +176,7 @@ export type FocusModeConfig = Readonly<{
export type GlobalConfigState = Readonly<{
lang: LanguageConfig;
misc: MiscConfig;
shortSyntax: ShortSyntaxConfig;
evaluation: EvaluationConfig;
idle: IdleConfig;
takeABreak: TakeABreakConfig;
Expand Down
6 changes: 6 additions & 0 deletions src/app/features/config/global-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
IdleConfig,
MiscConfig,
ScheduleConfig,
ShortSyntaxConfig,
SoundConfig,
SyncConfig,
TakeABreakConfig,
Expand All @@ -19,6 +20,7 @@ import {
selectEvaluationConfig,
selectIdleConfig,
selectMiscConfig,
selectShortSyntaxConfig,
selectSoundConfig,
selectSyncConfig,
selectTakeABreakConfig,
Expand All @@ -38,6 +40,10 @@ export class GlobalConfigService {
shareReplay(1),
);

shortSyntax$: Observable<ShortSyntaxConfig> = this._store.pipe(
select(selectShortSyntaxConfig),
);

sound$: Observable<SoundConfig> = this._store.pipe(
select(selectSoundConfig),
shareReplay(1),
Expand Down
5 changes: 5 additions & 0 deletions src/app/features/config/store/global-config.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
PomodoroConfig,
ReminderConfig,
ScheduleConfig,
ShortSyntaxConfig,
SoundConfig,
SyncConfig,
TakeABreakConfig,
Expand All @@ -29,6 +30,10 @@ export const selectMiscConfig = createSelector(
selectConfigFeatureState,
(cfg): MiscConfig => cfg.misc,
);
export const selectShortSyntaxConfig = createSelector(
selectConfigFeatureState,
(cfg): ShortSyntaxConfig => cfg.shortSyntax,
);
export const selectSoundConfig = createSelector(
selectConfigFeatureState,
(cfg): SoundConfig => cfg.sound,
Expand Down
1 change: 0 additions & 1 deletion src/app/features/project/store/project.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { OpenProjectCfg } from '../../issue/providers/open-project/open-project.
import { GiteaCfg } from '../../issue/providers/gitea/gitea.model';
import { RedmineCfg } from '../../issue/providers/redmine/redmine.model';

// TODO rename to selectProjectFeatureState
export const selectProjectFeatureState =
createFeatureSelector<ProjectState>(PROJECT_FEATURE_NAME);
const { selectAll } = projectAdapter.getSelectors();
Expand Down
11 changes: 11 additions & 0 deletions src/app/features/tasks/add-task-bar/add-task-bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ 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';
import { GlobalConfigService } from '../../config/global-config.service';
import { ShortSyntaxConfig } from '../../config/global-config.model';
import { DEFAULT_GLOBAL_CONFIG } from '../../config/default-global-config.const';

@Component({
selector: 'add-task-bar',
Expand Down Expand Up @@ -126,6 +129,7 @@ export class AddTaskBarComponent implements AfterViewInit, OnDestroy {
tags,
projects,
defaultColor: activeWorkContext.theme.primary,
shortSyntaxConfig: this._shortSyntaxConfig,
}),
),
startWith([]),
Expand Down Expand Up @@ -165,6 +169,7 @@ export class AddTaskBarComponent implements AfterViewInit, OnDestroy {
private _saveTmpTodoTimeout?: number;
private _lastAddedTaskId?: string;
private _subs: Subscription = new Subscription();
private _shortSyntaxConfig: ShortSyntaxConfig = DEFAULT_GLOBAL_CONFIG.shortSyntax;

constructor(
private _taskService: TaskService,
Expand All @@ -175,13 +180,19 @@ export class AddTaskBarComponent implements AfterViewInit, OnDestroy {
private _tagService: TagService,
private _cd: ChangeDetectorRef,
private _store: Store,
private _globalConfigService: GlobalConfigService,
) {
this._subs.add(
this.activatedIssueTask$.subscribe((v) => (this.activatedIssueTask = v)),
);
this._subs.add(this.shortSyntaxTags$.subscribe((v) => (this.shortSyntaxTags = v)));
this._subs.add(this.inputVal$.subscribe((v) => (this.inputVal = v)));
this._subs.add(this.tagSuggestions$.subscribe((v) => (this.tagSuggestions = v)));
this._subs.add(
this._globalConfigService.shortSyntax$.subscribe(
(shortSyntaxConfig) => (this._shortSyntaxConfig = shortSyntaxConfig),
),
);
}

ngAfterViewInit(): void {
Expand Down
4 changes: 4 additions & 0 deletions src/app/features/tasks/add-task-bar/short-syntax-to-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { DEFAULT_TODAY_TAG_COLOR } from '../../work-context/work-context.const';
import { Tag } from '../../tag/tag.model';
import { Project } from '../../project/project.model';
import { getWorklogStr } from '../../../util/get-work-log-str';
import { ShortSyntaxConfig } from '../../config/global-config.model';

export interface ShortSyntaxTag {
title: string;
Expand All @@ -18,18 +19,21 @@ export const shortSyntaxToTags = ({
tags,
projects,
defaultColor,
shortSyntaxConfig,
}: {
val: string;
tags: Tag[];
projects: Project[];
defaultColor: string;
shortSyntaxConfig: ShortSyntaxConfig;
}): ShortSyntaxTag[] => {
const r = shortSyntax(
{
title: val,
tagIds: [],
projectId: undefined,
},
shortSyntaxConfig,
tags,
projects,
);
Expand Down
Loading
Loading