Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: octane dummy app files #474

Merged
8 changes: 4 additions & 4 deletions addon/factory-guy.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ class FactoryGuy {
/**
```javascript

Person = DS.Model.extend({
type: DS.attr('string'),
name: DS.attr('string')
})
class Person extends Model {
@attr('string') type
@attr('string') name
}

FactoryGuy.define('person', {
sequences: {
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/controllers/profiles.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import Controller from '@ember/controller';
export default Controller.extend();
export default class extends Controller {}
11 changes: 11 additions & 0 deletions tests/dummy/app/controllers/search/results.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Controller from '@ember/controller';

export default class extends Controller {
get previousPage() {
return this.model.meta?.previous;
}

get nextPage() {
return this.model.meta?.next;
}
}
14 changes: 7 additions & 7 deletions tests/dummy/app/controllers/users.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Controller from '@ember/controller';
import { action } from '@ember/object';

export default Controller.extend({
actions: {
deleteUser(user) {
return user.destroyRecord();
},
},
});
export default class extends Controller {
@action
deleteUser(user) {
return user.destroyRecord();
}
}
6 changes: 3 additions & 3 deletions tests/dummy/app/models/big-group.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Group from './group';
import { attr } from '@ember-data/model';

export default Group.extend({
type: attr('string', { defaultValue: 'BigGroup' }),
});
export default class extends Group {
@attr('string', { defaultValue: 'BigGroup' }) type;
}
6 changes: 3 additions & 3 deletions tests/dummy/app/models/big-hat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Hat from './hat';
import { hasMany } from '@ember-data/model';

export default Hat.extend({
materials: hasMany('soft-material', { async: false }),
});
export default class extends Hat {
@hasMany('soft-material', { async: false }) materials;
}
6 changes: 3 additions & 3 deletions tests/dummy/app/models/billing-address.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { attr } from '@ember-data/model';
import Address from 'dummy/models/nested-fragment/address';

export default Address.extend({
billingAddressProperty: attr('number'),
});
export default class extends Address {
@attr('number') billingAddressProperty;
}
10 changes: 5 additions & 5 deletions tests/dummy/app/models/cat.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Model, { attr } from '@ember-data/model';

export default Model.extend({
type: attr('string'),
name: attr('string'),
friend: attr('string'),
});
export default class extends Model {
@attr('string') type;
@attr('string') name;
@attr('string') friend;
}
12 changes: 6 additions & 6 deletions tests/dummy/app/models/comic-book.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Model, { attr, hasMany, belongsTo } from '@ember-data/model';

export default Model.extend({
name: attr('string'),
company: belongsTo('company'),
characters: hasMany('person', { polymorphic: true }),
includedVillains: hasMany('villain'),
});
export default class extends Model {
@attr('string') name;
@belongsTo('company') company;
@hasMany('person', { polymorphic: true }) characters;
@hasMany('villain') includedVillains;
}
14 changes: 7 additions & 7 deletions tests/dummy/app/models/company.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Model, { attr, hasMany, belongsTo } from '@ember-data/model';

export default Model.extend({
type: attr('string', { defaultValue: 'Company' }),
name: attr('string'),
profile: belongsTo('profile', { async: false }),
users: hasMany('user', { async: true, inverse: 'company' }),
projects: hasMany('project', { async: true }),
});
export default class extends Model {
@attr('string', { defaultValue: 'Company' }) type;
@attr('string') name;
@belongsTo('profile', { async: false }) profile;
@hasMany('user', { async: true, inverse: 'company' }) users;
@hasMany('project', { async: true }) projects;
}
2 changes: 1 addition & 1 deletion tests/dummy/app/models/cool-stoner.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Stoner from './stoner';

export default Stoner.extend();
export default class extends Stoner {}
10 changes: 5 additions & 5 deletions tests/dummy/app/models/department-employment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { attr } from '@ember-data/model';
import Fragment from 'ember-data-model-fragments/fragment';
import { fragment } from 'ember-data-model-fragments/attributes';

export default Fragment.extend({
startDate: attr('date'),
endDate: attr('date'),
department: fragment('department'),
});
export default class extends Fragment {
@attr('date') startDate;
@attr('date') endDate;
@fragment('department') department;
}
11 changes: 6 additions & 5 deletions tests/dummy/app/models/department.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { attr } from '@ember-data/model';
import Fragment from 'ember-data-model-fragments/fragment';
import { fragmentArray } from 'ember-data-model-fragments/attributes';

export default Fragment.extend({
name: attr('string'),
addresses: fragmentArray('nested-fragment/address', {
export default class extends Fragment {
@attr('string') name;
@fragmentArray('nested-fragment/address', {
polymorphic: true,
typeKey: '$type',
}),
});
})
addresses;
}
12 changes: 6 additions & 6 deletions tests/dummy/app/models/dog.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Model, { attr, belongsTo } from '@ember-data/model';

export default Model.extend({
owner: belongsTo('person'),
dogNumber: attr('string'),
sound: attr('string'),
tag: attr(), // hash
});
export default class extends Model {
@belongsTo('person') owner;
@attr('string') dogNumber;
@attr('string') sound;
@attr() tag; // hash
}
18 changes: 9 additions & 9 deletions tests/dummy/app/models/employee.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {
fragmentArray,
} from 'ember-data-model-fragments/attributes';

export default Model.extend({
designation: fragment('name'),
name: fragment('name'),
titles: array('string'),
gender: attr('string'),
birthDate: attr('date'),
position: attr(),
departmentEmployments: fragmentArray('department-employment'),
});
export default class extends Model {
@fragment('name') designation;
@fragment('name') name;
@array('string') titles;
@attr('string') gender;
@attr('date') birthDate;
@attr() position;
@fragmentArray('department-employment') departmentEmployments;
}
8 changes: 4 additions & 4 deletions tests/dummy/app/models/entry-type.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Model, { attr, hasMany } from '@ember-data/model';

export default Model.extend({
name: attr('string'),
entries: hasMany('entry'),
});
export default class extends Model {
@attr('string') name;
@hasMany('entry') entries;
}
8 changes: 4 additions & 4 deletions tests/dummy/app/models/entry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Model, { attr, belongsTo } from '@ember-data/model';

export default Model.extend({
name: attr('string'),
entryType: belongsTo('entry-type'),
});
export default class extends Model {
@attr('string') name;
@belongsTo('entry-type') entryType;
}
9 changes: 5 additions & 4 deletions tests/dummy/app/models/fluffy-material.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import Material from './material';
import { belongsTo } from '@ember-data/model';

export default Material.extend({
hat: belongsTo('hat', {
export default class extends Material {
@belongsTo('hat', {
async: false,
inverse: 'fluffyMaterials',
polymorphic: true,
}),
});
})
hat;
}
20 changes: 11 additions & 9 deletions tests/dummy/app/models/group.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import Model, { attr, hasMany, belongsTo } from '@ember-data/model';

export default Model.extend({
type: attr('string', { defaultValue: 'Group' }),
name: attr('string'),
profiles: hasMany('profile', { async: false, inverse: 'group' }),
versions: hasMany('group', {
export default class extends Model {
@attr('string', { defaultValue: 'Group' }) type;
@attr('string') name;
@hasMany('profile', { async: false, inverse: 'group' }) profiles;
@hasMany('group', {
async: false,
polymorphic: true,
inverse: 'group',
}),
group: belongsTo('group', {
})
versions;
@belongsTo('group', {
async: false,
polymorphic: true,
inverse: 'versions',
}),
});
})
group;
}
18 changes: 9 additions & 9 deletions tests/dummy/app/models/hat.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Model, { attr, hasMany, belongsTo } from '@ember-data/model';

export default Model.extend({
type: attr('string'),
shape: attr('string'),
user: belongsTo('user', { async: false, inverse: 'hats' }),
outfit: belongsTo('outfit', { async: false, inverse: 'hats' }),
hat: belongsTo('hat', { async: false, inverse: 'hats', polymorphic: true }),
hats: hasMany('hat', { async: false, inverse: 'hat', polymorphic: true }),
fluffyMaterials: hasMany('fluffy-material', { async: false, inverse: 'hat' }),
});
export default class extends Model {
@attr('string') type;
@attr('string') shape;
@belongsTo('user', { async: false, inverse: 'hats' }) user;
@belongsTo('outfit', { async: false, inverse: 'hats' }) outfit;
@belongsTo('hat', { async: false, inverse: 'hats', polymorphic: true }) hat;
@hasMany('hat', { async: false, inverse: 'hat', polymorphic: true }) hats;
@hasMany('fluffy-material', { async: false, inverse: 'hat' }) fluffyMaterials;
}
6 changes: 3 additions & 3 deletions tests/dummy/app/models/mailing-address.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { attr } from '@ember-data/model';
import Address from 'dummy/models/nested-fragment/address';

export default Address.extend({
mailingAddressProperty: attr('number'),
});
export default class extends Address {
@attr('number') mailingAddressProperty;
}
10 changes: 5 additions & 5 deletions tests/dummy/app/models/manager.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Model, { hasMany, belongsTo } from '@ember-data/model';
import { fragment } from 'ember-data-model-fragments/attributes';

export default Model.extend({
name: fragment('name'),
salary: belongsTo('salary'),
reviews: hasMany('review'),
});
export default class extends Model {
@fragment('name') name;
@belongsTo('salary') salary;
@hasMany('review') reviews;
}
6 changes: 3 additions & 3 deletions tests/dummy/app/models/material.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Model, { attr } from '@ember-data/model';

export default Model.extend({
name: attr('string'),
});
export default class extends Model {
@attr('string') name;
}
8 changes: 4 additions & 4 deletions tests/dummy/app/models/name.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { attr } from '@ember-data/model';
import Fragment from 'ember-data-model-fragments/fragment';

export default Fragment.extend({
firstName: attr('string'),
lastName: attr('string'),
});
export default class extends Fragment {
@attr('string') firstName;
@attr('string') lastName;
}
12 changes: 6 additions & 6 deletions tests/dummy/app/models/nested-fragment/address.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { attr } from '@ember-data/model';
import Fragment from 'ember-data-model-fragments/fragment';

export default Fragment.extend({
street: attr('string'),
city: attr('string'),
region: attr('string'),
country: attr('string'),
});
export default class extends Fragment {
@attr('string') street;
@attr('string') city;
@attr('string') region;
@attr('string') country;
}
10 changes: 5 additions & 5 deletions tests/dummy/app/models/outfit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Model, { attr, hasMany, belongsTo } from '@ember-data/model';

export default Model.extend({
name: attr('string'),
person: belongsTo('person', { async: false, polymorphic: true }),
hats: hasMany('hat', { async: false, polymorphic: true }),
});
export default class extends Model {
@attr('string') name;
@belongsTo('person', { async: false, polymorphic: true }) person;
@hasMany('hat', { async: false, polymorphic: true }) hats;
}
16 changes: 8 additions & 8 deletions tests/dummy/app/models/person.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Model, { attr, hasMany, belongsTo } from '@ember-data/model';

export default Model.extend({
type: attr('string'),
name: attr('string'),
style: attr('string'),
category: attr('string'),
company: belongsTo('company', { async: false }),
outfits: hasMany('outfit', { async: false }),
});
export default class extends Model {
@attr('string') type;
@attr('string') name;
@attr('string') style;
@attr('string') category;
@belongsTo('company', { async: false }) company;
@hasMany('outfit', { async: false }) outfits;
}
2 changes: 1 addition & 1 deletion tests/dummy/app/models/philosopher.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Person from './person';

export default Person.extend();
export default class extends Person {}
Loading