Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
571b56cf
Commit
571b56cf
authored
Apr 02, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update template, cleanup methods
parent
30dfe711
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
32 deletions
+14
-32
ee/app/assets/javascripts/roadmap/components/timeline_header_item.vue
...s/javascripts/roadmap/components/timeline_header_item.vue
+8
-22
spec/javascripts/roadmap/components/timeline_header_item_spec.js
...vascripts/roadmap/components/timeline_header_item_spec.js
+6
-10
No files found.
ee/app/assets/javascripts/roadmap/components/timeline_header_item.vue
View file @
571b56cf
<
script
>
import
{
monthInWords
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
EPIC_DETAILS_CELL_WIDTH
,
TIMELINE_CELL_MIN_WIDTH
}
from
'
../constants
'
;
import
timelineHeaderSubItem
from
'
./timeline_header_sub_item.vue
'
;
export
default
{
...
...
@@ -22,7 +20,7 @@
type
:
Array
,
required
:
true
,
},
shell
Width
:
{
item
Width
:
{
type
:
Number
,
required
:
true
,
},
...
...
@@ -36,22 +34,10 @@
};
},
computed
:
{
thStyles
()
{
const
timeframeLength
=
this
.
timeframe
.
length
;
// Calculate minimum width for single cell
// based on total number of months in current timeframe
// and available shellWidth
const
minWidth
=
Math
.
ceil
((
this
.
shellWidth
-
EPIC_DETAILS_CELL_WIDTH
)
/
timeframeLength
);
// When shellWidth is too low, we need to obey global
// minimum cell width.
if
(
minWidth
<
TIMELINE_CELL_MIN_WIDTH
)
{
return
`min-width:
${
TIMELINE_CELL_MIN_WIDTH
}
px;`
;
}
return
`min-width:
${
minWidth
}
px;`
;
itemStyles
()
{
return
{
width
:
`
${
this
.
itemWidth
}
px`
,
};
},
timelineHeaderLabel
()
{
const
year
=
this
.
timeframeItem
.
getFullYear
();
...
...
@@ -97,9 +83,9 @@
</
script
>
<
template
>
<
th
<
span
class=
"timeline-header-item"
:style=
"
th
Styles"
:style=
"
item
Styles"
>
<div
class=
"item-label"
...
...
@@ -111,5 +97,5 @@
:timeframe-item=
"timeframeItem"
:current-date=
"currentDate"
/>
</
th
>
</
span
>
</
template
>
spec/javascripts/roadmap/components/timeline_header_item_spec.js
View file @
571b56cf
import
Vue
from
'
vue
'
;
import
timelineHeaderItemComponent
from
'
ee/roadmap/components/timeline_header_item.vue
'
;
import
{
TIMELINE_CELL_MIN_WIDTH
}
from
'
ee/roadmap/constants
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
mockTimeframe
,
mockShellWidth
}
from
'
../mock_data
'
;
import
{
mockTimeframe
,
mockShellWidth
,
mockItemWidth
}
from
'
../mock_data
'
;
const
mockTimeframeIndex
=
0
;
...
...
@@ -13,6 +12,7 @@ const createComponent = ({
timeframeItem
=
mockTimeframe
[
mockTimeframeIndex
],
timeframe
=
mockTimeframe
,
shellWidth
=
mockShellWidth
,
itemWidth
=
mockItemWidth
,
})
=>
{
const
Component
=
Vue
.
extend
(
timelineHeaderItemComponent
);
...
...
@@ -21,6 +21,7 @@ const createComponent = ({
timeframeItem
,
timeframe
,
shellWidth
,
itemWidth
,
});
};
...
...
@@ -42,15 +43,10 @@ describe('TimelineHeaderItemComponent', () => {
});
describe
(
'
computed
'
,
()
=>
{
describe
(
'
th
Styles
'
,
()
=>
{
it
(
'
returns style
string for th element based on shellWidth, timeframe length and Epic details cell width
'
,
()
=>
{
describe
(
'
item
Styles
'
,
()
=>
{
it
(
'
returns style
object for container element based on value of `itemWidth` prop
'
,
()
=>
{
vm
=
createComponent
({});
expect
(
vm
.
thStyles
).
toBe
(
'
min-width: 280px;
'
);
});
it
(
'
returns style string for th element with minimum permissible width when calculated width is lower defined minimum width
'
,
()
=>
{
vm
=
createComponent
({
shellWidth
:
1000
});
expect
(
vm
.
thStyles
).
toBe
(
`min-width:
${
TIMELINE_CELL_MIN_WIDTH
}
px;`
);
expect
(
vm
.
itemStyles
.
width
).
toBe
(
'
180px
'
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment