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
30dfe711
Commit
30dfe711
authored
Apr 02, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update template, move shared code to SectionMixin
parent
5e8d48d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
46 deletions
+28
-46
ee/app/assets/javascripts/roadmap/components/roadmap_timeline_section.vue
...vascripts/roadmap/components/roadmap_timeline_section.vue
+23
-26
spec/javascripts/roadmap/components/roadmap_timeline_section_spec.js
...ripts/roadmap/components/roadmap_timeline_section_spec.js
+5
-20
No files found.
ee/app/assets/javascripts/roadmap/components/roadmap_timeline_section.vue
View file @
30dfe711
<
script
>
import
eventHub
from
'
../event_hub
'
;
import
{
SCROLL_BAR_SIZE
}
from
'
../constants
'
;
import
SectionMixin
from
'
../mixins/section_mixin
'
;
import
timelineHeaderItem
from
'
./timeline_header_item.vue
'
;
...
...
@@ -9,6 +9,9 @@
components
:
{
timelineHeaderItem
,
},
mixins
:
[
SectionMixin
,
],
props
:
{
epics
:
{
type
:
Array
,
...
...
@@ -22,20 +25,16 @@
type
:
Number
,
required
:
true
,
},
listScrollable
:
{
type
:
Boolean
,
required
:
true
,
},
},
data
()
{
return
{
scrolledHeaderClass
:
''
,
};
},
computed
:
{
calcShellWidth
()
{
return
this
.
shellWidth
-
SCROLL_BAR_SIZE
;
},
theadStyles
()
{
return
`width:
${
this
.
calcShellWidth
}
px;`
;
},
},
mounted
()
{
eventHub
.
$on
(
'
epicsListScrolled
'
,
this
.
handleEpicsListScroll
);
},
...
...
@@ -43,30 +42,28 @@
eventHub
.
$off
(
'
epicsListScrolled
'
,
this
.
handleEpicsListScroll
);
},
methods
:
{
handleEpicsListScroll
(
scrollTop
)
{
handleEpicsListScroll
(
{
scrollTop
}
)
{
// Add class only when epics list is scrolled at 1% the height of header
this
.
scrolledHeaderClass
=
(
scrollTop
>
this
.
$el
.
clientHeight
/
100
)
?
'
scroll
ed-ahead
'
:
''
;
this
.
scrolledHeaderClass
=
(
scrollTop
>
this
.
$el
.
clientHeight
/
100
)
?
'
scroll
-top-shadow
'
:
''
;
},
},
};
</
script
>
<
template
>
<
thead
class=
"roadmap-timeline-section"
<
div
class=
"roadmap-timeline-section
clearfix
"
:class=
"scrolledHeaderClass"
:style=
"
thead
Styles"
:style=
"
sectionContainer
Styles"
>
<tr>
<th
class=
"timeline-header-blank"
></th>
<timeline-header-item
v-for=
"(timeframeItem, index) in timeframe"
:key=
"index"
:timeframe-index=
"index"
:timeframe-item=
"timeframeItem"
:timeframe=
"timeframe"
:shell-width=
"calcShellWidth"
/>
</tr>
</thead>
<span
class=
"timeline-header-blank"
></span>
<timeline-header-item
v-for=
"(timeframeItem, index) in timeframe"
:key=
"index"
:timeframe-index=
"index"
:timeframe-item=
"timeframeItem"
:timeframe=
"timeframe"
:item-width=
"sectionItemWidth"
/>
</div>
</
template
>
spec/javascripts/roadmap/components/roadmap_timeline_section_spec.js
View file @
30dfe711
...
...
@@ -10,6 +10,7 @@ const createComponent = ({
epics
=
[
mockEpic
],
timeframe
=
mockTimeframe
,
shellWidth
=
mockShellWidth
,
listScrollable
=
false
,
})
=>
{
const
Component
=
Vue
.
extend
(
roadmapTimelineSectionComponent
);
...
...
@@ -17,6 +18,7 @@ const createComponent = ({
epics
,
timeframe
,
shellWidth
,
listScrollable
,
});
};
...
...
@@ -37,33 +39,16 @@ describe('RoadmapTimelineSectionComponent', () => {
});
});
describe
(
'
computed
'
,
()
=>
{
describe
(
'
calcShellWidth
'
,
()
=>
{
it
(
'
returns shellWidth by deducting Scrollbar size
'
,
()
=>
{
// shellWidth is 2000 (as defined above in mockShellWidth)
// SCROLLBAR_SIZE is 15 (as defined in app's constants.js)
// Hence, calcShellWidth = shellWidth - SCROLLBAR_SIZE
expect
(
vm
.
calcShellWidth
).
toBe
(
1985
);
});
});
describe
(
'
theadStyles
'
,
()
=>
{
it
(
'
returns style string for thead based on calcShellWidth
'
,
()
=>
{
expect
(
vm
.
theadStyles
).
toBe
(
'
width: 1985px;
'
);
});
});
});
describe
(
'
methods
'
,
()
=>
{
describe
(
'
handleEpicsListScroll
'
,
()
=>
{
it
(
'
sets `scrolled-ahead` class on thead element based on provided scrollTop value
'
,
()
=>
{
// vm.$el.clientHeight is 0 during tests
// hence any value greater than 0 should
// update scrolledHeaderClass prop
vm
.
handleEpicsListScroll
(
1
);
expect
(
vm
.
scrolledHeaderClass
).
toBe
(
'
scroll
ed-ahead
'
);
vm
.
handleEpicsListScroll
(
{
scrollTop
:
1
}
);
expect
(
vm
.
scrolledHeaderClass
).
toBe
(
'
scroll
-top-shadow
'
);
vm
.
handleEpicsListScroll
(
0
);
vm
.
handleEpicsListScroll
(
{
scrollTop
:
0
}
);
expect
(
vm
.
scrolledHeaderClass
).
toBe
(
''
);
});
});
...
...
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