Skip to content

Commit

Permalink
[TECH] Passage de PixCertif vers Ember Octane (3.15)
Browse files Browse the repository at this point in the history
Merge pull request #976 from 1024pix/tech-pix-certif-to-ember-octane
  • Loading branch information
laura-bergoens authored Jan 24, 2020
2 parents 3e8d3cd + 3a34c38 commit f35f0b8
Show file tree
Hide file tree
Showing 112 changed files with 2,405 additions and 3,840 deletions.
1 change: 1 addition & 0 deletions certif/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
globals: {
server: true,
},
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
Expand Down
5 changes: 4 additions & 1 deletion certif/.template-lintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict';

module.exports = {

extends: 'octane',
rules: {
'no-invalid-interactive': false,
}
};
7 changes: 3 additions & 4 deletions certif/app/adapters/session.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ApplicationAdapter from './application';

export default ApplicationAdapter.extend({
export default class SessionAdapter extends ApplicationAdapter {

finalize(model) {
const url = `${this.buildURL('session', model.id)}/finalization`;
Expand All @@ -23,6 +23,5 @@ export default ApplicationAdapter.extend({
},
},
});
},

});
}
}
14 changes: 7 additions & 7 deletions certif/app/adapters/user.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import ApplicationAdapter from './application';

export default ApplicationAdapter.extend({
export default class UserAdapter extends ApplicationAdapter {

urlForQueryRecord(query) {
if (query.me) {
delete query.me;
return `${this._super(...arguments)}/me`;
return `${super.urlForQueryRecord(...arguments)}/me`;
}

return this._super(...arguments);
},
return super.urlForQueryRecord(...arguments);
}

urlForUpdateRecord(id, modelName, { adapterOptions }) {
const url = this._super(...arguments);
const url = super.urlForUpdateRecord(...arguments);

if (adapterOptions && adapterOptions.acceptPixCertifTermsOfService) {
delete adapterOptions.acceptPixCertifTermsOfService;
return url + '/pix-certif-terms-of-service-acceptance';
}

return url;
},
});
}
}
2 changes: 1 addition & 1 deletion certif/app/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Application from '@ember/application';
import Resolver from './resolver';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';

Expand Down
8 changes: 4 additions & 4 deletions certif/app/authenticators/oauth2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import OAuth2PasswordGrant from 'ember-simple-auth/authenticators/oauth2-password-grant';
import ENV from 'pix-certif/config/environment';

export default OAuth2PasswordGrant.extend({
serverTokenEndpoint: `${ENV.APP.API_HOST}/api/token`,
serverTokenRevocationEndpoint: `${ENV.APP.API_HOST}/api/revoke`,
});
export default class OAuth2Authenticator extends OAuth2PasswordGrant {
serverTokenEndpoint = `${ENV.APP.API_HOST}/api/token`;
serverTokenRevocationEndpoint = `${ENV.APP.API_HOST}/api/revoke`;
}
9 changes: 9 additions & 0 deletions certif/app/components/action-button.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{#if @isLoading }}
<button data-test-id="action-button" class="button button--regular button--link" {{on 'click' @handleClick}} ...attributes>
<span class="button__loader">&nbsp;</span>
</button>
{{else}}
<button data-test-id="action-button" class="button button--regular button--link" {{on 'click' @handleClick}} ...attributes>
{{yield}}
</button>
{{/if}}
10 changes: 0 additions & 10 deletions certif/app/components/action-button.js

This file was deleted.

102 changes: 102 additions & 0 deletions certif/app/components/certification-candidate-in-staging-item.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<tr>
<td data-test-id='panel-candidate__lastName__add-staging'>
<div class="certification-candidates-input-wrapper">
<input
value="{{@candidateData.lastName}}"
class="certification-candidates-input"
{{on 'input' (fn @updateCandidateData @candidateData 'lastName')}} >
</div>
</td>
<td data-test-id='panel-candidate__firstName__add-staging'>
<div class="certification-candidates-input-wrapper">
<input
value="{{@candidateData.firstName}}"
class="certification-candidates-input"
{{on 'input' (fn @updateCandidateData @candidateData 'firstName')}} >
</div>
</td>
<td data-test-id='panel-candidate__birthdate__add-staging'>
<div class="certification-candidates-input-wrapper">
<OneWayDateMask
@placeholder='dd/mm/yyyy'
@options={{hash inputFormat='dd/mm/yyyy' outputFormat='yyyy-mm-dd'}}
@class='certification-candidates-input'
@update={{this.updateCandidateDataBirthdate}}>
</OneWayDateMask>
</div>
</td>
<td data-test-id='panel-candidate__birthCity__add-staging'>
<div class="certification-candidates-input-wrapper">
<input
value="{{@candidateData.birthCity}}"
class="certification-candidates-input"
{{on 'input' (fn @updateCandidateData @candidateData 'birthCity')}} >
</div>
</td>
<td data-test-id='panel-candidate__birthProvinceCode__add-staging'>
<div class="certification-candidates-input-wrapper">
<input
value="{{@candidateData.birthProvinceCode}}"
class="certification-candidates-input"
{{on 'input' (fn @updateCandidateData @candidateData 'birthProvinceCode')}} >
</div>
</td>
<td data-test-id='panel-candidate__birthCountry__add-staging'>
<div class="certification-candidates-input-wrapper">
<input
value="{{@candidateData.birthCountry}}"
class="certification-candidates-input"
{{on 'input' (fn @updateCandidateData @candidateData 'birthCountry')}} >
</div>
</td>
<td data-test-id='panel-candidate__email__add-staging'>
<div class="certification-candidates-input-wrapper">
<input
value="{{@candidateData.email}}"
class="certification-candidates-input"
{{on 'input' (fn @updateCandidateData @candidateData 'email')}} >
</div>
</td>
<td data-test-id='panel-candidate__externalId__add-staging'>
<div class="certification-candidates-input-wrapper">
<input
value="{{@candidateData.externalId}}"
class="certification-candidates-input"
{{on 'input' (fn @updateCandidateData @candidateData 'externalId')}} >
</div>
</td>
<td data-test-id='panel-candidate__extraTimePercentage__add-staging'>
<div class="certification-candidates-input-wrapper">
<input
value="{{@candidateData.extraTimePercentage}}"
class="certification-candidates-input"
{{on 'input' (fn @updateCandidateData @candidateData 'extraTimePercentage')}} >
<span class="certification-candidates-percentage">
%
</span>
</div>
</td>
<td>
<div class="certification-candidates-input-wrapper certification-candidates-row-actions">
{{#if (and
@candidateData.firstName
@candidateData.lastName
(is-after @candidateData.birthdate '1900-01-01')
@candidateData.birthCity
@candidateData.birthProvinceCode
@candidateData.birthCountry
)}}
<button data-test-id='panel-candidate__action__save' class="button button--row-item" type="button" {{on "click" (fn @onClickSave @candidateData)}}>
Enregistrer
</button>
{{else}}
<button data-test-id='panel-candidate__action__save' class="button button--row-item button--disabled" type="button" disabled="true">
Enregistrer
</button>
{{/if}}
<button data-test-id='panel-candidate__action__cancel' class="button button--square button--lightgrey certification-candidates-row-actions__close" type="button" {{on "click" (fn @onClickCancel @candidateData)}}>
{{fa-icon "times" class="fa-fw certification-candidates-add-button__icon"}}
</button>
</div>
</td>
</tr>
23 changes: 8 additions & 15 deletions certif/app/components/certification-candidate-in-staging-item.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import moment from 'moment';
import Component from '@ember/component';
import { computed } from '@ember/object';
import Component from '@glimmer/component';
import { action } from '@ember/object';

export default Component.extend({
tagName: 'tr',
export default class CertificationCandidateInStagingItem extends Component {

isCandidateDataValid: computed('candidateData.{firstName,lastName,birthCountry,birthProvinceCode,birthCity,birthdate}', function() {
return this.candidateData.firstName &&
this.candidateData.lastName &&
this.candidateData.birthCity &&
this.candidateData.birthProvinceCode &&
this.candidateData.birthCountry &&
moment.utc(this.candidateData.birthdate, 'YYYY-MM-DD', true).isValid();
}),

});
@action
updateCandidateDataBirthdate(value) {
this.args.updateCandidateBirthdate(this.args.candidateData, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
Vous avez déjà un compte sur Pix.fr ? Vous pouvez utiliser ce compte pour rejoindre l'espace Pix Certif.
</div>

{{#if isErrorMessagePresent}}
{{#if this.isErrorMessagePresent}}
<div id="login-form-error-message" class="login-form__error-message error-message">
L'adresse e-mail et/ou le mot de passe saisis sont incorrects.
</div>
{{/if}}

<form {{action 'authenticate' on='submit'}}>
<form {{on 'submit' this.authenticate}} >

<div class="login-form__input-container">
<label for="login-email" class="label">Adresse e-mail</label>
Expand All @@ -27,7 +27,7 @@
@name="login"
@type="email"
@class="input"
@value={{email}}
@value={{this.email}}
@autocomplete="username"
/>
</div>
Expand All @@ -38,16 +38,16 @@
<Input
@id="login-password"
@name="password"
@type={{passwordInputType}}
@type={{this.passwordInputType}}
@class="input"
@value={{password}}
@value={{this.password}}
@autocomplete="current-password"
/>
<button type="button" aria-label="rendre le mot de passe lisible" class="login-form__icon" {{action 'togglePasswordVisibility'}} >
{{#if isPasswordVisible}}
<div tabindex="-1" onmousedown={{action 'togglePasswordVisibility'}}>{{fa-icon 'eye' class="fa-fw login-form-icon__eye"}}</div>
{{#if this.isPasswordVisible}}
<div tabindex="-1" onmousedown={{this.togglePasswordVisibility}}>{{fa-icon 'eye' class="fa-fw login-form-icon__eye"}}</div>
{{else}}
<div tabindex="-1" onmousedown={{action 'togglePasswordVisibility'}}>{{fa-icon 'eye-slash' class="fa-fw login-form-icon__eye"}}</div>
<div tabindex="-1" onmousedown={{this.togglePasswordVisibility}}>{{fa-icon 'eye-slash' class="fa-fw login-form-icon__eye"}}</div>
{{/if}}
</button>
</div>
Expand All @@ -60,7 +60,7 @@
</form>

<div class="login-form__forgotten-password one-line-text">
Vous avez oublié votre mot de passe ? Rendez-vous sur <a href="https://app.pix.fr/mot-de-passe-oublie" target="_blank">pix.fr</a> pour
Vous avez oublié votre mot de passe ? Rendez-vous sur <a href="https://app.pix.fr/mot-de-passe-oublie" target="_blank" rel="noopener noreferrer" >pix.fr</a> pour
le réinitialiser.
</div>

Expand Down
60 changes: 33 additions & 27 deletions certif/app/components/login-form.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
import Component from '@ember/component';
import { computed } from '@ember/object';
import { inject } from '@ember/service';
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';

export default Component.extend({
export default class LoginForm extends Component {

session: inject(),
@service session;
@tracked isPasswordVisible;
@tracked isErrorMessagePresent;

email: null,
password: null,
isPasswordVisible: false,
passwordInputType: computed('isPasswordVisible', function() {
return this.isPasswordVisible ? 'text' : 'password';
}),

isErrorMessagePresent: false,
constructor() {
super(...arguments);

actions: {
this.email = null;
this.password = null;
this.isPasswordVisible = false;
this.isErrorMessagePresent = false;
}

async authenticate() {
const email = this.email ? this.email.trim() : '';
const password = this.password;
const scope = 'pix-certif';
try {
await this.session.authenticate('authenticator:oauth2', email, password, scope);
} catch (err) {
this.set('isErrorMessagePresent', true);
}
},
get passwordInputType() {
return this.isPasswordVisible ? 'text' : 'password';
}

togglePasswordVisibility() {
this.toggleProperty('isPasswordVisible');
@action
async authenticate(event) {
event.preventDefault();
const email = this.email ? this.email.trim() : '';
const password = this.password;
const scope = 'pix-certif';
try {
await this.session.authenticate('authenticator:oauth2', email, password, scope);
} catch (err) {
this.isErrorMessagePresent = true;
}
}

@action
togglePasswordVisibility() {
this.isPasswordVisible = !this.isPasswordVisible;
}

});
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="no-session-panel">
<div class="no-session-panel__explain-create-session">
<img src="{{rootURL}}/icons/icon-session-start.svg" alt="Vous pouvez créer des sessions de certifications.">
<img src="{{this.rootURL}}/icons/icon-session-start.svg" alt="Vous pouvez créer des sessions de certifications.">
<h1 class="page-title">Créez votre première session de certification</h1>

<div class="no-session-panel__link-to-create">
Expand Down

This file was deleted.

Loading

0 comments on commit f35f0b8

Please sign in to comment.