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

Ember common UI impl #12

Merged
merged 13 commits into from
Jan 9, 2025
Merged
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
3 changes: 0 additions & 3 deletions .husky/_/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ call_lefthook()
elif command -v mint >/dev/null 2>&1
then
mint run csjones/lefthook-plugin "$@"
elif command -v npx >/dev/null 2>&1
then
npx lefthook "$@"
else
echo "Can't find lefthook in PATH"
fi
Expand Down
3 changes: 0 additions & 3 deletions .husky/_/prepare-commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ call_lefthook()
elif command -v mint >/dev/null 2>&1
then
mint run csjones/lefthook-plugin "$@"
elif command -v npx >/dev/null 2>&1
then
npx lefthook "$@"
else
echo "Can't find lefthook in PATH"
fi
Expand Down
57 changes: 57 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/sh

if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
set -x
fi

if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi

call_lefthook()
{
if test -n "$LEFTHOOK_BIN"
then
"$LEFTHOOK_BIN" "$@"
elif lefthook -h >/dev/null 2>&1
then
lefthook "$@"
else
dir="$(git rev-parse --show-toplevel)"
osArch=$(uname | tr '[:upper:]' '[:lower:]')
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook"
then
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" "$@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
"$dir/node_modules/lefthook/bin/index.js" "$@"

elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook "$@"
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook "$@"
elif pnpm lefthook -h >/dev/null 2>&1
then
pnpm lefthook "$@"
elif swift package plugin lefthook >/dev/null 2>&1
then
swift package --disable-sandbox plugin lefthook "$@"
elif command -v mint >/dev/null 2>&1
then
mint run csjones/lefthook-plugin "$@"
else
echo "Can't find lefthook in PATH"
fi
fi
}

call_lefthook run "pre-push" "$@"
57 changes: 57 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/sh

if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
set -x
fi

if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi

call_lefthook()
{
if test -n "$LEFTHOOK_BIN"
then
"$LEFTHOOK_BIN" "$@"
elif lefthook -h >/dev/null 2>&1
then
lefthook "$@"
else
dir="$(git rev-parse --show-toplevel)"
osArch=$(uname | tr '[:upper:]' '[:lower:]')
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook"
then
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" "$@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
"$dir/node_modules/lefthook/bin/index.js" "$@"

elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook "$@"
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook "$@"
elif pnpm lefthook -h >/dev/null 2>&1
then
pnpm lefthook "$@"
elif swift package plugin lefthook >/dev/null 2>&1
then
swift package --disable-sandbox plugin lefthook "$@"
elif command -v mint >/dev/null 2>&1
then
mint run csjones/lefthook-plugin "$@"
else
echo "Can't find lefthook in PATH"
fi
fi
}

call_lefthook run "prepare-commit-msg" "$@"
9 changes: 7 additions & 2 deletions app/changesets/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ export interface RegisterDTO {
id?: string;
firstName: string;
lastName: string;
category: string;
birthDate?: Date;
category: string | null;
birthDate: Date | null;
phone: string;
email: string;
gift: number;
password: string;
confirmPassword?: string;
isFree: boolean;
period: Date[] | null;
time: Date | null;
status: string | null;
cv: File | null;
}

export class RegisterChangeset extends ImmerChangeset<RegisterDTO> {}
208 changes: 141 additions & 67 deletions app/components/forms/register.gts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { RegisterChangeset } from 'ember-boilerplate/changesets/register';
import TpkForm from '@triptyk/ember-input-validation/components/tpk-form';
import type validationsRegister from 'ember-boilerplate/validations/register';
import Component from '@glimmer/component';
import { action } from '@ember/object';

