-
Notifications
You must be signed in to change notification settings - Fork 268
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
base: main
Are you sure you want to change the base?
Feature/JS-5173: Date #1064
Changes from 1 commit
7428887
d8b6276
91d0df2
dc3612a
42dec43
9ac88da
0fed45e
5c118ef
5eb4994
1bc9161
0d193be
4b6f7b5
c7a07f2
949aedd
9c188f7
c478767
9b02902
8a820f5
81b8db8
3791411
76bb93f
2d6c5c7
2594372
0e4efdc
d10e304
cb9973c
3f42d44
30bfd26
b0e5a5b
b17e078
4f5177a
9a00470
5bcdb92
ea26a9d
2736817
1e35eca
727be54
0f84865
89c1a9d
d36400b
e06ac79
ccdb254
e16ca21
c966841
cf856ba
a055fc3
4df18a5
747699c
aacd9e6
9ea13eb
d55b1e0
272dc92
65b6769
ade98eb
5e91461
1dc4606
87c3982
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
|
@@ -10,8 +10,6 @@ interface Props { | |
readonly?: boolean; | ||
noIcon?: boolean; | ||
onCreate?: () => void; | ||
rightSideStart?: React.ReactElement; | ||
rightSideEnd?: React.ReactElement; | ||
}; | ||
|
||
const EDITORS = [ | ||
|
@@ -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); | ||
|
@@ -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> | ||
); | ||
} | ||
|
||
if (!canWrite) { | ||
button = null; | ||
}; | ||
|
@@ -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> | ||
); | ||
|
@@ -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']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add spaces |
||
|
||
S.Menu.open('dataviewCalendar', { | ||
element: `#head-calendar-button`, | ||
element: '#calendar-icon', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
C.ObjectDateByTimestamp(U.Router.getRouteSpaceId(), object.timestamp + dir * 24 * 60 * 60, (message: any) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space id should be taken from StoreCommon
|
||
U.Object.openAuto(message.details); | ||
}); | ||
}; | ||
|
||
}); | ||
|
||
export default HeadSimple; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add semicolon