Skip to content

Commit 3f2edb3

Browse files
committed
fix: Display sponsor size according to their level
1 parent 84027ee commit 3f2edb3

File tree

6 files changed

+53
-23
lines changed

6 files changed

+53
-23
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="ui column">
2+
<a href="{{@sponsor.url}}" target="_blank" rel="noopener nofollow">
3+
<img src="{{@sponsor.logoUrl}}" height="250" width="250" class="ui image sponsor-image" alt="{{@sponsor.name}}">
4+
</a>
5+
</div>

app/components/public/sponsor-item.js

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{#each-in this.sponsorsGrouped as |key sponsorsGroup|}}
2+
{{#if (not-eq key 'null')}}
3+
<h4 class="ui header">{{key}}</h4>
4+
{{/if}}
5+
<div class="ui {{sponsorsGroup.columns}} column stackable grid">
6+
{{#each sponsorsGroup.sponsors as |sponsor|}}
7+
<Public::SponsorItem @sponsor={{sponsor}} />
8+
{{/each}}
9+
</div>
10+
{{/each-in}}
Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,50 @@
1-
import classic from 'ember-classic-decorator';
21
import { computed } from '@ember/object';
3-
import Component from '@ember/component';
2+
import Component from '@glimmer/component';
43
import { orderBy, groupBy } from 'lodash-es';
54

6-
@classic
75
export default class SponsorList extends Component {
6+
7+
getDistinctLevels(sponsors) {
8+
const levels = new Set(sponsors.toArray().map(sponsor => sponsor.level).filter(level => level != null));
9+
return [...levels].sort((a, b) => a - b);
10+
}
11+
12+
@computed('sponsors.[]')
13+
get distinctLevels() {
14+
return this.getDistinctLevels(this.args.sponsors);
15+
}
16+
17+
inferColumns(key, sponsors) {
18+
const levels = this.distinctLevels;
19+
const groupLevels = this.getDistinctLevels(sponsors);
20+
21+
const groupLevel = groupLevels.pop();
22+
if (groupLevel !== null || groupLevel !== undefined) {
23+
const index = levels.indexOf(groupLevel);
24+
const columns = ['three', 'four', 'five', 'six', 'seven'];
25+
return columns[Math.min(index, columns.length - 1)];
26+
}
27+
28+
return 'three';
29+
}
30+
831
@computed('sponsors.[]')
932
get sponsorsGrouped() {
10-
return groupBy(
33+
const grouped = groupBy(
1134
orderBy(
12-
this.sponsors.toArray(),
35+
this.args.sponsors.toArray(),
1336
sponsor => sponsor.get('level')
1437
),
1538
sponsor => sponsor.get('type')
1639
);
40+
41+
const finalGrouped = {};
42+
for (const [key, sponsors] of Object.entries(grouped)) {
43+
finalGrouped[key] = {
44+
sponsors,
45+
columns: this.inferColumns(key, sponsors)
46+
};
47+
}
48+
return finalGrouped;
1749
}
1850
}

app/controllers/register.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default class RegisterController extends Controller {
2222
this.model.save()
2323
.then(user => {
2424
this.set('session.newUser', user.get('email'));
25-
this.send('loginExistingUser', user.get('email'), password, this.inviteToken, this.event);
25+
this.send('loginExistingUser', user.get('email'), password, this.inviteToken, this.event);
2626
})
2727
.catch(reason => {
2828
if (reason && Object.prototype.hasOwnProperty.call(reason, 'errors') && reason.errors[0].status === 409) {

app/templates/components/public/sponsor-list.hbs

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)