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

Feature/JS-5173: Date #1064

Draft
wants to merge 57 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
7428887
date layout
ra3orblade Nov 13, 2024
d8b6276
date layout
ra3orblade Nov 13, 2024
91d0df2
update react router
ra3orblade Nov 13, 2024
dc3612a
Merge branch 'main' of github.com:anyproto/anytype-ts into feature/date
ra3orblade Nov 21, 2024
42dec43
Add date control icons
Nek Nov 21, 2024
9ac88da
Add working date page
Nek Nov 21, 2024
0fed45e
Update object list according to design
Nek Nov 20, 2024
5c118ef
Add date nav icons and a calendar menu
Nek Nov 21, 2024
5eb4994
Make it look more like designed in Figma
Nek Nov 21, 2024
1bc9161
Add obsolete code
Nek Nov 21, 2024
0d193be
Fix mentions filter
Nek Nov 21, 2024
4b6f7b5
remove unused variable
ra3orblade Nov 21, 2024
c7a07f2
Fix React missing key error
Nek Nov 21, 2024
949aedd
Merge remote-tracking branch 'refs/remotes/origin/feature/date' into …
Nek Nov 21, 2024
9c188f7
JS-5794: default date icon
ra3orblade Nov 21, 2024
c478767
JS-5176: date mentions
ra3orblade Nov 21, 2024
9b02902
Make calendar date selection work
Nek Nov 21, 2024
8a820f5
Merge remote-tracking branch 'refs/remotes/origin/feature/date' into …
Nek Nov 21, 2024
81b8db8
Remove code obsolete after merge
Nek Nov 21, 2024
3791411
Remove clear button from calendar
Nek Nov 21, 2024
76bb93f
JS-5822: review
ra3orblade Nov 21, 2024
2d6c5c7
code review
ra3orblade Nov 21, 2024
2594372
Clean up
Nek Nov 21, 2024
0e4efdc
Merge remote-tracking branch 'refs/remotes/origin/feature/date' into …
Nek Nov 21, 2024
d10e304
Add prev next day icons actions
Nek Nov 21, 2024
cb9973c
Fix missing relations names
Nek Nov 21, 2024
3f42d44
Merge branch 'main' of github.com:anyproto/anytype-ts into feature/date
ra3orblade Nov 21, 2024
30bfd26
Merge branch 'feature/date' of github.com:anyproto/anytype-ts into fe…
ra3orblade Nov 21, 2024
b0e5a5b
Hide icons of object list object type in date page
Nek Nov 21, 2024
b17e078
Merge remote-tracking branch 'refs/remotes/origin/feature/date' into …
Nek Nov 21, 2024
4f5177a
Sort relations when loading category
Nek Nov 21, 2024
9a00470
Unify next/prev date navigation
Nek Nov 21, 2024
5bcdb92
Move date navigation with calendar menu functionality into SimpleHeader
Nek Nov 21, 2024
ea26a9d
Code review fixes
Nek Nov 22, 2024
2736817
Add global date format setting
Nek Nov 22, 2024
1e35eca
Add global date & time settings section
Nek Nov 22, 2024
727be54
Add global time format setting
Nek Nov 22, 2024
0f84865
Make date & time selects work for 0 values
Nek Nov 22, 2024
89c1a9d
Fix relation creator translation name
Nek Nov 22, 2024
d36400b
Fix relation creator translation name
Nek Nov 22, 2024
e06ac79
Fetch global dateFormat setting when formatting dates
Nek Nov 25, 2024
ccdb254
Merge branch 'main' of github.com:anyproto/anytype-ts into feature/date
ra3orblade Nov 25, 2024
e16ca21
small fixes
ra3orblade Nov 25, 2024
c966841
small formatting fix
ra3orblade Nov 25, 2024
cf856ba
Apply new date and time format where relevant
Nek Nov 25, 2024
a055fc3
Format date in more places
Nek Nov 25, 2024
4df18a5
Improve date formatting logic
Nek Nov 25, 2024
747699c
JS-5845: fix
ra3orblade Nov 25, 2024
aacd9e6
Merge pull request #1070 from anyproto/feature/js-5418-global-datetim…
Nek Nov 25, 2024
9ea13eb
JS-5844: listObject sort
ra3orblade Nov 25, 2024
d55b1e0
Merge branch 'feature/date' of github.com:anyproto/anytype-ts into fe…
ra3orblade Nov 25, 2024
272dc92
small fix
ra3orblade Nov 25, 2024
65b6769
small fix
ra3orblade Nov 25, 2024
ade98eb
code review
ra3orblade Nov 25, 2024
5e91461
fix header
ra3orblade Nov 25, 2024
1dc4606
code review
ra3orblade Nov 25, 2024
87c3982
JS-5838: open dates from calendar
ra3orblade Nov 25, 2024
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
48 changes: 32 additions & 16 deletions src/ts/component/page/elements/head/simple.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { observer } from 'mobx-react';
import { IconObject, Block, Button, Editable } from 'Component';
import { I, M, S, U, J, Action, focus, keyboard, Relation, translate } from 'Lib';
import { IconObject, Block, Button, Editable, Icon } from 'Component';
import { I, M, S, U, J, Action, focus, keyboard, Relation, translate, C } from 'Lib';

interface Props {
rootId: string;
Expand All @@ -10,8 +10,6 @@ interface Props {
readonly?: boolean;
noIcon?: boolean;
onCreate?: () => void;
rightSideStart?: React.ReactElement;
rightSideEnd?: React.ReactElement;
};

const EDITORS = [
Expand All @@ -37,7 +35,7 @@ const HeadSimple = observer(class Controls extends React.Component<Props> {
};

render (): any {
const { rootId, onCreate, isContextMenuDisabled, readonly, noIcon, rightSideStart, rightSideEnd } = this.props;
const { rootId, onCreate, isContextMenuDisabled, readonly, noIcon } = this.props;
const check = U.Data.checkDetails(rootId);
const object = S.Detail.get(rootId, rootId, [ 'featuredRelations' ]);
const featuredRelations = Relation.getArrayValue(object.featuredRelations);
Expand Down Expand Up @@ -120,6 +118,16 @@ const HeadSimple = observer(class Controls extends React.Component<Props> {
};
};

if (isDate) {
button = (
<React.Fragment>
<Icon className="arrow left withBackground" onClick={() => this.changeDate(-1)} />
<Icon className="arrow right withBackground" onClick={() => this.changeDate(1)}/>
<Icon id="calendar-icon" className="calendar withBackground" onClick={this.onCalendar} />
</React.Fragment>
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Add semicolon


if (!canWrite) {
button = null;
};
Expand All @@ -144,8 +152,8 @@ const HeadSimple = observer(class Controls extends React.Component<Props> {
{featured}
</div>

{button || rightSideStart || rightSideEnd ? (
<div className="side right">{rightSideStart}{button}{rightSideEnd}</div>
{button ? (
<div className="side right">{button}</div>
) : ''}
</div>
);
Expand Down Expand Up @@ -291,26 +299,34 @@ const HeadSimple = observer(class Controls extends React.Component<Props> {
return sources.includes(rootId);
};

onCalendar () {
onCalendar = () => {
const { rootId } = this.props;
const object = S.Detail.get(rootId, rootId);
const object = S.Detail.get(rootId, rootId, ['timestamp']);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add spaces [ 'timestamp' ]


S.Menu.open('dataviewCalendar', {
element: `#head-calendar-button`,
element: '#calendar-icon',
Copy link
Contributor

Choose a reason for hiding this comment

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

Add #headSimple or .headSimple to element to narrow search.

horizontal: I.MenuDirection.Center,
data: {
value: object.timestamp,
data: {
value: object.timestamp,
canEdit: true,
canClear: false,
onChange: (value: number) => {
console.log('TIMESTAMP', value);

// TODO: Get date id from timestamp and route to new date object

C.ObjectDateByTimestamp(U.Router.getRouteSpaceId(), value, (message: any) => {
Nek marked this conversation as resolved.
Show resolved Hide resolved
U.Object.openAuto(message.details);
});
},
},
});
};

changeDate = (dir: number) => {
const { rootId } = this.props;
const object = S.Detail.get(rootId, rootId, ['timestamp']);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove [ 'timestamp' ], add line break. Add timestamp casting to StoreDetail mapDate as Number

C.ObjectDateByTimestamp(U.Router.getRouteSpaceId(), object.timestamp + dir * 24 * 60 * 60, (message: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Space id should be taken from StoreCommon

const { space } = S.Common;

U.Object.openAuto(message.details);
});
};

});

export default HeadSimple;
37 changes: 0 additions & 37 deletions src/ts/component/page/main/date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ const PageMainDate = observer(class PageMainDate extends React.Component<I.PageC
if (isLoading) {
content = <Loader id="loader" />;
} else {
const calendarMenu = (
<React.Fragment>
<Icon className="arrow left withBackground" onClick={() => this.changeDate(-1)} />
<Icon className="arrow right withBackground" onClick={() => this.changeDate(1)}/>
<Icon id="calendar-icon" className="calendar withBackground" onClick={this.onCalendar} />
</React.Fragment>
);

content = (
<div className="blocks wrapper">
<HeadSimple
Expand All @@ -84,7 +76,6 @@ const PageMainDate = observer(class PageMainDate extends React.Component<I.PageC
ref={ref => this.refHead = ref}
rootId={rootId}
readonly={true}
rightSideEnd={calendarMenu}
/>

<div className="categories">
Expand Down Expand Up @@ -145,26 +136,6 @@ const PageMainDate = observer(class PageMainDate extends React.Component<I.PageC
);
};

onCalendar = () => {
const rootId = this.getRootId();
const object = S.Detail.get(rootId, rootId, ['timestamp']);

S.Menu.open('dataviewCalendar', {
element: '#calendar-icon',
horizontal: I.MenuDirection.Center,
data: {
value: object.timestamp,
canEdit: true,
canClear: false,
onChange: (value: number) => {
C.ObjectDateByTimestamp(U.Router.getRouteSpaceId(), value, (message: any) => {
U.Object.openAuto(message.details);
});
},
},
});
};

componentDidMount () {
this._isMounted = true;
this.open();
Expand Down Expand Up @@ -270,14 +241,6 @@ const PageMainDate = observer(class PageMainDate extends React.Component<I.PageC
});
}

changeDate = (dir: number) => {
const rootId = this.getRootId();
const object = S.Detail.get(rootId, rootId, ['timestamp']);
C.ObjectDateByTimestamp(U.Router.getRouteSpaceId(), object.timestamp + dir * 24 * 60 * 60, (message: any) => {
U.Object.openAuto(message.details);
});
};

getRootId () {
const { rootId, match } = this.props;
return rootId ? rootId : match.params.id;
Expand Down
Loading