Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions app/helpers/mark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { helper } from '@ember/component/helper';
import { htmlSafe } from '@ember/template';

export default helper(function markdown(params) {
const phrase = params[1];

if (!phrase) {
return '';
}

const wordToMark = params[0];

if (!wordToMark) {
return phrase;
}

let html = phrase;

const regex = new RegExp(wordToMark, 'gi');

html = html.replace(regex, '<mark>$&</mark>');

return htmlSafe(html);
});
2 changes: 1 addition & 1 deletion app/models/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class ImageModel extends Model {
return `${ENV.cdnHost}/${path}.${ext}`;
}

const optimalWidth = 180;
const optimalWidth = 600;
const subset = variations.split(',').filter((x) => x.split('.')[1] === ext);
const sizes = subset.map((x) => x.split('.')[0].replace('@', ''));

Expand Down
1 change: 0 additions & 1 deletion app/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Model, { attr, belongsTo } from '@ember-data/model';

export default class UserModel extends Model {
@attr('string') email;
@attr('string') password;
@attr('string') abilities;

@belongsTo('person') person;
Expand Down
11 changes: 1 addition & 10 deletions app/pods/application/route.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
import BaseRoute from 'interflux/pods/base/route';
import { service } from '@ember/service';

export default class ApplicationRoute extends BaseRoute {
@service auth;

constructor() {
super(...arguments);

this.auth.revive();
}
}
export default class ApplicationRoute extends BaseRoute {}
32 changes: 32 additions & 0 deletions app/pods/components/button/group/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.button-group {
display: flex;
&.stretch-evenly {
a,
button {
&.button {
flex: 1;
}
}
}
a,
button {
&.button {
&.medium.grey {
position: relative;
margin-right: -1px;
border-radius: 0;
&:first-child {
border-radius: 3px 0 0 3px;
}
&:last-child {
border-radius: 0 3px 3px 0;
margin-right: 0;
}
&:hover,
&:focus {
z-index: 1;
}
}
}
}
}
3 changes: 3 additions & 0 deletions app/pods/components/button/group/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class='button-group {{@theme}}'>
{{yield}}
</div>
1 change: 0 additions & 1 deletion app/pods/components/field/boolean/pills/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
>
<Pills::Boolean
@layout={{@layout}}
{{!-- @onSelect={{fn (mut this.value)}} --}}
@onSelect={{this.onSelect}}
@selectedValue={{this.value}}
/>
Expand Down
150 changes: 150 additions & 0 deletions app/pods/components/list-view/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { service } from '@ember/service';

// <ListView
// @title='Images'
// @records={{this.records}}
// @config={{this.config}}
// @filters={{this.filters}}
// @buttons={{this.buttons}}
// @layouts={{array 'grid' 'list'}}
// @onFilter={{this.onFilter}}
// @onClickRecord={{this.onClickRecord}}
// @onClickButton={{this.onClickButton}}
// />

export default class ListViewComponent extends Component {
constructor() {
super(...arguments);
this.layout = this.args.layouts[0];
}

@tracked layout;

get showTable() {
return this.layout === 'table';
}

get showList() {
return this.layout === 'list';
}

get showGrid() {
return this.layout === 'grid';
}

get records() {
let records = this.args.records;

this.args.filters.forEach((filter) => {
if (filter.type === 'search' && filter.value) {
records = records.filter((record) => {
return this.args.config.labels.some((label) => {
const value = record.get(label.property);
const search = filter.value;

return value && value.toLowerCase().includes(search.toLowerCase());
});
});
}

if (filter.type === 'options') {
records = records.filterBy(filter.property, filter.value);
}
});

return records;
}

get search() {
return this.args.filters.find((f) => f.type === 'search');
}

@action
onInsertSearch(input) {
input.value = this.search.value;
}

@action
selectText(event) {
const input = event.target;
input.select();
}

@action
onSearchKeyUp(event) {
const input = event.target;
const searchHasChanged = input.value !== this.search.value;

// Pressing SHIFT or ARROW UP for example should not trigger a search
if (searchHasChanged) {
this.onFilter(this.search, input.value);
}
}

@action
onFilter(filter, value) {
const { type } = filter;
const queryParams = {};

if (type === 'search') {
queryParams['search'] = value;
}

if (type === 'options') {
if (filter.value === value) {
queryParams[filter.property] = null;
} else {
queryParams[filter.property] = value;
}
}

if (type === 'checkboxes') {
const arr = this[filter.property].split(',');

queryParams[filter.property] = arr.includes(value)
? arr.filter((x) => x !== value).join(',')
: [...arr, value].join(',');
}

this.router.transitionTo({ queryParams });
}

@service router;

// SORT

// @tracked sortBy;
// @tracked sortUp = true;

// get sortedRecords() {
// const arr = this.args.records.rejectBy('isNew').sortBy(this.sortBy);
// const isBlank = (x) => {
// return x[this.sortBy] === null || x[this.sortBy] === undefined;
// };
// const blanks = arr.filter(isBlank);
// const values = arr.reject(isBlank);
// const records = [...values, ...blanks];

// if (this.sortUp) {
// return records;
// } else {
// return records.reverse();
// }
// }

// @action
// setSortBy(key) {
// if (this.sortBy === key) {
// this.sortUp = !this.sortUp;
// } else {
// this.sortBy = key;
// this.sortUp = true;
// }

// // Always reset the highlight or it may jump down the list
// this.highlighted = null;
// }
}
Loading