Skip to content

Commit 81baad3

Browse files
committed
Style tweaks
1 parent 75eac2d commit 81baad3

File tree

6 files changed

+31
-161
lines changed

6 files changed

+31
-161
lines changed

app/controllers/application.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ const YEARS = [
88
];
99

1010
const MONTHS = [
11-
1,
12-
2,
13-
3,
14-
4,
15-
5,
16-
6,
17-
7,
18-
8,
19-
9,
20-
10,
21-
11,
22-
12
11+
{ name: 'Jan' , value: 1},
12+
{ name: 'Feb', value: 2 },
13+
{ name: 'Mar', value: 3 },
14+
{ name: 'Apr', value: 4 },
15+
{ name: 'May', value: 5 },
16+
{ name: 'Jun', value: 6 },
17+
{ name: 'Jul', value: 7 },
18+
{ name: 'Aug', value: 8 },
19+
{ name: 'Sep', value: 9 },
20+
{ name: 'Oct', value: 10 },
21+
{ name: 'Nov', value: 11 },
22+
{ name: 'Dec', value: 12 }
2323
];
2424

2525
const CURRENT_DATE = new Date();
@@ -33,21 +33,27 @@ export default Controller.extend({
3333
years: YEARS,
3434
months: MONTHS,
3535

36+
selectedMonth: computed('month', 'months', function() {
37+
let months = this.get('months');
38+
let month = parseInt(this.get('month'));
39+
return months.findBy('value', month);
40+
}),
41+
3642
showCTA: computed({
3743
get() {
3844
if (this.get('fastboot.isFastBoot')) {
3945
return;
4046
}
41-
return !localStorage.getItem('seenCTA');
47+
return !localStorage.getItem('seenCTA-2');
4248
},
4349
set(key, value) {
44-
localStorage.setItem('seenCTA', !value);
50+
localStorage.setItem('seenCTA-2', !value);
4551
return value;
4652
}
4753
}),
4854

4955
actions: {
50-
changeMonth(month) {
56+
changeMonth({ value: month }) {
5157
let year = this.get('year');
5258
this.get('router').transitionTo('graph', year, month);
5359
},

app/controllers/index.js

Lines changed: 0 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,3 @@
11
import Controller from '@ember/controller';
2-
import {computed} from '@ember/object';
3-
import createGraph from 'cats-client/utils/create-graph';
4-
import { A as emberA } from '@ember/array';
5-
import { inject as service } from '@ember/service';
6-
7-
export const ALL_MONTHS = 0;
8-
92
export default Controller.extend({
10-
store: service(),
11-
fastboot: service(),
12-
13-
allMonths: ALL_MONTHS,
14-
15-
showCTA: computed({
16-
get() {
17-
if (this.get('fastboot.isFastBoot')) {
18-
return;
19-
}
20-
return !localStorage.getItem('seenCTA');
21-
},
22-
set(key, value) {
23-
localStorage.setItem('seenCTA', !value);
24-
return value;
25-
}
26-
}),
27-
28-
selectedArtist: computed('artist', {
29-
get() {
30-
let artist = this.get('artist');
31-
if (artist) {
32-
return this.get('store').peekRecord('artist', artist);
33-
}
34-
35-
return null;
36-
},
37-
set(key, value) {
38-
this.set('showCTA', false);
39-
this.set('artist', value && value.get('id'));
40-
return value;
41-
}
42-
}),
43-
44-
sortDef: Object.freeze(['startTime:desc']),
45-
sortedEvents: computed.sort('events', 'sortDef'),
46-
47-
includeBandmates: true,
48-
month: ALL_MONTHS,
49-
year: null,
50-
51-
artist: null,
52-
53-
queryParams: Object.freeze([ 'month', 'year', 'includeBandmates', 'artist' ]),
54-
55-
// converter query-string month input "1"-"12"
56-
// do 0 based int 0-11 so that getMonth() works.
57-
monthInt: computed('month', function() {
58-
let month = this.get('month');
59-
if (month === ALL_MONTHS || month === null) {
60-
return null;
61-
}
62-
63-
return parseInt(month, 10) - 1;
64-
}),
65-
66-
// Filter on month and/or selectedArtist
67-
events: computed('monthInt', 'selectedArtist', 'includeBandmates', function() {
68-
let month = this.get('monthInt');
69-
let events;
70-
71-
let selectedArtist = this.get('selectedArtist');
72-
if (selectedArtist) {
73-
events = emberA();
74-
75-
let pushEvents = function(artist) {
76-
events.pushObjects(artist.get('events').filter(event => {
77-
if (month === null) {
78-
return true;
79-
}
80-
81-
return event.get('startTime').getMonth() === month;
82-
}));
83-
};
84-
85-
pushEvents(selectedArtist);
86-
87-
if (this.get('includeBandmates')) {
88-
let bandMates = emberA();
89-
events.forEach(event => {
90-
bandMates.pushObjects(event.get('artists').toArray());
91-
});
92-
93-
bandMates = bandMates.uniq().removeObject(selectedArtist);
94-
95-
bandMates.forEach(bandMate => pushEvents(bandMate));
96-
}
97-
98-
return events.uniq();
99-
}
100-
101-
// if (month !== null) {
102-
// return this.get('model').filter(event => {
103-
// return event.get('startTime').getMonth() === month;
104-
// });
105-
// }
106-
107-
return this.get('model');
108-
}),
109-
110-
graph: computed('events.[]', function() {
111-
let events = this.get('events');
112-
return createGraph(events);
113-
})
1143
});

app/styles/app.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ strong {
5959

6060
.ember-power-select-trigger {
6161
display: inline-block;
62+
min-width: 45px;
63+
margin-right: 10px;
64+
}
65+
66+
.ember-power-select-options[role=listbox] {
67+
max-height: none !important;
6268
}
6369

6470
@import "ember-power-select";

app/styles/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $margin: 10px;
1919
.index-container__cta {
2020
position: absolute;
2121
left: 50%;
22-
top: 25px;
22+
top: 30px;
2323
transform: translate(-50%, -50%);
2424
margin: 10px;
2525
text-align: center;

app/templates/application.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
{{#power-select options=months
2222
searchEnabled=false
23-
selected=month
23+
selected=selectedMonth
2424
onchange=(action 'changeMonth')
2525
as |value|}}
26-
{{value}}
26+
{{value.name}}
2727
{{/power-select}}
2828

2929
{{link-to "Monthly graph" "index" class="selectable"}}

app/templates/index.hbs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1 @@
1-
<div class='index-container'>
2-
<div class='index-container__column'>
3-
4-
{{#if showCTA}}
5-
<div {{action (mut showCTA) false}} class='index-container__cta selectable'>
6-
Click a dot or a musician's name to get started.
7-
</div>
8-
{{/if}}
9-
10-
<div class='index-container__events'>
11-
{{#if selectedArtist}}
12-
{{#artist-info artist=selectedArtist
13-
month=monthInt
14-
clearArtist=(action (mut selectedArtist))}}
15-
{{input type="checkbox" name="includeBandmates" checked=includeBandmates}} Graph Bandmates' Gigs
16-
{{/artist-info}}
17-
{{/if}}
18-
19-
{{#each sortedEvents as |event|}}
20-
{{event-info event=event
21-
selectArtist=(action (mut selectedArtist))
22-
selectedArtist=selectedArtist}}
23-
{{/each}}
24-
</div>
25-
</div>
26-
27-
<div class='index-container__column'>
28-
{{force-graph graph=graph
29-
selectArtist=(action (mut selectedArtist))
30-
selectedArtist=selectedArtist}}
31-
</div>
32-
</div>
1+
{{outlet}}

0 commit comments

Comments
 (0)