export interface FormsRegisterSignature {
Args: {
Expand All @@ -19,84 +18,159 @@ export interface FormsRegisterSignature {
}

export default class FormsRegister extends Component<FormsRegisterSignature> {
@action
setBirthdate(date: unknown) {
setBirthdate = (date: unknown) => {
this.args.changeset.set('birthDate', date as Date);
}
};

@action
selectCategory(category: unknown) {
selectCategory = (category: unknown) => {
this.args.changeset.set('category', category as string);
}
};

<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"
class="px-4 py-8 mt-8 rounded-lg sm:px-10 sm:mx-auto sm:w-full sm:max-w-5xl grid grid-cols-12 gap-x-6"
...attributes
as |F|
>
<F.TpkInputPrefab
class="input_block col-span-12"
@label={{t "components.forms.register.last_name"}}
@validationField="lastName"
data-test-input="lastName"
/>
<F.TpkInputPrefab
class="input_block col-span-12"
@label={{t "components.forms.register.first_name"}}
@validationField="firstName"
data-test-input="firstName"
/>
<F.TpkInputPrefab
class="input_block col-span-12"
@label={{t "components.forms.register.email"}}
@validationField="email"
data-test-input="email"
/>
<F.TpkMobilePrefab
class="input_block col-span-12"
@label={{t "components.forms.register.phone"}}
@validationField="phone"
data-test-input="phone"
/>
<F.TpkPasswordPrefab
class="input_block col-span-12"
@label={{t "components.forms.register.password"}}
@validationField="password"
data-test-input="password"
/>
<F.TpkDatepicker class="col-span-12" @validationField="birthDate" @label={{t "components.forms.register.birth_date"}} @onChange={{this.setBirthdate}} as |D|>
<D.Label />
<D.Input />
</F.TpkDatepicker>
<F.TpkSelectPrefab
@validationField="category"
@options={{@categories}}
@label={{t "components.forms.register.category"}}
@onChange={{this.selectCategory}}
class="col-span-12"
/>
<F.TpkPasswordPrefab
class="input_block col-span-12"
@label={{t "components.forms.register.confirm_password"}}
@validationField="confirmPassword"
data-test-input="confirmPassword"
/>
<F.TpkCurrencyPrefab
class="input_block col-span-6"
@label={{t "components.forms.register.gift"}}
@validationField="gift"
data-test-input="gift"
/>
<button data-test-submit type="submit" class="btn col-span-12">
<span>
{{t "global.submit"}}
</span>
</button>
<fieldset class="col-span-12 grid grid-cols-12 gap-x-6">
<h3 class="col-span-12 py-3 text-2xl border-b mb-2">
{{t "components.forms.register.titles.account_informations"}}
</h3>
<F.TpkInputPrefab
class="col-span-4"
@label={{t "components.forms.register.email"}}
@validationField="email"
data-test-input="email"
/>
<F.TpkPasswordPrefab
class="col-span-4"
@label={{t "components.forms.register.password"}}
@validationField="password"
data-test-input="password"
/>
<F.TpkPasswordPrefab
class="col-span-4"
@label={{t "components.forms.register.confirm_password"}}
@validationField="confirmPassword"
data-test-input="confirmPassword"
/>
</fieldset>
<fieldset class="col-span-12 grid grid-cols-12 gap-x-6">
<h3 class="col-span-12 py-3 text-2xl border-b mb-2">
{{t "components.forms.register.titles.base_informations"}}
</h3>
<F.TpkInputPrefab
class="col-span-4"
@label={{t "components.forms.register.last_name"}}
@validationField="lastName"
data-test-input="lastName"
/>
<F.TpkInputPrefab
class="col-span-4"
@label={{t "components.forms.register.first_name"}}
@validationField="firstName"
data-test-input="firstName"
/>
<F.TpkDatepickerPrefab
class="col-span-4"
@validationField="birthDate"
@label={{t "components.forms.register.birth_date"}}
data-test-input="birthDate"
/>
<F.TpkMobilePrefab
class="col-span-6"
@label={{t "components.forms.register.phone"}}
@validationField="phone"
data-test-input="phone"
/>
<F.TpkRadioGroupPrefab
@groupLabel={{t "components.forms.register.status.title"}}
@validationField="status"
data-test-input="status"
class="col-span-6 flex gap-x-4 !flex-row flex-wrap"
as |Radio|
>
<Radio
@value="jobseeker"
@label={{t "components.forms.register.status.jobseeker"}}
class="[&_label]:gap-x-3"
data-test-radio="jobseeker"
/>
<Radio
@value="employee"
@label={{t "components.forms.register.status.employee"}}
class="[&_label]:gap-x-3"
data-test-radio="employee"
/>
<Radio
@value="student"
@label={{t "components.forms.register.status.student"}}
class="[&_label]:gap-x-3"
data-test-radio="student"
/>
</F.TpkRadioGroupPrefab>
</fieldset>
<fieldset class="col-span-12 grid grid-cols-12 gap-x-6">
<h3 class="col-span-12 py-3 text-2xl border-b mb-2">
{{t "components.forms.register.titles.free"}}
</h3>
<F.TpkCheckboxPrefab
class="col-span-5 flex !flex-row items-center gap-x-3"
@label={{t "components.forms.register.is_free"}}
@validationField="isFree"
data-test-input="isFree"
/>
{{#if (F.changesetGet "isFree")}}
<F.TpkDatepickerRangePrefab
class="col-span-4"
@label={{t "components.forms.register.period"}}
@validationField="period"
data-test-input="period"
/>
<F.TpkTimepickerPrefab
class="col-span-3"
@label={{t "components.forms.register.time"}}
@validationField="time"
data-test-input="time"
/>
{{/if}}
</fieldset>
<fieldset class="col-span-12 grid grid-cols-12 gap-x-6">
<h3 class="col-span-12 py-3 text-2xl border-b mb-2">
{{t "components.forms.register.titles.extra"}}
</h3>
<F.TpkSelectPrefab
@validationField="category"
@options={{@categories}}
@label={{t "components.forms.register.category"}}
@onChange={{this.selectCategory}}
class="col-span-3"
data-test-input="category"
/>
<F.TpkCurrencyPrefab
class="col-span-3"
@label={{t "components.forms.register.gift"}}
@validationField="gift"
data-test-input="gift"
/>
<F.TpkFilePrefab
class="col-span-6"
@label={{t "components.forms.register.cv"}}
@validationField="cv"
data-test-input="cv"
/>
</fieldset>
<div class="col-span-12 flex justify-end mt-4">
<button data-test-submit type="submit" class="btn">
<span>
{{t "global.submit"}}
</span>
</button>
</div>
</TpkForm>
</template>;
</template>
}
Loading
Loading