Skip to content

Commit

Permalink
styles are back
Browse files Browse the repository at this point in the history
  • Loading branch information
AmauryD committed Oct 20, 2023
1 parent c3976ce commit 1035fd3
Show file tree
Hide file tree
Showing 27 changed files with 148 additions and 204 deletions.
4 changes: 1 addition & 3 deletions app/adapters/application.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { service } from '@ember/service';
import JSONAPIAdapter from '@ember-data/adapter/json-api';

import { mergedConfig } from 'ember-boilerplate/utils/get-config';

import config from '../config/environment';

import type SessionService from 'ember-boilerplate/services/session';
Expand All @@ -13,7 +11,7 @@ export default class ApplicationAdapter extends JSONAPIAdapter {
@service declare flashMessages: FlashMessageService;

get host() {
return mergedConfig.host;
return config.host;
}
namespace = config.namespace;

Expand Down
21 changes: 16 additions & 5 deletions app/components/inputs/select-validation.gts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ export interface InputsSelectValidationSignature {
};
}

function isArray(value: unknown): value is unknown[] {
return Array.isArray(value);
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
function toString(value: unknown): string {
return String(value);
}

const InputsSelectValidationComponent: TOC<InputsSelectValidationSignature> = <template>
<TpkValidationSelect
@label={{@label}}
Expand All @@ -51,14 +60,16 @@ const InputsSelectValidationComponent: TOC<InputsSelectValidationSignature> = <t
</span>
{{/if}}
</div>
{{!-- <S.Searchbar @isOpen={{true}} /> --}}
<S.Button class={{@inputSelectStyle}} as |selected|>
{{#if S.hasSelection}}
{{#if (has-block "selected")}}
{{#if @multiple}}
{{#each selected as |s|}}
{{yield s to="selected"}}
{{/each}}
{{! safe-guard }}
{{#if (isArray selected)}}
{{#each selected as |s|}}
{{yield s to="selected"}}
{{/each}}
{{/if}}
{{else}}
{{yield selected to="selected"}}
{{/if}}
Expand All @@ -77,7 +88,7 @@ const InputsSelectValidationComponent: TOC<InputsSelectValidationSignature> = <t
{{#if (has-block "option")}}
{{yield opt to="option"}}
{{else}}
{{opt.option}}
{{toString opt.option}}
{{/if}}
</div>
</Opts>
Expand Down
1 change: 0 additions & 1 deletion app/controllers/reset-password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Controller from '@ember/controller';

import { tracked } from 'tracked-built-ins';

// eslint-disable-next-line ember/no-controllers
export default class ResetPasswordController extends Controller {
@tracked token?: string;

Expand Down
4 changes: 2 additions & 2 deletions public/mocks/handlers/users.js → app/handlers/users.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { rest } from 'msw';

export const usersHandlers = [
export const usersHandlers= [
rest.post('http://localhost:8080/api/v1/auth/login', (_req, res, ctx) => {
return res(
ctx.status(200),
Expand Down Expand Up @@ -44,7 +44,7 @@ export const usersHandlers = [
data: {
type: 'users',
id: req.id,
attributes: req.body.data.attributes,
attributes: {}
},
}),
);
Expand Down
Empty file removed app/helpers/.gitkeep
Empty file.
11 changes: 1 addition & 10 deletions app/models/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,18 @@ import Model, { attr, belongsTo } from '@ember-data/model';

import type UserModel from './user';

export abstract class BaseDocumentModel extends Model {
export default class DocumentModel extends Model {
@attr() declare filename: string;

@attr() declare originalName: string;

@attr() declare path: string;

@attr() declare mimetype: string;

@attr() declare size: number;

@attr('date') declare updatedAt: Date;

@attr('date') declare createdAt: Date;
}

export default class DocumentModel extends BaseDocumentModel {
@belongsTo('user') declare user: UserModel;
}

// DO NOT DELETE: this is how TypeScript knows how to look up your models.
declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
document: DocumentModel;
Expand Down
1 change: 0 additions & 1 deletion app/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default class UserModel extends Model {
@attr() declare password: string;
}

// DO NOT DELETE: this is how TypeScript knows how to look up your models.
declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
user: UserModel;
Expand Down
12 changes: 7 additions & 5 deletions app/routes/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Route from '@ember/routing/route';
import { service } from '@ember/service';

import config from 'ember-boilerplate/config/environment';
import { loadConfig } from 'ember-boilerplate/utils/get-config';
import { usersHandlers } from 'ember-boilerplate/handlers/users';

import type CurrentUserService from 'ember-boilerplate/services/current-user';
import type SessionService from 'ember-simple-auth/services/session';
Expand All @@ -13,7 +13,6 @@ export default class Application extends Route {
@service declare currentUser: CurrentUserService;

async beforeModel() {
await loadConfig();
await this.setupMSWForDevelopment();
await this.session.setup();
await this.currentUser.load();
Expand All @@ -28,8 +27,11 @@ export default class Application extends Route {

async function setupMSW(context: object) {
// @ts-expect-error rewritten
let { worker } = await import('/mocks/index.js');
let { default: setupServer } = await import('/setup-worker.js');

await worker.start();
registerDestructor(context, () => worker.stop());
const server = setupServer(usersHandlers);

await server.start();

registerDestructor(context, () => server.stop());
}
85 changes: 0 additions & 85 deletions app/services/base-document.ts

This file was deleted.

3 changes: 1 addition & 2 deletions app/services/error-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default class ErrorHandlerService extends Service {
@service declare flashMessages: FlashMessageService;

public handle(changeset: Changeset, errors: Error[] | string) {
console.log('handle', changeset, errors);

this.flashMessages.danger(errors.toString());
}
}
45 changes: 44 additions & 1 deletion app/services/store.js
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
export { default } from 'ember-data/store';
import JSONAPICache from '@ember-data/json-api';
import { LegacyNetworkHandler } from '@ember-data/legacy-compat';
import { FetchManager } from '@ember-data/legacy-compat/-private';
import { buildSchema, instantiateRecord, modelFor, teardownRecord } from '@ember-data/model/hooks';
import RequestManager from '@ember-data/request';
import Fetch from '@ember-data/request/fetch';
import BaseStore, { CacheHandler, recordIdentifierFor } from '@ember-data/store';

export default class Store extends BaseStore {
constructor(args) {
super(args);
this.requestManager = new RequestManager();
this.requestManager.use([LegacyNetworkHandler, Fetch]);
this.requestManager.useCache(CacheHandler);
this.registerSchema(buildSchema(this));
}

createCache(storeWrapper) {
return new JSONAPICache(storeWrapper);
}

instantiateRecord(
identifier,
createRecordArgs
) {
return instantiateRecord.call(this, identifier, createRecordArgs);
}

teardownRecord(record) {
teardownRecord.call(this, record);
}

modelFor(type) {
return modelFor.call(this, type) || super.modelFor(type);
}

serializeRecord(record, options) {
if (!this._fetchManager) {
this._fetchManager = new FetchManager(this);
}

return this._fetchManager.createSnapshot(recordIdentifierFor(record)).serialize(options);
}
}
6 changes: 4 additions & 2 deletions app/templates/index.gts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default RouteTemplate(
<div class="bg-white">
<div class="max-w-7xl mx-auto py-16 px-4 sm:py-24 sm:px-6 lg:px-8">
<div class="text-center">
<img src="/assets/images/triptyk.png" class="w-16 inline-block" />
<h2 class="text-base font-semibold tracking-wide uppercase text-primary">
The Ember Boilerplate
</h2>
Expand All @@ -14,8 +15,9 @@ export default RouteTemplate(
Better, Faster, Stronger than ever.
</p>
<p class="max-w-xl mt-5 mx-auto text-xl text-gray-500">
TailwindCSS // Ember-simple-auth JWT // Embroider // Ember changeset
validations
The Ember Boilerplate is a modern, opinionated, and powerful
starting point for Ember apps.
Ready for Ember Polaris !
</p>
</div>
</div>
Expand Down
14 changes: 0 additions & 14 deletions app/utils/get-config.ts

This file was deleted.

13 changes: 10 additions & 3 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ module.exports = function (defaults) {
},
},
},
'ember-fetch': {
nativePromise: true
},
sourcemaps: {
enabled: true,
extensions: ['js'],
Expand All @@ -37,9 +40,9 @@ module.exports = function (defaults) {
path: ['node_modules'],
},
},
require('tailwindcss')('./app/tailwind/tailwind.config.js'),
require('tailwindcss')('tailwind.config.js'),
],
cacheInclude: [/.*\.(css|hbs|html)$/, /tailwind\.config\.js/],
cacheInclude: [/.*\.(css|hbs|html|gts|gjs|ts)$/, /tailwind\.config\.js/],
},
},
});
Expand All @@ -57,9 +60,13 @@ module.exports = function (defaults) {
package: 'qunit',
},
],
staticAddonTestSupportTrees: true,
staticAddonTrees: true,
staticAddonTestSupportTrees: true,
staticHelpers: true,
staticModifiers: true,
staticComponents: true,
splitControllers: true,
splitRouteClasses: true,
staticEmberSource: true,
});
};
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"@triptyk/ember-ui": "file:../ember-common-ui/packages/ember-ui",
"@triptyk/ember-utils": "^1.2.2",
"@tsconfig/ember": "~3.0.1",
"@types/ember": "^4.0.8",
"@types/ember-data": "~4.4.13",
"@types/ember-data__adapter": "~4.0.4",
"@types/ember-data__model": "~4.0.3",
Expand Down Expand Up @@ -87,7 +86,18 @@
"ember-cli-terser": "~4.0.2",
"ember-cli-typescript": "~5.2.1",
"ember-concurrency": "~3.1.1",
"ember-data": "~5.3.0",
"@ember-data/adapter": "~5.3.0",
"@ember-data/debug": "~5.3.0",
"@ember-data/graph": "~5.3.0",
"@ember-data/json-api": "~5.3.0",
"@ember-data/legacy-compat": "~5.3.0",
"@ember-data/model": "~5.3.0",
"@ember-data/private-build-infra": "~5.3.0",
"@ember-data/request": "~5.3.0",
"@ember-data/request-utils": "~5.3.0",
"@ember-data/serializer": "~5.3.0",
"@ember-data/store": "~5.3.0",
"@ember-data/tracking": "~5.3.0",
"ember-exam": "^8.0.0",
"ember-fetch": "~8.1.2",
"ember-flatpickr": "~4.0.0",
Expand Down
Loading

0 comments on commit 1035fd3

Please sign in to comment.