Skip to content

Commit

Permalink
upgrade common-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
AmauryD committed Oct 19, 2024
1 parent 7af1827 commit edf8a5c
Show file tree
Hide file tree
Showing 26 changed files with 474 additions and 771 deletions.
2 changes: 1 addition & 1 deletion app/abilities/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Ability } from 'ember-can';

import type CurrentUserService from 'ember-boilerplate/services/current-user';

export default abstract class BaseAbility<T = unknown> extends Ability<T> {
export default abstract class BaseAbility extends Ability {
@service declare currentUser: CurrentUserService;

@computed('currentUser.user')
Expand Down
14 changes: 3 additions & 11 deletions app/app.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
import { setBuildURLConfig } from '@ember-data/request-utils';
import Application from '@ember/application';
// @ts-expect-error
import initializer from 'ember-simple-auth/initializers/ember-simple-auth';
// @ts-expect-error
import initializerJwt from '@triptyk/ember-simple-auth-token/initializers/simple-auth-token';

import config from 'ember-boilerplate/config/environment';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';

export default class App extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
Resolver = Resolver;
}

// ember-load-initializers not working anymore, registering manually
function loadInitializers() {
App.instanceInitializer(initializer);
App.instanceInitializer(initializerJwt);
}

setBuildURLConfig({
host: config.host,
namespace: config.namespace,
});

loadInitializers();
loadInitializers(App, config.modulePrefix);

6 changes: 2 additions & 4 deletions app/components/forms/forgot-password.gts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { LinkTo } from '@ember/routing';

import InputsValidationComponent from 'ember-boilerplate/components/inputs/input-validation';
import t from 'ember-intl/helpers/t';
import TpkForm from '@triptyk/ember-input-validation/components/tpk-form';

Expand Down Expand Up @@ -28,9 +26,9 @@ const FormsForgotPassword: TOC<FormsForgotPasswordSignature> = <template>
@changeset={{@changeset}}
@validationSchema={{@validationSchema}}
...attributes
as |F|
>
<InputsValidationComponent
@changeset={{@changeset}}
<F.TpkInputPrefab
class="input_block"
@label={{t "components.forms.forgot-password.email"}}
@validationField="email"
Expand Down
9 changes: 3 additions & 6 deletions app/components/forms/login.gts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { LoginChangeset } from 'ember-boilerplate/changesets/login';
import type { Schema } from 'yup';
import t from 'ember-intl/helpers/t';
import { LinkTo } from '@ember/routing';
import InputsValidationComponent from '../inputs/input-validation';

export interface FormsLoginSignature {
Args: {
Expand All @@ -25,19 +24,17 @@ const FormsLogin: TOC<FormsLoginSignature> = <template>
@changeset={{@changeset}}
@validationSchema={{@validationSchema}}
data-test-form-login
as |F|
>
<InputsValidationComponent
@changeset={{@changeset}}
<F.TpkEmailPrefab
@label={{t "components.forms.login.email"}}
@validationField="email"
class="input_block"
data-test-input="email"
/>
<InputsValidationComponent
@changeset={{@changeset}}
<F.TpkPasswordPrefab
@label={{t "components.forms.login.password"}}
@validationField="password"
@type="password"
class="input_block"
data-test-input="password"
/>
Expand Down
8 changes: 3 additions & 5 deletions app/components/forms/password-recovery.gts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { ResetPasswordChangeset } from 'ember-boilerplate/changesets/reset-
import type { Schema } from 'yup';
import TpkForm from '@triptyk/ember-input-validation/components/tpk-form';
import t from 'ember-intl/helpers/t';
import InputsValidationComponent from '../inputs/input-validation';

export interface FormsPasswordRecoveryComponentSignature {
Args: {
Expand All @@ -24,16 +23,15 @@ const FormsPasswordRecovery: TOC<FormsPasswordRecoveryComponentSignature> = <tem
@changeset={{@changeset}}
@validationSchema={{@validationSchema}}
...attributes
as |F|
>
<InputsValidationComponent
<F.TpkPasswordPrefab
class="input_block"
@changeset={{@changeset}}
@label={{t "components.forms.reset-password.new_password"}}
@validationField="password"
data-test-input="password"
/>
<InputsValidationComponent
@changeset={{@changeset}}
<F.TpkPasswordPrefab
class="input_block"
@label={{t "components.forms.reset-password.confirm_new_password"}}
@validationField="confirmPassword"
Expand Down
59 changes: 15 additions & 44 deletions app/components/forms/register.gts
Original file line number Diff line number Diff line change
@@ -1,101 +1,71 @@
import Component from '@glimmer/component';
import { hash } from '@ember/helper';
import t from 'ember-intl/helpers/t';

import type { TOC } from '@ember/component/template-only';
import type { RegisterChangeset } from 'ember-boilerplate/changesets/register';
import type { Schema } from 'yup';
import TpkForm from '@triptyk/ember-input-validation/components/tpk-form';
import InputsValidationComponent from '../inputs/input-validation';
import type validationsRegister from 'ember-boilerplate/validations/register';

export interface FormsRegisterSignature {
Args: {
changeset: RegisterChangeset;
saveFunction: (changeset: RegisterChangeset) => void;
validationSchema: Schema;
validationSchema: typeof validationsRegister;
};
Blocks: {
default: [];
};
Element: HTMLFormElement;
}

export default class RegisterForm extends Component<FormsRegisterSignature> {
maskForEuro = {
mask: 'num €',
lazy: false,
blocks: {
num: {
mask: Number,
signed: true,
scale: 2,
radix: ',',
thousandsSeparator: '.',
},
},
overwrite: true,
};

<template>
const FormsRegisterSignature: TOC<FormsRegisterSignature> = <template>
<TpkForm
@changeset={{@changeset}}
@onSubmit={{@saveFunction}}
@validationSchema={{@validationSchema}}
data-test-form="register"
class="px-4 py-8 mt-8 bg-white rounded-lg shadow space-y-6 sm:px-10 sm:mx-auto sm:w-full sm:max-w-xl grid grid-cols-12 gap-x-6 gap-y-4"
...attributes
as |F|
>
<InputsValidationComponent
@changeset={{@changeset}}
<F.TpkInputPrefab
class="input_block col-span-12"
@label={{t "components.forms.register.last_name"}}
@validationField="lastName"
data-test-input="lastName"
/>
<InputsValidationComponent
@changeset={{@changeset}}
<F.TpkInputPrefab
class="input_block col-span-12"
@label={{t "components.forms.register.first_name"}}
@validationField="firstName"
data-test-input="firstName"
/>
<InputsValidationComponent
@changeset={{@changeset}}
<F.TpkInputPrefab
class="input_block col-span-12"
@label={{t "components.forms.register.email"}}
@validationField="email"
data-test-input="email"
/>
<InputsValidationComponent
@changeset={{@changeset}}
<F.TpkMobilePrefab
class="input_block col-span-12"
@label={{t "components.forms.register.phone"}}
@validationField="phone"
@mask="+30 000000000"
@maskOptions={{hash lazy=false}}
data-test-input="phone"
/>
<InputsValidationComponent
@changeset={{@changeset}}
<F.TpkPasswordPrefab
class="input_block col-span-12"
@label={{t "components.forms.register.password"}}
@validationField="password"
data-test-input="password"
/>
<InputsValidationComponent
@changeset={{@changeset}}
<F.TpkPasswordPrefab
class="input_block col-span-12"
@label={{t "components.forms.register.confirm_password"}}
@validationField="confirmPassword"
data-test-input="confirmPassword"
/>
<InputsValidationComponent
@changeset={{@changeset}}
<F.TpkCurrencyPrefab
class="input_block col-span-6"
@label={{t "components.forms.register.gift"}}
@validationField="gift"
@mask="Number €"
@maskOptions={{this.maskForEuro}}
@unmaskValue={{true}}
data-test-input="gift"
/>
<button data-test-submit type="submit" class="btn col-span-12">
Expand All @@ -104,5 +74,6 @@ export default class RegisterForm extends Component<FormsRegisterSignature> {
</span>
</button>
</TpkForm>
</template>
}
</template>;

export default FormsRegisterSignature;
44 changes: 0 additions & 44 deletions app/components/inputs/cancel-button.gts

This file was deleted.

26 changes: 0 additions & 26 deletions app/components/inputs/error-validation.gts

This file was deleted.

51 changes: 0 additions & 51 deletions app/components/inputs/file.gts

This file was deleted.

Loading

0 comments on commit edf8a5c

Please sign in to comment.